var submitDone = false;

function processForm(theForm) {

	var why = "";
	why += checkEmail(theForm.Email.value);
	why += checkCountry(theForm.Country.selectedIndex);

	if (why != "") {
		alert(why);
		return false;
	}

	if (theForm.Country.value=='US') {
		theForm.redirect.value = "http://takeaction.oceana.org/Forms/signup-us.jsp?Email=[[Email]]";
	}

	if (!submitDone) {
		submitDone = true;
		return true;
	} else {
		alert ("Already submitted, please wait!");
		return false;
	}
}


// EMAIL

function checkEmail (strng) {
	var error="";

	if (strng == "") {
		error = "Please enter your email address.\n";
	}

 	var emailFilter=/^.+@.+\..{2,3}$/;

	if (!(emailFilter.test(strng))) { 
		 error = "Please enter a valid email address.\n";
	} else {

		//test email for illegal characters

		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/

		if (strng.match(illegalChars)) {
			error = "The email address contains illegal characters.\n";
		}
	}
	return error;    
}

// COUNTRY

function checkCountry(choice) {
	var error = "";

	if (choice == 0) {
		error = "Please select your country.\n";
	}    
	return error;
}