// JavaScript Document

function FrontPage_Form1_Validator(theForm)
{

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

  if (theForm.UserName.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"Name\" field.");
    theForm.UserName.focus();
    return (false);
  }

  if (theForm.UserName.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"Name\" field.");
    theForm.UserName.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f";
  var checkStr = theForm.UserName.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 only letter and whitespace characters in the \"Name\" field.");
    theForm.UserName.focus();
    return (false);
  }

  if (theForm.Personal_Information_StreetAddress.value == "")
  {
    alert("Please enter a value for the \"Street Address\" field.");
    theForm.Personal_Information_StreetAddress.focus();
    return (false);
  }

  if (theForm.Personal_Information_StreetAddress.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Street Address\" field.");
    theForm.Personal_Information_StreetAddress.focus();
    return (false);
  }

  if (theForm.Personal_Information_StreetAddress.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Street Address\" field.");
    theForm.Personal_Information_StreetAddress.focus();
    return (false);
  }

  if (theForm.Personal_Information_City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.Personal_Information_City.focus();
    return (false);
  }

  if (theForm.Personal_Information_City.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"City\" field.");
    theForm.Personal_Information_City.focus();
    return (false);
  }

  if (theForm.Personal_Information_City.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"City\" field.");
    theForm.Personal_Information_City.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f";
  var checkStr = theForm.Personal_Information_City.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 only letter and whitespace characters in the \"City\" field.");
    theForm.Personal_Information_City.focus();
    return (false);
  }

  if (theForm.Personal_Information_State.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.Personal_Information_State.focus();
    return (false);
  }

  if (theForm.Personal_Information_State.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"State\" field.");
    theForm.Personal_Information_State.focus();
    return (false);
  }

  if (theForm.Personal_Information_State.value.length > 2)
  {
    alert("Please enter at most 2 characters in the \"State\" field.");
    theForm.Personal_Information_State.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ";
  var checkStr = theForm.Personal_Information_State.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 only letter characters in the \"State\" field.");
    theForm.Personal_Information_State.focus();
    return (false);
  }

  if (theForm.Personal_Information_ZipCode.value == "")
  {
    alert("Please enter a value for the \"Zip Code\" field.");
    theForm.Personal_Information_ZipCode.focus();
    return (false);
  }

  if (theForm.Personal_Information_ZipCode.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Zip Code\" field.");
    theForm.Personal_Information_ZipCode.focus();
    return (false);
  }

  if (theForm.Personal_Information_ZipCode.value.length > 9)
  {
    alert("Please enter at most 9 characters in the \"Zip Code\" field.");
    theForm.Personal_Information_ZipCode.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.Personal_Information_ZipCode.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Zip Code\" field.");
    theForm.Personal_Information_ZipCode.focus();
    return (false);
  }

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

  if (theForm.UserEmail.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.UserEmail.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@,.";
  var checkStr = theForm.UserEmail.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 only letter, digit and \"@,.\" characters in the \"UserEmail\" field.");
    theForm.UserEmail.focus();
    return (false);
  }

  if (theForm.Age_of_Home.value == "")
  {
    alert("Please enter a value for the \"Age of Home\" field.");
    theForm.Age_of_Home.focus();
    return (false);
  }

  if (theForm.Age_of_Home.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Age of Home\" field.");
    theForm.Age_of_Home.focus();
    return (false);
  }

  if (theForm.Age_of_Home.value.length > 3)
  {
    alert("Please enter at most 3 characters in the \"Age of Home\" field.");
    theForm.Age_of_Home.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.Age_of_Home.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Age of Home\" field.");
    theForm.Age_of_Home.focus();
    return (false);
  }

  if (theForm.Total_Square_Feet.selectedIndex == 0)
  {
    alert("The first \"Living Area Square Footage\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Total_Square_Feet.focus();
    return (false);
  }

  if (theForm.Number_Heating_Air_Units.selectedIndex == 0)
  {
    alert("The first \"Heating Air Units\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Number_Heating_Air_Units.focus();
    return (false);
  }

  if (theForm.Num_Bedrooms.selectedIndex == 0)
  {
    alert("The first \"Bedrooms\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Num_Bedrooms.focus();
    return (false);
  }

  if (theForm.Num_Bathrooms.selectedIndex == 0)
  {
    alert("The first \"Bathrooms\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Num_Bathrooms.focus();
    return (false);
  }
  
  if (theForm.InspectAgree.checked == false)
  {
	  alert("You must check the box acknowledging you have read and understood the Inspection Agreement")
	  theForm.InspectAgree.focus();
	  return false;
  }
  
  
  return (true);
}

