var xmlhttp;
var xmlhttpObjs=new Array();

function objAjax(onResponse) {
	this.xmlhttp=createAjax();
//	this.xmlhttp.async = true; 
	this.onResponse=onResponse;
//	this.xmlhttp.parent=this;
	this.owndata=[];
	xmlhttpObjs.push(this);
	xmlhttp=this.xmlhttp;
}

objAjax.prototype.sendRequest = function(url)    // Define Method
{
	this.xmlhttp.open('get', url);
	this.xmlhttp.onreadystatechange = this.handleResponse;
	this.xmlhttp.send(null);
}

objAjax.prototype.handleResponse = function () {
	if (typeof(this.readyState)=='undefined') 
		var obj=xmlhttp;
	else
		var obj=this;

	if(obj.readyState == 4)
	{
		
		var parent=null;
		for (var i=0;i<xmlhttpObjs.length;i++) {
			if (xmlhttpObjs[i].xmlhttp==obj) {
				parent=xmlhttpObjs[i];
				break;
			}
		}

		if (parent)
			parent.onResponse(obj.status,(obj.status == 200)?obj.responseText:"");
	}
}

function createAjax() {
	var xmlhttp
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	 xmlhttp=false
	@end @*/

	if (!xmlhttp && typeof createXMLHttpRequest!='undefined') {
		try {
			xmlhttp = createXMLHttpRequest();
		} catch (e) {
			xmlhttp=false
		}
	}

	return xmlhttp;
}

function createXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('couldn\'t create xmlhttp object');
	 }
	}
	return(xmlhttplocal);
}

function sndReq(xmlhttp,url) {	
	xmlhttp.open('get', url);
	xmlhttp.onreadystatechange=handleResponse;
	xmlhttp.send(null);
}

function handleResponse(obj) {
	alert(this.readyState);
	if(obj.readyState == 4){
		alert(obj);
		obj.onResponse(obj.status,(obj.status == 200)?obj.responseText:"");
	}
}
