function contactus_Validator(theForm)
{

  if (theForm.Name.value == "")
  {
    alert("Please enter a value for the \"name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length > 45)
  {
    alert("Please enter at most 45 characters in the \"name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.Company.focus();
    return (false);
  }
  
  if (theForm.Company.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"Company\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (!isEmail(theForm.Email.value))
  {
    alert("Please enter a valid address in the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }
  
  if (theForm.Comments.value.length > 150)
  {
	alert("Please enter at most 150 characters in the \"Comment\" field.");
    theForm.Phone.focus();
    return (false);
  }

  return (true);
}

function isEmail(argvalue) {

  if (argvalue.indexOf(" ") != -1)
    return false;
  else if (argvalue.indexOf("@") == -1)
    return false;
  else if (argvalue.indexOf("@") == 0)
    return false;
  else if (argvalue.indexOf("@") == (argvalue.length-1))
    return false;

  arrayString = argvalue.split("@");
  // var retSize = customSplit(argvalue, "@", "arrayString");
  if (arrayString[1].indexOf(".") == -1)
    return false;
  else if (arrayString[1].indexOf(".") == 0)
    return false;
  else if (arrayString[1].charAt(arrayString[1].length-1) == ".")
    return false;
  else if (arrayString[1].charAt(arrayString[1].length-2) == ".") {
    return false;
  }

  return true;

}

function contactlist_Validator(theForm)
{

  if (theForm.OwnersName.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.OwnersName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.OwnersName.value.length > 45)
  {
    alert("Please enter at most 45 characters in the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.CompanyName.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.Company.focus();
    return (false);
  }
  
  if (theForm.CompanyName.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"Company\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.EmailAddress.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (!isEmail(theForm.EmailAddress.value))
  {
    alert("Please enter a valid address in the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }
  
  if (theForm.Address.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Address.value.length > 40)
  {
	alert("Please enter at most 40 characters in the \"Address\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.Email.focus();
    return (false);
  }

if (theForm.City.value.length > 40)
  {
	alert("Please enter at most 40 characters in the \"City\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.State.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.Email.focus();
    return (false);
  }

if (theForm.State.value.length > 5)
  {
	alert("Please enter at most 5 characters in the \"State\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.ZipCode.value == "")
  {
    alert("Please enter a value for the \"ZipCode\" field.");
    theForm.Email.focus();
    return (false);
  }

if (theForm.ZipCode.value.length > 10)
  {
	alert("Please enter at most 10 characters in the \"ZipCode\" field.");
    theForm.Phone.focus();
    return (false);
  }

  return (true);
}
