function ObjetoListaInteractiva(){ this.list = new Array(); this.listaNombres = new Array(); this.listaCombos = new Array(); this.listaPestanas = new Array(); this.listaEnlaces = new Array(); this.elementosVisibles =1; this.posicion=0; this.modoOff=""; this.modoOn=""; this.modoPestanaOff=""; this.modoPestanaOn=""; this.anadir=anadir; this.mostrarAnterior=mostrarAnterior; this.mostrarSiguiente=mostrarSiguiente; this.mostrarPaginaAnterior=mostrarPaginaAnterior; this.mostrarPaginaSiguiente=mostrarPaginaSiguiente; this.borrarTodos=borrarTodos; this.setElementosVisibles=setElementosVisibles; this.getElementosVisibles=getElementosVisibles; this.setModoOn=setModoOn; this.getModoOn=getModoOn; this.setModoOff=setModoOff; this.getModoOff=getModoOff; this.setModoPestanaOn=setModoPestanaOn; this.getModoPestanaOn=getModoPestanaOn; this.setModoPestanaOff=setModoPestanaOff; this.getModoPestanaOff=getModoPestanaOff; this.hacerInvisible=hacerInvisible; this.hacerVisible=hacerVisible; this.init=init; this.init2=init2; this.setNombre=setNombre; this.getNombre=getNombre; this.ocultarTodos=ocultarTodos; this.insertOption=insertOption; this.anadirCombo=anadirCombo; this.mostrarCombo=mostrarCombo; this.mostrarPestana=mostrarPestana; this.anadirPestanas=anadirPestanas; this.getPosicion=getPosicion; this.mostrarCapa=mostrarCapa; this.mostrarAleatorio=mostrarAleatorio; this.setEnlace=setEnlace; this.getEnlace=getEnlace; this.enlaceSeccion=enlaceSeccion; this.enlaceSeccionCategoria=enlaceSeccionCategoria; this.pasas=pasas; } //Devuelve el objeto por ID function getObject(id) { if( window.mmIsOpera ) return(document.getElementById(id)); if (document.all) return(document.all[id]); if (document.getElementById) return(document.getElementById(id)); return(false); } //devuelve la posición en la que se encuentra el objeto //Esta función se utiliza para mostrar el número de foto que se está mostrando en un album function getPosicion(){ //sumamos uno a la posición, porque empieza en 0. return this.posicion+1; } function anadirCombo(select){ this.listaCombos.push(select); } function anadirPestanas(pestana){ this.listaPestanas.push(pestana); } function insertOption() { for (var i = 0; i < this.list.length; i++) { for (var j = 0; j < this.listaCombos.length; j++) { var y=document.createElement('option'); y.text=this.getNombre(this.list[i]); y.value=this.list[i]; var x=document.getElementById(this.listaCombos[j]); try { x.add(y,null); // standards compliant } catch(ex) { x.add(y); // IE only } } } } function mostrarPestana(id){ this.ocultarTodos(); this.hacerVisible(id); //Recorremos las pestanas para ponerlas en modo off for (var i = 0; i < this.listaPestanas.length; i++) { document.getElementById(this.listaPestanas[i]).className=this.getModoPestanaOff(); } //Ponemos la seleccionada en modo On document.getElementById("pestana"+id).className=this.getModoPestanaOn(); } function mostrarCombo(id){ var x=document.getElementById(id); //Si el seleccionado es el 0 no hacemos nada if (x.selectedIndex==0){ return; } this.ocultarTodos(); //situamos la posicion, será la seleccionada -1 this.posicion=x.selectedIndex-1; this.hacerVisible(x.options[x.selectedIndex].value); //Recorremos los combos para seleccionar el indice seleccionado for (var i = 0; i < this.listaCombos.length; i++) { var combos=document.getElementById(this.listaCombos[i]); combos.options[x.selectedIndex].selected=true; } } function anadir(id){ this.list.push(id); } function setNombre(id, nombre){ this.listaNombres[id]=nombre; } function getNombre(id){ return(this.listaNombres[id]); } function setEnlace(id, enlace){ this.listaEnlaces[id]=enlace; } function getEnlace(id){ return(this.listaEnlaces[id]); } function ocultarTodos(){ for (var i = 0; i < this.list.length; i++) { this.hacerInvisible(this.list[i]); } } function mostrarPaginaAnterior(){ for (var i = 0; i < this.getElementosVisibles(); i++) { this.mostrarAnterior(); } } function mostrarPaginaSiguiente(){ for (var i = 0; i < this.getElementosVisibles(); i++) { this.mostrarSiguiente(); } } function mostrarAnterior(){ if (this.list.length==1) { return; } if (this.list[this.posicion-1]!=null){ this.hacerVisible(this.list[this.posicion-1]); this.hacerInvisible(this.list[this.posicion+(this.getElementosVisibles()-1)]); this.posicion=this.posicion-1; } else{ //Si el salto es de uno, mostramos el ultimo if (this.getElementosVisibles()==1){ this.hacerVisible(this.list[this.list.length-1]); this.hacerInvisible(this.list[this.posicion]); this.posicion=this.list.length-1; } } } function mostrarSiguiente(){ if (this.list.length==1) { return; } if (this.list[this.posicion+this.getElementosVisibles()]!=null){ this.hacerVisible(this.list[this.posicion+this.getElementosVisibles()]); this.hacerInvisible(this.list[this.posicion]); this.posicion=this.posicion+1; } else{ //Si el salto es de uno, empezamos de nuevo if (this.getElementosVisibles()==1){ this.hacerVisible(this.list[0]); this.hacerInvisible(this.list[this.posicion]); this.posicion=0; } } } function pasas(direccion, url){ if (document.getElementById("ojd")!=null){ document.getElementById("ojd").src=url; } if (direccion=="1"){ this.mostrarSiguiente(); }else { this.mostrarAnterior(); } } function borrarTodos(){ for (var i = 0; i <= this.list.length; i++) { this.list.pop(); } } function setElementosVisibles(numero){ this.elementosVisibles=numero; } function getElementosVisibles(){ return this.elementosVisibles; } function setModoOn(clase){ this.modoOn=clase; } function getModoOn(){ return this.modoOn; } function setModoOff(clase){ return this.modoOff=clase; } function getModoOff(){ return this.modoOff; } function setModoPestanaOn(clase){ this.modoPestanaOn=clase; } function getModoPestanaOn(){ return this.modoPestanaOn; } function setModoPestanaOff(clase){ return this.modoPestanaOff=clase; } function getModoPestanaOff(){ return this.modoPestanaOff; } function init(){ //hacemos visible el numero de elementos visibles configurados for (var i = 0; i < this.getElementosVisibles(); i++) { document.getElementById(this.list[i]).className=this.getModoOn(); } //Si tienes pestanas ponemos la primera como seleccionada if (this.listaPestanas.length!=0){ document.getElementById(this.listaPestanas[0]).className=this.getModoPestanaOn(); } this.insertOption(); } function init2(){ //hacemos visible el numero de elementos visibles configurados for (var i = 0; i < this.getElementosVisibles(); i++) { document.getElementById(this.list[i]).className=this.getModoOn(); } //Si tienes pestanas ponemos la primera como seleccionada if (this.listaPestanas.length!=0){ document.getElementById(this.listaPestanas[0]).className=this.getModoPestanaOn(); } this.insertOption(); } function hacerInvisible(id){ document.getElementById(id).className=this.getModoOff(); } function hacerVisible(id){ document.getElementById(id).className=this.getModoOn(); } function mostrarCapa(id){ this.ocultarTodos(); this.hacerVisible(id); } function mostrarAleatorio (){ var tope=this.list.length; var VerElemento=Math.floor(Math.random()*tope); this.hacerInvisible(this.list[this.posicion]); this.hacerVisible(this.list[VerElemento]); this.posicion=VerElemento; } function enlaceSeccion(id){ var x=document.getElementById(id); //Si el seleccionado es el 0 no hacemos nada if (x.selectedIndex==0){ return; } var idSeleccionado = x.options[x.selectedIndex].value; this.enlaceSeccionCategoria(idSeleccionado); } function enlaceSeccionCategoria(id){ var enlace = this.getEnlace(id); if (enlace!=null){ document.location.href=enlace; } }