<!-- 



// the following function checks the mke 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.



// I also used a variety of sources on the web for a few details

// that weren't described in the book. I've listed their URLs at

// the bottom of the page.



function checkForm() {

  var error_mess = "";



  // check the first name field

  if ((document.getElementById("mke").fname.value == "")) 

		{

		error_mess += "- You must enter your First Name.\n";

		event.returnValue=false;

		document.getElementById("mke").fname.style.backgroundColor='#D9F1D3';

		document.getElementById("fnamepic").src='images/arrow01.gif';

		}



  // check the last name field

  if ((document.getElementById("mke").lname.value == "last") ||

	 (document.getElementById("mke").lname.value == "")) 

		{

		error_mess += "- You must enter your Last Name.\n";

		event.returnValue=false;

		document.getElementById("mke").lname.style.backgroundColor='#D9F1D3';

		document.getElementById("lnamepic").src='images/arrow01.gif';

		}



  // check the email field

    var atsymbol = document.getElementById("mke").uemail.value.indexOf("@");

  var lastdot = document.getElementById("mke").uemail.value.lastIndexOf(".");

  var space = document.getElementById("mke").uemail.value.indexOf(" ");

  var elength = document.getElementById("mke").uemail.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;

		 document.getElementById("mke").uemail.style.backgroundColor='#D9F1D3';

		 document.getElementById("emailpic").src='images/arrow01.gif';

		 }

  // check the area code field

  if ((document.getElementById("mke").acode.value == "")) 

		{

		error_mess += "- You must enter your Area Code.\n";

		event.returnValue=false;

		document.getElementById("mke").acode.style.backgroundColor='#D9F1D3';

		document.getElementById("phonepic").src='images/arrow01.gif';

		}

  // check the phone field

  if ((document.getElementById("mke").phone1.value == "") ||

	 (document.getElementById("mke").phone2.value == "")) 

		{

		error_mess += "- You must enter your Phone Number.\n";

		event.returnValue=false;

		document.getElementById("mke").phone1.style.backgroundColor='#D9F1D3';

		document.getElementById("mke").phone2.style.backgroundColor='#D9F1D3';

		document.getElementById("phonepic").src='images/arrow01.gif';

		}

  // check the state field

  if (document.getElementById("mke").state.value == "0") {

	error_mess += "- You must select a State.\n";

	event.returnValue=false;

	document.getElementById("mke").state.style.backgroundColor='#D9F1D3';

	document.getElementById("statepic").src='images/arrow01.gif';

	}

  // check the address field

  if ((document.getElementById("mke").address.value == "")) 

		{

		error_mess += "- You must enter your Home Address.\n";

		event.returnValue=false;

		document.getElementById("mke").address.style.backgroundColor='#D9F1D3';

		document.getElementById("addresspic").src='images/arrow01.gif';

		}

  // check the city field

  if ((document.getElementById("mke").city.value == "")) 

		{

		error_mess += "- You must enter your City.\n";

		event.returnValue=false;

		document.getElementById("mke").city.style.backgroundColor='#D9F1D3';

		document.getElementById("citypic").src='images/arrow01.gif';

		}

  // check the code field

  if ((document.getElementById("mke").code.value == "")) 

		{

		error_mess += "- You must enter your Zip Code.\n";

		event.returnValue=false;

		document.getElementById("mke").code.style.backgroundColor='#D9F1D3';

		document.getElementById("codepic").src='images/arrow01.gif';

		}

  // check the question field

  if ((document.getElementById("mke").question.value == "")) 

		{

		error_mess += "- You must enter a Question.\n";

		event.returnValue=false;

		document.getElementById("mke").question.style.backgroundColor='#D9F1D3';

		document.getElementById("questpic").src='images/arrow01.gif';

		}

  // 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 submission: \n" + error_mess;

	alert(error_mess);

	return false;

	}

  }



// -->