// Run Ajax request
// Return as XmlHttpObject object
function showResponseData(url, params, div, isPOST, showLoading) {

	var xmlHttp = null;
	
	// Create the xmlHttp object to use in the request 
	xmlHttp = GetXmlHttpObject();

	// Send the xmlHttp get to the specified url
	xmlHttp.onreadystatechange = function() {
		// ReadyState of 4 or 'complete' represents that data has been returned 
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') {
			if (xmlHttp.status == 200) {
				// Gather the results from the callback 
				document.getElementById(div).innerHTML = xmlHttp.responseText;
			}
		}else{
			if(showLoading){
				// Display the loading image
				document.getElementById(div).innerHTML = "<p align='center'><img src='/images/ajax-loader.gif' width='126' height='22' /></p>";	
			}
		}
	};
	
	if(isPOST){
		// Send params in POST method
		xmlHttp.open('POST', url, true);
		
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		
		xmlHttp.send(params);
		
	}else{
		// Send params in GET method
		xmlHttp.open('GET', url+'?'+params, true);
		xmlHttp.send(null);
	}
	
	// Return xmlHttp object
	return xmlHttp;
}

// Return as XmlHttpObject object
function GetXmlHttpObject(){ 
	var objXmlHttp=null;
	try{
		objXmlHttp = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){ 
		alert('object could not be created. Verify that active scripting and activeX controls are enabled'); 
	}
	return objXmlHttp; 
}
