function $(i){ return document.getElementById(i); } function ltrim(str){ return str.replace(/^(\s+)/g, ''); } function rtrim(str){ return str.replace(/(\s+)$/g, ''); } function trim(str){ return ltrim(rtrim(str)); } var Navegador = function(){ this.esIE = false;// Internet Explorer this.esIE6 = false; this.esIE7 = false; this.esIE8 = false; this.esFf = false;// Mozilla this.esOp = false;// Opera this.esNs = false;// Netscape if(window.navigator.userAgent.search(RegExp("MSIE","im"))!=-1){ this.esIE = true; if(window.navigator.userAgent.search(RegExp("MSIE 8","im"))!=-1) this.esIE8 = true; else if(window.navigator.userAgent.search(RegExp("MSIE 7","im"))!=-1) this.esIE7 = true; else if(window.navigator.userAgent.search(RegExp("MSIE 6","im"))!=-1) this.esIE6 = true; } else if(window.navigator.userAgent.search(RegExp("Firefox","im"))!=-1) this.esFf = true; else if(window.navigator.userAgent.search(RegExp("Opera","im"))!=-1) this.esOp = true; else if(window.navigator.userAgent.search(RegExp("Safari","im"))!=-1) this.esSa = true; else if(window.navigator.userAgent.search(RegExp("Netscape","im"))!=-1) this.esNs = true; }; var Nav = new Navegador(); Function.prototype.closure = function(obj){ // Init object storage. if (!window.__objs){ window.__objs = []; window.__funs = []; } // For symmetry and clarity. var fun = this; // Make sure the object has an id and is stored in the object store. var objId = obj.__objId; if (!objId) __objs[objId = obj.__objId = __objs.length] = obj; // Make sure the function has an id and is stored in the function store. var funId = fun.__funId; if (!funId) __funs[funId = fun.__funId = __funs.length] = fun; // Init closure storage. if (!obj.__closures) obj.__closures = []; // See if we previously created a closure for this object/function pair. var closure = obj.__closures[funId]; if (closure) return closure; // Clear references to keep them out of the closure scope. obj = null; fun = null; // Create the closure, store in cache and return result. var o = __objs[objId].__closures[funId] = function (){ if(!!__funs[funId] && !!__objs[objId]) return __funs[funId].apply(__objs[objId], arguments); else return false; }; o.__funId = funId; return o; }; var EliminarClosures = function(o){ var i = 0; if(o){ if(o.__objId){ for(i in o.__closures){ delete(window.__funs[i]); delete(o.__closures[i]); } delete(window.__objs[o.__objId]); /*delete(o.__closures); delete(o.__objId);*/ o.__closures = null; o.__objId = null; } } i = null; } var LimpiarClosures = function(){ if(!!Nav && !Nav.esIE) window.addEventListener('unload', LimpiarClosures, false); else window.detachEvent("onunload",LimpiarClosures); if(window.__objs){ for(i in window.__objs) EliminarClosures(window.__objs[i]); } window.__objs = []; window.__funs = []; }; var Limpiar = function(){ if(!!Nav && !Nav.esIE) window.addEventListener('unload', LimpiarClosures, false); else window.attachEvent("onunload", LimpiarClosures); }(); document.LimpiarClosures = LimpiarClosures; function AddEvent(o, e, f){ if(Nav.esIE) o.attachEvent('on'+e, f); else o.addEventListener(e, f, ((Nav.esOp)? false : true)); }; function RemEvent(o, e, f){ if(Nav.esIE) o.detachEvent('on'+e, f); else o.removeEventListener(e, f, ((Nav.esOp)? false : true)); }; function FireEvent(o, e){ var evt = null; if(Nav.esIE) o.fireEvent('on'+e); else{ if(e=='click' || e=='dblclick' || e=='mousedown' || e=='mousemove' || e=='mouseout' || e=='mouseover' || e=='mouseup'){ evt = document.createEvent("MouseEvents"); evt.initMouseEvent(e, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); } else if(e=='keydown' || e == 'keypress' || e == 'keyup'){ evt = document.createEvent("KeyboardEvent"); evt.initKeyEvent(e, true, true, null, false, false, false, false, 9, 0); } else{ evt = document.createEvent("Event"); evt.initEvent(e, true, false); } o.dispatchEvent(evt); } } function StopEvent(e){ if(Nav.esIE){ e.returnValue = false; e.cancelBubble = true; } else{ e.preventDefault(); e.stopPropagation(); } } // JavaScript Document Request = function(oListener, metodo){ this.pedido = new crearXHR(); this.reportar = true; this.respuestaXML = null; this.respuestaHTML = null; this.archivo=null; this.valores=null; this.listener=oListener; // if(!metodo) this.metodo = 'POST'; else this.metodo = metodo; } Request.prototype.pedir = function(a, v, m){ //inicializamos if(!!a) this.archivo = a; if(!!v) this.valores = v; if(!!m) this.metodo = m; // this.respuestaXML = null; this.respuestaHTML = null; // this.cancelar(this.pedido); // this.pedido.onreadystatechange = this.procesar.closure(this); // this.pedido.open(this.metodo, this.archivo, true); // if(this.valores){ this.valores = this.valores.puntualChars(); this.pedido.send(this.valores); } else this.pedido.send(); } Request.prototype.procesar = function(){ var termino = false; if(this.pedido && this.pedido.readyState == 4){ if(this.pedido.status == 200){ if(this.pedido.responseXML) this.respuestaXML = this.pedido.responseXML.documentElement; this.respuestaHTML = this.pedido.responseText; termino = true; } else if((this.pedido.status >= 12029 && this.pedido.status <= 12031) || // this.pedido.status == 12152 || this.pedido.status == 12159){ //cancelado por el servidor this.pedir(); } else if(this.reportar){ ERROR.reportar(" Error en clase Request.\nESTADO: "+this.pedido.status+" "+this.pedido.statusText+"\nARCHIVO: "+this.archivo+"\nMETODO: "+this.metodo); termino = true; } if(termino == true){ this.cancelar(); if(this.listener && this.listener.onRequestLoad) this.listener.onRequestLoad(); else if(typeof(this.listener)=='function') this.listener(); } } } Request.prototype.cancelar = function(){ cancelarPedido(this.pedido); } // String.prototype.puntualChars = function(){ var chrs = new Array({'chr':'€', 'ent':'€'}), i, str = this.toString(); for(i = 0; i < chrs.length; i++){ str = str.replace(chrs[i]['chr'], chrs[i]['ent']); } return str; } String.prototype.unPuntualChars = function(){ var chrs = new Array({'chr':'€', 'ent':'€'}), i, str = this.toString(); for(i = 0; i < chrs.length; i++){ str = str.replace(chrs[i]['ent'], chrs[i]['chr']); } return str; } /* FUNCION DE CREACION DE XMLHttpRequest */ crearXHR = function(){ var r = null if (window.XMLHttpRequest) r = new XMLHttpRequest() else if(window.ActiveXObject) { var msp = new Array('Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP') for(var i = 0; i < msp.length; i++){ try { r = new ActiveXObject(msp[i]) } catch (e){} } } return r } /* FUNCION DE DETENCION DE XMLHttpRequest */ cancelarPedido = function(reqXHR){ if(reqXHR!=null){ reqXHR.onreadystatechange=new Function()//una funcion vacia... reqXHR.abort() } } // ReportarError = function(f, m){ this.archivo = (!!f)? f:'xmlHttpRequest/reportarError.php'; this.metodo = (!!m)? m:'POST'; this.req = new Request(); this.req.reportar = false; this.alerta = true; this.reportar = function(msj){ this.req.pedir(this.archivo, msj, this.metodo); if(this.alerta) alert("Ha ocurrido un error.\nLos administradores del sistema ya han sido notificados del mismo.\nSi el error continua pongase en contacto con los mismos."+msj); return false; }; } ERROR = new ReportarError(); // JavaScript Document ToolTip = function(oConfig){ // var z = 1; var css = ''; var msg = ''; var cont = document.body; // if(oConfig && oConfig.zIndex) z = oConfig.zIndex-1; if(oConfig && oConfig.css) css = oConfig.css; if(oConfig && oConfig.mensaje) msg = oConfig.mensaje; if(oConfig && oConfig.cont) cont = oConfig.cont; var oT = this; // this.cont = document.createElement('div'); this.cont.style.position = 'absolute'; this.cont.style.visibility = 'hidden'; this.cont.style.zIndex = z; this.cont.unselectable = true; cont.appendChild(this.cont); // this.iframe = document.createElement('iframe'); this.iframe.style.position = 'absolute'; this.iframe.style.zIndex = z; this.iframe.style.width = 0; this.iframe.border = 0; this.iframe.scrolling = 'no'; this.iframe.frameBorder = 0; this.iframe.disabled = true; this.cont.appendChild(this.iframe); // this.tip = document.createElement('div'); this.tip.style.position = 'relative'; this.tip.style.zIndex = z + 1; this.tip.style.width = 0; if(css) this.tip.className = css; if(msg) this.tip.innerHTML = msg; this.tip.unselectable = true; this.cont.appendChild(this.tip); this.iframe.style.left = 0+"px"; this.tip.style.left = 0+"px"; // this.ocultar = function(){ this.cont.style.visibility = 'hidden'; if(this.ele){ RemEvent(this.ele,"mousemove",this.controlarUbicacion.closure(this)); } } this.mostrar = function(event,msg, css){ // this.mensaje(msg); if(css) this.tip.className = css; // this.iframe.style.width = 0; this.iframe.style.height = 0; this.tip.style.width = 'auto'; this.tip.style.height = 'auto'; // //this.controlarTamanios(); //this.controlarUbicacion(); if(Nav.esIE){ this.ele = window.event.srcElement; } else{ this.ele = event.target; } RemEvent(this.ele,"mousemove",this.controlarUbicacion.closure(this)); AddEvent(this.ele,"mousemove",this.controlarUbicacion.closure(this)); if(Nav.esIE){ window.event.cancelBubble = true; window.event.returnValue = false; } else event.preventDefault(); this.cont.style.visibility = "visible"; } this.mensaje = function(msg){ if(msg) this.tip.innerHTML = msg; } this.controlarUbicacion = function(event){ if(Nav.esIE){ if(event){ this.cont.style.top = (event.clientY + document.documentElement.scrollTop+ 19) + 'px'; if(event.clientX + this.cont.offsetWidth - 2 + document.documentElement.scrollLeft < document.body.offsetWidth){ this.cont.style.left = (event.clientX - 2 + document.documentElement.scrollLeft) + 'px'; } else{ this.cont.style.left = (event.clientX + document.documentElement.scrollLeft + 10 - this.cont.offsetWidth) + 'px'; } window.event.cancelBubble = true; window.event.returnValue = false; } } else{ if(event){ this.cont.style.top = (event.clientY + window.scrollY+ 19) + 'px'; if(event.clientX + this.cont.offsetWidth - 2 + window.scrollX < document.body.offsetWidth){ this.cont.style.left = (event.clientX - 2 + window.scrollX) + 'px'; } else{ this.cont.style.left = (event.clientX + window.scrollX + 10 - this.cont.offsetWidth) + 'px'; } event.preventDefault(); } } } this.controlarTamanios = function(){ // this.iframe.style.width = (this.tip.offsetWidth + 2) + 'px'; this.iframe.style.height = (this.tip.offsetHeight + 2) + 'px'; this.tip.style.width = (this.tip.offsetWidth - 4) + 'px'; this.tip.style.height = (this.tip.offsetHeight - 4) + 'px'; } //this.cont.attachEvent('onmouseover', this.ocultar.closure(this)); }