
function trim ( inputStringTrim ) {
  fixedTrim = "";
  lastCh = " ";
  for (x=0; x < inputStringTrim.length; x++) {
    ch = inputStringTrim.charAt(x);
    if ((ch != " ") || (lastCh != " ")) {
     fixedTrim += ch;
    }
  lastCh = ch;
  }
  if (fixedTrim.charAt(fixedTrim.length - 1) == " ") {
    fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1);
  }
  return fixedTrim;
}


function ValidatorShort(theForm)
{

  if (theForm.a0010_Name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.a0010_Name.focus();
    return (false);
  }

  if (theForm.a0010_Name.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"Name\" field.");
    theForm.a0010_Name.focus();
    return (false);
  }

  if (theForm.a0010_Name.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Name\" field.");
    theForm.a0010_Name.focus();
    return (false);
  }

  if (theForm.a0015_Phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.a0015_Phone.focus();
    return (false);
  }

  if (theForm.a0015_Phone.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"Phone\" field.");
    theForm.a0015_Phone.focus();
    return (false);
  }

  if (theForm.a0015_Phone.value.length > 25)
  {
    alert("Please enter at most 25 characters in the \"Phone\" field.");
    theForm.a0015_Phone.focus();
    return (false);
  }

  if (theForm.a0020_Email.value == "")
  {
    alert("Please enter a value for the \"E-mail\" field.");
    theForm.a0020_Email.focus();
    return (false);
  }

  if (theForm.a0020_Email.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"E-mail\" field.");
    theForm.a0020_Email.focus();
    return (false);
  }

  if (theForm.a0020_Email.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"E-mail\" field.");
    theForm.a0020_Email.focus();
    return (false);
  }

    var emailad = trim(theForm.a0020_Email.value);
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,3}$/;

		if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1))
		{
			alert ("Email is invalid. Please enter a       \nvalid email address.");
			theForm.a0020_Email.focus();
			return false;
		}

  return (true);
}


function Validator(theForm)
{

  if (theForm.a0010_Name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.a0010_Name.focus();
    return (false);
  }

  if (theForm.a0010_Name.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"Name\" field.");
    theForm.a0010_Name.focus();
    return (false);
  }

  if (theForm.a0010_Name.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Name\" field.");
    theForm.a0010_Name.focus();
    return (false);
  }

  if (theForm.a0015_Phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.a0015_Phone.focus();
    return (false);
  }

  if (theForm.a0015_Phone.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"Phone\" field.");
    theForm.a0015_Phone.focus();
    return (false);
  }

  if (theForm.a0015_Phone.value.length > 25)
  {
    alert("Please enter at most 25 characters in the \"Phone\" field.");
    theForm.a0015_Phone.focus();
    return (false);
  }

  if (theForm.a0020_Email.value == "")
  {
    alert("Please enter a value for the \"E-mail\" field.");
    theForm.a0020_Email.focus();
    return (false);
  }

  if (theForm.a0020_Email.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"E-mail\" field.");
    theForm.a0020_Email.focus();
    return (false);
  }

  if (theForm.a0020_Email.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"E-mail\" field.");
    theForm.a0020_Email.focus();
    return (false);
  }

    var emailad = trim(theForm.a0020_Email.value);
		var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
		var check=/@[\w\-]+\./;
		var checkend=/\.[a-zA-Z]{2,3}$/;

		if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1))
		{
			alert ("Email is invalid. Please enter a       \nvalid email address.");
			theForm.a0020_Email.focus();
			return false;
		}

	  if (theForm.a1000_587WWdv.value == "")
	  {
	    alert("Please enter a value for the \"Security Code\" field.");
	    theForm.a1000_587WWdv.focus();
	    return (false);
	  }

	  if (theForm.a1000_587WWdv.value.length < 4)
	  {
	    alert("Please enter at least 4 characters in the \"Security Code\" field.");
	    theForm.a1000_587WWdv.focus();
	    return (false);
	  }
  return (true);
}

