function validate(theForm) {
   var msg;
   var errors = "";
   var firsterror = 0;
   var phone_pattern = /^[0-9]{10}$/;
   var email_pattern = /^.+@.+$/;

   if ((theForm.name.value == null) || (theForm.name.value == "") || isblank(theForm.name.value)) {
      errors += "- The Name field is required.\n";

      if (firsterror == 0) {
         theForm.name.focus();
         firsterror = 1;
      }

   }

   if ((theForm.company.value == null) || (theForm.company.value == "") || isblank(theForm.company.value)) {
      errors += "- The Company field is required.\n";

      if (firsterror == 0) {
         theForm.company.focus();
         firsterror = 1;
      }

   }

   if ((theForm.address.value == null) || (theForm.address.value == "") || isblank(theForm.address.value)) {
      errors += "- The Address field is required.\n";

      if (firsterror == 0) {
         theForm.address.focus();
         firsterror = 1;
      }

   }

   if ((theForm.citystatezip.value == null) || (theForm.citystatezip.value == "") || isblank(theForm.citystatezip.value)) {
      errors += "- The City, State, Zip field is required.\n";

      if (firsterror == 0) {
         theForm.citystatezip.focus();
         firsterror = 1;
      }

   }

   if ((theForm.website.value == null) || (theForm.website.value == "") || isblank(theForm.website.value)) {
      errors += "- The Website field is required.\n";

      if (firsterror == 0) {
         theForm.website.focus();
         firsterror = 1;
      }

   }

   if ((theForm.email.value == null) || (theForm.email.value == "") || isblank(theForm.email.value)) {
      errors += "- The Email Address field is required.\n";

      if (firsterror == 0) {
         theForm.email.focus();
         firsterror = 1;
      }

   }

   if (email_pattern.test(theForm.email.value)) {

   }
   else {
      errors += "- Please enter a valid Email Address.\n";

      if (firsterror == 0) {
         theForm.email.focus();
         firsterror = 1;
      }

   }

   if ((theForm.phone.value == null) || (theForm.phone.value == "") || isblank(theForm.phone.value)) {
      errors += "- The Phone Number field is required.\n";

      if (firsterror == 0) {
         theForm.phone.focus();
         firsterror = 1;
      }

   }

   if (phone_pattern.test(theForm.phone.value)) {

   }
   else {
      errors += "- Please enter a valid Phone Number, digits only.\n";

      if (firsterror == 0) {
         theForm.phone.focus();
         firsterror = 1;
      }

   }

   if ((theForm.fax.value == null) || (theForm.fax.value == "") || isblank(theForm.fax.value)) {
      errors += "- The Fax Number field is required.\n";

      if (firsterror == 0) {
         theForm.fax.focus();
         firsterror = 1;
      }

   }

   if (phone_pattern.test(theForm.fax.value)) {

   }
   else {
      errors += "- Please enter a valid Fax Number, digits only.\n";

      if (firsterror == 0) {
         theForm.fax.focus();
         firsterror = 1;
      }

   }

   if (!errors) return true;

   msg = "________________________________________________________________\n\n";
   msg += "The form was not submitted because of the following error(s).\n";
   msg += "Please correct these error(s) and resubmit.\n";
   msg += "________________________________________________________________\n\n"
;
   msg += errors;

   alert(msg);

   return false;

}

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;
}
