// RVH alterna muestra de elementos
function mw_elementosalternos_elemento(){
	this.div=false;
	this.img=false;
	this.imgsrcon=false;
	this.imgsrcoff=false;
}

function mw_elementosalternos(nombre){
	this.nombre=nombre;
	this.activo=false;
	this.activoindex=false;
	this.timeout=1000;
	this.ocultaronmouseout=1;
	this.modoacordeon=false;
	this.modoacordeon_sentido="v";
	this.modoacordeon_avanzar=10;
	this.modoacordeon_milisegundos=10;
	
	this.usarelementosarray=false;
	this.elementos = new Array;
	this.elementosidindex = new Object;
	this.elementosindex = new Array;
	this.registrarelemento=function(index,id_cont,id_img,srcon,srcoff) {
		this.elementos[index]=new mw_elementosalternos_elemento;
		this.elementos[index].div=fp_get_element_by_id(id_cont);
		if (id_img){
			this.elementos[index].img=fp_get_element_by_id(id_img);
			this.elementos[index].imgsrcon=srcon;
			this.elementos[index].imgsrcoff=srcoff;
		}
		this.elementosindex[index]=id_cont;
		this.elementosidindex[id_cont]=index;
	}
	this.getelementoid=function(id_cont) {
		for (i=0;i<this.elementosindex.length;i++){
			if(	this.elementosindex[i]==id_cont){
				return i;
			}
		}
						
	}
	this.set_activo_si_visible_y_activo_noexiste_o_ocultar=function(id_cont) {
		var estado=fp_get_style(id_cont,'display');
		if (estado!="none"){
			if (this.activo){
				this.do_hide(id_cont);	
			}else{
				this.activo=id_cont;
			}
		}
	}
	this.clearTimeout_ocultar=function(){
		if (this.timerocultar){
			clearTimeout(this.timerocultar);
		}
	}
	this.iniciarTimeout_ocultar=function(){
		this.clearTimeout_ocultar();
		this.timerocultar =  setTimeout(this.nombre+".ocultar_activo()",this.timeout);
	}
	this.ocultar_activo=function(){
		this.clearTimeout_ocultar();
		if (this.activo){
			this.do_hide(this.activo);
			if (this.usarelementosarray){
				if(this.elementos[this.activoindex]){
					this.elementos[this.activoindex].img.src=this.elementos[this.activoindex].imgsrcoff;
				}
			}
			this.activo=false;
		}
	}
	this.set_activo=function(id_cont){
		if (id_cont==this.activo){
			this.clearTimeout_ocultar();
		}else{
			this.ocultar_activo();
			if (id_cont){
				if (this.usarelementosarray){
					this.activoindex=this.getelementoid(id_cont);
					if(this.elementos[this.activoindex]){
						this.elementos[this.activoindex].img.src=this.elementos[this.activoindex].imgsrcon;
					}
				}
				//set_opacity_id(id_cont,1);
				this.do_show(id_cont);
				this.activo=id_cont;
			}
		}
	}
	this.do_show=function(id_cont){
		if(this.modoacordeon){
			if(divobj=this.get_divobj(id_cont)){
				acordeon.call(divobj,this.modoacordeon_sentido,'show',this.modoacordeon_milisegundos,this.modoacordeon_avanzar); 					  
			}
		}else{
			fp_show(id_cont);	
		}
	}
	this.do_hide=function(id_cont){
		if(this.modoacordeon){
			if(divobj=this.get_divobj(id_cont)){
				acordeon.call(divobj,this.modoacordeon_sentido,'hide',this.modoacordeon_milisegundos,this.modoacordeon_avanzar); 					  
			}
		}else{
			fp_hide(id_cont);	
		}
	}
	this.get_divobj=function (id_cont){
		if(this.elementosidindex[id_cont]){
			if(this.elementos[this.elementosidindex[id_cont]]){
				if(this.elementos[this.elementosidindex[id_cont]].div){
					return 	this.elementos[this.elementosidindex[id_cont]].div;
				}
			}
		}
	}
	this.alsalirmouse=function (){
		if(this.ocultaronmouseout){
			this.iniciarTimeout_ocultar();
		}
	}
}

