// Javascript for Checkout2A.cfm
function checkForm() {
	var iError = 0;

	if (document.CustomerInfo.EMailAddress.value=="") 
	{
  		alert("Please enter your Email Address!");
		iError = 1;
      	document.CustomerInfo.EMailAddress.select();
   		document.CustomerInfo.EMailAddress.focus();
   		return false;
	}
	if (!isEmail(document.CustomerInfo.EMailAddress.value)) 
	{
		alert("\nThe e-mail field requires a \"@\" and a \".\" be used.\n\nPlease re-enter your e-mail address.")      
		iError = 1;
      	document.CustomerInfo.EMailAddress.select();
   		document.CustomerInfo.EMailAddress.focus();
   		return false;
	}
	if (document.CustomerInfo.Password.value=="") 
	{
  		alert("Please enter your Password!");
		iError = 1;
      	document.CustomerInfo.Password.select();
   		document.CustomerInfo.Password.focus();
   		return false;
	}
// PasswordVerify
	if (document.CustomerInfo.PasswordVerify.value=="") 
	{
  		alert("Please enter your Verify Password!");
		iError = 1;
      	document.CustomerInfo.PasswordVerify.select();
   		document.CustomerInfo.PasswordVerify.focus();
   		return false;
	}
	if (document.CustomerInfo.PasswordVerify.value!=document.CustomerInfo.Password.value) 
	{
  		alert("Please enter your Password and Verify Password must match!");
		iError = 1;
      	document.CustomerInfo.Password.select();
   		document.CustomerInfo.Password.focus();
   		return false;
	}

	if (document.CustomerInfo.PaymentType.value==0) 
	{
  		alert("Please select a payment type!");
		iError = 1;
   		document.CustomerInfo.PaymentType.focus();
   		return false;
	}
	if ((document.CustomerInfo.PaymentType.value==1) || (document.CustomerInfo.PaymentType.value==2) || (document.CustomerInfo.PaymentType.value==3)
		 || (document.CustomerInfo.PaymentType.value==4)) 
	{
//		alert("PaymentType="+document.CustomerInfo.PaymentType.value);
		sCreditCard = document.CustomerInfo.CreditCardNumber.value;
		if (!checkcreditcard(sCreditCard,true)) {
			alert("Please enter a valid Credit Card Number!");
			iError = 1;
			document.CustomerInfo.CreditCardNumber.select();
			document.CustomerInfo.CreditCardNumber.focus();
			return false;
		}
	}
	if (document.CustomerInfo.NameFirst.value=="") 
	{
  		alert("Please enter your First Name!");
		iError = 1;
      	document.CustomerInfo.NameFirst.select();
   		document.CustomerInfo.NameFirst.focus();
   		return false;
	}
	if (document.CustomerInfo.NameLast.value=="") 
	{
  		alert("Please enter your Last Name!");
		iError = 1;
      	document.CustomerInfo.NameLast.select();
   		document.CustomerInfo.NameLast.focus();
   		return false;
	}
	if (document.CustomerInfo.EveningTelephone.value=="") 
	{
  		alert("Please enter your Home Phone Number!");
		iError = 1;
      	document.CustomerInfo.EveningTelephone.select();
   		document.CustomerInfo.EveningTelephone.focus();
   		return false;
	}
	if (document.CustomerInfo.Address1.value=="") 
	{
  		alert("Please enter your Street Address!");
		iError = 1;
      	document.CustomerInfo.Address1.select();
   		document.CustomerInfo.Address1.focus();
   		return false;
	}
	if (document.CustomerInfo.City.value=="") 
	{
  		alert("Please enter your City!");
		iError = 1;
      	document.CustomerInfo.City.select();
   		document.CustomerInfo.City.focus();
   		return false;
	}
	if (document.CustomerInfo.Country.value=="") 
	{
  		alert("Please select your Country!");
		iError = 1;
//      	document.CustomerInfo.Country.select();
   		document.CustomerInfo.Country.focus();
   		return false;
	}
	if (document.CustomerInfo.Country.value=="United States") {
		if (document.CustomerInfo.State.value=="") 
		{
			alert("Please enter your State!");
			iError = 1;
			document.CustomerInfo.State.select();
			document.CustomerInfo.State.focus();
			return false;
		}
		if (document.CustomerInfo.State.value.length!=2) {
			alert("Please enter a two character State Abbreviation!");
			iError = 1;
			document.CustomerInfo.State.select();
			document.CustomerInfo.State.focus();
			return false;
		}
	}
	if (document.CustomerInfo.Country.value=="United States" || document.CustomerInfo.Country.value=="Canada") {
		if (document.CustomerInfo.Zip.value=="") 
		{
			alert("Please enter your Zip/Postal Code!");
			iError = 1;
			document.CustomerInfo.Zip.select();
			document.CustomerInfo.Zip.focus();
			return false;
		}
	}
	if (document.CustomerInfo.UseBillingInfo.checked==false)
	{
		if (document.CustomerInfo.ShipToNameFirst.value=="") 
		{
			alert("Please enter the Ship To First Name!");
			iError = 1;
			document.CustomerInfo.ShipToNameFirst.select();
			document.CustomerInfo.ShipToNameFirst.focus();
			return false;
		}
		if (document.CustomerInfo.ShipToNameLast.value=="") 
		{
			alert("Please enter your Ship To Last Name!");
			iError = 1;
			document.CustomerInfo.ShipToNameLast.select();
			document.CustomerInfo.ShipToNameLast.focus();
			return false;
		}
		if (document.CustomerInfo.ShipToEveningTelephone.value=="") 
		{
			alert("Please enter your Ship To Phone Number!");
			iError = 1;
			document.CustomerInfo.ShipToEveningTelephone.select();
			document.CustomerInfo.ShipToEveningTelephone.focus();
			return false;
		}
		if (document.CustomerInfo.ShipToAddress1.value=="") 
		{
			alert("Please enter your Ship To Street Address!");
			iError = 1;
			document.CustomerInfo.ShipToAddress1.select();
			document.CustomerInfo.ShipToAddress1.focus();
			return false;
		}
		if (document.CustomerInfo.ShipToCity.value=="") 
		{
			alert("Please enter your Ship To City!");
			iError = 1;
			document.CustomerInfo.ShipToCity.select();
			document.CustomerInfo.ShipToCity.focus();
			return false;
		}
		if (document.CustomerInfo.ShipToCountry.value=="United States") {
			if (document.CustomerInfo.ShipToState.value=="") 
			{
				alert("Please enter your Ship To State!");
				iError = 1;
				document.CustomerInfo.ShipToState.select();
				document.CustomerInfo.ShipToState.focus();
				return false;
			}
			if (document.CustomerInfo.ShipToState.value.length!=2) {
				alert("Please enter a two character Ship To State Abbreviation!");
				iError = 1;
				document.CustomerInfo.ShipToState.select();
				document.CustomerInfo.ShipToState.focus();
				return false;
			}
		}
		if (document.CustomerInfo.ShipToCountry.value=="United States" || document.CustomerInfo.ShipToCountry.value=="Canada") {
			if (document.CustomerInfo.ShipToZip.value=="") 
			{
				alert("Please enter your Ship To Zip/Postal Code!");
				iError = 1;
				document.CustomerInfo.ShipToZip.select();
				document.CustomerInfo.ShipToZip.focus();
				return false;
			}
		}
		if (document.CustomerInfo.ShipToCountry.value=="") 
		{
			alert("Please select your Ship To Country!");
			iError = 1;
	//      	document.CustomerInfo.ShipToCountry.select();
			document.CustomerInfo.ShipToCountry.focus();
			return false;
		}
	}
	if (iError == 0) {
		document.getElementById('ContinueSignup').style.display = 'none';
		document.getElementById('WaitMessage').style.display = '';
		document.CustomerInfo.submit();
		return true;
	}
}

