String.prototype.trim = function() 
{
		//This function rids only of spaces on the LHS and RHS of strings passed to it
        return this.replace(/^\s+|\s+$/g,"");
}


function Validate(theForm)
{ 
	var firstNameTargetList			=	"<>/\\@|%^#.*&()~[]{}?=':;$,`!\"";
	var middleInitialTargetList		=	"<>/\\@|%^#.*&()~[]{}?=:;'";
	var lastNameTargetList			=	"<>/\\@|%^#.*&()~[]{}?=:;$`!\"";
	var addressLine1TargetList		=	"<>/\\@|%^*&()~[]{}!?=+$:;";		
	var addressLine2TargetList		=	"<>/\\@|%^*&()~[]{}!?:;$+=";
	var cityTargetList				=	"<>/\\@|%^*&()~[]{}!?=+$:;";
	var AllNumbersList				=	"0123456789";
	var dateregex					=	/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
	var emailTargetList				=	"<>/\\|%^#*&()~[]{}?=!?+$;\"";
	var employerNameTargetList		=	"<>/\\@|%^#*&()~[]{},$+=?!\"";
	var	passwordRegExp				=	/^[a-zA-Z0-9]+$/;
	var licenseNumRegExpression		=	/^[a-zA-Z0-9]{1,}$/;
	var otherCountryFlag			=	0;
	
	
	if (theForm.country_code)
	{
		if (theForm.country_code.value =="Other")
		{ otherCountryFlag=1;	}
		else
		{ otherCountryFlag=0; }
	}
	else
	{ otherCountryFlag=0; }
	
	//alert("otherCountryFlag:"+otherCountryFlag);
	
	var NotRequireSSN=0;
	
	if (theForm.SSNRequiredFlag)
	{
		if (theForm.SSNRequiredFlag.value =="1")
		{NotRequireSSN=1;}
	}

	////alert("see:"+NotRequireSSN);
 if (theForm.first)
 {
 	theForm.first.value	=	theForm.first.value.trim();
 	if  ((theForm.first.value == null)||(theForm.first.value == ""))
	  {
		alert("Please complete the \"First Name\" field.");
		theForm.first.focus();
		return (false);
	  }
	  
	  var targetlist = firstNameTargetList;
	  var checkStr = theForm.first.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < targetlist.length;  j++)
		{
		  if (ch == targetlist.charAt(j))
			{
				
				allValid = false;
				break; 
			
			}
			
		}
		
		if (!allValid)
		  {
			alert("Special characters \"< > /  \\ @ |  %  ^  #  . * & ( ) ~ [ ] { } ? = \" can not be used in the \"First Name\" field");
			theForm.first.focus();
			
			return (false);
			//break;
		  }
		allNum += ch;
		
		
	  }
	  
	  
	
	 
 }
 /////// End of FirstName
 
 if (theForm.middle)
 {
 	theForm.middle.value	  =		theForm.middle.value.trim();	
 	if (theForm.middle.value != "")
	  {
			  var targetlist = middleInitialTargetList;
			  var checkStr = theForm.middle.value;
			  var allValid = true;
			  var decPoints = 0;
			  var allNum = "";
			  for (i = 0;  i < checkStr.length;  i++)
			  {
				ch = checkStr.charAt(i);
				
				for (j = 0;  j < targetlist.length;  j++)
				{
				  if (ch == targetlist.charAt(j))
					{
						
						allValid = false;
						break; 
					
					}
					
				}
				
				if (!allValid)
				  {
					alert("Special characters \"< > /  \\ @ |  %  ^  #  . * & ( ) ~ [ ] { }  ? =  \" can not be used in the \"Middle Initial\" field");
					theForm.middle.focus();
					
					return (false);
					//break;
				  }
				allNum += ch;
				
				
			  }
	  
	  }	  	  	  	  		 
 }
 //////////// end of Middle ////////////////////

 
 if (theForm.last)
 {
 	theForm.last.value		=		theForm.last.value.trim();
 	if ((theForm.last.value == "") ||  (theForm.last.value == null))
	  {
		alert("Please complete the \"Last Name\" field.");
		theForm.last.focus();
		return (false);
	  }
	  
	  var targetlist = lastNameTargetList;
	  var checkStr = theForm.last.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < targetlist.length;  j++)
		{
		  if (ch == targetlist.charAt(j))
			{
				
				allValid = false;
				break; 
			
			}
			
		}
		
		if (!allValid)
		  {
			alert("Special characters \"< > /  \\ @ |  %  ^  #  . * & ( ) ~ [ ] { }  ? =  \" can not be used in the \"Last Name\" field");
			theForm.last.focus();
			
			return (false);
			//break;
		  }
		allNum += ch;
		
		
	  }
	  
	  
	
 }
 
  
  if (theForm.address1)
  {
  	theForm.address1.value	=	theForm.address1.value.trim();	
 	if (theForm.address1.value == "")
	  {
		alert("Please complete the \"Address 1\" field.");
		theForm.address1.focus();
		return (false);
	  }
	  
	 var targetlist = addressLine1TargetList;
	  var checkStr = theForm.address1.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < targetlist.length;  j++)
		{
		  if (ch == targetlist.charAt(j))
			{
				
				allValid = false;
				break; 
			
			}
			
		}
		
		if (!allValid)
		  {
			alert("Special characters \"< > /  \\ @ |  %  ^   . * & ( ) ~ [ ] { } ? \" can not be used in the \"Address 1\" field");
			theForm.address1.focus();
			
			return (false);
			//break;
		  }
		allNum += ch;
		
		
	  }
	  
	  
  
  	  
 }
 /////// end of Address1
 
 if (theForm.address2)
 {
 	theForm.address2.value	=	theForm.address2.value.trim();	
 	if (theForm.address2.value != "")
	  {
				  var targetlist = addressLine2TargetList;
				  var checkStr = theForm.address2.value;
				  var allValid = true;
				  var decPoints = 0;
				  var allNum = "";
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					
					for (j = 0;  j < targetlist.length;  j++)
					{
					  if (ch == targetlist.charAt(j))
						{
							
							allValid = false;
							break; 
						
						}
						
					}
					
					if (!allValid)
					  {
						alert("Special characters \"< > /  \\ @ |  %  ^   . * & ( ) ~ [ ] { } ? \" can not be used in the \"Address 2\" field");
						theForm.address2.focus();
						
						return (false);
						//break;
					  }
					allNum += ch;
					
					
				  }
	  
	  	  
		  }
	  

 }
 
 ///// end of address2
 

 if (theForm.city)
 {
 	theForm.city.value		=		theForm.city.value.trim();
 	if (theForm.city.value == "")
	  {
		alert("Please complete the \"City\" field.");
		theForm.city.focus();
		return (false);
	  }
	  
	  var targetlist = cityTargetList;
	  var checkStr = theForm.city.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < targetlist.length;  j++)
		{
		  if (ch == targetlist.charAt(j))
			{
				
				allValid = false;
				break; 
			
			}
			
		}
		
		if (!allValid)
		  {
			alert("Special characters \"< > /  \\ @ |  %  ^   . * & ( ) ~ [ ] { } ? \" can not be used in the \"city\" field");
			theForm.city.focus();
			
			return (false);
			//break;
		  }
		allNum += ch;
		
		
	  }
	  
 }
 //////// End of City ///////////////////
 
  
  if (theForm.state1 || theForm.state2 )
 {
 	theForm.state2.value	 =		theForm.state2.value.trim();
	theForm.state1.value	 =		theForm.state1.value.trim();
	
 	if (theForm.country_code.value == "US")
	{
		if (theForm.state1.value == "" )
		  {
			alert("Please complete the \"state\" field.");
			theForm.state1.focus();
			return (false);
		  }
	}
	else if (theForm.country_code.value == "CA")
	{		
		if (theForm.state2.value == "" )
		  {
			alert("Please complete the \"Province\" field.");
			theForm.state2.focus();
			return (false);
		  }
	} 
	
 }
 
 if (theForm.state3)
 {
 	theForm.state3.value 	 =		theForm.state3.value.trim();
 	if (theForm.state3.value == "" )
		{
			alert("Please complete the \"state\" field.");
			theForm.state3.focus();
			return (false);
		}
 }
  
  
  if (otherCountryFlag==1)
  {
  			/*if (theForm.state2)
			 {
				if (theForm.state2.value == "")
				  {
					alert("Please complete the \"State/Province/Region\" field.");
					theForm.state2.focus();
					return (false);
				  }
			 }
			 */
			 
			 if (theForm.CountryInputField)
			 {
			 	theForm.CountryInputField.value		=	theForm.CountryInputField.value.trim();
				if (theForm.CountryInputField.value == "")
				  {
					alert("Please complete the \"Country\" field.");
					theForm.CountryInputField.focus();
					return (false);
				  }
			 }
			 
			 if (theForm.zip2)
			 {
			 	theForm.zip2.value		=	theForm.zip2.value.trim();
				if (theForm.zip2.value == "")
				  {
					alert("Please complete the \"Zip Code\" field.");
					theForm.zip2.focus();
					return (false);
				  }
			 }
			 
			 
			 ////////// validate Foreign phone  ///////
			 if (theForm.countryCode)
			 {
			 	theForm.countryCode.value	  =		theForm.countryCode.value.trim();
				if (theForm.countryCode.value == "")
				  {
					alert("Please complete the \"Telephone Country Code\" field.");
					theForm.countryCode.focus();
					return (false);
				  }
				  
				  var checkOK 	= AllNumbersList;
				  var checkStr 	= theForm.countryCode.value;
				  var allValid = true;
				  var decPoints = 0;
				  var allNum = "";
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
					allNum += ch;
				  }
				  if (!allValid)
				  {
					alert("Please enter only digits in the \"Telephone Country Code\" field.");
					theForm.countryCode.focus();
					return (false);
				  }
				  
			 }
			 
			 if (theForm.wholePhoneNum)
			 {
			 	theForm.wholePhoneNum.value		=		theForm.wholePhoneNum.value.trim();
				if (theForm.wholePhoneNum.value == "")
				  {
					alert("Please complete the \"Telephone Number\" field.");
					theForm.wholePhoneNum.focus();
					return (false);
				  }
			 }
			 
			 	  var checkOK = AllNumbersList;
				  var checkStr = theForm.wholePhoneNum.value;
				  var allValid = true;
				  var decPoints = 0;
				  var allNum = "";
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
					allNum += ch;
				  }
				  if (!allValid)
				  {
					alert("Please enter only digits in the \"Telephone Number\" field.");
					theForm.wholePhoneNum.focus();
					return (false);
				  }
				  
				  
				  ////////// validate Foreign Mobile Phone  ///////
				 if (theForm.McountryCode)
				 {
				 	theForm.McountryCode.value		=		theForm.McountryCode.value.trim();		
					if (theForm.McountryCode.value != "" || theForm.MwholePhoneNum.value != "")
					  {
							 if (theForm.McountryCode.value =="")
							 {
							 	alert("Please complete the \"Cell Phone Number\" field.");
								theForm.McountryCode.focus();
								return (false);
							 }
							  var checkOK = AllNumbersList;
							  var checkStr = theForm.McountryCode.value;
							  var allValid = true;
							  var decPoints = 0;
							  var allNum = "";
							  for (i = 0;  i < checkStr.length;  i++)
							  {
								ch = checkStr.charAt(i);
								for (j = 0;  j < checkOK.length;  j++)
								  if (ch == checkOK.charAt(j))
									break;
								if (j == checkOK.length)
								{
								  allValid = false;
								  break;
								}
								allNum += ch;
							  }
							  if (!allValid)
							  {
								alert("Please enter only digits in the \"Cell Phone Country Code\" field.");
								theForm.McountryCode.focus();
								return (false);
							  }
							  
							  
							  if (theForm.MwholePhoneNum.value =="")
							 {
							 	alert("Please complete the \"Cell Phone Number\" field.");
								theForm.MwholePhoneNum.focus();
								return (false);
							 }
							  var checkOK = AllNumbersList;
							  var checkStr = theForm.MwholePhoneNum.value;
							  var allValid = true;
							  var decPoints = 0;
							  var allNum = "";
							  for (i = 0;  i < checkStr.length;  i++)
							  {
								ch = checkStr.charAt(i);
								for (j = 0;  j < checkOK.length;  j++)
								  if (ch == checkOK.charAt(j))
									break;
								if (j == checkOK.length)
								{
								  allValid = false;
								  break;
								}
								allNum += ch;
							  }
							  if (!allValid)
							  {
								alert("Please enter only digits in the \"Cell Phone Number\" field.");
								theForm.MwholePhoneNum.focus();
								return (false);
							  }
					  }
					  
					  
					  
				 }
				  //////////// end of Checking mobile phone////////
				  
				  
				  //////////////////////////////////////////
				  //   Check License Tyep           ////////
				  //////////////////////////////////////////
				 if ( theForm.ICA2 || theForm.licensetype_202)
				 {
					 var licensechosedflag2=0;
					  if ( theForm.ICA2)
					  {
						if (theForm.ICA2.checked != false )
						{  licensechosedflag2=1; }
					  }
					  
					  if (theForm.licensetype_202)
						{
							if (theForm.licensetype_202.checked != false )
							{  licensechosedflag2=1; }
							
						}
					  
						if ( licensechosedflag2==0 )
						{
							alert("Please select your license Type");
							if (theForm.ICA2)
								{theForm.ICA2.focus }
							else if (theForm.licensetype_202)
								{theForm.licensetype_202.focus }
							return false;
							
						}
					}
  }
  
  if (otherCountryFlag==0)
  {
			  if (theForm.zip)
			 {
			 	theForm.zip.value	  =		theForm.zip.value.trim();	
				if (theForm.zip.value == "")
				  {
					alert("Please complete the \"Zip Code\" field.");
					theForm.zip.focus();
					return (false);
				  }
			 }
  
  
			 if (theForm.zip)
			 {
				if (theForm.zip.value.length < 5)
				  {
					alert("Please enter 5 digits in the \"Zip Code\" field.");
					theForm.zip.focus();
					return (false);
				  }
				  
				  var checkOK = AllNumbersList;
				  var checkStr = theForm.zip.value;
				  var allValid = true;
				  var decPoints = 0;
				  var allNum = "";
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
					allNum += ch;
				  }
				  if (!allValid)
				  {
					alert("Please enter only digits in the \"Zip Code\" field.");
					theForm.zip.focus();
					return (false);
				  }
			 }
	}
	
  

  if (otherCountryFlag==0)
  {
  
  		///////////////////////////////////////
		//  validate phone number   ////
		/////////////////////////////////////
		  if (theForm.area)
		  {	
		  	theForm.area.value	   =		theForm.area.value.trim();	
			if (theForm.area.value == "")
			  {
				alert("Please complete the \"Telephone Number\" field.");
				theForm.area.focus();
				return (false);
			  }
			
			  if (theForm.area.value.length < 3)
			  {
				alert("Please complete the \"Telephone Number\" field.");
				theForm.area.focus();
				return (false);
			  }
			
			  var checkOK = AllNumbersList;
			  var checkStr = theForm.area.value;
			  var allValid = true;
			  var decPoints = 0;
			  var allNum = "";
			  for (i = 0;  i < checkStr.length;  i++)
			  {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				  if (ch == checkOK.charAt(j))
					break;
				if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
				allNum += ch;
			  }
			  if (!allValid)
			  {
				alert("Please enter only digits in the \"Telephone Number\" field.");
				theForm.area.focus();
				return (false);
			  }
			
			  theForm.prefix.value     =		theForm.prefix.value.trim();
			  	
			  if (theForm.prefix.value == "")
			  {
				alert("Please complete the \"Telephone Number\" field.");
				theForm.prefix.focus();
				return (false);
			  }
			
			  if (theForm.prefix.value.length < 3)
			  {
				alert("Please complete the \"Telephone Number\" field.");
				theForm.prefix.focus();
				return (false);
			  }
			
			  var checkOK = AllNumbersList;
			  var checkStr = theForm.prefix.value;
			  var allValid = true;
			  var decPoints = 0;
			  var allNum = "";
			  for (i = 0;  i < checkStr.length;  i++)
			  {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				  if (ch == checkOK.charAt(j))
					break;
				if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
				allNum += ch;
			  }
			  if (!allValid)
			  {
				alert("Please enter only digits in the \"Telephone Number\" field.");
				theForm.prefix.focus();
				return (false);
			  }
			
			  theForm.suffix.value		=		theForm.suffix.value.trim();
			  
			  if (theForm.suffix.value == "")
			  {
				alert("Please complete the \"Telephone Number\" field.");
				theForm.suffix.focus();
				return (false);
			  }
			
			  if (theForm.suffix.value.length < 4)
			  {
				alert("Please complete the \"Telephone Number\" field.");
				theForm.suffix.focus();
				return (false);
			  }
			
			  var checkOK 	= AllNumbersList;
			  var checkStr 	= theForm.suffix.value;
			  var allValid = true;
			  var decPoints = 0;
			  var allNum = "";
			  for (i = 0;  i < checkStr.length;  i++)
			  {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				  if (ch == checkOK.charAt(j))
					break;
				if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
				allNum += ch;
			  }
			  if (!allValid)
			  {
				alert("Please enter only digits in the \"Telephone Number\" field.");
				theForm.suffix.focus();
				return (false);
			  }
		  }
		  
		  
		 ///////////////////////////////////////
		//  validate Mobile phone number   ////
		/////////////////////////////////////
		 if (theForm.Marea)
		  {
		  	theForm.Marea.value 	=	theForm.Marea.value.trim();
			theForm.Mprefix.value	=	theForm.Mprefix.value.trim();
			theForm.Msuffix.value	=	theForm.Msuffix.value.trim();
			
			if (theForm.Marea.value != "" || theForm.Mprefix.value != "" || theForm.Msuffix.value != "")
			  {				
					if (theForm.Marea.value.length < 3)
					  {
						alert("Please complete the \"Cell Phone Number\" field.");
						theForm.Marea.focus();
						return (false);
					  }
					
					  var checkOK = AllNumbersList;
					  var checkStr = theForm.Marea.value;
					  var allValid = true;
					  var decPoints = 0;
					  var allNum = "";
					  for (i = 0;  i < checkStr.length;  i++)
					  {
						ch = checkStr.charAt(i);
						for (j = 0;  j < checkOK.length;  j++)
						  if (ch == checkOK.charAt(j))
							break;
						if (j == checkOK.length)
						{
						  allValid = false;
						  break;
						}
						allNum += ch;
					  }
					  if (!allValid)
					  {
						alert("Please enter only digits in the \"Cell Phone Number\" field.");
						theForm.Marea.focus();
						return (false);
					  }
					
					 
					 
					
					  if (theForm.Mprefix.value.length < 3)
					  {
						alert("Please complete the \"Cell Phone Number\" field.");
						theForm.Mprefix.focus();
						return (false);
					  }
					
					  var checkOK = AllNumbersList;
					  var checkStr = theForm.Mprefix.value;
					  var allValid = true;
					  var decPoints = 0;
					  var allNum = "";
					  for (i = 0;  i < checkStr.length;  i++)
					  {
						ch = checkStr.charAt(i);
						for (j = 0;  j < checkOK.length;  j++)
						  if (ch == checkOK.charAt(j))
							break;
						if (j == checkOK.length)
						{
						  allValid = false;
						  break;
						}
						allNum += ch;
					  }
					  if (!allValid)
					  {
						alert("Please enter only digits in the \"Cell Phone Number\" field.");
						theForm.Mprefix.focus();
						return (false);
					  }
					
					  
					  
					  
					
					  if (theForm.Msuffix.value.length < 4)
					  {
						alert("Please complete the \"Cell Phone Number\" field.");
						theForm.Msuffix.focus();
						return (false);
					  }
					
					  var checkOK   = AllNumbersList;
					  var checkStr  = theForm.Msuffix.value;
					  var allValid  = true;
					  var decPoints = 0;
					  var allNum = "";
					  for (i = 0;  i < checkStr.length;  i++)
					  {
						ch = checkStr.charAt(i);
						for (j = 0;  j < checkOK.length;  j++)
						  if (ch == checkOK.charAt(j))
							break;
						if (j == checkOK.length)
						{
						  allValid = false;
						  break;
						}
						allNum += ch;
					  }
					  if (!allValid)
					  {
						alert("Please enter only digits in the \"Cell Phone Number\" field.");
						theForm.Msuffix.focus();
						return (false);
					  }
				
				
			  }
			
		  }
		  
		  ////////  end of validating Moblie phone //////
		  
  }
  
  
  /////////////////////////////////////////////////
 ////   License state2  same state Yes or NO  ///
