var target		=	"";
var holding	=	"";
var xmlHttp	=	null;

/****************************************************************************************
** GetXmlHttpObject																															**
** FIRST FIND OUT WHICH VERSION OF XMLREQUEST WE ARE USING AND SET THAT TO VARIABLE xmlHttp	**
*****************************************************************************************/
function GetXmlHttpObject()
{
	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;
}

/****************************************************************************************
** GetAJAXContentNow - USED TO SET UP AN AJAX STYLE TRANSACTION													**
*****************************************************************************************
** theurl 		- The URL of the page you wish to get the data from															**
** atarget		- The ID of the div where the results will be loaded into														**
** aholding	- The holding content for that will replace the target while it's loading									**
*****************************************************************************************/
function GetAJAXContentNow(theurl, atarget, aholding){
	target	=	atarget;
	holding	=	aholding;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp == null){
		//alert ("No AJAX!");
		document.location.href = theurl ;
	}else{
		xmlHttp.onreadystatechange=stateChanged;
		//alert(target +" " +  holding);
		xmlHttp.open("GET",theurl,true);
		//document.getElementById("results").innerHTML=xmlHttp.responseText;
		xmlHttp.send(null); 
	}
}

/****************************************************************************************
** stateChanged - CHECKS THE READYSTATE AND IF THE DATE IS SLILL LOADING, DISPLAYS holding			**
*****************************************************************************************/
function stateChanged() { 
	if (xmlHttp.readyState==4){ 
		document.getElementById(target).innerHTML=xmlHttp.responseText;
	}
	if ( xmlHttp.readyState==1){ 
		if (holding != "") document.getElementById(target).innerHTML=holding;
	}
	//alert(xmlHttp.readyState);
}
/****************************************************************************************
** GetAJAXContent - QUEUE UP A AJAX REQUEST SO THAT ONE FINISHES FIRST                                			**
*****************************************************************************************/
function GetAJAXContent(theurl, atarget, aholding) { 
	if (xmlHttp){
		if (xmlHttp.readyState==4){ 
			GetAJAXContentNow(theurl, atarget, aholding);
		}else{
			setTimeout("GetAJAXContent('"+theurl+"','"+atarget+"','"+aholding+"');",1000)
		}
	}else{
		GetAJAXContentNow(theurl, atarget, aholding);
	}
}


