function formVal()
{

  if (document.theForm.email.value == "")
  {
    alert("Please enter a valid email address.");
    document.theForm.email.focus();
    return (false);
  }

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

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

if (document.theForm.email.value.indexOf("@", 0) < 0)
 {
    alert("Please enter a valid email address.");
    document.theForm.email.focus();
    return (false);
 }

if (document.theForm.email.value.indexOf(".", 0) < 0)
 {
    alert("Please enter a valid email address.");
    document.theForm.email.focus();
    return false;
 }

 if (document.theForm.email.value.indexOf("www.", 0) >= 0)
 {
	alert ("Please enter a valid e-mail address. Valid email addresses do not start with \" www.\"");
	document.theForm.email.focus();
	return(false);
}

 if (document.theForm.email.value.indexOf(",", 0) >= 0)
 {
	alert ("Please enter a valid e-mail address. Valid email addresses do not have commas.");
	document.theForm.email.focus();
	return(false);
}

if (document.theForm.zipcode.value == "")
  {
    alert("Please enter your Zip Code.");
    document.theForm.zipcode.focus();
    return (false);
  }

  if (document.theForm.zipcode.value.length < 5)
  {
    alert("Please enter your Zip Code.");
    document.theForm.zipcode.focus();
    return (false);
  }

  if (document.theForm.zipcode.value.length > 5)
  {
    alert("Please enter at most 5 numbers in the \"Zip Code\" field.");
    document.theForm.zipcode.focus();
    return (false);
  }

  var checkOK = "0123456789";
  var checkStr = document.theForm.zipcode.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 numbers in the \"Zip Code\" field. Sorry, U.S. residents only.");
    document.theForm.zipcode.focus();
    return (false);
  }


  if (document.theForm.month_of_birth.selectedIndex == 0)
  {
    alert("Please enter your month of birth.");
    document.theForm.month_of_birth.focus();
    return (false);
  }

  if (document.theForm.day_of_birth.selectedIndex == 0)
  {
    alert("Please enter you day of birth.");
    document.theForm.day_of_birth.focus();
    return (false);
  }

  if (document.theForm.birthyear.value == "")
  {
    alert("Please enter your birth year.");
    document.theForm.birthyear.focus();
    return (false);
  }

  if (document.theForm.birthyear.value.length < 4)
  {
    alert("Please enter at least 4 numbers in the \"birth year\" field.");
    document.theForm.birthyear.focus();
    return (false);
  }

  if (document.theForm.birthyear.value.length > 4)
  {
    alert("Please enter at most 4 numbers in the \"birth year\" field.");
    document.theForm.birthyear.focus();
    return (false);
  }

  var checkOK = "0123456789";
  var checkStr = document.theForm.birthyear.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 numbers in the \"birth year\" field.");
    document.theForm.birthyear.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"birth year\" field.");
    document.theForm.birthyear.focus();
    return (false);
  }
  
  var today = new Date();
//alert("Today's date is: " + today);

var milli = today.valueOf();
//alert("Today's date in milliseconds is: " + milli);

//var thirteen = (1000*60*60*24*365.242199*13);
//alert("The number of milliseconds in 13 years is: " + thirteen);

var oneyr = (1000*60*60*24*365.242199);
//alert("The number of milliseconds in 1 years is: " + oneyear);

var by, bm, bd, birthmilli, OK;
by = document.theForm.birthyear.value
bm = document.theForm.month_of_birth.value
bd = document.theForm.day_of_birth.value

//alert("The birth year is: " + by);
//alert("The birth month is: " + bm);
//alert("The birth day is: " + bd);

birthmilli = new Date(by,bm,bd);
//alert("birthmilli is: " + birthmilli);

var birthmilliconv = birthmilli.valueOf();
//alert("birthmilliconv is: " + birthmilliconv);

var agetest = ((milli - birthmilliconv) / oneyr);
//alert("agetest is: " + agetest);
  
if (agetest < 13){
	               window.location = "http://www.teenfreeway.com/hcunderaged.htm";
 return (false);
}

document.theForm.Age.value = agetest
//alert("the value of the hidden age field is " + document.theForm.Age.value);


//Maine compliance w. age
var mainezip, agecomp;
mainezip = document.theForm.zipcode.value;
mainezip = mainezip.toString();
agecomp = document.theForm.Age.value;
agecomp = agecomp.toString();
//alert(agetest);
if (mainezip >= "03901" & mainezip <= "04990" & agecomp < "18")
  {
   window.location.replace("http://www.teenfreeway.com/hcunderaged_maine.htm");
    return (false);
  }	

{
var syn = document.theForm.EMAIL.value;
//alert("vera = " + vera);
document.theForm.EMAIL.value = syn
document.cookie = "syncookie" + "=" + escape(document.theForm.EMAIL.value) + "; path=/"
}





  return (true);
}
