// Some cribbed from O'Reilly's Javascript and DHTML Cookbook
// http://www.oreilly.com/catalog/jvdhtmlckbk/

function vetSubmission(elem) {

	var fieldEmpty = isEmpty(elem);
	var isValid;

	if (fieldEmpty) {
		return false;
	}

	return isEmailAddr(elem);
}

// validates that the entry is formatted as an e-mail address
function isEmailAddr(elem) {
	var str = elem.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!str.match(re)) {
		alert("The supplied email address appears to be invalid. Please verify it.");
		return false;
	} else {
		return true;
	}
}

// validates that the field value string has one or more characters in it
function isEmpty(elem) {
	var str = elem.value;
	var re = /.+/;
	if(!str.match(re)) {
		alert("Please enter an email address for your newsletter subscription.");
		return true;
	} else {
		return false;
	}
}



