ajax=new Object();
ajax.ENABLED_sys=false;
ajax.ALERT_C=false;
ajax.startld=function () {
setTimeout("ajax.various.display('loadingp',1);",50);
setTimeout("ajax.ENABLED_sys=true;ajax.loadp(\"index\");",500);
};
ajax.CURR_PAGE=null;CURR_bURL=null;
ajax.CURR_REQ=null;
ajax.engine=function (override) {
if (!override) override="text/plain";
if (!ajax.ENABLED_sys) return; /* Si no esta activado an el siste (carga inicial) */
var http_request = false;
var sErr = "";
alert("Ajax()");
if (window.XMLHttpRequest) { /* Casi todos */
try {
http_request = new XMLHttpRequest();
if (override!="application/nooverride" && http_request.overrideMimeType)
http_request.overrideMimeType(override);
} catch (e) {sErr = e;};
} else if (window.ActiveXObject) { /* MSIE < 7 */
var sVers = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0",
"Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0",
"Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP",
"Microsoft.XMLHTTP"];
for (var cii=0;cii< sVers.length;cii++)
try {
http_request = new ActiveXObject(sVers[cii]);
sErr="";
break;
} catch (e) {sErr = e;};
}
if (!http_request) {
alert('Abandonando. Error en XMLHttpRequest.\n'+sErr);
return false;
}
return http_request;
};
///////////////////////////////Funciones varias/////////////////
ajax.various=new Object();
ajax.various.display=function (cap,set) {
if (set==true) {
try {
document.getElementById(cap).style.display = "block";
} catch(e) {
return false;
};
} else {
try {
document.getElementById(cap).style.display = "none";
} catch(e) {
return false;
};
}
};
ajax.various.textlay=function (msg,cap){
if (!msg) msg=" ";
if (!cap) cap='visual';
try {
document.getElementById(cap).innerHTML=msg;
} catch(e) {
return false;
};
};
ajax.various.visib=function (cap,set) {
if (set==1) {
try {
document.getElementById(cap).style.visibility = "visible";
} catch(e) {
return false;
};
} else {
try {
document.getElementById(cap).style.visibility = "hidden";
} catch(e) {
return false;
};
}
};
////////////////////////////////////////////////////////////////
ajax.PHP="";
ajax.loadp=function (php,values,cap,bURL,notab) {
if (!bURL) bURL="/loadphp.php/";
if (!cap) cap="visual";
if (!values) values="";
if (!php) php="index";
if (!document.getElementById(cap))
{alert("Capa inexistente ("+cap+")."); return;}
_ajaxO=ajax.engine();
if (!_ajaxO) return;
_values_send=values;
_URL_=bURL+php;
_ajaxO.open("POST",_URL_,true);
_ajaxO.onreadystatechange=
function() {
if (_ajaxO.readyState==1)
ajax.various.display("loadingp",1);
else if(_ajaxO.readyState==4) {
if(_ajaxO.status>=200 && _ajaxO.status<=210) {
if (ajax.ALERT_C) alert(_ajaxO.responseText);
try {
while(document.getElementById(cap).firstChild)
document.getElementById(cap).removeChild(document.getElementById(cap).firstChild);
document.getElementById(cap).innerHTML=_ajaxO.responseText;
ajax.various.display("loadingp",0);
} catch (e) {
ajax.various.textlay("Error inesperado procesando documento.
Puede deberse a un BUG de su navegador.
"+e+"");
return false;
}
} else
ajax.various.textlay("Resultado inesperado.
Error durante la peticion. El servidor devolvio "+_ajaxO.statusText+".");
return false;
}
};
_ajaxO.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
if (_values_send=="")
_values_send="ini=ini";
_ajaxO.send(_values_send);
if (cap=="visual") {
ajax.CURR_bURL=bURL;
ajax.CURR_PAGE=php;
ajax.CURR_REQ=values;
/* if (!notab) {
ajax.PHP=php;
setTimeout('ajax.loadp(PHP__,"js=yes","asubmenu","loadmenut.phpsec=",true);',100);
}*/
}
return;
};
function loaddata(xml,get,args) {
}
ajax.various.popup=function (url,retur,width,height,scroll) {
if (!url) url="about:blank";
if (!width) width="510";
if (!height) height="510";
if (!scroll) scroll="no";
var w=window.open(url,'gpl_popup','status=no,resizable=no,toolbar=no,directories=no,menubar=no,scrollbars='+scroll+',width='+width+',height='+height);
if (retur) return w;
};
ajax.form=function (formID,target,layer,extravals) {
/* Si no existe el elemento, o se llam sin parmetros, salir */
if (!formID && !document.getElementById(formID)) return;
if (!target) target=formID;
if (!extravals) extravals="ini=ini";
/* Consigue el elemento */
var form=document.getElementById(formID);
/* Bloquea el formulario */
lockForm(formID,true);
/* Inicializar variables */
var args=encodeURIComponent(extravals);
var g=function(form,el) {
var i=0,j=0,ff='';
j=form.getElementsByTagName(el);
for (i=0;;i++) {
if (j[i]) {
if ((j[i].type=="radio" || j[i].type=="checkbox") && j[i].checked==false) {continue;}
if (j[i].type=="submit" || j[i].type=="reset" || j[i].type=="button") {continue;}
ff+="&"+j[i].name+"="+encodeURIComponent(j[i].value);
} else break;
}
return ff;
};
args+=g(form,"input");
args+=g(form,"select");
args+=g(form,"textarea");
ajax.loadp(target,args,layer);
return;
};
function fmd5() {
ajax.form("makemd5");
}
function send_upart() {
ajax.orm("writeartf");
}