<!-- /**VERSION 02**/

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

    //--[SUBJECT SELECTION]--//
    if (document.contact.subjectRequired.value == "Y") {
      if (document.contact.sendto.selectedIndex == 0) {
        error += "  Select a Subject from pulldown list\n";
        document.contact.sendto.focus();
        sFocus= "Y";
      }
    }

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

    //--[YOUR EMAIL VALUE]--//
    if (document.contact.emailRequired.value == "Y") {
      if (!document.contact.email.value || isblank(document.contact.email.value)) {
        document.contact.email.value = "";
        error += "  Email Address box is empty\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.phoneRequired.value == "Y") {
      if (!document.contact.phone.value || isblank(document.contact.phone.value)) {
        document.contact.phone.value = "";
        error += "  Phone Number box is empty\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.messageRequired.value == "Y") {
      if (!document.contact.message.value || isblank(document.contact.message.value)) {
        document.contact.message.value = "";
        error += "  Message box is empty\n";
        if (sFocus == "N") {
          document.contact.message.focus();
          sFocus= "Y";
        }
      }
    }

    //--[ERROR ALERT]--//
    if (error) {
      alert("Send A Message Online 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 < 8) { 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;
    }

//-->