function getXMLHttpObject() {
	var ret = false;
    if (window.XMLHttpRequest) {
        ret = new XMLHttpRequest ();
		if(ret.readyState == null){
				ret.readyState = 1;
				ret.addEventListener('load', function(){
					ret.readyState = 4;
					if(typeof(ret.onreadystatechange)=='function')
						ret.onreadystatechange();
				}, false);
		}		
    } else if (window.ActiveXObject) {     
        try { ret = new ActiveXObject ("Msxml2.XMLHTTP"); }
        catch (e)
        { try { ret = new ActiveXObject ("Microsoft.XMLHTTP"); }
          catch (e) { }
        }
    } 
    return ret;
}
	
function jxcll(url, onComplete, onError)
{
	var xmlHttp = getXMLHttpObject();
	if (xmlHttp) {		
		xmlHttp.onreadystatechange = function ()
		{		
			if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") {
				var res_status = 0;
				try {res_status = xmlHttp.status;} catch(e){};				
				if ((res_status >= 200) && (res_status < 300)) {					
					if(onComplete) onComplete(xmlHttp.responseText);
				} else {					
					if(onError) onError(xmlHttp.responseText);
				}
			}
		}
		// Evitar cache en IE
		// url += (url.indexOf("?") == -1) ? '?' + Math.random() : ',' + Math.random();
		xmlHttp.open ('GET', url, true);
		xmlHttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		xmlHttp.send (null);
	}
}

function jxcllPost(url, parms, onComplete, onError )
{
	var xmlHttp = getXMLHttpObject();
	if (xmlHttp) {		
		xmlHttp.onreadystatechange = function ()
		{		
			if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") {
				var res_status = 0;
				try {res_status = xmlHttp.status;} catch(e){};
				if ((res_status >= 200) && (res_status < 300)) {
					if(onComplete) onComplete(xmlHttp.responseText);
				} else {
					if(onError) onError(xmlHttp.responseText); 
				}
			}
		}
		xmlHttp.open ('POST', url, true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		var qstr = null;
		for (var parm in parms) {
			if (qstr) 
				qstr += '&' + parm + '=' + escape(parms[parm]); // encodeURIComponent(parms[parm]);
			else
				qstr = parm + '=' + escape(parms[parm]); // encodeURIComponent(parms[parm]);	
		}		
		xmlHttp.send (qstr);
	}
}

