
// Get the HTTP Object
function getHTTPObject(){
	if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) return new XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX.");
		return null;
	}
}

 
// Change the value of the outputText field

function setOutput(){
	//takes in a div and sets its innerHTML to the httpObject's response text
	if(httpObject.readyState == 4) {
		document.getElementById(divobj).innerHTML = httpObject.responseText;
	}
}


// Implement business logic

function addNewsletter(email, formpage){
	//send this function a url and it will put whatever that url returns
	//into the divobject
	divobj = 'newsletterform';
	httpObject = getHTTPObject();
	if (httpObject != null) {
		httpObject.open("GET", 'ajax_newsletter.php?email='+email+'&formpage='+formpage, true);
		httpObject.send(null);
		//document.getElementById(divobj).innerHTML = '<img src="images/red-ajax-loader.gif">';
		httpObject.onreadystatechange = setOutput;
	}
}

var httpObject = null;
var divobj = null;
