var USStateCodeDelimiter = "|";
var USStateCodes = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP"



function doVerify(TheForm) {

  if (TheForm.name.value == "") {
	alert("Please enter your name.");
	document.TheForm.name.focus();
        return;
  }

  if (document.TheForm.addr.value.length == 0) {
	alert("Please enter an address.");
	document.TheForm.addr.focus();
        return;
  }


  if (document.TheForm.city.value.length == 0) {
	alert("Please enter a city.");
	document.TheForm.city.focus();
        return;
  }

  if (document.TheForm.state.value.length == 0) {
	alert("Please enter a state.");
	document.TheForm.state.focus();
        return;
  }
  
  

  if (document.TheForm.zip.value.length == 0) {
	alert("Please enter a zip.");
	document.TheForm.zip.focus();
        return;
  }

  if (document.TheForm.email.value == "" ){
  		alert("Please enter valid e-mail adress.");
			document.TheForm.email.focus();
        return;
  }


   // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var i = 1;
    var sLength = document.TheForm.email.value.length;
    // look for @
    while ((i < sLength) && (document.TheForm.email.value.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (document.TheForm.email.value.charAt(i) != "@"))
    {
	  		alert("Please enter valid e-mail adress.");
				document.TheForm.email.focus();
	        return;
    }
    else i += 2;

    // look for .
    while ((i < sLength) && (document.TheForm.email.value.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (document.TheForm.email.value.charAt(i) != "."))
     {
		  		alert("Please enter valid e-mail adress.");
					document.TheForm.email.focus();
		        return;
    }




 document.TheForm.submit();

}


// isStateCode (STRING s [, BOOLEAN emptyOK])
// 
// Return true if s is a valid U.S. Postal Code 
// (abbreviation for state).
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isStateCode(s)
{   if (isEmpty(s)) 
       if (isStateCode.arguments.length == 1) return defaultEmptyOK;
       else return (isStateCode.arguments[1] == true);
    return ( (USStateCodes.indexOf(s) != -1) &&
             (s.indexOf(USStateCodeDelimiter) == -1) )
}



