// JavaScript Document

function ajax(u,str,div,win,post) {
	
	var w = win;
	var d = div;

	if (str.length==0) { 

		eval(d+".document.getElementById('"+d+"').innerHTML=xmlHttp.responseText;");

		return;
		
	}

	// if the http_request variable is used globally, competing functions calling makeRequest() may overwrite each other, causing a race condition. Declaring the http_request variable local to the function and passing it to the alertContent() function prevents the race condition.
	
	var xmlHttp;
	xmlHttp=GetXmlHttpObject();
	
	if (xmlHttp==null) {
	
		alert ("Browser does not support HTTP Request");
	
		return;
		
	} 
	
	xmlHttp.onreadystatechange=function(){ stateChanged(xmlHttp,w,d) };
	
	if( post ) {

		xmlHttp.open("POST",u,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		xmlHttp.send(str);

	} else {
	
		var url=u+"?"+str;
		xmlHttp.open("GET",url,true); 
		xmlHttp.send(null);
		
	}
	
} 

function stateChanged(xmlHttp,w,d) {

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	
		eval(w+".document.getElementById('"+d+"').innerHTML=xmlHttp.responseText;");
		
	} 
	
} 

function GetXmlHttpObject() { 

	var objXMLHttp=null;
	
	if (window.XMLHttpRequest) {
	
		objXMLHttp=new XMLHttpRequest();
		
	} else if (window.ActiveXObject) {
		
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	}
	
	return objXMLHttp;
	
} 