////////////////////////////////////////////////

/*
  if (theForm.Licensestate2)
  { 
  	if (theForm.Licensestate2[0].checked != true && theForm.Licensestate2[1].checked != true)
	{
		alert("Please select your license state");
		theForm.Licensestate2[0].focus();
		return false;
	}
	else if ( theForm.Licensestate2[1].checked == true )
	{ //alert("OK1");
		if (theForm.country_code.value == "US")
		{
			if (theForm.licensestate_select1.value == ""  )
			{	
				alert("Please select your license state");
				theForm.licensestate_select1.focus();
				return false;
			}
		}
		else if (theForm.country_code.value == "CA")
		{
			if (theForm.licensestate_select2.value == ""  )
			{	
				alert("Please select your license province");
				theForm.licensestate_select2.focus();
				return false;
			}
		}
		
	}
	
  } 
  
 */ 
 
 
  
  /////////////////////////////////////////////////////
  //  License type
  ////////////////////////////////////////////////////
  if (otherCountryFlag==0)
  {
		  if (theForm.licensetype_1 || theForm.licensetype_2 || theForm.licensetype_200 || theForm.CFP || theForm.CPCU || theForm.CLU || theForm.CLF || theForm.CHFC || theForm.RHU || theForm.REBC || theForm.IRES || theForm.ICA || theForm.CPDM || theForm.CCMP || theForm.WCCP)
		  {
				var licensechosedflag=0;
				if (theForm.licensetype_1)
				{
					if (theForm.licensetype_1.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.licensetype_2)
				{
					if (theForm.licensetype_2.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.CFP)
				{
					if (theForm.CFP.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.CPCU)
				{
					if (theForm.CPCU.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.CLU)
				{
					if (theForm.CLU.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.CLF)
				{
					if (theForm.CLF.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.CHFC)
				{
					if (theForm.CHFC.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.RHU)
				{
					if (theForm.RHU.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.REBC)
				{
					if (theForm.REBC.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.IRES)
				{
					if (theForm.IRES.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.ICA)
				{
					if (theForm.ICA.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				
				if (theForm.CPDM)
				{
					if (theForm.CPDM.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.CCMP)
				{
					if (theForm.CCMP.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.WCCP)
				{
					if (theForm.WCCP.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				
				if (theForm.licensetype_200)
				{
					if (theForm.licensetype_200.checked != false )
					{  licensechosedflag=1; }
					
				}
				
				if (theForm.importing_600)
				{
					if (theForm.importing_600.value == 0 )
					{  licensechosedflag=1; }
					
				}
		  
				
				if ( licensechosedflag==0 )
				{
					alert("Please select your license Type");
					if (theForm.licensetype_1)
						{theForm.licensetype_1.focus }
					else if (theForm.licensetype_2)
						{theForm.licensetype_2.focus }
					return false;
					
				}
				
				
				if (theForm.licensetype_1)
				{
						//////////////////////////////////////////////////
						//  validation for insurance license type    ////
						////////////////////////////////////////////////
						if (theForm.licensetype_1.checked== true)
						{
							if (theForm.Licensestate2[0].checked== false && theForm.Licensestate2[1].checked== false)
							{
								//////////////////////////////////////////////////
								//  user doesn't choose Yes and NO           ////
								////////////////////////////////////////////////
								alert("Please select your Insurance license State");
								return false;
							}
							else if (theForm.Licensestate2[1].checked== true)
							{
								//////////////////////////////////
								//  user  choosed NO       ////
								////////////////////////////////
								if (theForm.country_code.value == "US")
								{
									if (theForm.InsurLicState.value=="")
									{
										alert("Please select your Insurance license State");
										theForm.InsurLicState.focus();
										return false;
									}
								}
								else if (theForm.country_code.value == "CA")
								{
									if (theForm.InsurLicState2.value=="")
									{
										alert("Please select your Insurance license state");
										theForm.InsurLicState2.focus();
										return false;
									}
								}
								
							}
							
							
							
							////////////////////////////////////////
							// validation for license Due day  ////
							///////////////////////////////////////
							if (theForm.LicenseDueDate)
							{
								if (theForm.LicenseDueDate.value == "")
								{
									alert("Please complete the \"CE Deadline Date\" field.");
									
									theForm.SelectMonth.focus();
									return false;
								}
								else 
								{	
									
									var strLicenseDueDate=theForm.LicenseDueDate.value;
									
									
									var match=strLicenseDueDate.match(dateregex);
									
									if (match) 
									{
										 
									}
									else
									 {
										alert("Please enter valid values for the day, month and year(mm/dd/yyyy)!");
										//theForm.LicenseDueDate.focus();
										theForm.SelectMonth.focus();
										 return false;
									 } 
								}
							}//////end of Due day
							
						  
						}
				}
				
				
				
				
				if (theForm.licensetype_2)
				{
						/////////////////////////////////////////////////
						//// validate for Adjuster type  ///////////////
						////////////////////////////////////////////////
						if (theForm.licensetype_2.checked== true)
						{
							var totaladjrow, totalSubadjrow
							totaladjrow=document.all.totaladjCheckbox.value;
							totalSubadjrow=document.all.totaladjSublicCheckbox.value;
							
							var ajcount=0
							var findingadj=0
							var findadjNH=0
								//alert("adj"+numtotaladj);
							while (ajcount<totaladjrow)
							{
								if ( document.all.adjCheckbox[ajcount].value !="" )
								{
									findingadj=1;
									if ( document.all.adjCheckbox[ajcount].value =="NH" )
									{
										findadjNH=1
										//alert("NH");
										break;
									}
								}
								
									ajcount++;
							}
							/////////////////////////////////////////////////
							//// no state had been choosed for adjuster   //
							////////////////////////////////////////////////
							if (findingadj==0)
							{
								alert("Please select at least one Adjuster State");
								if (theForm.licensetype_2.checked== true)
								{
									var adjChildWin;
									adjChildWin=window.open('AdjLicAccttForm.asp','adjusterstatelist','scrollbars=yes,resizable=yes,width=640,height=638');
									adjChildWin.focus();
								}						
								return false;
								
							}
							
							///////////////////////////////////////
							//// NH has been choosen///////////////
							//////////////////////////////////////
							
							if (findadjNH ==1)
							{
								var findadjSub=0;
								var sbjcount=0;
								while (sbjcount<totalSubadjrow)
								{
									if (document.all.adjSublicCheckbox[sbjcount].value !="" )
									{
										findadjSub=1;
										break;
									}
									sbjcount++;
								}
								
								///////////////////////////////////////
								//// no NH subtype has been choosen ///
								//////////////////////////////////////
								if (findadjSub==0)
								{
									alert("Please select at least one subtype for New Hampshire adjuster");
									if (theForm.licensetype_2.checked== true)
									{
										var adjChildWin;
										adjChildWin=window.open('AdjLicAccttForm.asp','adjusterstatelist','scrollbars=yes,resizable=yes,width=640,height=638');
										//adjChildWin.focus();
										//adjChildWin.document.all.adjustSubTypeArea.style.display="";
										//alert(" New Hampshire adjuster");
									}						
									return false;
								}
							
							}
							
						}
					}			
		  }
  
  }
  
  
  
   /////////////////////////////////////////////////
 ////   License Subtype  //////////////////////////
////////////////////////////////////////////////

  if (theForm.adjuster_Sub_license)
  {
  		
	if (theForm.licensetype[1].checked==true)
	{
		if (theForm.state1 && theForm.state1.value=="NH" && theForm.Licensestate2[0].checked==true ) 
		{
			
			
			if (theForm.adjuster_Sub_license.value=="NONE")
			{	
				alert("Please select your Adjuster Type");
				theForm.adjuster_Sub_license.focus();
				return false;
			}
		
		}
		else if(theForm.Licensestate2[1].checked==true && theForm.licensestate_select1.value=="NH")
		{
			if (theForm.adjuster_Sub_license.value=="NONE")
			{	
				alert("Please select your Adjuster Type");
				theForm.adjuster_Sub_license.focus();
				return false;
			}
		}
	}
	
  
  }
    
    /////////////////////////////////////
  //	Referrer's Email ///////////////
  //					//////////////
 if(theForm.referral)
 {
  if(theForm.referral.value.length > 0)
  {
		theForm.referral.value	=	theForm.referral.value.trim();
		if (theForm.referral.value == "")
	  	{
			alert("Please complete the \"Referrer's Email\" field.");
			theForm.referral.focus();
			return (false);
	  	}
	  else
	  {
		var checkStr = theForm.referral.value;
		var atnum = 0
		var atdot = 0
		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			if (ch == "@")
				atnum = atnum +1;
			else if (ch == ".")
				atdot = atdot +1;
		}
		if ((atnum == 0 || atnum > 1) || (atdot == 0))
		{
			alert("You must enter a valid referrer's email address");
			theForm.referral.focus();
			return (false);
		}
		
		
		////special charaters in email address
		
		  var targetlist = emailTargetList;
		  var checkStr2 = theForm.referral.value;
		  var allValid = true;
		  var decPoints = 0;
		  var allNum = "";
		  for (i = 0;  i < checkStr2.length;  i++)
		  {
			ch = checkStr2.charAt(i);
			
			for (j = 0;  j < targetlist.length;  j++)
			{
			  if (ch == targetlist.charAt(j))
				{
					
					allValid = false;
					break; 
				
				}// If
				
			}//	For j
			
			if (!allValid)
			  {
				alert("Special characters \"< > /  \\  |  %  ^  #   * & ( ) ~ [ ] { } ? = ! \" can not be used in the \"Referrer's Email\" field");
				theForm.referral.focus();
				
				return (false);
				//break;
			  }
			allNum += ch;						
		  }//For i		
		////end of checking special charaters in email address		
  	}//Else


  }
}
  
  /////////////////////////////////////////////////
 ////   Email    /////////////////////////////////
 ////////////////////////////////////////////////
  if (theForm.email)
  {
  	theForm.email.value		=	theForm.email.value.trim();
  	if (theForm.email.value == "")
	  {
		alert("Please complete the \"Email\" field.");
		theForm.email.focus();
		return (false);
	  }
	  else
	  {
		var checkStr = theForm.email.value;
		var atnum = 0
		var atdot = 0
		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			if (ch == "@")
				atnum = atnum +1;
			else if (ch == ".")
				atdot = atdot +1;
		}
		if ((atnum == 0 || atnum > 1) || (atdot == 0)){
			alert("You must enter a valid email address");
			theForm.email.focus();
			return (false);
		}
		
		
		////special charaters in email address
		
		  var targetlist = emailTargetList;
		  var checkStr2 = theForm.email.value;
		  var allValid = true;
		  var decPoints = 0;
		  var allNum = "";
		  for (i = 0;  i < checkStr2.length;  i++)
		  {
			ch = checkStr2.charAt(i);
			
			for (j = 0;  j < targetlist.length;  j++)
			{
			  if (ch == targetlist.charAt(j))
				{
					
					allValid = false;
					break; 
				
				}
				
			}
			
			if (!allValid)
			  {
				alert("Special characters \"< > /  \\  |  %  ^  #   * & ( ) ~ [ ] { } ? = ! \" can not be used in the \"Email\" field");
				theForm.email.focus();
				
				return (false);
				//break;
			  }
			allNum += ch;
			
			
		  }
		
		////end of checking special charaters in email address
	  }		
  }

  
  /////////////////////////////////////////////////
 ////   Employer    //////////////////////////////
 ////////////////////////////////////////////////
   if (theForm.employer)
   {
   		theForm.employer.value		=	theForm.employer.value.trim();
   		if (theForm.employer.value == "")
		  {
			alert("Please complete the \"Employer\" field.");
			theForm.employer.focus();
			return (false);
		  }
		  
	  var targetlist = employerNameTargetList;
	  var checkStr 	 = theForm.employer.value;
	  var allValid 	 = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < targetlist.length;  j++)
		{
		  if (ch == targetlist.charAt(j))
			{
				allValid = false;
				break; 			
			}			
		}
		
		if (!allValid)
		  {
			alert("Special characters \"< > /  \\ @ |  %  ^  #  . * & ( ) ~ [ ] { } \" can not be used in the \"Employer\" field");
			theForm.employer.focus();			
			return (false);
			//break;
		  }
		allNum += ch;
		
		
	  }
	  
	  
	  
   }
   
  
  /////////////////////////////////////////////////
 ////   Number of Licenseees    ///////////////////
 ////////////////////////////////////////////////
   if (theForm.NumOfLicensee)
   {
   		if (theForm.NumOfLicensee.value == "")
		  {
			alert("Please complete the \"Number of Licensees\" field.");
			theForm.NumOfLicensee.focus();
			return (false);
		  }
		  
		  var checkOK = AllNumbersList;
		  var checkStr = theForm.NumOfLicensee.value;
		  var allValid = true;
		  var decPoints = 0;
		  var allNum = "";
		  
		  for (i = 0;  i < checkStr.length;  i++)
		  {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				  if (ch == checkOK.charAt(j))
					break;
				if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
				allNum += ch;
			}
			  
			  if (!allValid)
			  {
				alert("Please enter only digits in the \"Number of Licensees\" field.");
				theForm.NumOfLicensee.focus();
				return (false);
			  }
			  
			  
			  
   }

  	if (NotRequireSSN==0)
  	{
		  if (theForm.ss1)
		  {
			  var checkOK = AllNumbersList;
			  var checkStr = theForm.ss1.value;
			  var allValid = true;
			  var decPoints = 0;
			  var allNum = "";
			  
			  if ( checkStr.length < 3 )
			  {
				alert("Please complete the \"Social Security Number\" field.");
				theForm.ss1.focus();

				return (false);
			  }
			
			  for (i = 0;  i < checkStr.length;  i++)
			  {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				  if (ch == checkOK.charAt(j))
					break;
				if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
				allNum += ch;
			  }
			  if (!allValid)
			  {
				alert("Please enter only digits in the \"Social Security Number\" field.");
				theForm.ss1.focus();
				return (false);
			  }	
				
		  }
		  
		  
		  if (theForm.ss2)
		  {
			  var checkOK = AllNumbersList;
			  var checkStr = theForm.ss2.value;
			  var allValid = true;
			  var decPoints = 0;
			  var allNum = "";
			  if ( checkStr.length < 2 )
			  {
				alert("Please complete the \"Social Security Number\" field.");
				theForm.ss2.focus();
				return (false);
			  }
			
			  for (i = 0;  i < checkStr.length;  i++)
			  {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				  if (ch == checkOK.charAt(j))
					break;
				if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
				allNum += ch;
			  }
			  if (!allValid)
			  {
				alert("Please enter only digits in the \"Social Security Number\" field.");
				theForm.ss2.focus();
				return (false);
			  }
		  }
		  
		  
		  if (theForm.ss3)
		  {
			  var checkOK = AllNumbersList;
			  var checkStr = theForm.ss3.value;
			  var allValid = true;
			  var decPoints = 0;
			  var allNum = "";
			  if ( checkStr.length < 4 )
			  {
				alert("Please complete the \"Social Security Number\" field.");
				theForm.ss3.focus();
				return (false);
			  }
			
			  for (i = 0;  i < checkStr.length;  i++)
			  {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				  if (ch == checkOK.charAt(j))
					break;
				if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
				allNum += ch;
			  }
			  if (!allValid)
			  {
				alert("Please enter only digits in the \"Social Security Number\" field.");
				theForm.ss3.focus();
				return (false);
			  }
		  }
		  
		  
		  /// Retype SS and check if it match with the previous input
		  
		  ///  rr1  ///
		  if (theForm.rr1)
		  {  
		  	  if ( theForm.rr1.value.length < 3 )
			  {
				alert("Please complete the \"Retype Social Security Number\" field.");
				theForm.rr1.focus();
				return (false);
			  }
			  
			  if (theForm.rr1.value != theForm.ss1.value)
			  {
			  	alert("Please reenter your social security number again so that the \"Social Security #\" and the \"Retype Social Security #\" fields are the same.  Thank you!");
				theForm.rr1.focus();
				return (false);
			  }
		  }
		  
		  ///  rr2  ///
		  if (theForm.rr2)
		  {  
		  	  if ( theForm.rr2.value.length < 2 )
			  {
				alert("Please complete the \"Retype Social Security Number\" field.");
				theForm.rr2.focus();
				return (false);
			  }
			  
			  if (theForm.rr2.value != theForm.ss2.value)
			  {
			  	alert("Please reenter your social security number again so that the \"Social Security #\" and the \"Retype Social Security #\" fields are the same.  Thank you!");
				theForm.rr2.focus();
				return (false);
			  }
		  }
		  
		  
		  ///  rr3  ///
		  if (theForm.rr3)
		  {  
		  	  if ( theForm.rr3.value.length < 4 )
			  {
				alert("Please complete the \"Retype Social Security Number\" field.");
				theForm.rr3.focus();
				return (false);
			  }
			  
			  if (theForm.rr3.value != theForm.ss3.value)
			  {
			  	alert("Please reenter your social security number again so that the \"Social Security #\" and the \"Retype Social Security #\" fields are the same.  Thank you!");
				theForm.rr3.focus();
				return (false);
			  }
		  }
		  
		  
		  
  	} ////end if checking NotRequireSSN=0
	
	
	//////// NPN start/////
		if (theForm.NPN)
		  {
			  if (theForm.NPNRequireFlag)
			  {
			  		if (theForm.NPN.value == "")
					  {
						alert("Please complete the \"National Producer Number\" field.");
						theForm.NPN.focus();
						return (false);
					  }
					 else
					  {
					  		  var checkOK = AllNumbersList;
							  var checkStr = theForm.NPN.value;
							  var allValid = true;
							  var leadingzero =	true;
							  var decPoints = 0;
							  var allNum = "";
							  
							  if ( checkStr.length < 3 )
							  {
								alert("Please complete the \"National Producer Number \" field.");
								theForm.NPN.focus();
								return (false);
							  } 
							
							  for (i = 0;  i < checkStr.length;  i++)
							  {
								ch = checkStr.charAt(i);
								if (i ==0)
								{
									if (ch ==0)
									{
										leadingzero = false;
										break;
									}
								}
								for (j = 0;  j < checkOK.length;  j++)
								  if (ch == checkOK.charAt(j))
									break;
								if (j == checkOK.length)
								{
								  allValid = false;
								  break;
								}
								allNum += ch;
							  }
							  
							  if (!leadingzero)
							  {
								alert("Can not start with 0 in the \"National Producer Number \" field.");
								theForm.NPN.focus();
								return (false);
							  }
							  
							  if (!allValid)
							  {
								alert("Please enter only digits in the \"National Producer Number \" field.");
								theForm.NPN.focus();
								return (false);
							  }
					  
					  }
					  
					if (theForm.NPN2.value == "")
					  {
						alert("Please complete the \"Retype National Producer Number\" field.");
						theForm.NPN2.focus();
						return (false);
					  }
					  
					if (theForm.NPN.value != theForm.NPN2.value)
					  {
						alert("Please reenter your National Producer Number  again so that the \"National Producer Number \" and the \"Retype National Producer Number \" fields are the same.  Thank you!");
						theForm.NPN2.focus();
						return (false);
					  }
					  
					  
					  
			  }
			  else
			  {
			  		if (  theForm.NPN.value !="" || theForm.NPN2.value != "" )
					  {
							  var checkOK = AllNumbersList;
							  var checkStr = theForm.NPN.value;
							  var allValid = true;
							  var leadingzero =	true;
							  var decPoints = 0;
							  var allNum = "";
							  
							  if ( checkStr.length < 3 )
							  {
								alert("Please complete the \"National Producer Number \" field.");
								theForm.NPN.focus();
								return (false);
							  } 
							
							  for (i = 0;  i < checkStr.length;  i++)
							  {
								ch = checkStr.charAt(i);
								if (i ==0)
								{
									if (ch ==0)
									{
										leadingzero = false;
										break;
									}
								}
								for (j = 0;  j < checkOK.length;  j++)
								  if (ch == checkOK.charAt(j))
									break;
								if (j == checkOK.length)
								{
								  allValid = false;
								  break;
								}
								allNum += ch;
							  }
							  
							  if (!leadingzero)
							  {
								alert("Can not start with 0 in the \"National Producer Number \" field.");
								theForm.NPN.focus();
								return (false);
							  }
							  
							  if (!allValid)
							  {
								alert("Please enter only digits in the \"National Producer Number \" field.");
								theForm.NPN.focus();
								return (false);
							  }
							  
							  
							  
							 /* if ( theForm.NPN2.value.length < 10 )
							  {
								alert("Please complete the \"Retype National Producer Number \" field.");
								theForm.NPN2.focus();
								return (false);
							  }
							  */
							  
							  if (theForm.NPN.value != theForm.NPN2.value)
							  {
								alert("Please reenter your National Producer Number  again so that the \"National Producer Number \" and the \"Retype National Producer Number \" fields are the same.  Thank you!");
								theForm.NPN2.focus();
								return (false);
							  }
				  
							  
					  } //// end of either NPN1 or NPN2 is not empty
					  
			  }/////end of checking NPNRequireFlag
			  
				  	
				
		  }
			 
		//////// NPN end/////	 
			 
			 	  
  
   
	
   if (theForm.licensenumber)
   {
   		if (theForm.licensenumber.value == "")
		  {
			alert("Please complete the \"license number\" field.");
			theForm.licensenumber.focus();
			return (false);
		  }
		 else
		 {
			var re 		   =	licenseNumRegExpression; 
			var m 		   = 	re.test(theForm.licensenumber.value);
			if (m == false) 
			{
			    alert("License Number Field is invalid, please try again!");
				theForm.licensenumber.focus();
				return false;
			} 	
		 }
   }
   
   
   /////  Check Retype License number field  /////
   if (theForm.licensenumber2)
   {
   		if (theForm.licensenumber2.value == "")
		  {
			alert("Please complete the \"Retype license number\" field.");
			theForm.licensenumber2.focus();
			return (false);
		  }
		 else
		 {
		 	var re 		   =	licenseNumRegExpression; 
			var m 		   = 	re.test(theForm.licensenumber2.value);
			if (m == false) 
			{
			    alert("\"Retype license number\" field is invalid, please try again!");
				theForm.licensenumber2.focus();
				return false;
			} 	
		 }
		  
		if ( theForm.licensenumber2.value != theForm.licensenumber.value)
		  {
		  	alert("Please make sure the input in \"Retype license number\" field is the same as the input in \"license number\" field. ");
			theForm.licensenumber2.focus();
			return (false);
		  }
   }
   
   
   
   //////// HI student Vendor number start/////
		
		if (theForm.HIVenRequireFlag)
		{
			  		if (theForm.HIVendorNumber.value == "")
					  {
						alert("Please complete the \"Vendor ID\" field.");
						theForm.HIVendorNumber.focus();
						return (false);
					  }
					 else
					  {
					  		  var checkOK = AllNumbersList;
							  var checkStr = theForm.HIVendorNumber.value;
							  var allValid = true;
							  var leadingzero =	true;
							  var decPoints = 0;
							  var allNum = "";
							  
							  if ( checkStr.length < 6 )
							  {
								alert("Please complete the \"Vendor ID\" field.");
								theForm.HIVendorNumber.focus();
								return (false);
							  } 
							
							  for (i = 0;  i < checkStr.length;  i++)
							  {
								ch = checkStr.charAt(i);
								
								for (j = 0;  j < checkOK.length;  j++)
								  if (ch == checkOK.charAt(j))
									break;
								if (j == checkOK.length)
								{
								  allValid = false;
								  break;
								}
								allNum += ch;
							  }
							  
							  
							  
							  if (!allValid)
							  {
								alert("Please enter only digits in the \"Vendor ID\" field.");
								theForm.HIVendorNumber.focus();
								return (false);
							  }
					  
					  }
					  
					if (theForm.HIVendorNumber2.value == "")
					  {
						alert("Please complete the \"Retype Vendor ID\" field.");
						theForm.HIVendorNumber2.focus();
						return (false);
					  }
					  
					if (theForm.HIVendorNumber.value != theForm.HIVendorNumber2.value)
					  {
						alert("Please reenter your Vendor ID  again so that the \"Vendor ID \" and the \"Retype Vendor ID \" fields are the same.  Thank you!");
						theForm.HIVendorNumber2.focus();
						return (false);
					  }
					  
					  
			
			  
					  
		}/////end of checking HIVenRequireFlag
			  
				  	
			 
		//////// HI student Vendor number end/////
   
   
   
   if (theForm.Proctornumber)
   {
   		if (theForm.Proctornumber.value == "")
		  {
			alert("You should fill out the proctor number before you take the exam!!");
			theForm.Proctornumber.focus();
			return (false);
		  }
		else
		  {
		  
		  	var nyproctorpart1;
			nyproctorpart1=theForm.Proctornumber.value.slice(0,4);
			
			//alert("1: "+nyproctorpart1);
			if ( nyproctorpart1.toUpperCase() !="NYMO")
			{
				alert("This is not a New York Proctor Number, please fill out a correct New York Proctor Number!!");
				theForm.Proctornumber.focus();
				return false;
			}
			
			 
		  }
   }
   
   
  if (theForm.ReadFLform)
  {
  		if (theForm.ReadFLform.value==0 )
		{
			alert("You are not allowed to take exam !!");
  			return (false);
		}
  }	
  
  if (theForm.report2NC)
  {
  	if (theForm.report2NC.checked==true )
	{
		if (theForm.LHPC2[0].checked ==false && theForm.LHPC2[1].checked ==false)
		{
			alert("Please indicate your license type if you want to report credits");
  			return (false);	
		}
	}
  }
  else
  {
  	if (theForm.LHPC1)	
	{
		if (theForm.LHPC1[0].checked ==false && theForm.LHPC1[1].checked ==false)
		{
			alert("Please indicate your license type if you want to report credits");
			return (false);
		}
	}
  }
  
  
  
  //***************License renew date depends on birthday**********************************
  //if (theForm.askDOB.value == "1")
  //if (theForm.askDOB == 'object')
  if (theForm.askDOB)
  {
  	//alert("inside Dob!!!");	
  	if (theForm.DOB4License.value == "")
	{
  		alert("Please complete the \"Your License Date Birthday \" field");
    	theForm.DOB4License.focus();
    	return (false);
	}
	if (theForm.licensecycle.value == "")
	{
		alert("the license cycle for this state is empty!!");
    	theForm.DOB4License.focus();
    	return (false);
	}
	else 
	{
		var msg;
		var strDOB=theForm.DOB4License.value;
		var cyctime=theForm.licensecycle.value
		//var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
		var match=strDOB.match(dateregex);
		if (match) 
        {
            var tmpdate=new Date(match[3],parseInt(match[1],10)-1,match[2]);
             if (tmpdate.getDate()==parseInt(match[2],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[1],10))
              { 
                 var today= new Date();
				 var nextlicenserenewday=new Date(tmpdate);
				 var newyear=parseInt(tmpdate.getFullYear())+parseInt(cyctime);
				 nextlicenserenewday.setYear(newyear);
				 //alert("next license renew day"+nextlicenserenewday);
				
				if (nextlicenserenewday.getFullYear()<today.getFullYear())
				{
					msg="Your license has expired ! \n click ok to continue";
					if (confirm(msg))
					{
						theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
					}
					else
					{
						theForm.DOB4License.focus();
						return false;
					}
					
				}
				else if ( nextlicenserenewday.getFullYear()==today.getFullYear() )
				{
					if ((nextlicenserenewday.getMonth()+1) < (today.getMonth()+1)) 
					{
						msg="Your license has expired ! \n click ok to continue";
						if (confirm(msg))
						{
							theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
						}
						else
						{
							theForm.DOB4License.focus();
							return false;
						}
						
					}
					else if ((nextlicenserenewday.getMonth()+1) == (today.getMonth()+1))
					{
						if ( nextlicenserenewday.getDate() < today.getDate() )
						{
							msg="Your license has expired ! \n click ok to continue";
							if (confirm(msg))
							{
								theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
							}
							else
							{
								theForm.DOB4License.focus();
								return false;
							}
							
						}
						else	//***********4 day ok
						{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
						
					}
					else	//***********4 month ok
					{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
					
					
				}
				else	//*************4 year ok
				{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
				
				
               }
			  
        }
		else	//************for not match
		{
         alert("Please enter valid values for the day, month and year(mm/dd/yyyy)!");
		 theForm.DOB4License.focus();
         return false;
		 }
	
	}
  }
  
  //*********************End   License renew date depends on birthday***************************
  
  
   //***************License renew date depends on License day**********************************
  //if (theForm.askDOB.value == "1")
  //if (theForm.askDOB == 'object')
  if (theForm.askLicenseDate)
  {
  	//alert("inside Dob!!!");
	if (theForm.statelicensedueday)		//*******************depends on user's license day and state rule ***********type 7
	{
		
			if (theForm.LicenseDate.value == "")
			{
  				alert("Please complete the \"Your License Date \" field");
    			theForm.LicenseDate.focus();
    			return (false);
			}
			else if (theForm.licensecycle.value == "")
			{
				alert("the license cycle for this state is empty!!");
    			theForm.LicenseDate.focus();
    			return (false);
			}
			else if (theForm.statelicensedueday.value == "")
			{
				alert("the state's license cycle for this state is empty!! \n contact with DBA");
    			theForm.LicenseDate.focus();
    			return (false);
			}
			else
			{
				var msg;
				var strDOB=theForm.LicenseDate.value;
				var cyctime=theForm.licensecycle.value;
				var strstatelicensedueday=theForm.statelicensedueday.value;
				
				//var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
				var match=strDOB.match(dateregex);
				var match4statelicensedueday=strstatelicensedueday.match(dateregex);
				if (match) 
        		{
            		var tmpdate=new Date(match[3],parseInt(match[1],10)-1,match[2]);
					var tmpstatedueday= new Date(match4statelicensedueday[3],parseInt(match4statelicensedueday[1],10)-1,match4statelicensedueday[2]);
					//alert("tmpstatedueday: "+tmpstatedueday);
					var newday=parseInt(tmpstatedueday.getDate())
					var newmonth=parseInt(tmpstatedueday.getMonth())
					
             		if (tmpdate.getDate()==parseInt(match[2],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[1],10))
              		{ 
                 		var today= new Date();
				 		var nextlicenserenewday=new Date(tmpdate);
				 		var newyear=parseInt(tmpdate.getFullYear())+parseInt(cyctime);
				 		nextlicenserenewday.setYear(newyear);
						nextlicenserenewday.setMonth(newmonth);
						nextlicenserenewday.setDate(newday);
						
				 		//alert("next license renew day nextlicenserenewday: "+nextlicenserenewday);
				
						if (nextlicenserenewday.getFullYear()<today.getFullYear())
						{
							msg="Your license has expired ! \n click ok to continue";
							if (confirm(msg))
							{
								theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
							}
							else
							{
								theForm.LicenseDate.focus();
								return false;
							}
					
						}
						else if ( nextlicenserenewday.getFullYear()==today.getFullYear() )
						{
							if ((nextlicenserenewday.getMonth()+1) < (today.getMonth()+1)) 
							{
								msg="Your license has expired ! \n click ok to continue";
								if (confirm(msg))
								{
									theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
								}
								else
								{
									theForm.LicenseDate.focus();
									return false;
								}
						
							}
							else if ((nextlicenserenewday.getMonth()+1) == (today.getMonth()+1))
							{
								if ( nextlicenserenewday.getDate() < today.getDate() )
								{
									msg="Your license has expired ! \n click ok to continue";
									if (confirm(msg))
									{
										theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
									}
									else
									{
										theForm.LicenseDate.focus();
										return false;
									}
							
								}
								else	//***********4 day ok
								{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
						
								}
							else	//***********4 month ok
							{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
					
					
							}
					else	//*************4 year ok
					{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
				
				
               		}
			  
        		}
				else	//************for not match
				{
         		alert("Please enter valid values for the day, month and year(mm/dd/yyyy)!");
		 		theForm.LicenseDate.focus();
         		return false;
		 		}
				
			}	//***************end of depends on user's license day and state
			
	}
	else	//*******************depends on user's licnese day only ******type 3
	{
			if (theForm.LicenseDate.value == "")
			{
  				alert("Please complete the \"Your License Date  \" field");
    			theForm.LicenseDate.focus();
    			return (false);
			}
			else if (theForm.licensecycle.value == "")
			{
				alert("the license cycle for this state is empty!!");
    			theForm.LicenseDate.focus();
    			return (false);
			}
	
			else 
			{
				var msg;
				var strDOB=theForm.LicenseDate.value;
				var cyctime=theForm.licensecycle.value;
				//var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
				var match=strDOB.match(dateregex);
				if (match) 
        		{
            		var tmpdate=new Date(match[3],parseInt(match[1],10)-1,match[2]);
             		if (tmpdate.getDate()==parseInt(match[2],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[1],10))
              		{ 
                 		var today= new Date();
				 		var nextlicenserenewday=new Date(tmpdate);
				 		var newyear=parseInt(tmpdate.getFullYear())+parseInt(cyctime);
				 		nextlicenserenewday.setYear(newyear);
				 		//alert("next license renew day"+nextlicenserenewday);
				
						if (nextlicenserenewday.getFullYear()<today.getFullYear())
						{
							msg="Your license has expired ! \n click ok to continue";
							if (confirm(msg))
							{
								theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
							}
							else
							{
								theForm.LicenseDate.focus();
								return false;
							}
					
						}
						else if ( nextlicenserenewday.getFullYear()==today.getFullYear() )
						{
							if ((nextlicenserenewday.getMonth()+1) < (today.getMonth()+1)) 
							{
								msg="Your license has expired ! \n click ok to continue";
								if (confirm(msg))
								{
									theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
								}
								else
								{
									theForm.LicenseDate.focus();
									return false;
								}
						
							}
							else if ((nextlicenserenewday.getMonth()+1) == (today.getMonth()+1))
							{
								if ( nextlicenserenewday.getDate() < today.getDate() )
								{
									msg="Your license has expired ! \n click ok to continue";
									if (confirm(msg))
									{
										theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();
									}
									else
									{
										theForm.LicenseDate.focus();
										return false;
									}
							
								}
								else	//***********4 day ok
								{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
						
								}
							else	//***********4 month ok
							{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
					
					
							}
					else	//*************4 year ok
					{theForm.yournextlicensedueday.value=(nextlicenserenewday.getMonth()+1)+"/"+nextlicenserenewday.getDate()+"/"+nextlicenserenewday.getYear();}
				
				
               		}
			  
        		}
				else	//************for not match
				{
         		alert("Please enter valid values for the day, month and year(mm/dd/yyyy)!");
		 		theForm.LicenseDate.focus();
         		return false;
		 		}
	
			}
  		}
  
  		//*********************End   License renew date depends on License only***************************
  	
	}	
  //*******************************end of using License renewal day****************************************
  
  
  ///////////////////////////////////////////////////
  ///          License type                 ////////
  //////////////////////////////////////////////////
  if (theForm.state_licensesubtype)
  {
  	if (theForm.state_licensesubtype.value==0)
	{
		alert("Please select your license type");
		theForm.state_licensesubtype.focus();
		return false;
	}
  }
  
  
  
   



   
  // if(theForm.InsuranceExpDate.value=="")
  // {
   //alert("Please fill out the \"Insurance Experiation Date\" Field!");
   //theForm.InsuranceExpDate.focus();
   //return(false);
   
   
//}


//Checking Date to see if valid
//function checkDate(strDate)
//{
   // if(strDate.length>0)
        // {
           // var dateregex=/^[ ]*[0]?(\d{1,2})\/(\d{1,2})\/(\d{4,})[ ]*$/;
           //  var match=strDate.match(dateregex);
           //  if (match) 
           //   {
           //            var tmpdate=new Date(match[3],parseInt(match[1],10)-1,match[2]);
           //       if (tmpdate.getDate()==parseInt(match[2],10) && tmpdate.getFullYear()==parseInt(match[3],10) && (tmpdate.getMonth()+1)==parseInt(match[1],10))
           //       { 
           //        return true; 
           //        }
           //  }
         //alert("Please enter valid values for the day, month and year(mm/dd/yyyy)!");
		 //theForm.InsuranceExpDate.focus();
         //return false;
         //}
    //else
         //{
        // return true;
         //}
//}






///////alert("here1");
   
//if(theForm.type1.checked !=true && theForm.type2.checked !=true && theForm.type3.checked !=true)
//{
//alert("Please Check One of the Checkboxes License Expiration Type.")
//theForm.type1.focus();
//return(false);

//}
/////alert("here2");   


  

 if (theForm.id)
 { 
 	theForm.id.value	=	theForm.id.value.trim();
	
 	if (theForm.id.value == "")
	  {
		alert("Please complete the \"ID\" field.");
		theForm.id.focus();
		return (false);
	  }
	
	  var checkStr = theForm.id.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  if (checkStr.length < 4)
	  {
		alert("Please enter at least 4 characters in the \"ID\" field.");
		theForm.id.focus();
		return (false);
	  }
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		if (ch == "'" || ch == "&" || ch == "," || ch == "`" || ch == "%" || ch == "*" || ch == "#" || ch == "~" || ch == "<" || ch == ">" || ch == "/" || ch == ":" || ch == ";" || ch == "\\" || ch == "$" || ch == "=" || ch == "!")
		  allValid = false;
		  
		
	
		allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Special characters like ' & , % # ~ * are not allowed in the \"ID\" field.");
		theForm.id.focus();
		return (false);
	  }
 }

 
 if (theForm.pw)
 {
 	theForm.pw.value	 =		theForm.pw.value.trim();		
 	if (theForm.pw.value == "")
	  {
		alert("Please complete the \"Password\" field.");
		theForm.pw.focus();
		return (false);
	  }
	
	  var checkStr = theForm.pw.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  if (checkStr.length < 6)
	  {
		alert("Please enter at least 6 characters in the \"Password\" field.");
		theForm.pw.focus();
		return (false);
	  }
	  
	  var atLeast1numerber, atLeast1Letter
	  atLeast1numerber=0;
	  atLeast1Letter=0;
		
	  for (i = 0;  i < checkStr.length;  i++)
	  {
			var TargetC= checkStr.charAt(i);
			if (TargetC.match(passwordRegExp))
			{
					if (atLeast1numerber==0)
					{
						if (TargetC.match(/^[0-9]+$/))
						{
							atLeast1numerber=1;
						} 
					}
					
					if (atLeast1Letter==0)
					{
						if (TargetC.match(/^[a-zA-Z]+$/))
						{
							atLeast1Letter=1;
						} 
					}
					
			}
			else
			{
					//alert("false");
					alert("Please only use alphanumeric characters in the password.");
					theForm.pw.focus();
					return (false);
			} 
		
	}  /// of For loop
		
	if (atLeast1numerber==0)
	{
		alert("Password has to have at least one number");
		theForm.pw.focus();
		return (false);
	}
	
	if (atLeast1Letter==0)
	{
		alert("Password has to have at least one letter");
		theForm.pw.focus();
		return (false);
	}
	
		 
 }
 
 
 
 
 if (theForm.rpw)
 {
	theForm.rpw.value	=		theForm.rpw.value.trim();	
 	if (theForm.rpw.value == "")
	  {
		alert("Please complete the \"Retrype Password\" field.");
		theForm.rpw.focus();
		return (false);
	  }
	 else if (theForm.rpw.value != theForm.pw.value)
	 {
	 	alert("Retype password is not same as the password");
		theForm.rpw.focus();
		return (false);
	 }
 }
 

 if (theForm.pwanswer)
 {
 	if (theForm.pwanswer.value == "")
	  {
		alert("Please answer the password reminder question.");
		theForm.pwanswer.focus();
		return (false);
	  }
 }

 

 
////////////////////////////////////////////////////////////////
/////      choose at least one course             /////////////
///////////////////////////////////////////////////////////////

	if (theForm.course1)
	{
 		if (theForm.course1.value == "" || theForm.course1.value == "No")
  		{
   			 alert("Please select a course.");
    		theForm.course1.focus();
    		return (false);
  		}
	}
  
////////////////////////////////////////////////////////////////
/////  choose at least one course for special deal $129  //////
///////////////////////////////////////////////////////////////
 
 var selectflage=0;
 if (theForm.ceucourses)
 {	
  	for (i=0; i<theForm.ceucourses.length; i++)
	{
		if (theForm.ceucourses[i].checked==true)
		{	selectflage=1;
			break;
		}
	}
	
	if (selectflage==0)
	{	alert("Please select a course");
		return false;
	}
	
 }
 
 ////////////////////////////////////////////////////////////////
/////  choose at least one course for special deal $129  //////
///////////////////////////////////////////////////////////////
 var Numberofcourses=0;
 if (theForm.NumOfSelectedCourse)
 {	Numberofcourses=theForm.NumOfSelectedCourse.value;
 	///alert("Number:"+Numberofcourses);
 }
 
 if (theForm.optionselect)
 {
	 if (theForm.optionselect.value==10)
	 {
		 var selectflage=0;
			
			for (i=1; i<=Numberofcourses; i++)
			{
				
				
				if (eval("theForm.coursecheckbox_"+i+".checked")==true)
				{	selectflage=1;
					break;
				}
			}
			
			if (selectflage==0)
			{	alert("Please select a course");
				return false;
			}
			
		
	 }
 }
 
 
////////////////////////////////////////
 ////   Terms of Agreement Accept    ///
//////////////////////////////////////

  if (theForm.TermsAccept)
  { 
  	if (theForm.TermsAccept.checked != true)
	{
		alert("Please put a check on box next to \"Terms of Agreement\" to show that you accept the terms. Thank-you");
		theForm.TermsAccept.focus();
		return false;
	}
  }
  
  
  
  
  //////////////////////////////////////////////////
  ////   Payment method               ///
  /////////////////////////////////////////////////
  
   if (theForm.Paymentmethod)
   { 
   		
		if (theForm.Paymentmethod[0].checked==false && theForm.Paymentmethod[1].checked==false && theForm.Paymentmethod[2].checked==false && theForm.Paymentmethod[3].checked==false)
		{
			alert("Please select your payment method!");
			
			return false;
		}
		else if (theForm.Paymentmethod[0].checked==true)
		{
		
			//////////////////////////////////////////////////
		  ////   Credit Card type    ///
		  /////////////////////////////////////////////////
		  if (theForm.credcard)
		  {
		  	if (theForm.credcard.value=="")
			{
				alert("You must select the \"Credit Card Type\" Field  ");
				theForm.credcard.focus();
				return false;

			}	
		  }
			
			//////////////////////////////////////////////////
		  ////   Credit Card Number     ///
		  /////////////////////////////////////////////////
		  
		  
		  
		  if (theForm.credcardNum )
		  {
			if (theForm.credcardNum.value == "" )
			  {
				alert("You must complete the \"Credit Card\" field ");
				theForm.credCardField.focus();
				return false;
			  }
			
			  var checkOK = AllNumbersList;
			  var checkStr = theForm.credcardNum.value;
			  var allValid = true;
			  var decPoints = 0;
			  var allNum = "";
			  if (0 < checkStr.length && checkStr.length < 15)
			  {
				alert("Invalid Credit Card Number.");
				theForm.credCardField.focus();
				return (false);
			  }
			  for (i = 0;  i < checkStr.length;  i++)
			  {
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkOK.length;  j++)
				  if (ch == checkOK.charAt(j))
					break;
				if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
				if (ch != ",")
				  allNum += ch;
			  }
			  if (!allValid)
			  {
				alert("Please enter only digits in the \"Credit Card Number\" field.");
				theForm.credCardField.focus();
				return (false);
			  }
			  
			
			 ///if (theForm.expyear.value == "04" && (theForm.expmonth.value == "01" || theForm.expmonth.value == "02" ))
			 if (theForm.expyear.value == "05" && (theForm.expmonth.value == "01" || theForm.expmonth.value == "02" || theForm.expmonth.value == "03"))
			   {
			   alert("Credit card expired.");
			   theForm.expmonth.focus();
			   return (false);
			   }
			   
			   <!-- Begin
			   
				var Cards = new makeArray(4);
				Cards[0] = new credCard("MasterMoney", "51,52,53,54,55", "16");
				var MasterCard = Cards[0];
				Cards[1] = new credCard("Visa", "4", "13,16");
				var VisaCard = Cards[1];
				Cards[2] = new credCard("AmEx", "34,37", "15");
				var AmExCard = Cards[2];
				Cards[3] = new credCard("Discover", "6011", "16");
				var DiscoverCard = Cards[3];
				
				
				function CheckCardNumber(theForm) {
				var tmpyear;
				if (theForm.credcardNum.value.length == 0) {
				alert("Please enter a Card Number.");
				theForm.credCardField.focus();
				return;
				}
				if (theForm.expyear.value.length == 0) {
				alert("Please enter the Expiration Year.");
				theForm.expyear.focus();
				return;
				}
				if (theForm.expyear.value > 96)
				tmpyear = "19" + theForm.expyear.value;
				else if (theForm.expyear.value < 21)
				tmpyear = "20" + theForm.expyear.value;
				else {
				alert("The Expiration Year is not valid.");
				return;
				}
				tmpmonth = theForm.expmonth.options[theForm.expmonth.selectedIndex].value;
				// The following line doesn't work in IE3, you need to change it
				// to something like "(new credCard())...".
				// if (!credCard().isExpiryDate(tmpyear, tmpmonth)) {
				
				if (!(new credCard()).isExpiryDate(tmpyear, tmpmonth)) {
				alert("This card has already expired.");
				return;
				}
				card = theForm.credCard.options[theForm.credCard.selectedIndex].value;
				var retval = eval(card + ".checkCardNumber(\"" + theForm.credcardNum.value +
				"\", " + tmpyear + ", " + tmpmonth + ");");
				cardname = "";
				if (retval)
				
				   return (true);
				
				else {
				// The cardnumber has the valid luhn checksum, but we want to know which
				// credCard it belongs to.
				for (var n = 0; n < Cards.size; n++) {
				if (Cards[n].checkCardNumber(theForm.credcardNum.value, tmpyear, tmpmonth)) {
				cardname = Cards[n].getcredCard();
				break;
				   }
				}
				if (cardname.length > 0) {
				alert("This looks like a " + cardname + " number, not a " + card + " number.");
				}
				else {
				alert("This card number is not valid.");
					  }
				   }
				}
				/*************************************************************************\
				Object credCard([String credCard, String rules, String len, int year, 
														int month])
				credCard    : type of card, eg: MasterCard, Visa, etc.
				rules       : rules of the cardnumber, eg: "4", "6011", "34,37".
				len         : valid length of cardnumber, eg: "16,19", "13,16".
				year        : year of expiry date.
				month       : month of expiry date.
				eg:
				var VisaCard = new credCard("Visa", "4", "16");
				var AmExCard = new credCard("AmEx", "34,37", "15");
				\*************************************************************************/
				function credCard() {
				var n;
				var argv = credCard.arguments;
				var argc = credCard.arguments.length;
				
				this.objname = "object credCard";
				
				var tmpcredCard = (argc > 0) ? argv[0] : "CardObject";
				var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
				var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";
				
				this.setCardNumber = setCardNumber;  // set CardNumber method.
				this.setcredCard = setcredCard;  // setcredCard method.
				this.setLen = setLen;  // setLen method.
				this.setRules = setRules;  // setRules method.
				this.setExpiryDate = setExpiryDate;  // setExpiryDate method.
				
				this.setcredCard(tmpcredCard);
				this.setLen(tmplen);
				this.setRules(tmprules);
				if (argc > 4)
				this.setExpiryDate(argv[3], argv[4]);
				
				this.checkCardNumber = checkCardNumber;  // checkCardNumber method.
				this.getExpiryDate = getExpiryDate;  // getExpiryDate method.
				this.getcredCard = getcredCard;  // getcredCard method.
				this.isCardNumber = isCardNumber;  // isCardNumber method.
				this.isExpiryDate = isExpiryDate;  // isExpiryDate method.
				this.luhnCheck = luhnCheck;// luhnCheck method.
				return this;
				}
				
				/*************************************************************************\
				boolean checkCardNumber([String cardnumber, int year, int month])
				return true if cardnumber pass the luhncheck and the expiry date is
				valid, else return false.
				\*************************************************************************/
				function checkCardNumber() {
				var argv = checkCardNumber.arguments;
				var argc = checkCardNumber.arguments.length;
				var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
				var year = (argc > 1) ? argv[1] : this.year;
				var month = (argc > 2) ? argv[2] : this.month;
				
				this.setCardNumber(cardnumber);
				this.setExpiryDate(year, month);
				
				if (!this.isCardNumber())
				return false;
				if (!this.isExpiryDate())
				return false;
				
				return true;
				}
				/*************************************************************************\
				String getcredCard()
				return the credCard.
				\*************************************************************************/
				function getcredCard() {
				return this.credCard;
				}
				/*************************************************************************\
				String getExpiryDate()
				return the expiry date.
				\*************************************************************************/
				function getExpiryDate() {
				return this.month + "/" + this.year;
				}
				/*************************************************************************\
				boolean isCardNumber([String cardnumber])
				return true if cardnumber pass the luhncheck and the rules, else return
				false.
				\*************************************************************************/
				function isCardNumber() {
				var argv = isCardNumber.arguments;
				var argc = isCardNumber.arguments.length;
				var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
				if (!this.luhnCheck())
				return false;
				
				for (var n = 0; n < this.len.size; n++)
				if (cardnumber.toString().length == this.len[n]) {
				for (var m = 0; m < this.rules.size; m++) {
				var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
				if (headdigit == this.rules[m])
				return true;
				}
				return false;
				}
				return false;
				}
				
				/*************************************************************************\
				boolean isExpiryDate([int year, int month])
				return true if the date is a valid expiry date,
				else return false.
				\*************************************************************************/
				function isExpiryDate() {
				var argv = isExpiryDate.arguments;
				var argc = isExpiryDate.arguments.length;
				
				year = argc > 0 ? argv[0] : this.year;
				month = argc > 1 ? argv[1] : this.month;
				
				if (!isNum(year+""))
				return false;
				if (!isNum(month+""))
				return false;
				today = new Date();
				expiry = new Date(year, month);
				if (today.getTime() > expiry.getTime())
				return false;
				else
				return true;
				}
				
				/*************************************************************************\
				boolean isNum(String argvalue)
				return true if argvalue contains only numeric characters,
				else return false.
				\*************************************************************************/
				function isNum(argvalue) {
				argvalue = argvalue.toString();
				
				if (argvalue.length == 0)
				return false;
				
				for (var n = 0; n < argvalue.length; n++)
				if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
				return false;
				
				return true;
				}
				
				/*************************************************************************\
				boolean luhnCheck([String CardNumber])
				return true if CardNumber pass the luhn check else return false.
				Reference: http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
				\*************************************************************************/
				function luhnCheck() {
				var argv = luhnCheck.arguments;
				var argc = luhnCheck.arguments.length;
				
				var CardNumber = argc > 0 ? argv[0] : this.cardnumber;
				
				if (! isNum(CardNumber)) {
				return false;
				  }
				
				var no_digit = CardNumber.length;
				var oddoeven = no_digit & 1;
				var sum = 0;
				
				for (var count = 0; count < no_digit; count++) {
				var digit = parseInt(CardNumber.charAt(count));
				if (!((count & 1) ^ oddoeven)) {
				digit *= 2;
				if (digit > 9)
				digit -= 9;
				}
				sum += digit;
				}
				if (sum % 10 == 0)
				return true;
				else
				return false;
				}
				
				
				/*************************************************************************\
				ArrayObject makeArray(int size)
				return the array object in the size specified.
				\*************************************************************************/
				function makeArray(size) {
				this.size = size;
				return this;
				}
				
				/*************************************************************************\
				credCard setCardNumber(cardnumber)
				return the credCard object.
				\*************************************************************************/
				function setCardNumber(cardnumber) {
				this.cardnumber = cardnumber;
				return this;
				}
				
				/*************************************************************************\
				credCard setcredCard(credCard)
				return the credCard object.
				\*************************************************************************/
				function setcredCard(credCard) {
				this.credCard = credCard;
				return this;
				}
				
				/*************************************************************************\
				credCard setExpiryDate(year, month)
				return the credCard object.
				\*************************************************************************/
				function setExpiryDate(year, month) {
				this.year = year;
				this.month = month;
				return this;
				}
				
				/*************************************************************************\
				credCard setLen(len)
				return the credCard object.
				\*************************************************************************/
				function setLen(len) {
				// Create the len array.
				if (len.length == 0 || len == null)
				len = "13,14,15,16,19";
				
				var tmplen = len;
				n = 1;
				while (tmplen.indexOf(",") != -1) {
				tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
				n++;
				}
				this.len = new makeArray(n);
				n = 0;
				while (len.indexOf(",") != -1) {
				var tmpstr = len.substring(0, len.indexOf(","));
				this.len[n] = tmpstr;
				len = len.substring(len.indexOf(",") + 1, len.length);
				n++;
				}
				this.len[n] = len;
				return this;
				}
				
				/*************************************************************************\
				credCard setRules()
				return the credCard object.
				\*************************************************************************/
				function setRules(rules) {
				// Create the rules array.
				if (rules.length == 0 || rules == null)
				rules = "0,1,2,3,4,5,6,7,8,9";
				  
				var tmprules = rules;
				n = 1;
				while (tmprules.indexOf(",") != -1) {
				tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
				n++;
				}
				this.rules = new makeArray(n);
				n = 0;
				while (rules.indexOf(",") != -1) {
				var tmpstr = rules.substring(0, rules.indexOf(","));
				this.rules[n] = tmpstr;
				rules = rules.substring(rules.indexOf(",") + 1, rules.length);
				n++;
				}
				this.rules[n] = rules;
				return this;
				} 
			   
		  }
		
			//////////////////////////////////////////////////
			///  end of Credit Card//////////////////////////
			/////////////////////////////////////////////////
		}
		else if (theForm.Paymentmethod[1].checked==true)
		{
			// PayPal is checked
			return (true);
		}
		else if (theForm.Paymentmethod[3].checked==true)
		{
			// Employer Code is  checked:
			if ( theForm.authorization.value == "")
			{
				alert("Please enter your employer code");   
			   
			   return (false);
			  }
		}
		else if (theForm.Paymentmethod[2].checked==true)
		{
			//Pay by Check is chosen
			return (true);			
		}
   }
  
  
  
  
  
 //////////////////////////////////////////////////
////   Credit Card Number and authorization    ///
/////////////////////////////////////////////////
 if (theForm.credcardNum && theForm.authorization)
 {
 	if (theForm.credcardNum.value == "" && theForm.authorization.value == "")
	  {
		alert("You must complete either the \"Credit Card\" field or the \"Employer Code\" field");
		theForm.credCardField.focus();
		return (false);
	  }
	
	  var checkOK = AllNumbersList;
	  var checkStr = theForm.credcardNum.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  if (0 < checkStr.length && checkStr.length < 15)
	  {
		alert("Invalid Credit Card Number.");
		theForm.credCardField.focus();
		return (false);
	  }
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
		if (ch != ",")
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter only digits in the \"Credit Card Number\" field.");
		theForm.credCardField.focus();
		return (false);
	  }
	  if (theForm.credcardNum.value == "" && theForm.authorization.value != ""){
	   return (true);
	  }
	
	  if (theForm.credcardNum.value != "" && theForm.authorization.value != "") {
		alert("Please enter either a credit card number or authorization number.\n But not both.");
		return (false);
	  }
	 if (theForm.expyear.value == "02" && (theForm.expmonth.value == "01" || theForm.expmonth.value == "02"))
	   {
	   alert("Credit card expired.");
	   return (false);
	   }
	   
	   <!-- Begin
		var Cards = new makeArray(4);
		Cards[0] = new credCard("MasterMoney", "51,52,53,54,55", "16");
		var MasterCard = Cards[0];
		Cards[1] = new credCard("Visa", "4", "13,16");
		var VisaCard = Cards[1];
		Cards[2] = new credCard("AmEx", "34,37", "15");
		var AmExCard = Cards[2];
		Cards[3] = new credCard("Discover", "6011", "16");
		var DiscoverCard = Cards[3];
		
		
		function CheckCardNumber(theForm) {
		var tmpyear;
		if (theForm.credcardNum.value.length == 0) {
		alert("Please enter a Card Number.");
		theForm.credCardField.focus();
		return;
		}
		if (theForm.expyear.value.length == 0) {
		alert("Please enter the Expiration Year.");
		theForm.expyear.focus();
		return;
		}
		if (theForm.expyear.value > 96)
		tmpyear = "19" + theForm.expyear.value;
		else if (theForm.expyear.value < 21)
		tmpyear = "20" + theForm.expyear.value;
		else {
		alert("The Expiration Year is not valid.");
		return;
		}
		tmpmonth = theForm.expmonth.options[theForm.expmonth.selectedIndex].value;
		// The following line doesn't work in IE3, you need to change it
		// to something like "(new credCard())...".
		// if (!credCard().isExpiryDate(tmpyear, tmpmonth)) {
		if (!(new credCard()).isExpiryDate(tmpyear, tmpmonth)) {
		alert("This card has already expired.");
		return;
		}
		card = theForm.credCard.options[theForm.credCard.selectedIndex].value;
		var retval = eval(card + ".checkCardNumber(\"" + theForm.credcardNum.value +
		"\", " + tmpyear + ", " + tmpmonth + ");");
		cardname = "";
		if (retval)
		
		   return (true);
		
		else {
		// The cardnumber has the valid luhn checksum, but we want to know which
		// credCard it belongs to.
		for (var n = 0; n < Cards.size; n++) {
		if (Cards[n].checkCardNumber(theForm.credcardNum.value, tmpyear, tmpmonth)) {
		cardname = Cards[n].getcredCard();
		break;
		   }
		}
		if (cardname.length > 0) {
		alert("This looks like a " + cardname + " number, not a " + card + " number.");
		}
		else {
		alert("This card number is not valid.");
			  }
		   }
		}
		/*************************************************************************\
		Object credCard([String credCard, String rules, String len, int year, 
												int month])
		credCard    : type of card, eg: MasterCard, Visa, etc.
		rules       : rules of the cardnumber, eg: "4", "6011", "34,37".
		len         : valid length of cardnumber, eg: "16,19", "13,16".
		year        : year of expiry date.
		month       : month of expiry date.
		eg:
		var VisaCard = new credCard("Visa", "4", "16");
		var AmExCard = new credCard("AmEx", "34,37", "15");
		\*************************************************************************/
		function credCard() {
		var n;
		var argv = credCard.arguments;
		var argc = credCard.arguments.length;
		
		this.objname = "object credCard";
		
		var tmpcredCard = (argc > 0) ? argv[0] : "CardObject";
		var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
		var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";
		
		this.setCardNumber = setCardNumber;  // set CardNumber method.
		this.setcredCard = setcredCard;  // setcredCard method.
		this.setLen = setLen;  // setLen method.
		this.setRules = setRules;  // setRules method.
		this.setExpiryDate = setExpiryDate;  // setExpiryDate method.
		
		this.setcredCard(tmpcredCard);
		this.setLen(tmplen);
		this.setRules(tmprules);
		if (argc > 4)
		this.setExpiryDate(argv[3], argv[4]);
		
		this.checkCardNumber = checkCardNumber;  // checkCardNumber method.
		this.getExpiryDate = getExpiryDate;  // getExpiryDate method.
		this.getcredCard = getcredCard;  // getcredCard method.
		this.isCardNumber = isCardNumber;  // isCardNumber method.
		this.isExpiryDate = isExpiryDate;  // isExpiryDate method.
		this.luhnCheck = luhnCheck;// luhnCheck method.
		return this;
		}
		
		/*************************************************************************\
		boolean checkCardNumber([String cardnumber, int year, int month])
		return true if cardnumber pass the luhncheck and the expiry date is
		valid, else return false.
		\*************************************************************************/
		function checkCardNumber() {
		var argv = checkCardNumber.arguments;
		var argc = checkCardNumber.arguments.length;
		var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
		var year = (argc > 1) ? argv[1] : this.year;
		var month = (argc > 2) ? argv[2] : this.month;
		
		this.setCardNumber(cardnumber);
		this.setExpiryDate(year, month);
		
		if (!this.isCardNumber())
		return false;
		if (!this.isExpiryDate())
		return false;
		
		return true;
		}
		/*************************************************************************\
		String getcredCard()
		return the credCard.
		\*************************************************************************/
		function getcredCard() {
		return this.credCard;
		}
		/*************************************************************************\
		String getExpiryDate()
		return the expiry date.
		\*************************************************************************/
		function getExpiryDate() {
		return this.month + "/" + this.year;
		}
		/*************************************************************************\
		boolean isCardNumber([String cardnumber])
		return true if cardnumber pass the luhncheck and the rules, else return
		false.
		\*************************************************************************/
		function isCardNumber() {
		var argv = isCardNumber.arguments;
		var argc = isCardNumber.arguments.length;
		var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
		if (!this.luhnCheck())
		return false;
		
		for (var n = 0; n < this.len.size; n++)
		if (cardnumber.toString().length == this.len[n]) {
		for (var m = 0; m < this.rules.size; m++) {
		var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
		if (headdigit == this.rules[m])
		return true;
		}
		return false;
		}
		return false;
		}
		
		/*************************************************************************\
		boolean isExpiryDate([int year, int month])
		return true if the date is a valid expiry date,
		else return false.
		\*************************************************************************/
		function isExpiryDate() {
		var argv = isExpiryDate.arguments;
		var argc = isExpiryDate.arguments.length;
		
		year = argc > 0 ? argv[0] : this.year;
		month = argc > 1 ? argv[1] : this.month;
		
		if (!isNum(year+""))
		return false;
		if (!isNum(month+""))
		return false;
		today = new Date();
		expiry = new Date(year, month);
		if (today.getTime() > expiry.getTime())
		return false;
		else
		return true;
		}
		
		/*************************************************************************\
		boolean isNum(String argvalue)
		return true if argvalue contains only numeric characters,
		else return false.
		\*************************************************************************/
		function isNum(argvalue) {
		argvalue = argvalue.toString();
		
		if (argvalue.length == 0)
		return false;
		
		for (var n = 0; n < argvalue.length; n++)
		if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
		return false;
		
		return true;
		}
		
		/*************************************************************************\
		boolean luhnCheck([String CardNumber])
		return true if CardNumber pass the luhn check else return false.
		Reference: http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
		\*************************************************************************/
		function luhnCheck() {
		var argv = luhnCheck.arguments;
		var argc = luhnCheck.arguments.length;
		
		var CardNumber = argc > 0 ? argv[0] : this.cardnumber;
		
		if (! isNum(CardNumber)) {
		return false;
		  }
		
		var no_digit = CardNumber.length;
		var oddoeven = no_digit & 1;
		var sum = 0;
		
		for (var count = 0; count < no_digit; count++) {
		var digit = parseInt(CardNumber.charAt(count));
		if (!((count & 1) ^ oddoeven)) {
		digit *= 2;
		if (digit > 9)
		digit -= 9;
		}
		sum += digit;
		}
		if (sum % 10 == 0)
		return true;
		else
		return false;
		}
		
		
		/*************************************************************************\
		ArrayObject makeArray(int size)
		return the array object in the size specified.
		\*************************************************************************/
		function makeArray(size) {
		this.size = size;
		return this;
		}
		
		/*************************************************************************\
		credCard setCardNumber(cardnumber)
		return the credCard object.
		\*************************************************************************/
		function setCardNumber(cardnumber) {
		this.cardnumber = cardnumber;
		return this;
		}
		
		/*************************************************************************\
		credCard setcredCard(credCard)
		return the credCard object.
		\*************************************************************************/
		function setcredCard(credCard) {
		this.credCard = credCard;
		return this;
		}
		
		/*************************************************************************\
		credCard setExpiryDate(year, month)
		return the credCard object.
		\*************************************************************************/
		function setExpiryDate(year, month) {
		this.year = year;
		this.month = month;
		return this;
		}
		
		/*************************************************************************\
		credCard setLen(len)
		return the credCard object.
		\*************************************************************************/
		function setLen(len) {
		// Create the len array.
		if (len.length == 0 || len == null)
		len = "13,14,15,16,19";
		
		var tmplen = len;
		n = 1;
		while (tmplen.indexOf(",") != -1) {
		tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
		n++;
		}
		this.len = new makeArray(n);
		n = 0;
		while (len.indexOf(",") != -1) {
		var tmpstr = len.substring(0, len.indexOf(","));
		this.len[n] = tmpstr;
		len = len.substring(len.indexOf(",") + 1, len.length);
		n++;
		}
		this.len[n] = len;
		return this;
		}
		
		/*************************************************************************\
		credCard setRules()
		return the credCard object.
		\*************************************************************************/
		function setRules(rules) {
		// Create the rules array.
		if (rules.length == 0 || rules == null)
		rules = "0,1,2,3,4,5,6,7,8,9";
		  
		var tmprules = rules;
		n = 1;
		while (tmprules.indexOf(",") != -1) {
		tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
		n++;
		}
		this.rules = new makeArray(n);
		n = 0;
		while (rules.indexOf(",") != -1) {
		var tmpstr = rules.substring(0, rules.indexOf(","));
		this.rules[n] = tmpstr;
		rules = rules.substring(rules.indexOf(",") + 1, rules.length);
		n++;
		}
		this.rules[n] = rules;
		return this;
		}
		//  End -->	
 }
 
 ////////end of Credit Card Number and authorization


if (theForm.employeeID)
 {
 	theForm.employeeID.value	 =		theForm.employeeID.value.trim();
 	if (theForm.employeeID.value == "")
	{
 		alert("Please enter your employee ID.");
		theForm.employeeID.focus();
		return (false);
	}	
 }
 
  if (theForm.username)
 {
 	theForm.username.value 		=	theForm.username.value.trim();
 	if (theForm.username.value == "")
	  {
		alert("Please complete the \"User name\" field.");
		theForm.username.focus();
		return (false);
	  }
 }
 
  if (theForm.Password)
 {
 	theForm.Password.value 		=	theForm.Password.value.trim();	
 	if (theForm.Password.value == "")
	  {
		alert("Please complete the \"Password\" field.");
		theForm.Password.focus();
		return (false);
	  }
 }
 
 if (theForm.CouponCode)
 {	
 	theForm.CouponCode.value	 =		theForm.CouponCode.value.trim();		
 	if (theForm.CouponCode.value == "")
	  {
		alert("Please enter the \"Coupon Code\" field.");
		theForm.CouponCode.focus();
		return (false);
	  }
 }

//alert("hj"); 

   return (true);
} 
 

function validateField(checkStr)
{	 
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		if (ch == "'" || ch == "&" || ch == "," || ch == "`" || ch == "%" || ch == "*" || ch == "#" || ch == "~" || ch == "<" || ch == ">" || ch == "/" || ch == ":" || ch == ";" || ch == "\\")
		  allValid = false;
		allNum += ch;
	  }
	  return(allValid);	  		
}

function changeCountry(control)
{
	var myCountry = control.value;
	window.location = "/registration/newMemberInfo.asp?country="+ myCountry;
}