<!-- 

// the following function checks the contact form for errors
// that may have been entered by the user. Errors in the form
// could prevent the web author from building an accurate
// database of potential customers.

// To write this form, I relied primarily on an example in a good
// book called The Book of JavaScript, by Thau!. Thau! is also the
// author of the JavaScript tutorials on www.webmonkey.com.

function checkForm() {
  var error_mess = "";


  // check the full name field
  if ((document.getElementById("contact").full_name.value == "full_name") ||
	 (document.getElementById("contact").full_name.value == "")) 
		{
		error_mess += "- You must enter your Full Name.\n";
		event.returnValue=false;
		}

  // check the address field
  if ((document.getElementById("contact").address.value == "address") ||
	 (document.getElementById("contact").address.value == "")) 
		{
		error_mess += "- You must enter your Address.\n";
		event.returnValue=false;
		}

  // check the city field
  if ((document.getElementById("contact").city.value == "city") ||
	 (document.getElementById("contact").city.value == "")) 
		{
		error_mess += "- You must enter your City.\n";
		event.returnValue=false;
		}


  // check the state  field
  if ((document.getElementById("contact").state.value == "state") ||
	 (document.getElementById("contact").state.value == "")) 
		{
		error_mess += "- You must enter your State.\n";
		event.returnValue=false;
		}


  // check the zip  field
  if ((document.getElementById("contact").zip.value == "zip") ||
	 (document.getElementById("contact").zip.value == "")) 
		{
		error_mess += "- You must enter your Zip Code.\n";
		event.returnValue=false;
		}

  // check the phone field
  if ((document.getElementById("contact").phone.value == "phone") ||
	 (document.getElementById("contact").phone.value == "")) 
		{
		error_mess += "- You must enter your Phone Number.\n";
		event.returnValue=false;
		}
  
     // check the night phone field
  if ((document.getElementById("contact").phone_night.value == "phone_night") ||
	 (document.getElementById("contact").phone_night.value == "")) 
		{
		error_mess += "- You must enter your Night Phone Number.\n";
		event.returnValue=false;
		}

  // check the age field
  if ((document.getElementById("contact").age.value == "age") ||
	 (document.getElementById("contact").age.value == "")) 
		{
		error_mess += "- You must enter your age in years.\n";
		event.returnValue=false;
		}

  // check the date of birth field
  if ((document.getElementById("contact").dob.value == "dob") ||
	 (document.getElementById("contact").dob.value == "")) 
		{
		error_mess += "- You must enter your date of birth with the month/day/year.\n";
		event.returnValue=false;
		} 

  // check the height field
  if ((document.getElementById("contact").height.value == "height") ||
	 (document.getElementById("contact").height.value == "")) 
		{
		error_mess += "- You must enter your height.\n";
		event.returnValue=false;
		}

    // check the weight field
  if ((document.getElementById("contact").weight.value == "height") ||
	 (document.getElementById("contact").weight.value == "")) 
		{
		error_mess += "- You must enter your weight.\n";
		event.returnValue=false;
		}


  // check the howheard field  Please choose from the list below:
  if ((document.getElementById("contact").how_heard_about_us.value == "how_heard_about_us") ||
	 (document.getElementById("contact").how_heard_about_us.value == "")) 
		{
		error_mess += "- You must enter How your Heard about Us.\n";
		event.returnValue=false;
		}



// check the email field
  var atsymbol = document.getElementById("contact").email.value.indexOf("@");
  var lastdot = document.getElementById("contact").email.value.lastIndexOf(".");
  var space = document.getElementById("contact").email.value.indexOf(" ");
  var elength = document.getElementById("contact").email.value.length;
  if ((atsymbol == -1) ||     // '@' is missing from e-mail address
	  (atsymbol == 0) ||        // '@' is first character in email address
	  (lastdot == -1) ||            // '.' is missing from email address
	  (lastdot - 1 == atsymbol) ||  // '@' and '.' next to each other
	  (lastdot < atsymbol) ||       // '.' before '@' symbol
	  (lastdot == elength -1 ) ||   // '.' is last character in e-mail address
	  (space >= 1))             // email address contains a space
		{
		 error_mess += "- You must enter a valid E-mail address.\n";
		 event.returnValue=false;
		 }

  

  // displays itemized error message
  // if the error message is blank, then the user didn't make any mistakes and the
  // form can be submitted to the cgi script for processing. If an error message
  // does display, the form returns false to prevent the errors from getting submitted.
  if (error_mess == "") {
	return true;
	} else {
	error_mess = "We found the following errors in your form: \n" + error_mess;
	alert(error_mess);
	return false;
	}

  }

// -->