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.removeEventListener("unload",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.addEventListener("unload", LimpiarClosures); }(); document.LimpiarClosures = LimpiarClosures; function AddEvent(o, e, f){ if(!o) return; // Guard against null objects 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{ if(e == true) return true e.preventDefault(); e.stopPropagation(); } } // JavaScript Document var msjVacio = function(o, m, h, p){ this.init(o, m, h, p); } var p = msjVacio.prototype; //PROPs p.oEle = null; p.sMsj = ''; p.bHTML = false; p.bTagP = false; //METs p.init = function(o, m, h, p){ if(!o) return alert('msjVacio.init: El objeto no existe.'); this.oEle = o; this.sMsj = m; this.oEle.__msjVacio = m; if(h === true){ this.bHTML = true; } if(p === true){ this.bTagP = true; } AddEvent(this.oEle, "focus", function(){ this.onfocus(); }.closure(this)); AddEvent(this.oEle, "blur", function(){ this.onblur(); }.closure(this)); } p.destroy = function(){ EliminarClosures(this); this.oEle = null; } // p.onfocus = function(){ var t = this.oEle.tagName.toLowerCase(); if((t == 'input' || t == 'textarea') && trim(this.oEle.value) == this.sMsj) this.oEle.value = ''; else if(t != 'input' && t != 'textarea' && trim(this.oEle.innerText) == this.sMsj){ if(!this.bTagP){ this.oEle.innerText = ''; } else{ this.oEle.innerHTML = '

'; } } } p.onblur = function(){ var t = this.oEle.tagName.toLowerCase(); if(t == 'input' || t == 'textarea'){ if(trim(this.oEle.value) == ''){ this.oEle.value = this.sMsj; } else{ this.oEle.value = trim(this.oEle.value); } } else{ if(trim(this.oEle.innerText) == ''){ if(!this.bTagP){ this.oEle.innerText = this.sMsj; } else{ this.oEle.innerHTML = '

' + this.sMsj + '

'; } } else if(this.bHTML){ this.oEle.innerHTML = trim(this.oEle.innerHTML); } else{ this.oEle.innerText = trim(this.oEle.innerText); } } } // JavaScript Document //Recibe como parametro un objeto de configuracion, con las siguientes propiedades // o.zIndex = int // o.width = int // o.css = str (nombre del estilo previamente declarado) // o.msg = str (mensaje que se visualizara default) // //Metodos // mostrar(msg) = despliega el tooltip sobre el elemento en foco // ocultar() = oculta el tooltip // mensaje(msg) = para cambiar el mensaje del tooltip ToolTip = function(oConfig){ // var z = 1; var css = ''; var msg = ''; // if(oConfig && oConfig.zIndex) z = oConfig.zIndex-1; if(oConfig && oConfig.css) css = oConfig.css; if(oConfig && oConfig.mensaje) msg = oConfig.mensaje; // this.cont = document.createElement('div'); this.cont.style.position = 'absolute'; this.cont.style.display = 'none'; this.cont.style.zIndex = z; this.cont.unselectable = true; document.body.insertBefore(this.cont, document.body.firstChild); // /*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.src = 'about:blank'; 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.ocultar = function(){ this.cont.style.display = 'none'; if(this.ele) RemEvent(this.ele, 'mousemove', function(e){ this.controlarUbicacion(e); }.closure(this)); } this.mostrar = function(e, msg, css){ // this.mensaje(msg); if(css) this.tip.className = css; // this.cont.style.display = 'block'; //this.iframe.style.width = 0; //this.iframe.style.height = 0; this.tip.style.width = 'auto'; this.tip.style.height = 'auto'; // this.controlarTamanios(); this.controlarUbicacion(e); // if(e && e.srcElement.uniqueID!=this.tip.uniqueID){ this.ele = e.srcElement; RemEvent(this.ele, 'mousemove', function(e){ this.controlarUbicacion(e); }.closure(this)); AddEvent(this.ele, 'mousemove', function(e){ this.controlarUbicacion(e); }.closure(this)); } } this.mensaje = function(msg){ if(msg) this.tip.innerHTML = msg; } this.controlarUbicacion = function(e){ this.cont.style.top = (e.clientY + document.documentElement.scrollTop+ 19) + 'px'; if(e.clientX + this.cont.offsetWidth - 2 + document.documentElement.scrollLeft < document.body.offsetWidth) this.cont.style.left = (e.clientX - 2 + document.documentElement.scrollLeft) + 'px'; else this.cont.style.left = (e.clientX + document.documentElement.scrollLeft + 10 - this.cont.offsetWidth) + 'px'; }.closure(this); 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'; } } // JavaScript Document var ponerToolTip = function(ele, msj){ ele.__msjToolTip = msj; AddEvent(ele, 'mouseover', function(e){ oToolTip.mostrar(e, this.__msjToolTip); }.closure(ele)); AddEvent(ele, 'mouseout', function(){ oToolTip.ocultar(); }); };// JavaScript Document function number_format( number, decimals, dec_point, thousands_sep ) { // Format a number with grouped thousands // // + discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_number_format/ // + version: 806.816 // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfix by: Michael White (http://crestidg.com) // + bugfix by: Benjamin Lupton // + bugfix by: Allan Jensen (http://www.winternet.no) // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + bugfix by: Howard Yeend // * example 1: number_format(1234.5678, 2, '.', ''); // * returns 1: 1234.57 var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals; var d = dec_point == undefined ? "." : dec_point; var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : ""; var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); } // JavaScript Document function bcadd( numA, numB, dec ) { // Suma el segundo número de precisión arbitraria al primer número de precisión arbitraria // // + version: 1.0 // + original by: Marcos Alejandro Gallardo // * example 1: bcadd('1245.123', '1.451'); // * returns 1: 1246 // * example 2: bcadd('156.507', '10', 2); // * returns 2: 166.51 numA = Number(numA); numB = Number(numB); dec = (isNaN(dec))? 0 : dec; return String((numA + numB).toFixed(dec)); } function bcsub( numA, numB, dec ) { // Resta el segundo número de precisión arbitraria al primer número de precisión arbitraria // // + version: 1.0 // + original by: Marcos Alejandro Gallardo // * example 1: bcadd('1245.123', '1.451', 2); // * returns 1: 1246,57 numA = Number(numA); numB = Number(numB); dec = (isNaN(dec))? 0 : dec; return String((numA - numB).toFixed(dec)); } function bcmul( numA, numB, dec ) { // Multiplica el primer número de precisión arbitraria por el segundo número de precisión arbitraria // // + version: 1.0 // + original by: Marcos Alejandro Gallardo numA = Number(numA); numB = Number(numB); dec = (isNaN(dec))? 0 : dec; return String((numA * numB).toFixed(dec)); } function bcdiv( numA, numB, dec ) { // Divide el primer número de precisión arbitraria por el segundo número de precisión arbitraria // // + version: 1.0 // + original by: Marcos Alejandro Gallardo numA = Number(numA); numB = Number(numB); dec = (isNaN(dec))? 0 : dec; return String((numA / numB).toFixed(dec)); } var imgRollOver = function(img, over){ img = (typeof(img)=='object')? img : $(img); if(!img) return; // Guard against null elements img.__over = over; img.__out = img.src; AddEvent(img, 'mouseover', function(){ this.src = this.__over; }.closure(img)); AddEvent(img, 'mouseout', function(){ this.src = this.__out; }.closure(img)); } function hoy(){ var d = new Date; var dia = d.getDate(); if (dia < 10) { dia = '0'+dia; } var mes = d.getMonth() + 1; if (mes < 10) { mes = '0'+mes; } return dia+'/'+mes+'/'+d.getFullYear(); }