
var message      /*  Variable used to build the alert message string. */
var fieldtofocus /*  Stores the name of the data field to receive the focus. */

function isMailReady(form) {
	var passed = true; /* This variable is set to "false" if the mail is not ready. */
	fieldtofocus = ""; /* Data field to receive the focus after the alert is closed. */

	message ="Please enter one of the following required fields: \n"

 if (form.firstname.value == "") {
			/* If the field is empty, add this to the message. */
    		message += "- - First Name \n";
			/* Then set the passed variable to "false"...we check this later. */
		passed = false;
		fieldtofocus = form.firstname;
   	 }
		/* This is repeated for each required field. */

   	if (form.surname.value == "") {
    		message += "- - Surname \n";
		passed = false;
		if (fieldtofocus == "")  {fieldtofocus = form.surname}
 	   }
	   
	if (form.subject2.value == "") {
    		message += "- - Subject \n";
		passed = false;
		if (fieldtofocus == "")  {fieldtofocus = form.subject2}
	   }
	   
	if (form.comments.value == "") {
    		message += "- - Comments \n";
		passed = false;
		if (fieldtofocus == "")  {fieldtofocus = form.comments}
	   }	   
	
	if (form.email.value == "") {
    		message += "- - E-mail \n";
		passed = false;
		if (fieldtofocus == "")  {fieldtofocus = form.email}
	}

	if (passed == false)  {
		fixFieldInfo(message, fieldtofocus); 
	}
		/*  We need to return a "true" to the form's submit so that it will send
		the form. If a "false" is returned, nothing happens with the form 
		submittal.  */

	return passed;
	
}

function fixFieldInfo(message, fieldtofocus) {
	alert(message);
	fieldtofocus.focus();
}
