/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
//	   try {
//		    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
//	   } catch (e) {
//		    alert("Permission UniversalBrowserRead denied.");
//	   }
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* http holds our new XMLHttpRequest object. */
var http = createRequestObject(); 

/* when the server is done, replace the button table with the new contents */
function handleEntity(){
	// State 4 means the response is finished
	if(http.readyState == 4) { 
		var response = http.responseText;
		
//		alert(response);
		document.getElementById('emailsignup').value = response;
	}
}

/* called when the email signup button is clicked */
function signup_email(){
		var email  = document.email.emailsignup.value;
		var zip  = document.email.Zip.value;

//		alert(email);
		var postList = 'email='+email;

		http.open('GET', 'http://www.missionariesofafrica.org/contact/moaemailsignup.php?email='+escape(email)+'&zip='+escape(zip),true);
//		http.open('GET', 'http://survey.vdsys.com/services/moaemailsignup.php?email='+escape(email)+'&zip='+escape(zip),true);
		http.onreadystatechange = handleEntity; 
		http.send(postList);
	return false;
}
	