function scroll11()
{
	window.scrollTo(0,0);
}

function Validate(th)
{
  //  1.first name
   
	var i=0,useridlen=0,acd,cnt=0;
   	var user;
   	ErrMsg="";
   	var user_id = new Array();
   	user = th.txt_first_name.value;
   	useridlen = user.length;
   	
   	if(user == "")
	{ 
		ErrMsg = ErrMsg + "Please enter your Name\n";
   		window.alert(ErrMsg);
   		th.txt_first_name.focus();
   		th.txt_first_name.value="";
   		return false;
   	}     
   	
   	if((useridlen < 3) || (useridlen > 30))
   	{
		ErrMsg = ErrMsg + "Name should be between 3 and 30 characters only\n";
   		window.alert(ErrMsg);
  		th.txt_first_name.focus();
   		//th.txt_first_name.value="";
   		return false;
   	}

   	for(i=0; i<useridlen; i++)
   	{
   		user_id[i] = user.substr(i,1);
 	 	acd = user_id[i];

		if((acd.charCodeAt(0) >= 65 && acd.charCodeAt(0) <= 90) && (acd.charCodeAt(0) >= 97 && acd.charCodeAt(0) <= 122))	
		{
		}

		if(acd.charCodeAt(0) > 47 && acd.charCodeAt(0) < 65)
   		{  
        		ErrMsg = ErrMsg + "Name should be Characters only\n";
              		window.alert(ErrMsg);
			th.txt_first_name.focus();
           		//th.txt_first_name.value="";
           		return false;
   		}

		// 32 is for Space Character and 39 is for ' and 46 is for .
   		if((acd.charCodeAt(0) < 48) && (acd.charCodeAt(0) != 32) && (acd.charCodeAt(0) != 39) && (acd.charCodeAt(0) != 46))
   		{  
			ErrMsg = ErrMsg + "You entered Invalid Characters for Name\n";
              		window.alert(ErrMsg);
              		th.txt_first_name.focus();
              		//th.txt_first_name.value="";
              		return false;
   		}

   		if((acd.charCodeAt(0) > 90) && (acd.charCodeAt(0) < 97))
   		{  
			ErrMsg = ErrMsg + "You entered Invalid Characters for Name\n";
   	        	window.alert(ErrMsg);
   	        	th.txt_first_name.focus();
   	        	//th.txt_first_name.value="";
   	        	return false;
   		}

   		if(acd.charCodeAt(0) > 122)
	   	{   
   	          	ErrMsg = ErrMsg + "You entered Invalid Characters for Name\n";
	   		window.alert(ErrMsg);
   	          	th.txt_first_name.focus();
   	          	//th.txt_first_name.value="";
   	          	return false;
   		}

	}
   	

  //  2. address1

	var i=0,useridlen=0,acd,cnt=0;
	var user;
	var user_id = new Array();
	ErrMsg = "";
	user = th.txt_addr_line1.value;
	useridlen = user.length;
   
	if(user == "")
	{
		ErrMsg = ErrMsg + "Please enter your Address1\n";
		window.alert(ErrMsg);	
		th.txt_addr_line1.focus();
		th.txt_addr_line1.value="";
		return false;
	}

	if((useridlen < 3) || (useridlen > 50))
	{
		ErrMsg = ErrMsg + "Address1 should be between 3 and 50 length only\n";
	        window.alert(ErrMsg);
	        th.txt_addr_line1.focus();
	        //th.txt_addr_line1.value="";
	        return false;
	}   	


  // 3. day phone1
  	var ph;
	ph = th.txt_ph_num1.value;
        var phlen = ph.length;
        var user_id = new Array();
        
        if(phlen == 0)
        {
        	ErrMsg = ErrMsg + "Please enter your Phone1\n";
        	window.alert(ErrMsg);
        	th.txt_ph_num1.focus();
        	th.txt_ph_num1.value = "";
        	return false;
        }
                
        for(i = 0; i < phlen; i++)
	{
		user_id[i] = ph.substr(i,1);
		var acd = user_id[i];  
		if((acd.charCodeAt(0) >= 48 && acd.charCodeAt(0) <= 57) || acd.charCodeAt(0) == 32 || acd.charCodeAt(0) == 45 || acd.charCodeAt(0) == 43 || acd.charCodeAt(0)==30 || acd.charCodeAt(0) == 40 || acd.charCodeAt(0) == 41)
		{
			
		}
		else
		{   
				
			ErrMsg = ErrMsg + "You entered Invalid Characters for Phone1\n";
		        window.alert(ErrMsg);
			th.txt_ph_num1.focus();
			th.txt_ph_num1.value="";
			return false;
		}
	}
					
	if((phlen < 4) || (phlen > 20))
	{
		ErrMsg = ErrMsg + "Please enter your Phone1 whose length is between 4 and 20 digits only\n";
		window.alert(ErrMsg);
		th.txt_ph_num1.focus();
		//th.txt_ph_num1.value="";
		return false;
	}




  // 4.  email id
       
	var emailid;
       	emailid = th.txt_email_acct.value;
       	emailidlen = emailid.length;
		        
       	if(emailid == "")
       	{
		ErrMsg = ErrMsg + "Please enter your E-mail\n";
              	window.alert(ErrMsg);
              	th.txt_email_acct.focus();
              	//th.txt_email_acct.value="";
              	return false;
	}
	
	if((emailidlen < 8) || (emailidlen > 40))
	{
		ErrMsg = ErrMsg + "Please enter your valid E-mail which is minimum 8 characters \n e.g.andy@hotmail.com,john_123@usa.net\n";
              	window.alert(ErrMsg);
              	th.txt_email_acct.focus();
              	//th.txt_email_acct.value="";
              	return false;
	}

	if(th.txt_email_acct.value != "")
	{
		if(th.txt_email_acct.value.indexOf("@")==-1 || th.txt_email_acct.value.indexOf(".")==-1	|| 
  		   th.txt_email_acct.value.lastIndexOf(".") < th.txt_email_acct.value.indexOf("@")	||
		   th.txt_email_acct.value.indexOf("@")== 0 || th.txt_email_acct.value.indexOf(".")== 0 ||
		   (th.txt_email_acct.value.indexOf(".") - th.txt_email_acct.value.indexOf("@") == 1) ||
		   (th.txt_email_acct.value.indexOf("@") - th.txt_email_acct.value.indexOf(".") == 1) ||
		   th.txt_email_acct.value.indexOf(" ")!=-1)
		{

               		ErrMsg = ErrMsg + "Please enter your valid E-mail which is minimum 8 characters for e.g.andy@hotmail.com,john_123@usa.net\n";
               		window.alert(ErrMsg);
               		th.txt_email_acct.focus();
               		//th.txt_email_acct.value="";
               		return false;
		}
	}
   	

  // 5. day faxno
	var ph;
	ph = th.txt_fx_num1.value;
	phlen = ph.length;
        var user_id = new Array();
                      
        if(phlen == 0)
        {
        	ErrMsg = ErrMsg + "Please enter your FaxNo\n";
        	window.alert(ErrMsg);
        	th.txt_fx_num1.focus();
        	th.txt_fx_num1.value = "";
        	return false;
        }
                

       	for(i=0; i < phlen; i++)
	{
		user_id[i] = ph.substr(i,1);
	       	var acd = user_id[i];
 			 	
	   	if((acd.charCodeAt(0)>=48 && acd.charCodeAt(0)<=57)||acd.charCodeAt(0)==32||acd.charCodeAt(0)==45||acd.charCodeAt(0)==43||acd.charCodeAt(0)==30||acd.charCodeAt(0)==41||acd.charCodeAt(0)==40)
	   	{
				 
	   	}
	   	else
	   	{
			ErrMsg = ErrMsg + "You entered Invalid Characters for Fax\n";
			window.alert(ErrMsg);
			th.txt_fx_num1.focus();
			//th.txt_fx_num1.value="";
			return false;
		}
				
	}
			
	if((phlen < 4) || (phlen > 20))
	{
		ErrMsg = ErrMsg + "Please enter your Faxno whose length is between 4 and 20 digits only\n";
		window.alert(ErrMsg);
		th.txt_fx_num1.focus();
		//th.txt_fx_num1.value="";
		return false;
	}
			

     
  //   6 address2
    
   	var i=0,useridlen=0,acd,cnt=0;
	var user;
	var user_id = new Array();
	ErrMsg="";
	user = th.txt_addr_line2.value;
	useridlen = user.length;
   
	if(user=="")
	{
	    
	}
	
	if(useridlen > 50)
 	{

	           ErrMsg = ErrMsg + "Please enter your Address2 which is between 3 and 50 characters only\n";
	           window.alert(ErrMsg);
	           th.txt_addr_line2.focus();
	           th.txt_addr_line2.value="";
	           return false;
	}
	 	   	
// 7.city

	var i=0,citylen=0,acd,cnt=0;
	var city;
	var city_id = new Array();
	ErrMsg="";
        city = th.txt_city_name.value;
        citylen = city.length;
	if(city=="")
	{
	}
	
	if(citylen > 18)
	{

		      ErrMsg = ErrMsg + "Please enter your City which is between 2 and 18 characters only\n";
		      window.alert(ErrMsg);
		      th.txt_city_name.focus();
		      th.txt_city_name.value="";
		      return false;
    	}

	for(i=0; i<citylen; i++)
	{
	    var acd = city.substr(i,1);
		if((acd.charCodeAt(0) >=65  && acd.charCodeAt(0) <=90)||(acd.charCodeAt(0) >=97 && acd.charCodeAt(0) <=122))
		{
			
		}
		else
		{      
		       ErrMsg = ErrMsg + "Please enter your City which is between 2 and 18 characters only\n";
		       window.alert(ErrMsg);
		       th.txt_city_name.focus();
		       th.txt_city_name.value="";
		       return false;
		}
	}
	
	
// 8 state

	var i=0,citylen=0,acd,cnt=0;
	var city;
	var city_id = new Array();
    city = th.txt_state_id.value;
   	citylen = city.length;
   	ErrMsg="";
		
	if(city=="")
	{
		 
	}
	if(citylen > 18)
	{

			   ErrMsg = ErrMsg + "Please enter your State which is between 2 and 18 characters only\n";
			   window.alert(ErrMsg);
			   th.txt_state_id.focus();
			   th.txt_state_id.value="";
			   return false;
 	 }

	for(i=0; i<citylen; i++)
	{
		var acd = city.substr(i,1);			
		if((acd.charCodeAt(0)>=65 && acd.charCodeAt(0) <=90) ||(acd.charCodeAt(0) >=97 && acd.charCodeAt(0) <=122))
		{
		
		}
		else
		{
		        ErrMsg = ErrMsg + "Please enter your State which is between 2 and 18 characters only\n";
	            window.alert(ErrMsg);
	            th.txt_state_id.focus();
	            th.txt_state_id.value="";
	            return false;
		}
	}

			
		
// 9. zip code
      	var zipcode,zipcodelen=0;
		zipcode = th.txt_zip_cd.value;
		zipcodelen = zipcode.length;
		ErrMsg="";

        if(zipcode=="")
        {
      
        }
	    if((zipcodelen > 10) || (isNaN(zipcode)== true))
	    {
				
                 ErrMsg = ErrMsg + "Please enter your Zipcode which is maximum 10 digits only\n";
	             alert(ErrMsg);
	             th.txt_zip_cd.value="";
	             th.txt_zip_cd.focus();
	             return false;
		}

// 10. day phone2
		var ph;
		ph = th.txt_ph_num2.value;
		phlen=ph.length;
		var user_id=new Array();
			     
        if(ph=="")
		{
		}
			
		for(i=0; i < phlen; i++)
		{
			user_id[i] = ph.substr(i,1);
	 		var acd = user_id[i];
	            
		if((acd.charCodeAt(0)>=48 && acd.charCodeAt(0)<=57)||acd.charCodeAt(0)==32||acd.charCodeAt(0)==45||acd.charCodeAt(0)==43||acd.charCodeAt(0)==30||acd.charCodeAt(0)==41||acd.charCodeAt(0)==40)
		{
		}
				
		else
		{
			    ErrMsg = ErrMsg + "Please enter your Phone2 whose length is between 4 and 20 digits only\n";
			    window.alert(ErrMsg);
			    th.txt_ph_num2.focus();
			    th.txt_ph_num2.value="";
			    return false;
		}
		}
			
		if(phlen > 20)
		{

		        ErrMsg = ErrMsg + "Please enter your Phone2 whose length is between 4 and 20 digits only\n";
		        window.alert(ErrMsg);
		        th.txt_ph_num2.focus();
		        th.txt_ph_num2.value="";
		        return false;
		}
	if(! ErrMsg) 
	{
		th.submit();
	}		

 }



function checkmail()
{
	var str;
	var myArr = new Array();
	str = th.txt_email_acct.value.substr((th.txt_email_acct.value.lastIndexOf(".")+1), th.txt_email_acct.value.length);
	if( str.length < 2 )
		return true;
	
	myArr = th.txt_email_acct.value.split(".");
	
	for(i=0; i<myArr.length; i++)
	{
		if((myArr[i].length) == 0)
		{
			return true;
		}	
	}
	return false;
}
