//var myConn = new XHConn();

//if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");

function checkEmail(foo,bar){
	if(foo.value && bar.value){
		myConn.connect("/phpscripts/emailCheck.php", "GET", "email="+foo.value+"&campaign="+bar.value, returnEmail);
	}
}

function returnEmail(foo){
	if(foo.responseText == "ok"){
		//document.getElementById('submitButton').disabled = "";
		document.Form.submit();
		return true;
	} else {
		alert("Sorry, that email address has already been registered.\nPlease use a different one.");
		//document.getElementById('submitButton').disabled = "disabled";
		return false;
	}
}
var emailFailed;
function emailCheck(foo) {
	if(!foo.nodeName) foo = document.getElementById(foo);
	if (foo.value=="") {
		alert("Please enter your email address.");
		foo.focus();
		emailFailed = true;
		return false;
	}
	regex = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	if(regex && !regex.test(foo.value)){
		alert("Please enter a valid email address.");
		foo.focus();
		emailFailed = true;
		return false;
	}
	emailFailed = false;
	noPop = true;
	return true; // temporary line while PHP is down... remove this to make it work again 
	checkEmail(document.getElementById('from'),document.getElementById('campaign'));
	return false;
}