//fpv=10
function mw_elementosalternos(nombre){
	this.nombre=nombre;
	this.activo=false;
	this.timeout=1000;
	this.ocultaronmouseout=1;
	this.indexado=false;
	this.nitems = 0;
   
	this.elementosindex = new Array;
	this.elementosinfo = new Object;
	this.registrarelemento=function(id_cont) {
		this.indexado=true;
		this.elementosindex[this.nitems]=id_cont;
		this.elementosinfo[id_cont]=this.nitems;
		this.nitems++;
	}
	this.cambiarelemento=function(mov) {
		if(!this.indexado){
			return false;	
		}
		var indexactual=0;
		if(this.activo){
			var indexactual=this.elementosinfo[this.activo];
		}
		var movhacia=indexactual+mov;
		if(movhacia<0){
			movhacia=this.nitems-1;
		}
		if(movhacia>=this.nitems){
			movhacia=0;
		}
		if(this.elementosindex[movhacia]){
			this.set_activo(this.elementosindex[movhacia]);
		}
	}
	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){
				fp_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){
			fp_hide(this.activo);
			this.activo=false;
		}
	}
	this.set_activo=function(id_cont){
		if (id_cont==this.activo){
			this.clearTimeout_ocultar();
		}else{
			this.ocultar_activo();
			if (id_cont){
				fp_show(id_cont);
				this.activo=id_cont;
			}
		}
	}
	this.alsalirmouse=function (){
		if(this.ocultaronmouseout){
			this.iniciarTimeout_ocultar();
		}
	}
}

