// JavaScript Document

function FrontPage_Form1_Validator(theForm)
{
  
    if (theForm.First_Name.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.First_Name.focus();
    return (false);
  }
  
      if (theForm.Last_Name.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.Last_Name.focus();
    return (false);
  }
  
      if (theForm.Street.value == "")
  {
    alert("Please enter a value for the \"Street\" field.");
    theForm.Street.focus();
    return (false);
  }
  
      if (theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.City.focus();
    return (false);
  }
  
    if (theForm.State.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.State.focus();
    return (false);
  }
  
  
  if (theForm.Zip.value == "")
  {
    alert("Please enter a value for the \"Zip\" field.");
    theForm.Zip.focus();
    return (false);
  }

  if (theForm.Zip.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Zip\" field.");
    theForm.Zip.focus();
    return (false);
  }
  
    if (theForm.Email.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"E-mail\" field.");
    theForm.Email.focus();
    return (false);
  }
  
    if (theForm.Resume.value.length < 2)
  {
    alert("Please copy and paste your resume.");
    theForm.Resume.focus();
    return (false);
  }

  if (theForm.State.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"State\" field.");
    theForm.State.focus();
    return (false);
  }

  if (theForm.State.value.length > 2)
  {
    alert("Please enter at most 2 characters in the \"State\" field.");
    theForm.State.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ";
  var checkStr = theForm.State.value;
  var allValid = true;
  var validGroups = 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.State.focus();
    return (false);
  }

  if (theForm.Zip.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Zip\" field.");
    theForm.Zip.focus();
    return (false);
  }

  var checkOK = "0123456789-.";
  var checkStr = theForm.Zip.value;
  var allValid = true;
  var validGroups = 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;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Zip\" field.");
    theForm.Zip.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"Zip\" field.");
    theForm.Zip.focus();
    return (false);
  }

  if (theForm.Referral.value.length > 255)
  {
    alert("Please enter at most 255 characters in the \"Name\" field.");
    theForm.Referral.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Desired_Hourly.value;
  var allValid = true;
  var validGroups = 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;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Name\" field.");
    theForm.Desired_Hourly.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"Desired_Hourly\" field.");
    theForm.Desired_Hourly.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseFloat(allNum);
  if (chkVal != "" && !(prsVal > "0" && prsVal <= "200"))
  {
    alert("Please enter a value greater than \"0\" and less than or equal to \"200\" in the \"Name\" field.");
    theForm.Desired_Hourly.focus();
    return (false);
  }

  if (theForm.Availability.value.length > 255)
  {
    alert("Please enter at most 255 characters in the \"Name\" field.");
    theForm.Availability.focus();
    return (false);
  }
  return (true);
}
