// Start Form Validation
function FrontPage_Form1_Validator(theForm)
{
  if (theForm.City.value == "")
  {
    alert("Please enter your Village or City");
    theForm.City.focus();
    return (false);
  }

   if (theForm.DDay.value == "")
   {
	    alert("Please enter a complete date.");
	    theForm.DDay.focus();
	    return (false);
   }

	var dTime = new Date();
	dTime.setMonth(theForm.DMonth.value-1);		// 0 = January
	dTime.setDate(theForm.DDay.value);
	dTime.setYear(theForm.Dyear.value);
	dTime.setHours(2);

	var today = new Date();
	today.setHours(1);

	if (dTime == "NaN")
	{
	    alert("Please enter a valid date.");
	    theForm.DMonth.focus();
	    return (false);
	}
	else if (dTime < today)
	{
	    alert("Please enter a certificate request date later than today.");
	    theForm.DMonth.focus();
	    return (false);
	}

  if (theForm.Name.value == "")
  {
    alert("Please specify whose requesting the certificate.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Phone.value == "")
  {
    alert("Please enter the Phone Number.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Email.value == "")
  {
    alert("Please enter your Email Address.");
    theForm.Email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-._@|-";
  var checkStr = theForm.Email.value;
  var allValid = true;
  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)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter a valid Email Address.");
    theForm.Email.focus();
    return (false);
  }
  if (theForm.CHolder.value == "")
  {
    alert("Please enter the name of the Certificate Holder.");
    theForm.CHolder.focus();
    return (false);
  }

  if (theForm.Contact.value == "")
  {
    alert("Please enter the Contact.");
    theForm.Contact.focus();
    return (false);
  }

  if (theForm.Address.value == "")
  {
    alert("Please enter the Address.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.CCity.value == "")
  {
    alert("Please enter the City.");
    theForm.CCity.focus();
    return (false);
  }

  if (theForm.CState.value == "")
  {
    alert("Please enter the State.");
    theForm.CState.focus();
    return (false);
  }

  if (theForm.CZip.value == "")
  {
    alert("Please enter the Zip Code.");
    theForm.CZip.focus();
    return (false);
  }
  if (theForm.CFaxYes.checked && theForm.CFax.value == "")
  {
  alert("Please enter the Fax Number of the Certificate Holder.");
  theForm.CFax.focus();
  return (false);
  }
  //Add Limits Validation
		//General 
  if (theForm.GeneralLiability.checked && theForm.GeneralLimit.value == "")
  {
  alert("Please enter a limit to the General Liability.");
  theForm.GeneralLimit.focus();
  return (false);
  }
  var checkOK = "0123456789-$,.";
  var checkStr = theForm.GeneralLimit.value;
  var allValid = true;
  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)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter a dollar amount.  For example: $100,000 ");
    theForm.GeneralLimit.focus();
    return (false);
  }
  	//Auto
if (theForm.AutoLiability.checked && theForm.AutoLimit.value == "")
  {
  alert("Please enter a limit to the Auto Liability.");
  theForm.AutoLimit.focus();
  return (false);
  }
  var checkOK = "0123456789-$,.";
  var checkStr = theForm.AutoLimit.value;
  var allValid = true;
  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)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter a dollar amount.  For example: $100,000 ");
    theForm.AutoLimit.focus();
    return (false);
  }
  	//Excess Liability
if (theForm.ExcessLiability.checked && theForm.ExcessLimit.value == "")
  {
  alert("Please enter a limit to the Excess Liability.");
  theForm.ExcessLimit.focus();
  return (false);
  }
  var checkOK = "0123456789-$,.";
  var checkStr = theForm.ExcessLimit.value;
  var allValid = true;
  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)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter a dollar amount.  For example: $100,000 ");
    theForm.ExcessLimit.focus();
    return (false);
  }
  	
  //Other Coverage
if (theForm.OtherCoverage.checked && theForm.OtherLimit.value == "")
  {
  alert("Please enter a limit to the Other Coverage.");
  theForm.OtherLimit.focus();
  return (false);
  }
  var checkOK = "0123456789-$,.";
  var checkStr = theForm.OtherLimit.value;
  var allValid = true;
  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)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter a dollar amount.  For example: $100,000 ");
    theForm.OtherLimit.focus();
    return (false);
  }
 // End Limits validation 
  return (true);
}
