function before_destinationCheck(DnEvents)
{
	K = navigator.appName=="Netscape" ? DnEvents.which : DnEvents.keyCode
	if (K==13) destinationCheck(); 
}


//*****************************************************************************

function destinationCheck(menu, option)
{
	var strUserName = "Please enter your Username"
	var strPassword = "Please enter your Password"
	
	var check_flag = true;

 	if ( document.prompt.username.value == "" && check_flag )	{
 		alert(strUserName)
 		document.prompt.username.focus();
 		check_flag = false;
 	}
 	if ( document.prompt.password.value == "" && check_flag )	{
 		alert(strPassword)
 		document.prompt.password.focus();
 		check_flag = false;
 	}

	if (check_flag)
	{
		//alert(document.prompt.action)
		//document.prompt.action = "login.asp?sponsor=" + "<%=sponsor%>";		
		document.prompt.submit();				
	}	

}

//********************************************************************************

function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) history.go(0);
}


//*************************************************************************************

function checkRegForm(a, freeSession) 
{
	var check_flag = true;
	var strFirstName = "Please enter your first name"
	var strLastName = "Please enter your last name"
	
	var strPhone = "Please enter a valid phone number."
	
	var strStreet = "Please enter your street address (line 1)"
	
	var strCity = "Please enter your city"
	
	var strState = "Please enter your State/Province/Region"
	
	var strCountry = "Please enter your Country"
	
	var strZipcode = "Please enter your Postal Code"
	var ZipcodeLen = document.regpage.Zipcode.value.length;
	var strZipcodeLen = "Postal code must be 5 numeric characters."
	var strZipcodeNumeric = "Postal Code must be numeric."
	
	var strPassword = "Please enter your Password"
	var strPasswordLength = "Password mube be at least four charactuers"
	var strReenterPassword = "Please confirm the password by reentering the password"
	var strPasswordNoMatch = "Re-entered password does not match password"
	var strPasswordLength = "Password must be at least four characters"
	
	var strChallengequestion = "Please select a Challenge Question"
	var strChallengeResponse = "Please enter a Challenge Question Response"
	
	
	var strUserName = "Please enter a Login Name"
	var strUserNameLength = "Username must be at least four characters"
	
	
 	var numberCheck = /\d/i
 	var nonnumberCheck = /\D/i
 	var check_input_flag = false
 	
	var nonvalidCountry = "The Country you have selected does not match your selection for State/Province/Region."
	var nonvalidUSstate = "The selection you have made for State/Province/Region does not match the Country you have selected."
	var nonvalidCAstate = "The selection you have made for State/Province/Region does not match the Country you have selected."
	var strValidZipcode = "Please enter valid Postal Code"
	

 	if (check_flag && document.regpage.first_name.value == "")	{
 		alert(strFirstName)
 		document.regpage.first_name.focus();
 		check_flag = false;
 	}
 	if (check_flag && document.regpage.last_name.value == "" )	{
 		alert(strLastName)
 		document.regpage.last_name.focus();
 		check_flag = false;
 	}


 	var validEmail = validate_Email(document.regpage.email.value);
 		if (check_flag && !(validEmail[0])){ 
			alert(validEmail[1]);
			document.regpage.email.focus();
			check_flag = false;
	}
	
	if (document.regpage.secondary_email && document.regpage.secondary_email.value != "")
	{
	
		validEmail = validate_Email(document.regpage.secondary_email.value);
 		if (check_flag && !(validEmail[0]))
 		{ 
			alert(validEmail[1]);
			document.regpage.secondary_email.focus();
			check_flag = false;
		}
		
	}
	
	
	if (document.regpage.secondary_email2 && document.regpage.secondary_email2.value != "")
	{
	
		validEmail = validate_Email(document.regpage.secondary_email2.value);
 		if (check_flag && !(validEmail[0]))
 		{ 
			alert(validEmail[1]);
			document.regpage.secondary_email2.focus();
			check_flag = false;
		}
		
	}
		
	var phone_area = document.regpage.area_code.value;
	var phone1 = document.regpage.phone_exchange.value;
	var phone2 = document.regpage.phone_4digits.value;
	var phone_ext = document.regpage.ext.value;
	
	if (check_flag && phone_area== "" )
	{
			alert(strPhone)
 			document.regpage.area_code.focus();
 			check_flag = false;
	}
	
	if (check_flag && phone1 == "") {
 			alert(strPhone)
 			document.regpage.phone_exchange.focus();
 			check_flag = false;
 	}
 	
 	if (check_flag && phone2 == "") {
 			alert(strPhone)
 			document.regpage.phone_4digits.focus();
 			check_flag = false;
 	}	
 	
 	if (check_flag && !verifyDigit(phone_area, 3))	{
 			alert(strPhone)
 			document.regpage.area_code.focus();
 			check_flag = false;
 	}
 	
 	
 	if (check_flag && !verifyDigit(phone1, 3))	{
 			alert(strPhone)
 			document.regpage.phone_exchange.focus();
 			check_flag = false;
 	}
 		
 		
 	if (check_flag && !verifyDigit(phone2, 4))	{
 			alert(strPhone)
 			document.regpage.phone_4digits.focus();
 			check_flag = false;
 	}		
	

	if (check_flag && document.regpage.address1.value == "" )
	{
	
		alert(strStreet)
		document.regpage.address1.focus();
		check_flag = false;
	
	}
	
 	
 	
 	if ( check_flag && document.regpage.City.value == ""   )	{
 		alert(strCity)
 		document.regpage.City.focus();
 		check_flag = false;
 	}
 	
 	
 	//alert(document.regpage.Country.selectedIndex)
 	
 	var CountryIdx = document.regpage.Country.selectedIndex
 	var StateIdx = document.regpage.State.selectedIndex
 	
 	if (check_flag && CountryIdx == 0)	{
 		alert(strCountry)
 		document.regpage.Country.focus();
 		check_flag = false;
 	}
 	
 	
 	
 	
 	if (  check_flag && ( document.regpage.Country.options[CountryIdx].value == "US" || document.regpage.Country.options[CountryIdx].value == "CA" ) )
	{ 
 			if ( check_flag && StateIdx == 0   )	
 			{
 				alert(strState)
 				document.regpage.State.focus();
 				check_flag = false;
 			}
 			
 			
 			if (  check_flag  && document.regpage.Zipcode.value == "" )	
 			{
 				alert(strZipcode)
 				document.regpage.Zipcode.focus();
 				check_flag = false;
 			}
 			
 	}
 		 	
 	
	
 	if (document.regpage.Country.options[CountryIdx].value == "US")
 	{
		if (check_flag && !checkStateUS(document.regpage.State.options[StateIdx].value)) {
 			alert(nonvalidUSstate)
 			document.regpage.State.focus();
 			check_flag = false;
 		}
		if (check_flag && !verifyDigit(document.regpage.Zipcode.value, 5)) {
 			alert(strValidZipcode)
 			document.regpage.Zipcode.focus();
 			check_flag = false;
 		}
 	}
 	
 	if ( document.regpage.Country.options[CountryIdx].value == "CA" )
 	{
		if (check_flag && !checkStateCA(document.regpage.State.options[StateIdx].value)) {
 			alert(nonvalidCAstate)
 			document.regpage.State.focus();
 			check_flag = false;
 		}
		if (check_flag && !isValidPostalcode(document.regpage.Zipcode.value)) {
 			alert(strValidZipcode)
 			document.regpage.Zipcode.focus();
 			check_flag = false;
 		}
 	}

	if (check_flag && document.regpage.Country.options[CountryIdx].value != "CA" && document.regpage.Country.options[CountryIdx].value != "US") {
		if (StateIdx > 0) {
 			alert(nonvalidCountry)
 			document.regpage.Country.focus();
 			check_flag = false;			
		}
		document.regpage.Zipcode.value = ""
	}
	
	//alert(a);
	if (a !='true'){
	
	var usernameLen = document.regpage.Username.value.length;
	var passwordLen = document.regpage.password.value.length;
	
 	if (check_flag && document.regpage.Username.value == "" )	{
 		alert(strUserName)
 		document.regpage.Username.focus();
 		check_flag = false;
 	}

 	if (check_flag && usernameLen < 4 )	{
 		alert(strUserNameLength)
 		document.regpage.Username.focus();
 		check_flag = false; 	
 	}

 	if (check_flag && document.regpage.password.value == "" )	{
 		alert(strPassword)
 		document.regpage.password.focus();
 		check_flag = false;
 	}

 	if (check_flag && passwordLen < 4 )	{
 		alert(strPasswordLength)
 		document.regpage.password.focus();
 		check_flag = false; 	
 	}

 	if (check_flag && document.regpage.Reenterpassword.value == "" )	{
 		alert(strReenterPassword)
 		document.regpage.Reenterpassword.focus();
 		check_flag = false;
 	}
 	if (check_flag && document.regpage.password.value != document.regpage.Reenterpassword.value) {
      alert(strPasswordNoMatch);
      document.regpage.password.focus();
      check_flag = false;       
    }

 	if (check_flag && document.regpage.CHALLENGE_QUESTION.selectedIndex == "0" )	{
 		alert(strChallengequestion);
 		document.regpage.CHALLENGE_QUESTION.focus();
 		check_flag = false;
 	}

 	if (check_flag && document.regpage.CHALLENGE_RESPONSE.value == "" )	{
 		alert(strChallengeResponse)
 		document.regpage.CHALLENGE_RESPONSE.focus();
 		check_flag = false;
 	}
 	}
 	
 	

if (freeSession != "true")
{ 	
 	if (check_flag && document.regpage.time_to_contact_mon.selectedIndex !=0)
 	{
 		document.regpage.daymon.checked = true;
 	}	
 	
 	if (check_flag && document.regpage.time_to_contact_tue.selectedIndex !=0)
 	{
 		document.regpage.daytue.checked = true;
 	}	
 	
 	if (check_flag && document.regpage.time_to_contact_wed.selectedIndex !=0)
 	{
 		document.regpage.daywed.checked = true;
 	}	
 	
 	if (check_flag && document.regpage.time_to_contact_thu.selectedIndex !=0)
 	{
 		document.regpage.daythu.checked = true;
 	}	
 	
 	if (check_flag && document.regpage.time_to_contact_fri.selectedIndex !=0)
 	{
 		document.regpage.dayfri.checked = true;
 	}	
 	
 	if (check_flag && document.regpage.time_to_contact_sat.selectedIndex !=0)
 	{
 		document.regpage.daysat.checked = true;
 	}
 	
 	if (check_flag && document.regpage.time_to_contact_sun.selectedIndex !=0)
 	{
 		document.regpage.daysun.checked = true;
 	}			
}
	if (check_flag)
	{
		document.regpage.submit();		
	}	
}

//******************************************************************************



