var xmlhttp;
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your browser does not support XMLHttp!\nIt's about time to upgrade don't you think?");
	}
}
function state_Change() {
	// if xmlhttp shows "loaded"
	//var svw = document.getElementById('mail_subscribe_status'); // will want to set this!
	var f = document.forms['mail_subscribe_form'];
	if (xmlhttp.readyState==4 && xmlhttp.responseText != null) {
		//alert("something happening");
		//alert(xmlhttp.responseText);
		var t = document.getElementById('response');
		t.innerHTML = "<span style='color: red;'>" + xmlhttp.responseText + "</span>";
	}
	return true;
}	
function loadXMLDoc(url) {
	xmlhttp = getXmlHttpRequestObject();
	if (xmlhttp!=null) {
		xmlhttp.onreadystatechange=state_Change;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
	else {
	  alert("Your browser does not seem to support XMLHTTP.");
	}
}
function save() {
	var f = document.forms['mail_subscribe_form'];
	if (f.elements['email'].value == "") {
		var t = document.getElementById('response');
		t.innerHTML = "<span style='color: red;'>Email address cannot be blank.</span>";
		return false;
	}
	loadXMLDoc('mcapi_jd_listSubscribe.php?email=' + f.email.value);
	return false;
}
function GetXmlHttpObject() {
	var xmlhttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlhttp=new XMLHttpRequest();
	}
	catch (e) {
		//Internet Explorer
		try {
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlhttp;
}	
function clear_email() {
	var f = document.forms['mail_subscribe_form'];
	if (f.elements['email'].value == "join our mailing list") {
		f.elements['email'].value = "";
	}
}

