<!--
function Form_Validator(theForm)
{

  if (theForm.Name.value == "")
  {
    alert("Please enter a name in the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (checkNumeric(theForm.Name.value,""))
  {
    alert("Please enter only characters in the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }


  if (theForm.PostalCode.value != "")
  {
    if (!checkNumeric(theForm.PostalCode.value,"-"))
    {
      alert("Please enter only digits or dash (-) in the \"Zip\" field.");
      theForm.PostalCode.focus();
      return (false);
    }

    if(!validPostalCode(theForm.PostalCode.value))
    {
      alert("You have entered an invalid Zip Code. Please re-enter it.");
      theForm.PostalCode.focus();
      return (false);
    }
  }

  if(!validEmail(theForm.EmailAddress.value))
  {
    alert("You have entered an invalid Email address. Please re-enter it.");
    theForm.EmailAddress.focus();
    return (false);
  }

  if (theForm.DayPhone1.value == "")
  {
    alert("Please enter a value for \"Day Phone Area Code\" field.");
    theForm.DayPhone1.focus();
    return (false);
  }

  if (!checkNumeric(theForm.DayPhone1.value,""))
  {
    alert("Please enter only digits in the \"Day Phone Area Code\" field.");
    theForm.DayPhone1.focus();
    return (false);
  }

  if (theForm.DayPhone2.value == "")
  {
    alert("Please enter a value for \"Day Phone\" field.");
    theForm.DayPhone2.focus();
    return (false);
  }

  if (!checkNumeric(theForm.DayPhone2.value,"-"))
  {
    alert("Please enter only digits or dash (-) in the \"Day Phone\" field.");
    theForm.DayPhone2.focus();
    return (false);
  }

  if(!validPhone(theForm.DayPhone2.value))
  {
    alert("You have entered an invalid Day Phone number. Please re-enter it.");
    theForm.DayPhone2.focus();
    return (false);
  }

  if (theForm.EvePhone1.value != "")
  {
    if (!checkNumeric(theForm.EvePhone1.value,""))
    {
      alert("Please enter only digits in the \"Evening Phone Area Code\" field.");
      theForm.EvePhone1.focus();
      return (false);
    }

    if (theForm.EvePhone2.value == "")
    {
      alert("Please enter a value for \"Evening DayPhone\" field.");
      theForm.EvePhone2.focus();
      return (false);
    }

    if (!checkNumeric(theForm.EvePhone2.value,"-"))
    {
      alert("Please enter only digits or dash (-) in the \"Evening Phone\" field.");
      theForm.EvePhone2.focus();
      return (false);
    }

    if(!validPhone(theForm.EvePhone2.value))
    {
      alert("You have entered an invalid Evening Phone number. Please re-enter it.");
      theForm.EvePhone2.focus();
      return (false);
    }
  }

  if (theForm.CellPhone1.value != "")
  {
    if (!checkNumeric(theForm.CellPhone1.value,""))
    {
      alert("Please enter only digits in the \"Cell Phone Area Code\" field.");
      theForm.CellPhone1.focus();
      return (false);
    }

    if (theForm.CellPhone2.value == "")
    {
      alert("Please enter a value for \"Cell DayPhone\" field.");
      theForm.CellPhone2.focus();
      return (false);
    }

    if (!checkNumeric(theForm.CellPhone2.value,"-"))
    {
      alert("Please enter only digits or dash (-) in the \"Cell Phone\" field.");
      theForm.CellPhone2.focus();
      return (false);
    }

    if(!validPhone(theForm.CellPhone2.value))
    {
      alert("You have entered an invalid Cell Phone number. Please re-enter it.");
      theForm.CellPhone2.focus();
      return (false);
    }
  }

  return (true);
}

function checkNumeric(checkStr, more)
{
  var checkOK = "0123456789" + more;

  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
      return(false);
  }

  return(true);

}

function validEmail(email)
{
  var invalidchars = " ~`!#$%^&*()+={}[]|\"<>,?'/:;" //@ and . ok

// remove leading spaces
	while(email.substring(0,1)==" ")
	{
		email = email.substring(1,email.length);
	}

// remove trailing spaces
	while(email.substring(email.length-1,email.length)==" ")
	{
		email = email.substring(0,email.length-1);
	}

	if(email == "")
	{			//checks to see if blank field
		return (false);
	}
			
	for(i=0;i<invalidchars.length;i++) //checks for invalid chars
	{			
		badchars = invalidchars.charAt(i)
			
		if(email.indexOf(badchars,0)!= -1)
		{
			return (false);
		}
	}
	atPos = email.indexOf("@",1)  //holds position of "@"
			
	if(atPos == -1) 
	{	//checks to see if "@" present
		return (false);
	}

	if(email.indexOf("@",atPos+1) != -1) 
	{ //checks for second "@"
		return (false);
	}

	periodPos = email.indexOf(".",atPos) //holds position of "." after "@"

	if(periodPos == -1)
	{ //checks for presence of "."
		return (false);
	}
	if (periodPos == (atPos + 1))
	{ //checks for "@."
		return (false);
	}
	if(periodPos+3 > email.length)
	{//makes sure at least two chars after the period
		return (false);
	}

	return (true);
}

function validPhone(phone)
{
// remove leading spaces
	while(phone.substring(0,1)==" ")
	{
		phone = phone.substring(1,phone.length);
	}

// remove trailing spaces
	while(phone.substring(phone.length-1,phone.length)==" ")
	{

		phone = phone.substring(0,phone.length-1);
	}

	if(phone == "")
	{			//checks to see if blank field
		return (false);
	}
			
	if(phone.length < 7)
	{			//checks to see if not enough or too many numbers
		return (false);
	}

	if(phone.length == 7)
    {
		dashPos = phone.indexOf("-",1)  //holds position of first "-"

		if(dashPos != -1) 
			return (false);

	}

	if(phone.length == 8)
    {
		dashPos = phone.indexOf("-",1)  //holds position of first "-"

		if(dashPos != 3) 
			return (false);

		if(phone.indexOf("-",dashPos+1) != -1) 
			return (false);
	}

	return (true);
}

function validPostalCode(zip)
{
// remove leading spaces
	while(zip.substring(0,1)==" ")
	{
		zip = zip.substring(1,zip.length);
	}

// remove trailing spaces
	while(zip.substring(zip.length-1,zip.length)==" ")
	{
		zip = zip.substring(0,zip.length-1);
	}

	if(zip == "")
	{			//checks to see if blank field
		return (false);
	}
			
	if(zip.length < 5)
	{			//checks to see if not enough or too many numbers
		return (false);
	}

	if(zip.length == 5 || zip.length == 9)
    {
		dashPos = zip.indexOf("-",1)  //holds position of first "-"

		if(dashPos != -1) 
			return (false);

		return(true);
	}

	if(zip.length == 10)
    {
		dashPos = zip.indexOf("-",1)  //holds position of first "-"
		
		if(dashPos != 5) 
			return (false);

		if(zip.indexOf("-",dashPos+1) != -1) 
			return (false);

		return(true);
	}

	return (false);
}

//-->