// JavaScript Document
// Verify Data on Membership Form
function membership_verify() {
	var errors = '';
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var area = /[2-9]\d{2}/; // 2-9 in pos 1, any #s in next two positions
	var pfx = /\d{3}/; 
	var sfx = /\d{4}/; 
	if (document.contact.email.value == "") errors += "Email is required\n";
	if (reg.test(document.contact.email.value) == false) errors += "Email is invalid\n";
	if (document.contact.first_name.value == "") errors += "First Name is required\n";
	if (document.contact.last_name.value == "") errors += "Last Name is required\n";
	if (document.contact.address1.value == "") errors += "Address1 is required\n";
	if (document.contact.city.value == "") errors += "City is required\n";
	if (document.contact.state.value == "") errors += "State is required\n";
	if (document.contact.zip.value == "") errors += "Zip is required\n";
	if (document.contact.state.value == "KS" && document.contact.county.value == "") errors += "County is required, when State is Kansas\n";
	if (document.contact.night_phone_a.value == "") errors += "Phone Area Code is required\n";
	if (area.test(document.contact.night_phone_a.value) == false) errors += "Phone Area Code must be a valid area code\n";
	if (document.contact.night_phone_b.value == "") errors += "Phone Prefix is required\n";
	if (pfx.test(document.contact.night_phone_b.value) == false) errors += "Phone Prefix must be numeric\n";
	if (document.contact.night_phone_c.value == "") errors += "Phone Suffix is required\n";		
	if (sfx.test(document.contact.night_phone_c.value) == false) errors += "Phone Suffix must be numeric\n";
	if (errors) alert('The following error(s) occurred:\n'+errors);
	return (errors == '');
//alert("First Name is required");
}

// obj = document.getElementById("add_contact");
//obj.onclick = verify_contact;
