<!--
// Contact Us Web Form Validation Script (updated 06/13/02)

//--[THIS FUNCTION VALIDATES CONTACT US FORM]--//
  function checkForm() {
    error = "";
    sFocus = "N";

  //--[SUBJECT SELECTION]--//
    if (document.contact.sendto.selectedIndex == 0) {
      error += "  No \"Subject\" selected\n";
      document.contact.sendto.focus();
      sFocus= "Y";
    }

  //--[YOUR NAME VALUE]--//
    if (!document.contact.name.value || isblank(document.contact.name.value)) {
      document.contact.name.value = "";
      error += "  \"Your Name\" box is blank\n";
      if (sFocus == "N") {
        document.contact.name.focus();
        sFocus= "Y";
      }
    }

  //--[YOUR EMAIL VALUE]--//
    if (!document.contact.email.value || isblank(document.contact.email.value)) {
      document.contact.email.value = "";
      error += "  \"Email Address\" box is blank\n";
      if (sFocus == "N") {
        document.contact.email.focus();
        sFocus= "Y";
      }
     } else {
      if (bademail(document.contact.email.value)) {
        error += "  \"Email Address\" is not formatted properly\n";
        if (sFocus == "N") {
          document.contact.email.focus();
          sFocus= "Y";
        }
      }
    }

  //--[YOUR PHONE VALUE]--//
    if (!document.contact.phone.value || isblank(document.contact.phone.value)) {
      document.contact.phone.value = "";
      error += "  \"Phone Number\" box is blank\n";
      if (sFocus == "N") {
        document.contact.phone.focus();
        sFocus= "Y";
      }
     } else {
      if (badphone(document.contact.phone.value)) {
        error += "  \"Phone Number\" is not formatted properly\n";
        if (sFocus == "N") {
          document.contact.phone.focus();
          sFocus= "Y";
        }
      }
    }

  //--[MESSAGE VALUE]--//
    if (!document.contact.message.value || isblank(document.contact.message.value)) {
      document.contact.message.value = "";
      error += "  \"Message\" box is blank\n";
      if (sFocus == "N") {
        document.contact.message.focus();
        sFocus= "Y";
      }
    }

  //--[ERROR ALERT]--//
    if (error) {
      alert("Reach Us Online Form cannot be submitted due to errors.\n" +
            "Please correct the following error(s) and resend the form.\n" +
            "_________________________________________________\n\n" +
            error);
      return false;
    }
  }

//--[VALIDATION TEST FUNCTIONS]--//

  //--[TEST FOR BLANKS]--//
    function isblank(s) {
      for(var i=0; i<s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) { return false; }
      }
      return true;
    }

  //--[TEST FOR PROPERLY FORMATTED EMAIL ADDRESS]--//
    function bademail(s) {
      if (s.length < 6) { return true; }	//LENGTH REQUIREMENT
      var sChars = "~`!#$%^&*()+={}[]|\\:;\"\'<>,?/";	//UNACCEPTABLE CHARACTERS
      for (var i=0; i<s.length; i++) {
        if (sChars.indexOf(s.charAt(i)) != -1) { return true; }
      }
      var error = "Y";
      var sChars = "@";	//MANDATORY CHARACTER
      for (var i=0; i<s.length; i++) {
        if (sChars.indexOf(s.charAt(i)) != -1) { error = "N"; }
      }
      if (error == "Y") { return true; }
      var error = "Y";
      var sChars = ".";	//MANDATORY CHARACTER
      for (var i=0; i<s.length; i++) {
        if (sChars.indexOf(s.charAt(i)) != -1) { error = "N"; }
      }
      if (error == "Y") { return true; }
    }

  //--[TEST FOR ACCEPTABLE CHARACTERS IN PHONE NUMBER]--//
    function badphone(s) {
      if (s.length < 10) { return true; }	//LENGTH REQUIREMENT
      var sChars = "0123456789()- ";	//ACCEPTABLE CHARACTERS
      for (var i=0; i<s.length; i++) {
        if (sChars.indexOf(s.charAt(i)) == -1) { return true; }
      }
      return false;
    }

//-->
