



function Validator(theForm)
{

  if (theForm.contactName.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.contactName.focus();
    return (false);
  }

  if (theForm.contactCompany.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.contactCompany.focus();
    return (false);
  }

if (theForm.contactField.value == "")
  {
    alert("Please enter a value for the \"Field of service\" field.");
    theForm.contactField.focus();
    return (false);
  }

  if (theForm.contactEmail.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.contactEmail.focus();
    return (false);
  }


  if (theForm.contactPhone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.contactPhone.focus();
    return (false);
  }



  if (theForm.comments.value == "")
  {
    alert("Please enter a value for the \"Comments\" field.");
    theForm.comments.focus();
    return (false);
  }



var input_str=theForm.contactEmail.value;
var input_len1=input_str.length;
var iserror=0;

input_len1=input_str.length;

    if (input_len1<=5) {
        alert("You must enter a Valid Email Address!\n");
        iserror=1;
    }

    var lastdot=-1;
    var lastat=-1;
    var numberat=0
    for (var j = 0; j < input_len1; j++) {
         var ch2 = input_str.substring(j, j + 1);
         if (((ch2 < "a") ||  (ch2 > "z")) && ((ch2 < "A") || (ch2 > "Z")) && ((ch2 < "0") ||  (ch2 > "9")) && (ch2 != "@" ) && (ch2 != ".") && (ch2 != "_") && (ch2 != "-")){
             alert("Please input a valid email address!\nValid characters include A-Z, a-z, 0-9, -, _, . and @");
             iserror=1;
         }
         if (ch2==".") {
             if ( j == lastdot + 1) {
                 alert("Please input a valid email address!\nYou can't have two dots next to\neach other'..'.");
                 iserror=1;
             }
             lastdot=j;
         }
         if (ch2=="@") {
             lastat=j;
             numberat=numberat+1
         }
         if (ch2==" ") {
             alert("Please input a valid email address!\nYou can't have any spaces in the address.");
             iserror=1;
         }
    }
    if (lastat == -1) {
         alert("Please input a valid email address!\nYou don't have an '@'.");
         iserror=1;
    }
    if (lastat == 0) {
         alert("Please input a valid email address!\nYou don't have a name before the '@'.");
         iserror=1;
    }
    if (numberat > 1) {
         alert("Please input a valid email address!\nYou may have only one '@'.");
         iserror=1;
    }
    if ((lastdot <= lastat) || (lastdot > input_len1 - 3 ) || (input_len1 - lastdot > 4)) {
         alert("Please input a valid email address!\nYou don't have a proper domain name!\nUse .com, .org, .net, .cc, etc");
         iserror=1;
    }
    if (lastdot == lastat + 1) {
         alert("Please input a valid email address!\nYou don't have a proper organization name!\nUse name@organization.domain");
         iserror=1;
    }
    if (iserror==1) {
         theForm.contactEmail.focus();
         return false;
    }

  
var note = theForm.Comments.value;
var intNote = note.length;

 if (intNote > 500)
  {
	alert("Your Comments are " + intNote + " Characters long. Please enter a comment of no more than 500 characters.");
    theForm.Comments.focus();
    return (false);
  }
  
  
  return (true);
}


