// 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[0].checked && !f.coppa[1].checked && !f.coppa[2].checked) {

		alert("In compliance with COPPA, you must specify that you are at least 13 or that you are a member of our Community before joining our mailing lists.");

		return;

	}

	if(f.coppa[1].checked && f.coppaName.length ==0) {

		alert("You must specify your Art of Problem Solving Community username if you are a member under the age of 13.");

		return;

	}

	if(!f.newProducts.checked && !f.newClasses.checked && !f.mathJams.checked ) {

		alert("You must select at least one mailing list to join or to quit.");

		return;

	}

	

	f.submit();

		

}

<!--formBackground(document.mlForm);-->

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