/*For form validation on the /offers/whole.asp page*/

function FormValidator(theForm)
{

 if (theForm.State.selectedIndex == 0)
  {
    alert("Please Select the State for Your Request.");
    theForm.State.focus();
    return (false);
  }

if(theForm.bmonth.selectedIndex == 0) {
	alert("Please indicate what month you were born.");
	theForm.bmonth.focus();
	return false;
}
if(theForm.bday.selectedIndex == 0) {
	alert("Please indicate what day you were born.");
	theForm.bday.focus();
	return false;
}
if(theForm.byear.selectedIndex == 0) {
	alert("Please indicate what year you were born.");
	theForm.byear.focus();
	return false;
}

  if (theForm.weight.value == "")
  {
    alert("Please enter a value for the \"weight\" field.");
    theForm.weight.focus();
    return (false);
  }

  if (theForm.weight.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"weight\" field.");
    theForm.weight.focus();
    return (false);
  }

  if (theForm.weight.value.length > 3)
  {
    alert("Please enter at most 3 characters in the \"weight\" field.");
    theForm.weight.focus();
    return (false);
  }

  var checkOK = "0123456789-.";
  var checkStr = theForm.weight.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 \"weight\" field.");
    theForm.weight.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"weight\" field.");
    theForm.weight.focus();
    return (false);
  }

  if (theForm.FromEmail.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.FromEmail.focus();
    return (false);
  }

  if (theForm.FromEmail.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Email Address\" field.");
    theForm.FromEmail.focus();
    return (false);
  }

  if (theForm.FromName.value == "")
  {
    alert("Please enter a value for the \"Your Name\" field.");
    theForm.FromName.focus();
    return (false);
  }

  if (theForm.FromName.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Your Name\" field.");
    theForm.FromName.focus();
    return (false);
  }

 
  return (true);
}
