//<!--
function validate() {

// Step 1: check that required fields are
// filled in, alert and exit without
// submitting if not

// check that the subject field is valued
if (isEmpty("subject")) {
	alert("Please fill in the SUBJECT field.");
	setFocus("subject");
	return false;
}

// check that the name field is valued
if (isEmpty("realname")) {
	alert("Please fill in the NAME field.");
	setFocus("realname");
	return false;
}

// check that the email field is valued
if (isEmpty("email")) {
	alert("Please fill in the EMAIL field.");
	setFocus("email");
	return false;
}

// check that the name field is valued
if (isEmpty("msg")) {
	alert("Please fill in the MESSAGE field.");
	setFocus("msg");
	return false;
}
// Step 2: check that the email address is
// even close, alert and exit without
// submitting if not
if (!isAnEmailAddress("email")) {
	alert("Please enter a valid EMAIL address.");
	setFocus("email");
	return false;
}

// if we get this far everthing is ok, so
// let the form submit
return true;
}


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; }
}

//-->
