// JavaScript Document

var xmlhttp = false;
		
//Check if we are using IE.
try {
	//If the Javascript version is greater than 5.
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	//alert ("You are using Microsoft Internet Explorer.");
} catch (e) {
	//If not, then use the older active x object.
	try {
		//If we are using Internet Explorer.
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		//alert ("You are using Microsoft Internet Explorder");
	} catch (E) {
		//Else we must be using a non-IE browser.
		xmlhttp = false;
	}
}
		
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
{
	xmlhttp = new XMLHttpRequest();
	//alert ("You are not using Microsoft Internet Explorer");
}


function ajax(page, objID, loadObj, getOrPost, str)
{
	// get XMLHttp Object:
	//alert('called');
	var xmlhttp=false; //Clear our fetching variable
	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
		} catch (E) {
			xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
	}
	
	// Process Ajax:
	obj=document.getElementById(objID); // Object where retrieved content will display.
	
	if (loadObj!=='0') {
		obj.innerHTML='<img src="images/loading.gif" height="22" width="16" style="padding-left:20px; margin-top:-6px;" />'; // Start Loading...
	}
	
	//page = '<?=$site_url?>includes/php/ajax.php?';
	var file = page; // Server Page
	
	xmlhttp.open('GET', file+str , true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
	
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status == 200) { //Check if it is ready to recieve data
			var content = xmlhttp.responseText; //The content data which has been retrieved ***
			if( content ){ //Make sure there is something in the content variable
				obj.innerHTML = xmlhttp.responseText; //Change the inner content of your div to the newly retrieved content ****
			}
			else
			{
				obj.innerHTML = '&nbsp;';
			}
		}
	}
	xmlhttp.send(null); //Nullify the XMLHttpRequest
}


