var ajax=new Array();
function objetus(file) {
    xmlhttp=false;
    this.AjaxFailedAlert='Su navegador no soporta las funciónalidades de este sitio y podria experimentarlo de forma diferente a la que fue pensada.Por favor habilite javascript en su navegador para verlo normalmente.\n';
    this.requestFile = file;
    this.encodeURIString = true;
    this.execute = false;
    if (window.XMLHttpRequest) { 
        this.xmlhttp = new XMLHttpRequest();
        if (this.xmlhttp.overrideMimeType) {
            this.xmlhttp.overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) { // IE
        try {
            this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e) {
            try {
                this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                this.xmlhttp = null;
            }
        }
        if (!this.xmlhttp && typeof XMLHttpRequest!='undefined') {
            this.xmlhttp = new XMLHttpRequest();
            if (!this.xmlhttp){
                this.failed = true; 
            }
        } 
    }
    return this.xmlhttp ;
}
function recibeid(pPagina,pValorGet,pValorPost,pCapa,pPosicion,pValorCarga){
	if(pValorCarga=="")
		pValorCarga=1;
    ajax[pPosicion]=objetus(pPagina);
    if(pValorPost!=""){
        ajax[pPosicion].open("POST", pPagina+"?"+pValorGet+"&tiempo="+new Date().getTime(),true);
    } else {
        ajax[pPosicion].open("GET", pPagina+"?"+pValorGet+"&tiempo="+new Date().getTime(),true);
    }
    ajax[pPosicion].onreadystatechange=function() {
        if (ajax[pPosicion].readyState==1){
            document.getElementById(pCapa).innerHTML = "<div style='width:100%;padding:10px;text-align=center;'><img src='images/progress.gif' align='center'> Loading...</div>";
			//document.getElementById("layForm").innerHTML="<div class='capaOculta'>qqqqqqqqqqqqqqqqq</div>";
        }
        if (ajax[pPosicion].readyState==4) {
            if(ajax[pPosicion].status==200)
            {	if(pValorCarga==1)
				{	document.getElementById(pCapa).innerHTML = ajax[pPosicion].responseText;
				}
				else
				{	if((parseInt(ajax[pPosicion].responseText.indexOf('php'))>0)||(parseInt(ajax[pPosicion].responseText.indexOf('htm'))>0)||(parseInt(ajax[pPosicion].responseText.indexOf('html'))>0))
						document.location.href=ajax[pPosicion].responseText;
					else
						document.getElementById(pCapa).innerHTML = ajax[pPosicion].responseText;
				}
			}
            else if(ajax[pPosicion].status==404)
            {
                pCapa.innerHTML = "La direccion no existe";
            }
            else
            {
                pCapa.innerHTML = "Error: ".ajax[pPosicion].status;
            }
        }
    }
    if(pValorPost!=""){
        ajax[pPosicion].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax[pPosicion].send(pValorPost);
    } else {
        ajax[pPosicion].send(null);
    }
}
function recibeid2(pPagina,pValorGet,pValorPost,pCapa,pPosicion,pValorCarga,pLinkVolver){
	if(pValorCarga=="")
		pValorCarga=1;
    ajax[pPosicion]=objetus(pPagina);
    if(pValorPost!=""){
        ajax[pPosicion].open("POST", pPagina+"?"+pValorGet+"&tiempo="+new Date().getTime(),true);
    } else {
        ajax[pPosicion].open("GET", pPagina+"?"+pValorGet+"&tiempo="+new Date().getTime(),true);
    }
    ajax[pPosicion].onreadystatechange=function() {
        if (ajax[pPosicion].readyState==1){
            document.getElementById(pCapa).innerHTML = "<div style='width:100%;padding:10px;text-align=center;'><img src='../images/loading.gif' align='center'> Cargando...</div>";
        }
        if (ajax[pPosicion].readyState==4) {
            if(ajax[pPosicion].status==200)
            {	if(pValorCarga==1)
					document.getElementById(pCapa).innerHTML = ajax[pPosicion].responseText;
				else
				{	if(ajax[pPosicion].responseText=="ERROR")
						document.location.href=pLinkVolver;
					else
						document.getElementById(pCapa).innerHTML = ajax[pPosicion].responseText;
				}
			}
            else if(ajax[pPosicion].status==404)
            {
                pCapa.innerHTML = "La direccion no existe";
            }
            else
            {
                pCapa.innerHTML = "Error: ".ajax[pPosicion].status;
            }
        }
    }
    if(pValorPost!=""){
        ajax[pPosicion].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax[pPosicion].send(pValorPost);
    } else {
        ajax[pPosicion].send(null);
    }
}