function validate()
{
//variables for caputing the form objects.

		var fname,lname;
 		var email,email2,email3,email4,email5,email6;
		var MailMe,MailVakils; 
		var vCtr;
	
//Capture text box "First Name"
	fname = document.frmEmail.txtFirstName.value;
	if(fname == "")
	{
		alert('Please Enter Your First Name');
		document.frmEmail.txtFirstName.focus();
		return false;
	}
	else if(fname.length > 25)
	{
		alert('Please Enter A Valid First Name');
		document.frmEmail.txtFirstName.focus();
		return false;
	}
	
//Checking for Number in the First Name-Anjali
	vCtr=chkNumber(fname);
	if(vCtr!=0)
	{
	alert("You have entered a Number in the First Name. Please enter valid data.");
	document.frmEmail.txtFirstName.focus();
	return false;
	}
			vCtr="";								
	
	
//Capture text box "Last Name"
	lname = document.frmEmail.txtLastName.value; 
	if(lname == "")
	{
		alert('Please Enter Your Last Name');
		document.frmEmail.txtLastName.focus();
		return false;
	}
	else if(lname.length > 25)
	{
		alert('Please Enter A Valid Last Name');
		document.frmEmail.txtLastName.focus();
		return false;
	}

//Checking for Number in the Last Name-Anjali
	vCtr=chkNumber(lname);
	if(vCtr!=0)
	{
	alert("You have entered a Number in the Lastt Name. Please enter valid data.");
	document.frmEmail.txtLastName.focus();
	return false;
	}
			vCtr="";		
	

//Capture value of text box "Your Email" this is a mandatory field asked by Sangeeta
	email = document.frmEmail.txtEmail1.value;	
	if(email== "")
	{
		alert("Please enter your Email Id");
		document.frmEmail.txtEmail1.focus();
		return false;
	}																					
			
	if (email != 0) 
	{
		
		temp = email;
		var joined_email;
		//removing all the extra spaces between email
		joined_email = temp.split(" ");
		joined_email = joined_email.join("");
		email = joined_email;
		
		
		//checking for first character validation, only alphabets allowed
		
		var first_char=0;
		first_char = joined_email.charCodeAt(0);
		if ((first_char>=97) && (first_char<=122) || (first_char>=65) && (first_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail1.focus();
			return false;
		}
		
		
		//checking for last character validation, only alpabets allowed
		
		var last_char;		
		
		last_char = joined_email.charCodeAt((joined_email.length-1));
			
		if ((last_char>=97) && (last_char<=122) || (last_char>=65) && (last_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail1.focus();
			return false;
		}
		
		
		//checking for any special characters other than @ _ . -
		
		var temp_2 = 0;
		for(n=0;n<joined_email.length;n++)
		 {
			temp_2 = joined_email.charCodeAt(n);
			if ((temp_2<48) || (temp_2>57))
			  {
			    if ((temp_2<97) || (temp_2>122))
			       {	
			        
			        if ((temp_2<65) || (temp_2>90))
			         {	
			       
							if ((temp_2 == 95) || (temp_2==46) || (temp_2==64) || (temp_2==45))
								 {
									//alert("special but correct");
								 }
							 else
								 {	
									alert("Invalid Email Id");
									document.frmEmail.txtEmail1.focus();
									return false;
								 }
					}
					}
				}
		
			}
			
			//checking for more than two @'s or atleast one @
			
						
			if ((joined_email.match("@")) == null)  // for atleast one
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail1.focus();
				return false;
			}
			
						
			if ((joined_email.indexOf("@")) != (joined_email.lastIndexOf("@"))) // for more than one 
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail1.focus();
				return false;			
			}
			
			// if dot . is there or not
			if (joined_email.indexOf(".") == -1)
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail1.focus();
				return false;		
			}
			
			//checking for _ after @, which is not allowed
			if ((joined_email.indexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail1.focus();
				return false;	
			}
			
			//checking for underscore_ after @, which is invalid
			if ((joined_email.lastIndexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail1.focus();
				return false;	
			}
			
			else
			{
				//alert("will Submit");
				//document.frm_email.submit();	
			}
		}	





	//Capture value of all text boxes "Your Friends Email"
			email2 = document.frmEmail.txtEmail2.value;
			email3 = document.frmEmail.txtEmail3.value;	
			email4 = document.frmEmail.txtEmail4.value;	
			email5 = document.frmEmail.txtEmail5.value;	
			email6 = document.frmEmail.txtEmail6.value;	
			
		if(email2 == "" && email3 == "" && email4 == "" && email5 == "" && email6 == "")
		{
				alert("Please enter atleast one friends' email id");
				document.frmEmail.txtEmail2.focus();
				return (false);
				
				with(email2)
				{
					if(email2 != "" && (email2.indexOf('@')<2) || (email2.indexOf('.')<4))
					{
					alert("Please enter atleast one friends' email id");
					document.frmEmail.txtEmail2.focus();
					return (false);
					}
				}
			 
			 	with(email3)
				{
			 		if(email3 != "" && (email3.indexOf('@')<2) || (email3.indexOf('.')<4))
					{
					alert("Please enter atleast one friends' email id");
					document.frmEmail.txtEmail3.focus();
					return (false);
					}
				}
					
				with(email4)
				{
			  		if(email4 != "" && (email4.indexOf('@')<2) || (email4.indexOf('.')<4))
					{
					alert("Please enter atleast one friends' email id");
					document.frmEmail.txtEmail4.focus();
					return (false);
					}
				}
					
				with(email5)
				{	
					if(email5 != "" && (email5.indexOf('@')<2) || (email5.indexOf('.')<4))
					{
					alert("Please enter atleast one friends' email id");
					document.frmEmail.txtEmail5.focus();
					return (false);
					}
				} 
					
				with(email6)
				{
					if(email6 != "" && (email6.indexOf('@')<2) || (email6.indexOf('.')<4))
					{
					alert("Please enter atleast one friends' email id");
					document.frmEmail.txtEmail6.focus();
					return (false);
					}
				}
		}
		
//validate email2
		
	if (email2 != 0) 
	{
		temp = email2;
		var joined_email;
		
		//removing all the extra spaces between email
		joined_email = temp.split(" ");
		joined_email = joined_email.join("");
		email2 = joined_email;
	
		
		//checking for first character validation, only alphabets allowed
		
		var first_char=0;
				
		first_char = joined_email.charCodeAt(0);
		if ((first_char>=97) && (first_char<=122) || (first_char>=65) && (first_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail2.focus();
			return false;
		}
			
		//checking for last character validation, only alpabets allowed
		var last_char;		
		last_char = joined_email.charCodeAt((joined_email.length-1));
			
		if ((last_char>=97) && (last_char<=122) || (last_char>=65) && (last_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail2.focus();
			return false;
		}		
		//checking for any special characters other than @ _ . -		
		var temp_2 = 0;
		for(n=0;n<joined_email.length;n++)
		 {
			temp_2 = joined_email.charCodeAt(n);
			if ((temp_2<48) || (temp_2>57))
			  {
			    if ((temp_2<97) || (temp_2>122))
			       {	
			        
			        if ((temp_2<65) || (temp_2>90))
			         {	
			       
							if ((temp_2 == 95) || (temp_2==46) || (temp_2==64) || (temp_2==45))
								 {
									//alert("special but correct");
								 }
							 else
								 {	
									alert("Invalid Email Id");
									document.frmEmail.txtEmail2.focus();
									return false;
								 }
					}
					}
				}
		
			}
			
			//checking for more than two @'s or atleast one @
			if ((joined_email.match("@")) == null)  // for atleast one
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail2.focus();
				return false;
			}
			
						
			if ((joined_email.indexOf("@")) != (joined_email.lastIndexOf("@"))) // for more than one 
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail2.focus();
				return false;			
			}
			
			// if dot . is there or not
			if (joined_email.indexOf(".") == -1)
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail2.focus();
				return false;		
			}
			
			//checking for _ after @, which is not allowed
			if ((joined_email.indexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail2.focus();
				return false;	
			}
			
			//checking for underscore_ after @, which is invalid
			if ((joined_email.lastIndexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail2.focus();
				return false;	
			}
			
			else
			{
				//alert("will Submit");
				//document.frm_email.submit();	
			}
		}	
//validate email3
		
	if (email3 != 0) 
	{
		temp = email3;
		var joined_email;
		
		//removing all the extra spaces between email
		joined_email = temp.split(" ");
		joined_email = joined_email.join("");
		email3 = joined_email;
	
		
		//checking for first character validation, only alphabets allowed
		
		var first_char=0;
				
		first_char = joined_email.charCodeAt(0);
		if ((first_char>=97) && (first_char<=122) || (first_char>=65) && (first_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail3.focus();
			return false;
		}
			
		//checking for last character validation, only alpabets allowed
		var last_char;		
		last_char = joined_email.charCodeAt((joined_email.length-1));
			
		if ((last_char>=97) && (last_char<=122) || (last_char>=65) && (last_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail3.focus();
			return false;
		}		
		//checking for any special characters other than @ _ . -		
		var temp_2 = 0;
		for(n=0;n<joined_email.length;n++)
		 {
			temp_2 = joined_email.charCodeAt(n);
			if ((temp_2<48) || (temp_2>57))
			  {
			    if ((temp_2<97) || (temp_2>122))
			       {	
			        
			        if ((temp_2<65) || (temp_2>90))
			         {	
			       
							if ((temp_2 == 95) || (temp_2==46) || (temp_2==64) || (temp_2==45))
								 {
									//alert("special but correct");
								 }
							 else
								 {	
									alert("Invalid Email Id");
									document.frmEmail.txtEmail3.focus();
									return false;
								 }
					}
					}
				}
		
			}
			
			//checking for more than two @'s or atleast one @
			if ((joined_email.match("@")) == null)  // for atleast one
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail3.focus();
				return false;
			}
			
						
			if ((joined_email.indexOf("@")) != (joined_email.lastIndexOf("@"))) // for more than one 
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail3.focus();
				return false;			
			}
			
			// if dot . is there or not
			if (joined_email.indexOf(".") == -1)
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail3.focus();
				return false;		
			}
			
			//checking for _ after @, which is not allowed
			if ((joined_email.indexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail3.focus();
				return false;	
			}
			
			//checking for underscore_ after @, which is invalid
			if ((joined_email.lastIndexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail3.focus();
				return false;	
			}
			
			else
			{
				//alert("will Submit");
				//document.frm_email.submit();	
			}
		}	

//validate email4
		
	if (email4 != 0) 
	{
		temp = email4;
		var joined_email;
		
		//removing all the extra spaces between email
		joined_email = temp.split(" ");
		joined_email = joined_email.join("");
		email4 = joined_email;
	
		
		//checking for first character validation, only alphabets allowed
		
		var first_char=0;
				
		first_char = joined_email.charCodeAt(0);
		if ((first_char>=97) && (first_char<=122) || (first_char>=65) && (first_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail4.focus();
			return false;
		}
			
		//checking for last character validation, only alpabets allowed
		var last_char;		
		last_char = joined_email.charCodeAt((joined_email.length-1));
			
		if ((last_char>=97) && (last_char<=122) || (last_char>=65) && (last_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail4.focus();
			return false;
		}		
		//checking for any special characters other than @ _ . -		
		var temp_2 = 0;
		for(n=0;n<joined_email.length;n++)
		 {
			temp_2 = joined_email.charCodeAt(n);
			if ((temp_2<48) || (temp_2>57))
			  {
			    if ((temp_2<97) || (temp_2>122))
			       {	
			        
			        if ((temp_2<65) || (temp_2>90))
			         {	
			       
							if ((temp_2 == 95) || (temp_2==46) || (temp_2==64) || (temp_2==45))
								 {
									//alert("special but correct");
								 }
							 else
								 {	
									alert("Invalid Email Id");
									document.frmEmail.txtEmail4.focus();
									return false;
								 }
					}
					}
				}
		
			}
			
			//checking for more than two @'s or atleast one @
			if ((joined_email.match("@")) == null)  // for atleast one
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail4.focus();
				return false;
			}
			
						
			if ((joined_email.indexOf("@")) != (joined_email.lastIndexOf("@"))) // for more than one 
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail4.focus();
				return false;			
			}
			
			// if dot . is there or not
			if (joined_email.indexOf(".") == -1)
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail4.focus();
				return false;		
			}
			
			//checking for _ after @, which is not allowed
			if ((joined_email.indexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail4.focus();
				return false;	
			}
			
			//checking for underscore_ after @, which is invalid
			if ((joined_email.lastIndexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail4.focus();
				return false;	
			}
			
			else
			{
				//alert("will Submit");
				//document.frm_email.submit();	
			}
		}	

//validate email5
	
	if (email5 != 0) 
	{
		temp = email5;
		var joined_email;
		
		//removing all the extra spaces between email
		joined_email = temp.split(" ");
		joined_email = joined_email.join("");
		email5 = joined_email;
	
		
		//checking for first character validation, only alphabets allowed
		
		var first_char=0;
				
		first_char = joined_email.charCodeAt(0);
		if ((first_char>=97) && (first_char<=122) || (first_char>=65) && (first_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail5.focus();
			return false;
		}
			
		//checking for last character validation, only alpabets allowed
		var last_char;		
		last_char = joined_email.charCodeAt((joined_email.length-1));
			
		if ((last_char>=97) && (last_char<=122) || (last_char>=65) && (last_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail5.focus();
			return false;
		}		
		//checking for any special characters other than @ _ . -		
		var temp_2 = 0;
		for(n=0;n<joined_email.length;n++)
		 {
			temp_2 = joined_email.charCodeAt(n);
			if ((temp_2<48) || (temp_2>57))
			  {
			    if ((temp_2<97) || (temp_2>122))
			       {	
			        
			        if ((temp_2<65) || (temp_2>90))
			         {	
			       
							if ((temp_2 == 95) || (temp_2==46) || (temp_2==64) || (temp_2==45))
								 {
									//alert("special but correct");
								 }
							 else
								 {	
									alert("Invalid Email Id");
									document.frmEmail.txtEmail5.focus();
									return false;
								 }
					}
					}
				}
		
			}
			
			//checking for more than two @'s or atleast one @
			if ((joined_email.match("@")) == null)  // for atleast one
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail5.focus();
				return false;
			}
			
						
			if ((joined_email.indexOf("@")) != (joined_email.lastIndexOf("@"))) // for more than one 
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail5.focus();
				return false;			
			}
			
			// if dot . is there or not
			if (joined_email.indexOf(".") == -1)
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail5.focus();
				return false;		
			}
			
			//checking for _ after @, which is not allowed
			if ((joined_email.indexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail5.focus();
				return false;	
			}
			
			//checking for underscore_ after @, which is invalid
			if ((joined_email.lastIndexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail5.focus();
				return false;	
			}
			
			else
			{
				//alert("will Submit");
				//document.frm_email.submit();	
			}
		}	
//validate email6 
		
	if (email6 != 0) 
	{
		temp = email6;
		var joined_email;
		
		//removing all the extra spaces between email
		joined_email = temp.split(" ");
		joined_email = joined_email.join("");
		email6 = joined_email;
	
		
		//checking for first character validation, only alphabets allowed
		
		var first_char=0;
				
		first_char = joined_email.charCodeAt(0);
		if ((first_char>=97) && (first_char<=122) || (first_char>=65) && (first_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail6.focus();
			return false;
		}
			
		//checking for last character validation, only alpabets allowed
		var last_char;		
		last_char = joined_email.charCodeAt((joined_email.length-1));
			
		if ((last_char>=97) && (last_char<=122) || (last_char>=65) && (last_char<=90))
		{
			// correct first character
		}
		else
		{
			alert("Invalid Email Id");
			document.frmEmail.txtEmail6.focus();
			return false;
		}		
		//checking for any special characters other than @ _ . -		
		var temp_2 = 0;
		for(n=0;n<joined_email.length;n++)
		 {
			temp_2 = joined_email.charCodeAt(n);
			if ((temp_2<48) || (temp_2>57))
			  {
			    if ((temp_2<97) || (temp_2>122))
			       {	
			        
			        if ((temp_2<65) || (temp_2>90))
			         {	
			       
							if ((temp_2 == 95) || (temp_2==46) || (temp_2==64) || (temp_2==45))
								 {
									//alert("special but correct");
								 }
							 else
								 {	
									alert("Invalid Email Id");
									document.frmEmail.txtEmail6.focus();
									return false;
								 }
					}
					}
				}
		
			}
			
			//checking for more than two @'s or atleast one @
			if ((joined_email.match("@")) == null)  // for atleast one
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail6.focus();
				return false;
			}
			
						
			if ((joined_email.indexOf("@")) != (joined_email.lastIndexOf("@"))) // for more than one 
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail6.focus();
				return false;			
			}
			
			// if dot . is there or not
			if (joined_email.indexOf(".") == -1)
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail6.focus();
				return false;		
			}
			
			//checking for _ after @, which is not allowed
			if ((joined_email.indexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail6.focus();
				return false;	
			}
			
			//checking for underscore_ after @, which is invalid
			if ((joined_email.lastIndexOf("_")) > (joined_email.lastIndexOf("@")))
			{
				alert("Invalid Email ID");
				document.frmEmail.txtEmail6.focus();
				return false;	
			}
			
			else
			{
				//alert("will Submit");
				//document.frm_email.submit();	
			}
		}	
		
	//return true;	
	frmEmail.submit();	
}

function clearall()
	{
			document.frmEmail.txtFirstName.value = "";
			document.frmEmail.txtLastName.value = "";
			document.frmEmail.txtEmail1.value = "";
			document.frmEmail.txtEmail2.value = "";
			document.frmEmail.txtEmail3.value = "";
			document.frmEmail.txtEmail4.value = "";
			document.frmEmail.txtEmail5.value = "";
			document.frmEmail.txtEmail6.value = "";
			document.frmEmail.txtMailMessage.value = "";
			document.frmEmail.txtFirstName.focus();
	}

