// --- Mailing List Validation ---------------------------------------------------------
// Copyright 2007 (c) Active Office
// Version: 2.22
// ------------------------------------------------------------------------------
function setFocus(aField) {
document.getElementById(aField).focus();
}
function isAnEmailAddress(aTextField) {
// 1+@3+ [or x@x.x] is as close as we will test
if (document.getElementById(aTextField).value.length<5) {
return false;
}
else if (document.getElementById(aTextField).value.indexOf("@") < 1) {
return false;
}
else if (document.getElementById(aTextField).value.length -
 document[FrmName][aTextField].value.indexOf("@") < 4) {
return false;
}
else { return true; }
}

function isEmpty(aTextField) {
if ((document.getElementById(aTextField).value.length==0) || (document.getElementById(aTextField).value==null)) {
return true;
}
else { return false; }
}

function isDefaultValue(aTextField, DefValue) {
if (document.getElementById(aTextField).value==DefValue) {
return true;
}
else { return false; }
}

function validate(FrmToValidate) {
if ((isEmpty("MailName")) || (isDefaultValue("MailName","Name"))) {
	alert("Please supply your name and email address.");
	setFocus("MailName");
	return false;
}

if ((isEmpty("EmailAddress")) || (isDefaultValue("EmailAddress","Email"))) {
	alert("Please supply your name and email address.");
	setFocus("EmailAddress");
	return false;
}

if (!isAnEmailAddress("EmailAddress")) {
	alert("The entered email address is invalid.");
	setFocus(FrmToValidate,"EmailAddress");
	return false;
}
return true;
}
