// ************************************************************** //
// ************** START CORE SCRIPT FOR AJAX CALLS ************** //
// ************************************************************** //

/****************************
function name: getXMLHTTPRequest()
purpose:       check for browser version to create the correct type of object
arguments:     none
returns:       the requested object type
*****************************/
function getXMLHTTPRequest() {
	var req = false;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return req;
}
var xmlhttp = getXMLHTTPRequest();
/****************************
function name: sendRequest()
purpose:       perform a specific action and update the div
arguments:     pageURL, div
returns:       requested page
*****************************/	
function sendRequest(pageURL, div) {
	var bodyofrequest = getBody(pageURL);
	xmlhttp.open("GET", pageURL, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			document.getElementById(div).innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(bodyofrequest);
}
/****************************
function name: getBody()
purpose:       encode URI
arguments:     pageURL
returns:       the pageURL var
*****************************/
function getBody(pageURL) {
	var argument = "value=";
	argument += encodeURIComponent(pageURL)
	return argument;
}

/****************************
function name: updater()
purpose:       creates a dynamic URL to send to sendRequest()
arguments:     page, urlVarName, urlValue, divContent
returns:       requested page
*****************************/			  
function updater(pageURL, divContent) {
	setTimeout(function(){sendRequest(pageURL, divContent)},000);
}

// ************************************************************** //
// *************** END CORE SCRIPT FOR AJAX CALLS *************** //
// ************************************************************** //