// JavaScript Document

function test_email(email) {
	if(email.length==0)
		return true;
	var pattern = /[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9_\.\-]+\.[a-zA-Z0-9_\.\-]+/;//need to add invalid one
	var is_email = pattern.test(email.value);
	if(is_email == false) {
		var msg = "The email address "+email.value+" is not valid";
		alert(msg);
		email.value="";
		return false;
	}
	return true;
}


function submitForm(isReturn) {
	var f = document.mlForm;

	if(isReturn) //only return value if form is sumbitted by typing <Return>
		return false;
	if(f.email.value.length == 0) {
		alert("You must enter an email address.");
		return;
	}
	if(!test_email(f.email))
		return;
	
	if(f.actionTaken[0].checked && !f.coppa.checked) {
		alert("In compliance with COPPA, you must specify that you are at least 13 before joining our mailing lists.");
		return;
	}
	if(!f.usamts.checked) {
		alert("You must select at least one mailing list to join or to quit.");
		return;
	}
	
	f.submit();
		
}

document.mlForm.onsubmit=function(){return submitForm(1);}