var _xmlHttp;
var _userfunction;

function iajax(psurl) {
	this.requestURL=psurl;
	this.is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
	this.is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
	this.is_opera = ((navigator.userAgent.indexOf("Opera 6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
}


iajax.prototype.call=function(fnptr,param) {
	_userfunction = fnptr;

	var objXmlHttp = null;
	var handler = this.cb;

	if (this.is_ie) {
		var strObjName = (this.is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';

		try {
			objXmlHttp = new ActiveXObject(strObjName);
			objXmlHttp.onreadystatechange = handler;
		} catch(e) {
			//Error por la configuración del navegador.
			alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled');
			return;
		}
	} else if (this.is_opera) {
		alert('Opera detected. The page may not behave as expected.');
		return;
	} else {
		// Resto (NS, FF, Mozilla, Safari)
		objXmlHttp = new XMLHttpRequest();
		objXmlHttp.onload = handler;
		objXmlHttp.onerror = handler;
	}

	_xmlHttp = objXmlHttp;

	var url = this.requestURL + param;
	objXmlHttp.open('GET', url, true);
	objXmlHttp.send(null);
}


iajax.prototype.cb=function() {
	if (_xmlHttp.readyState == 4 || _xmlHttp.readyState == 'complete') {
		var str = _xmlHttp.responseText;
		_userfunction(str);
		//_xmlHttp = null;
	}
}

