// JavaScript Document
function testBlank(field, msg) {
	if (field.value == "") {
		alert(msg);
		field.focus();
		field.select();
		return false;
	} else
		return true;
}

function testNumber(field, msg) {
	var maxRe = /^[\d]+$/
	if (!maxRe.test(field.value)) {
		alert(msg);
		field.focus();
		field.select();
		return false;
	} else
		return true;
}

function testEmail(field, msg) {
	if (navigator.userAgent.indexOf("Opera") >= 0) {
		var maxRe = /^[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/
	} else {
		var maxRe = /^[^\s]+?\@[^\s]+?\.\w{2,}$/
	}
	if (!maxRe.test(field.value)) {
		alert(msg);
		field.focus();
		field.select();
		return false;
	} else
		return true;
}

function testOption(field, msg) {
	if (field.selectedIndex == 0) {
		alert(msg);
		field.focus();
		return false;
	}
	else
		return true;
}

function testAndSubmit(form) {
	return (
		testBlank(form.FirstName, "First Name (must not be blank)") &&
		testBlank(form.LastName, "Last Name (must not be blank)") &&
/*		testBlank(form.Address, "Address (must not be blank)") &&
		testBlank(form.City, "City (must not be blank)") &&
		testOption(form.state, "State (A State must be selected)") &
		testBlank(form.Zip, "Zip Code (must not be blank)") && */
		testBlank(form.home_phone_area, "Area Code (must not be blank)") &&
		testBlank(form.home_phone_prefix, "Prefix (must not be blank)") &&
		testBlank(form.home_phone_number, "Last Four Digits (must not be blank)")
	);
}