function objetus(file) {
    xmlhttp=false;
    this.AjaxFailedAlert = "Su navegador no soporta las funciónalidades de este sitio";
    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 HayNotasAjax(_pagina,valorget,valorpost,capa){
    ajax=objetus(_pagina);
    if(valorpost!=""){
        ajax.open("POST", _pagina,true);
    } else {
        ajax.open("GET", _pagina+"?"+valorget+"&tiempo="+new Date().getTime(),true);
    }
    ajax.onreadystatechange=function() {
        if (ajax.readyState==1){
            document.getElementById(capa).innerHTML = "<img src='../Gifs/radar.gif' align='center'> Un momento por favor...";
        }
        if (ajax.readyState==4) {
            if (ajax.status==200) {
			    document.getElementById(capa).innerHTML = ajax.responseText;
			}
            else if(ajax.status==404) {
                capa.innerHTML = "La direccion no existe";
            }
            else {
                capa.innerHTML = "Error: ".ajax.status;
            }
        }
    }
    if(valorpost!=""){
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.send(valorpost+"&tiempo="+new Date().getTime());
    } else {
        ajax.send(null);
    }
} 
function Ajax(_pagina,valorget,valorpost,capa,form,pagsig){
    ajax=objetus(_pagina);
    if(valorpost!=""){
        ajax.open("POST", _pagina,true);
    } else {
        ajax.open("GET", _pagina+"?"+valorget+"&tiempo="+new Date().getTime(),true);
    }
    ajax.onreadystatechange=function() {
        if (ajax.readyState==1){
            document.getElementById(capa).innerHTML = "<img src='loading.gif' align='center'> Un momento por favor...";
        }
        if (ajax.readyState==4) {
            if (ajax.status==200) {
			    document.getElementById(capa).innerHTML = ajax.responseText;
				if (ajax.responseText.length<=1 ) {
				   form.action=pagsig;
                   form.submit();
				}				
			}
            else if(ajax.status==404) {
                capa.innerHTML = "La direccion no existe";
            }
            else {
                capa.innerHTML = "Error: ".ajax.status;
            }
        }
    }
    if(valorpost!=""){
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.send(valorpost+"&tiempo="+new Date().getTime());
    } else {
        ajax.send(null);
    }
} 

