function objetus(){
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E){
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined'){
		xmlhttp = new XMLHttpRequest();
	}
		return xmlhttp;
}

/*Funcions ajax*/
function requestGET(url, query, req) {
	myRand=parseInt(Math.random()*99999999);
	req.open("GET",url+'?'+query+'&rand='+myRand,true);
	req.send(null);
}
function requestPOST(url, query, req) {
	req.open("POST", url,true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	req.send(query);
}
function doCallback(callback,item) {
	if(item!=""){
		eval(callback + '(item)');
	}else{
		eval(callback + '()');
	}
}
function doAjax(url,query,callback,reqtype,getxml) {
	// crea la instancia del objeto XMLHTTPRequest
	var myreq = objetus();
	myreq.onreadystatechange = function() {
		if(myreq.readyState == 4) {
			if(myreq.status == 200) {
				var item = myreq.responseText;
				if(getxml==1) {
					item = myreq.responseXML;
				}
				if(callback!=""){
					doCallback(callback, item);
				}
			}
		}
	}
	if(reqtype=='post'){
		requestPOST(url,query,myreq);
	}else{
		requestGET(url,query,myreq);
	}
}