function setFocus(aField) {
document.forms[0][aField].focus();
}

function isAnEmailAddress(aTextField) {
// 1+@3+ [or x@x.x] is as close as we will test

if (document.forms[0][aTextField].value.length<5) {
return false;
}
else if (document.forms[0][aTextField].value.indexOf("@") < 1) {
return false;
}
else if (document.forms[0][aTextField].value.length -
 document.forms[0][aTextField].value.indexOf("@") < 4) {
return false;
}
else { return true; }
}

function isEmpty(aTextField) {  if ((document.forms[0][aTextField].value.length==0) ||
 (document.forms[0][aTextField].value==null)) {
return true;
}
else { return false; }
}

function validate() {

// Step 1: check required fields
	
// check that the email field is valued
if (isEmpty("Email")) {
   alert("Please enter your full email address (ie. youremail@youremail.com)");
   setFocus("Email");
   return false;
   }
	
   
// Step 2: check that the email address is
// even close, alert and exit without
// submitting if not

if (!isAnEmailAddress("Email")) {
   alert("The entered email address is invalid.");
   setFocus("Email");
   return false;
}

// if we get this far everthing is ok, so
// let the form submit
return true;

}

