var ajaxReq
function requestAjax(url, callback, loadingElement, loadingText){
	var containerid
	var randItem =  '&sid=' + new Date().getTime(); 	//Randomize the url to prevent caching
	url += randItem
	if (document.getElementById(loadingElement)!= undefined) {
		document.getElementById(loadingElement).innerHTML = loadingText;
	}

	ajaxReq = false
		if (window.XMLHttpRequest){ // if Mozilla, Safari etc
			ajaxReq = new XMLHttpRequest()
		}else if (window.ActiveXObject){ // if IE
			try {
				ajaxReq = new ActiveXObject("Msxml2.XMLHTTP")
			} 
			catch (e){
				try{
					ajaxReq = new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch (e){
					alert("You are running a unsupported browser");
				}
			}
		}else{
			return false
		}
	ajaxReq.onreadystatechange=callback;
	ajaxReq.open('GET', url, true)
	ajaxReq.send(null)
}

function postAjax(url, params, callback, loadingElement, loadingText){
	var containerid
	var randItem =  '&sid=' + new Date().getTime(); 	//Randomize the url to prevent caching
	params += randItem
	if (document.getElementById(loadingElement)!= undefined) {document.getElementById(loadingElement).innerHTML = loadingText;}

	ajaxReq = ajaxObj2()
	if (!ajaxReq) {return false}
	ajaxReq.open("POST", url, true);
	
	//Send the proper header information along with the request
	ajaxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxReq.setRequestHeader("Content-length", params.length);
	ajaxReq.setRequestHeader("Connection", "close");
	
	ajaxReq.onreadystatechange=callback;
	ajaxReq.send(params);

}

function ajaxObj2() {
	var ajaxReq = false

	if (window.XMLHttpRequest){ // if Mozilla, Safari etc
		ajaxReq = new XMLHttpRequest()
	}else if (window.ActiveXObject){ // if IE
		try {
			ajaxReq = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
				ajaxReq = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){
				alert("You are running a unsupported browser");
			}
		}
	}else{
		return false
	}
	return ajaxReq
}
