/*
	this file defines functions which can 
	make requests to, and receive responses from, a server

	any HTML document which includes this script as well as XMLHttpRequest.js
	simply has to call sendHere() to initiate the transaction
*/

/*
sends a request to the server
*/
function sendRequest(pageChoice, outType)
{
	//choose a serverscript
	/*
	if you want to send additional data to the server
	append it to the url below eg
	var url = "processing_script.php?firstname=Shania&lastname=Twain";
	var url = "processing_script.php?percent=" . percentage;
	var url = "processing_script.php?pagenumber=page02";
	*/
	var url = "CRGRightPaneForms.php?pagenumber="+pageChoice;//+"&outType="+outType;
	//prepare the message
	request.open("GET", url, true);
	request.onreadystatechange=respondToRequest;
	//send it!
	request.send(null);			
}

/*
receive a response from a server
*/

function respondToRequest(){
	//only act if the server response indicates the request successful
	if((request.readyState == 4) && (request.status == 200)) {
		//get a copy of the XML responsetext
		var response = request.responseText;
		//use the response to update the html page via javascript
		var content = document.getElementById("content_tab");
		content.innerHTML = response;
	}
}
