<!-- Begin
function Field_Validator(theForm)
{
	if (theForm.FName.value == "")
	{
		alert("Please enter your first name.");
		theForm.FName.focus();
		return (false);
	}

	if (theForm.LName.value == "")
	{
		alert("Please enter your last name.");
		theForm.LName.focus();
		return (false);
	}

	if (theForm.Address.value == "")
	{
		alert("Please enter your address.");
		theForm.Address.focus();
		return (false);
	}

	if (theForm.City.value == "")
	{
		alert("Please enter your city.");
		theForm.City.focus();
		return (false);
	}

	if (theForm.State.value == "")
	{
		alert("Please enter your state.");
		theForm.State.focus();
		return (false);
	}

	if (!(VerifyState(theForm.State)))
	    return (false);

	if (theForm.Zip.value == "")
	{
		alert("Please enter your zip code.");
		theForm.Zip.focus();
		return (false);
	}

	if (!(VerifyZipCode(theForm.Zip)))
	    return (false);

	if (theForm.Email.value == "")
	{
		alert("Please enter your email address.");
		theForm.Email.focus();
		return (false);
	}

	if (!(VerifyEmailAddress(theForm.Email)))
	    return (false);

	return (true);
}

function VerifyEmailAddress(EmailForm)
{
  var Reason  = "Email Address entered incorrectly. \n\nReason:"
  var checkStr = EmailForm.value;
  var ix = (checkStr.length - 4)
  var RC = true;
  var at_position = MissingDomainName = MissingUserName = 0
  var x = CharsInValid = AtSignValid = DoublePeriod = PeriodValid = SpaceValid = ExtValid = RL = 0;
	for (i = 0;  i < checkStr.length;  i++)
	{
		if (checkStr.charAt(i) == '@')
		{
			at_position = i;
			AtSignValid++;
			if (at_position == 0)
				MissingUserName++;
		}
		else if (checkStr.charAt(i) == '.')
		{
			if (x == (i-1) && i != 1)
				DoublePeriod++;
			else
			{
				x = i;
				PeriodValid++;
				if (at_position == (i-1) && i != 1)
					MissingDomainName++;
			}
		}
		else
		{
			if (!( (checkStr.charAt(i) >= "A" && checkStr.charAt(i) <= "Z") 
				|| (checkStr.charAt(i) >= "a" && checkStr.charAt(i) <= "z") 
				|| (checkStr.charAt(i) == "@") 
				|| (checkStr.charAt(i) == ".") 
				|| (checkStr.charAt(i) == "_") 
				|| (checkStr.charAt(i) == "-") 
				|| (checkStr.charAt(i) >= "0" && checkStr.charAt(i) <= "9")
				)){
				if (checkStr.charAt(i) == ' ')
					SpaceValid ++;
				else
					CharsInValid++;
				}
		}
	}
	if (checkStr.indexOf(".COM", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".EDU", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".NET", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".ORG", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".GOV", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".MIL", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".US", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".BIZ", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".INT", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".INFO", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".CA", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".MX", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".PR", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".UK", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".com", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".edu", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".net", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".org", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".gov", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".mil", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".int", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".info", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".us", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".ca", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".biz", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".mx", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".pr", ix) > -1)
		ExtValid++;
	else if (checkStr.indexOf(".uk", ix) > -1)
		ExtValid++;
	RL = Reason.length;
	ExtValid = 1;
	if (AtSignValid != 1)
		Reason += "\nOnly one '@' allowed, " + AtSignValid + " found.";
	if (MissingUserName > 0)
		Reason += "\nThe user name is missing.";
	if (MissingDomainName > 0)
		Reason += "\nThe domain name is missing.";
	if (PeriodValid == 0)
		Reason += "\nAddress must contain at least one period.";
	if (SpaceValid > 0)
		Reason += "\nNo Spaces allowed. Address contains " + SpaceValid + " space";
	if (SpaceValid > 1)
		Reason += "s.";
	if (CharsInValid > 0)
		Reason += "\nAddress contains " + CharsInValid + " invalid character";
	if (CharsInValid > 1)
		Reason += "s.";
	if (DoublePeriod > 0)
		Reason += "\nAddress contains multiple periods in a row.";
	if (ExtValid == 0)
		Reason += "\nInvalid Domain Suffix entered.\n(Valid: .com, .edu, .net, .org, .gov, .mil, .us)";
	if (checkStr.length > 120)
		Reason += "\nPlease limit the Email Address to 120 characters.";

	if (RL != Reason.length)
	{
		alert(Reason);
		EmailForm.focus();
		RC = false;
		}
	else
		RC = true;
	return(RC);
}

function VerifyZipCode(ZipCodeField)
{
	var checkOK = "0123456789";
	var checkStr = ZipCodeField.value;
	var allValid = true;
	if (checkStr.length < 5)
	{
		alert("Please enter at least 5 digits into zip code.");
		ZipCodeField.focus();
		return (false);
	}

	if (checkStr.length > 5)
	{
		alert("Please enter at most 5 digits into zip code.");
		ZipCodeField.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 (!allValid)
	{
		alert("Please enter only 5 digits into zip code.");
		ZipCodeField.focus();
		return (false);
	}

	return (true);
}

function VerifyState(StateForm) {

  var Reason  = "State entered incorrectly. \n\nReason:"
  var str = StateForm.value;  
  var RL = "";      

  var re = /^AL$|^AK$|^AZ$|^AR$|^CA$|^CO$|^CT$|^DE$|^DC$|^FL$|^GA$|^HI$|^ID$|^IL$|^IN$|^IA$|^KS$|^KY$|^LA$|^ME$|^MD$|^MA$|^MI$|^MN$|^MS$|^MO$|^MT$|^NE$|^NV$|^NH$|^NJ$|^NM$|^NY$|^NC$|^ND$|^OH$|^OK$|^OR$|^PA$|^RI$|^SC$|^SD$|^TN$|^TX$|^UT$|^VT$|^VA$|^WA$|^WV$|^WI$|^WY$/i;

  if (re.test(str)) {
    StateForm.value = str.toUpperCase();
    RL = Reason.length;
  }
  else
  	Reason += str + " is an invalid U.S. state code!";
  
  if (RL != Reason.length)
  {
	alert(Reason);
	StateForm.focus();
	RC = false;
  }
  else
	RC = true;

  return(RC);

}

// End -->
