function Navegador(){ this.esIE = false;// Internet Explorer this.esIE6 = false; this.esIE7 = false; this.esFf = this.esMz = 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("6","im"))!=-1) this.esIE6 = true; else if(window.navigator.userAgent.search(RegExp("7","im"))!=-1) this.esIE7 = true; } else if(window.navigator.userAgent.search(RegExp("Firefox","im"))!=-1) this.esFf = this.esMz = 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(); // JavaScript Document 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; }; //window.__objs[obj.__objId] = null; 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.esMz) 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 = []; }; Limpiar = function(){ if(!!Nav && Nav.esMz) window.addEventListener('unload', LimpiarClosures, false); else window.attachEvent("onunload", LimpiarClosures); }(); document.LimpiarClosures = LimpiarClosures; AddEvent = function(o, e, f){ if(Nav.esIE) o.attachEvent('on'+e, f); else o.addEventListener(e, f, ((Nav.esOp)? false : true)); }; RemEvent = function(o, e, f){ if(Nav.esIE) o.detachEvent('on'+e, f); else o.removeEventListener(e, f, ((Nav.esOp)? false : true)); }; FireEvent = function(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); } } StopEvent = function(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; 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.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); } /* 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 trim = function(str){ if(str && typeof(str)=='string'){ var i = 0, x = (l = str.length) - 1; while(i0 && str.charAt(x)==" ") x--; str = str.substring(i, x + 1); } return str; } /*//////////// File: Tween.js Creation Date: January 20 2006 Author: Philippe Maegerman Email: mx2004-at-pandora.be Website: http://jsTween.blogspot.com Download: http://cfpim.coffeeflower.com/jsTween/Tween.js *///////////// function Delegate() {} Delegate.create = function (o, f) { var a = new Array() ; var l = arguments.length ; for(var i = 2 ; i < l ; i++) a[i - 2] = arguments[i] ; return function() { var aP = [].concat(arguments, a) ; f.apply(o, aP); } } Tween = function(obj, prop, func, begin, finish, duration, suffixe){ this.init(obj, prop, func, begin, finish, duration, suffixe) } var t = Tween.prototype; t.obj = new Object(); t.prop=''; t.func = function (t, b, c, d) { return c*t/d + b; }; t.begin = 0; t.change = 0; t.prevTime = 0; t.prevPos = 0; t.looping = false; t._duration = 0; t._time = 0; t._pos = 0; t._position = 0; t._startTime = 0; t._finish = 0; t.name = ''; t.suffixe = ''; t._listeners = new Array(); t.setTime = function(t){ this.prevTime = this._time; if (t > this.getDuration()) { if (this.looping) { this.rewind (t - this._duration); this.update(); this.broadcastMessage('onMotionLooped',{target:this,type:'onMotionLooped'}); } else { this._time = this._duration; this.update(); this.stop(); this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'}); } } else if (t < 0) { this.rewind(); this.update(); } else { this._time = t; this.update(); } } t.getTime = function(){ return this._time; } t.setDuration = function(d){ this._duration = (d == null || d <= 0) ? 100000 : d; } t.getDuration = function(){ return this._duration; } t.setPosition = function(p){ this.prevPos = this._pos; var a = this.suffixe != '' ? this.suffixe : ''; this.obj[this.prop] = Math.round(p) + a; this._pos = p; this.broadcastMessage('onMotionChanged',{target:this,type:'onMotionChanged'}); } t.getPosition = function(t){ if (t == undefined) t = this._time; return this.func(t, this.begin, this.change, this._duration); }; t.setFinish = function(f){ this.change = f - this.begin; }; t.geFinish = function(){ return this.begin + this.change; }; t.init = function(obj, prop, func, begin, finish, duration, suffixe){ if (!arguments.length) return; this._listeners = new Array(); this.addListener(this); if(suffixe) this.suffixe = suffixe; this.obj = obj; this.prop = prop; this.begin = begin; this._pos = begin; this.setDuration(duration); if (func!=null && func!='') { this.func = func; } this.setFinish(finish); } t.start = function(){ this.rewind(); this.startEnterFrame(); this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'}); //alert('in'); } t.rewind = function(t){ this.stop(); this._time = (t == undefined) ? 0 : t; this.fixTime(); this.update(); } t.fforward = function(){ this._time = this._duration; this.fixTime(); this.update(); } t.update = function(){ this.setPosition(this.getPosition(this._time)); } t.startEnterFrame = function(){ this.stopEnterFrame(); this.isPlaying = true; this.onEnterFrame(); } t.onEnterFrame = function(){ if(this.isPlaying) { this.nextFrame(); setTimeout(Delegate.create(this, this.onEnterFrame), 0); } } t.nextFrame = function(){ this.setTime((this.getTimer() - this._startTime) / 1000); } t.stop = function(){ this.stopEnterFrame(); this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'}); } t.stopEnterFrame = function(){ this.isPlaying = false; } t.continueTo = function(finish, duration){ this.begin = this._pos; this.setFinish(finish); if (this._duration != undefined) this.setDuration(duration); this.start(); } t.resume = function(){ this.fixTime(); this.startEnterFrame(); this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'}); } t.yoyo = function (){ this.continueTo(this.begin,this._time); } t.addListener = function(o){ this.removeListener (o); return this._listeners.push(o); } t.removeListener = function(o){ var a = this._listeners; var i = a.length; while (i--) { if (a[i] == o) { a.splice (i, 1); return true; } } return false; } t.broadcastMessage = function(){ var arr = new Array(); for(var i = 0; i < arguments.length; i++){ arr.push(arguments[i]) } var e = arr.shift(); var a = this._listeners; var l = a.length; for (var i=0; i 4){ //cambiamos this.lista.style.height = (this.altoMaximo) + 'px'; this.lista.style.overflowY = 'scroll'; } else{ this.lista.style.height = ''; this.lista.style.overflowY = ''; if(this.lista.style.width!=(this.anchoMaximo+'px')) this.lista.style.width = this.anchoMaximo + 'px'; } } this.crearOpcion = function(texto, oInfo){ var a = document.createElement('div'); this.lista.appendChild(a); var oOpcion = {objeto:a, oInfo:oInfo, pos:this.opciones.length, seleccionado:false}; a.oPadre = this; a.unselectable = true; a.innerHTML = texto; a.className = 'FiltradorOpcionOff'; //a.style.width = this.anchoMaximo+'px'; AddEvent(a, "mouseover", function(){ RemEvent(this.oPadre.input, "blur", fa_1); this.className = 'FiltradorOpcionOn'; }.closure(a)); AddEvent(a, "mouseout", function(){ AddEvent(this.oPadre.input, "blur", fa_1); this.className = 'FiltradorOpcionOff'; }.closure(a)); AddEvent(a, "focus", function(){ RemEvent(this.oPadre.input, "blur", fa_1); this.className = 'FiltradorOpcionOn'; }.closure(a)); AddEvent(a, "blur", function(){ AddEvent(this.oPadre.input, "blur", fa_1); this.className = 'FiltradorOpcionOff'; }.closure(a)); AddEvent(a, "click", function(e){ if(this.seleccionado) return false; this.seleccionado = true; oClase.cancelarSalida(); oClase.seleccionar(this, false); if(Nav.esMz){ event.preventDefault(); event.stopPropagation(); } else{ event.cancelBubble = true; event.returnValue = false; } }.closure(oOpcion)); AddEvent(a, "mouseup", function(e){ if(!!e && Nav.esMz) event = e; if(this.seleccionado) return false; this.seleccionado = true; oClase.cancelarSalida(); oClase.seleccionar(this, false); if(Nav.esMz){ event.preventDefault(); event.stopPropagation(); } else{ event.cancelBubble = true; event.returnValue = false; } }.closure(oOpcion)); AddEvent(a, "keydown", function(){ oClase.detectarTecla() }.closure(a)); this.opciones.push(oOpcion); a = oOpcion = null; } this.crearMsgError = function(){ var a = document.createElement('div'); a.unselectable = true; a.innerHTML = this.msgError; a.className = 'FiltradorError'; this.lista.appendChild(a); } this.seleccionarOpcion = function(valor, campo){ campo = (typeof(campo)=='string')? campo : 'id'; for(var i = 0; i < this.opciones.length; i++){ if(this.opciones[i].oInfo[campo]==valor) return this.seleccionar(this.opciones[i], false); } } this.seleccionar = function(oOpcion, darFocus){ this.input.value = oOpcion.objeto.innerHTML; this.valorBuscado = this.input.value; this.input.oInfo = oOpcion.oInfo; this.opcionElegida = null; this.salir(darFocus); if(this.cuandoSelecciono) this.cuandoSelecciono(oOpcion.oInfo); } this.deseleccionar = function(){ this.input.value = ''; this.input.oInfo = null; this.valorBuscado = '=¿_|+¡-'; this.opcionElegida = null; this.mostrarLista('none'); this.req.cancelar(); this.esperar = false; //if(objConf && objConf.archivo) this.archivoReq = objConf.archivo; } // /*this.iniciarCarga = function(){ this.seleccionarOpcion(this.__dato,this.__campo); this.cuandoAcerto = this.__func; this.archivoReq = this.__file; delete(this.__func); delete(this.__dato); delete(this.__campo); delete(this.__file); }*/ this.iniciar = function(dato, campo){ var a = '', v = ''; /*this.deseleccionar(); this.__func = this.cuandoAcerto; this.__dato = dato; this.__campo = campo; this.__file = this.archivoReq;*/ if(this.archivoReq.search(/\?/)!=-1) a = this.archivoReq+'&'+campo+'='+dato; else a = this.archivoReq+'?'+campo+'='+dato; v = campo+'|=|'+dato+'|&|'; /*this.cuandoAcerto = this.iniciarCarga; this.enviar(true);*/ this.enviarPorAtras(v, a); } // this.limpiar = function(){ // this.input.oInfo = null; this.opcionElegida = null; //eliminamos todas las opciones cargadas var i = null; var op = null; while(this.opciones.length > 0){ op = this.opciones[this.opciones.length-1]; op.objeto.parentNode.removeChild(op.objeto); this.opciones.pop(); EliminarClosures(op.objeto); EliminarClosures(op); op = null; } //por las dudas while(this.lista.hasChildNodes()){ EliminarClosures(this.lista.firstChild); this.lista.removeChild(this.lista.firstChild); } i = null; } this.controlObligatorio=function(e){ if(!!e && Nav.esMz) event = e; if((this.obligatorio==true || this.input.value!='') && this.opciones.length!=1){ //try{this.input.focus();}catch(e){;}; if(this.lista.style.display!='none') this.mostrarLista('none'); if(!!event){ if(Nav.esMz){ event.preventDefault(); event.stopPropagation(); } else{ event.cancelBubble = true; event.returnValue = false; } } } } this.inputBlur = function(e){ if(!!e && Nav.esMz) event = e; if(this.input.value == this.input.__msjVacio){ if(this.cuandoFallo) this.cuandoFallo(); return false; } if((this.obligatorio==true || this.input.value!='') && (this.input.oInfo==null || // this.valorBuscado.substr(0,this.valorBuscado.length)==this.input.value.substr(0,this.input.value.length))){ if(Nav.esMz){ event.preventDefault(); event.stopPropagation(); } else{ event.returnValue = false; event.cancelBubble = true; } this.enviar(); } else{ if(this.input.value==''){ this.deseleccionar(); this.exito = false; } this.salir(false); this.input.oInfo = null; if(this.input.value=='' && this.cuandoFallo) this.cuandoFallo(); } } this.detectarTecla = function(e){ if(!!e && Nav.esMz) event = e; //si es flecha arriba y tuvimos exito en la busqueda if(event.keyCode==38 && this.exito) this.moverArriba(); //si es flecha abajo y tuvimos exito en la busqueda else if(event.keyCode==40 && this.exito) this.moverAbajo(); //si es enter else if(event.keyCode==13 && this.exito && this.opcionElegida!=null){ FireEvent(this.opcionElegida.objeto, 'click'); this.salir(); } else if(event.keyCode==37 && this.exito){ try{this.input.focus();}catch(e){;} this.opcionElegida = null; } if(Nav.esMz){ event.preventDefault(); event.stopPropagation(); } else{ event.returnValue = false; event.cancelBubble = true; } } this.moverAbajo = function(){ var oOpcion = this.opcionElegida; if(oOpcion==null && this.lista.style.display != 'none'){ //le quitamos el evento temporalmente RemEvent(this.input, 'blur', fa_1); // oOpcion = this.opciones[0]; } else if(oOpcion!=null && (this.opcionElegida.pos+1) < this.opciones.length) oOpcion = this.opciones[this.opcionElegida.pos+1]; // if(oOpcion!=null && this.lista.style.display != 'none'){ try{oOpcion.objeto.focus();}catch(e){;} } // this.opcionElegida = oOpcion; } this.moverArriba = function(){ var oOpcion = this.opcionElegida; if(oOpcion==null && this.lista.style.display!='none'){ //le quitamos el evento temporalmente RemEvent(this.input, 'blur', fa_1); oOpcion = this.opciones[0]; } else if(this.opcionElegida.pos-1 >= 0) oOpcion = this.opciones[this.opcionElegida.pos-1]; else if(oOpcion!=null){ //volvemos al input try{this.input.focus();}catch(e){;} oOpcion = null; } if(oOpcion!=null && this.lista.style.display!='none'){ try{oOpcion.objeto.focus();}catch(e){;} } this.opcionElegida = oOpcion; } this.onRequestLoad = function(){ // this.analizarRespuesta(this.req.respuestaXML); this.esperar = false; } this.enviar = function(noDesplegar){ //si no esperamos if(noDesplegar==true) this.noDesplegar = noDesplegar; if(!this.esperar && this.input.value!=this.valorBuscado){ this.esperar = true; this.valorBuscado = this.input.value; this.req.pedir(this.archivoReq, this.postVarName+this.input.value); } /*else if(this.input.value==this.valorBuscado){ this.mostrarLista('block'); this.controlarAlto(); this.controlObligatorio(); }*/ } this.enviarPorAtras = function(v, a){ this.mostrarLista('none'); this.noDesplegar = true; if(this.esperar) this.req.cancelar(); this.esperar = true; if(!a) a = this.archivoReq; this.req.pedir(a, v); } this.analizarRespuesta= function(oXML){ // if(this.nodoPadre){ var nodoPadre = oXML.ownerDocument.getElementsByTagName(this.nodoPadre); oXML = nodoPadre[0]; } // if(oXML){ //borramos this.limpiar(); //creamos las nuevas opciones for(var i = 0; i < oXML.childNodes.length; i++){ //vemos los atributos var oInfo = new Object; for(var x = 0; x < oXML.childNodes[i].attributes.length; x++) oInfo[oXML.childNodes[i].attributes[x].nodeName] = oXML.childNodes[i].attributes[x].nodeValue; // this.crearOpcion((oXML.childNodes[i].text)? oXML.childNodes[i].text: oXML.childNodes[i].textContent, oInfo); } // if(i>0){ this.exito = true; if(this.opciones.length==1){ this.seleccionar(this.opciones[0], false); this.valorBuscado = this.opciones[0].objeto.innerHTML; } } else{ this.exito = false; this.crearMsgError(); } // this.controlObligatorio(); // if(i!=1 && !this.noDesplegar){ this.mostrarLista('inline'); this.controlarAlto(); } else this.noDesplegar = false; // if(this.exito && this.cuandoAcerto){ if(this.obligatorio && i!=1){ this.input.oInfo = null; if(this.cuandoFallo) this.cuandoFallo(); } else this.cuandoAcerto(); } else if(!this.exito && this.cuandoFallo){ this.input.oInfo = null; this.cuandoFallo(); } } else{ return ERROR.reportar("Error en la clase Filtrador al recibir los datos.\nHTML: "+this.req.respuestaHTML+"\nARCHIVO: "+this.req.archivo); } } // var fa_1 = fa_2 = fa_3 = fa_4 = fa_5 = fa_6 = fa_7 = null; this.ponerEventos = function(){ AddEvent(this.input, "blur", fa_1 = this.inputBlur.closure(this)); AddEvent(this.input, "focus", fa_2 = function(){ RemEvent(this.input, "blur", fa_1); AddEvent(this.input, "blur", fa_1); }.closure(this)); AddEvent(this.input, "keydown", fa_3 = function(e){ this.filtrar(e) }.closure(this)); AddEvent(this.input, "dblclick", fa_4 = function(e){ this.filtrar(e, true) }.closure(this)); AddEvent(this.lista, "focus", fa_5 = this.cancelarSalida.closure(this)); AddEvent(this.lista, "keydown", fa_6 = this.detectarTecla.closure(this)); AddEvent(this.lista, "blur", fa_7 = this.salir.closure(this)); } this.ponerEventos(); this.quitarEventos = function(){ RemEvent(this.input, "blur", fa_1); RemEvent(this.input, "focus", fa_2); RemEvent(this.input, "keydown", fa_3); RemEvent(this.input, "dblclick", fa_4); RemEvent(this.lista, "focus", fa_5); RemEvent(this.lista, "keydown", fa_6); RemEvent(this.lista, "blur", fa_7); } } var DIR_RAIZ = '/home/peruentr/public_html/'; var DIR_RAIZ_WEB = 'http://www.juantoselli.com/'; var DIR_PROGRAMAS = 'programas_files/'; var DIR_HOTELES = 'hoteles_files/'; var DIR_AUTOS = 'autos_files/'; var DIR_CRUCEROS = 'cruceros_files/'; var DIR_AEREOS = 'aereos_files/'; var DIR_NORMAS = 'normas_files/'; var DIR_EVENTOS = 'eventos_files/'; var DIR_CONSEJOS = 'consejos_files/'; var DIR_NOTICIAS = 'notas_files/'; var DIR_QUIENES_SOMOS = 'DIR_QUIENES_SOMOS'; var ID_PAIS = 'PE'; var DIR_SERVER_ROOT = '/';