//fpv=9
function fp_slide (nomgenerico) {
   	this.nitems = 0;
    this.nomgenerico = nomgenerico;
    this.elemactual = 0;
    this.abririmgoriginalalhacerclick = 1;

	this.hideshowportransicion = 0;
	this.hideshowportransicionmseg = 10;
	this.hideshowportransicionav = 1;
	this.modoxml = 0;
	this.xmlurl = "";
	this.mostrarprimerelemento = 0;
 	this.elementos = new Array;
 	this.elementosids = new Object;
	this.modoxml_cargado = 0;
	this.marcoocultochecked = 0;
	
	this.modomostrarenarea = 0;
	
	this.datosactualcargado = 0;
	this.actualizar_hideshow_elems_in_tbl=function(){
		if(!this.hideshow_elems_in_tbl_ok){
			return false;	
		}
		var eactualindex=0;
		var cell;
		var ocultar=true;
		var numelemsmostrar=this.hideshow_elems_in_tbl_num_pos+this.hideshow_elems_in_tbl_num_ant+1;
		var primer_elem_mostrar=this.elemactual-this.hideshow_elems_in_tbl_num_ant;
		if(primer_elem_mostrar<0){
			primer_elem_mostrar=0;	
		}
		var ultimoelem_mostrar=primer_elem_mostrar+numelemsmostrar-1;

		if(ultimoelem_mostrar>=this.hideshow_elems_in_tbl_contenedores.length){
			ultimoelem_mostrar=this.hideshow_elems_in_tbl_contenedores.length-1;
			primer_elem_mostrar=ultimoelem_mostrar-numelemsmostrar+1;
		}
		if(primer_elem_mostrar<0){
			primer_elem_mostrar=0;	
		}
		for(var i=0;i<this.hideshow_elems_in_tbl_contenedores.length;i++){
			cell=this.hideshow_elems_in_tbl_contenedores[i];
			ocultar=true;
			if(i>=primer_elem_mostrar){
				if(i<=ultimoelem_mostrar){	
					ocultar=false;	
				}
			}
			if(ocultar){
				cell.style.display="none";
			}else{
				cell.style.display="";
			}
		}
	}
	this.do_hideshow_elems_in_tbl=function(){
		if(!this.hideshow_elems_in_tbl){
			return false;	
		}
		if(!this.hideshow_elems_in_tbl_obj){
			if(this.hideshow_elems_in_tbl_idtbl){
				this.hideshow_elems_in_tbl_obj=fp_get_element_by_id_siexiste(this.hideshow_elems_in_tbl_idtbl);
			}
		}
		if(!this.hideshow_elems_in_tbl_obj){
			this.hideshow_elems_in_tbl=false;
			return false;
		}
		if(!this.hideshow_elems_in_tbl_num_ant){
			this.hideshow_elems_in_tbl_num_ant=1;	
		}
		if(!this.hideshow_elems_in_tbl_num_pos){
			this.hideshow_elems_in_tbl_num_pos=1;	
		}
		this.hideshow_elems_in_tbl_ok=true;
		this.hideshow_elems_in_tbl_contenedores=new Array();
		var c;
		for (var r=0;r<this.hideshow_elems_in_tbl_obj.rows.length;r++){
			for (c=0;c<this.hideshow_elems_in_tbl_obj.rows[r].cells.length;c++){
				this.hideshow_elems_in_tbl_contenedores.push(this.hideshow_elems_in_tbl_obj.rows[r].cells[c]);	
			}
		}
		this.actualizar_hideshow_elems_in_tbl();
		
	}
   	this.loaddatosxml=function(){
		if (!this.modoxml){
			return false;	
		}
		if (!this.xmlurl){
			return false;	
		}
		var fp_ajax;
		if (fp_ajax=fp_ajax_crear_Request()){
			fp_ajax.fpparentcaller=this;
			fp_ajax.onreadystatechange = function (){
				if (fp_ajax.readyState == 4) {
					if (fp_ajax.status == 200) {
						var datafromajaxxml;
						if(datafromajaxxml=fp_ajax_xml2obj(fp_ajax)){
							this.fpparentcaller.datosfromxml=datafromajaxxml;
							this.fpparentcaller.add_elementos_from_xmldata();
							//fp_get_output_get_debugbox(fp_ajax_xml2objdebug(datafromajaxxml));
						}
						//fp_get_output_get_debugbox(fp_ajax.responseText);
					}
				}
			}
			fp_ajax.open("GET", this.xmlurl, true);
			fp_ajax.send(null);	
		}
	}
   	this.add_elementos_from_xmldata=function(){
		if (this.datosfromxml.items){
			for (var k in this.datosfromxml.items){
				this.add_elemento(k);
			}
			this.modoxml_cargado=1;
			if (this.mostrarprimerelemento){
				 this.getdatosactualxml();
				 this.showdatosactual();
			}
			
		}
	}
    this.add_elemento = function(idelem) {
         this.elementos[this.nitems]=idelem;
		 this.elementosids[idelem]=this.nitems;
		 this.nitems=this.nitems+1;
    };
    this.getdatosactualxml = function() {
		this.datosactual=Object();
		if (!this.modoxml_cargado){
			return false;	
		}
		
		if (this.datosfromxml.items[this.elementos[this.elemactual]]){
			this.datosactual=this.datosfromxml.items[this.elementos[this.elemactual]];
			this.datosactualcargado=1;

			return true;
			
		}
		
	}
    this.getdatosactualfromdiv = function() {
       if (this.modoxml){
			return  this.getdatosactualxml(); 
	   }
	   var id_div_item=this.nomgenerico+"_item_"+ this.elementos[this.elemactual];
		this.datosactual=Object();
		this.datosactual.titulo=fp_get_contenido(id_div_item+'_titulo');
		this.datosactual.titalbum=fp_get_contenido(id_div_item+'_titalbum');
	  	this.datosactual.desc=fp_get_contenido(id_div_item+'_desc');
	  	this.datosactual.urlimg=fp_get_contenido(id_div_item+'_urlimg');
	  	this.datosactual.urlimgorig=fp_get_contenido(id_div_item+'_urlimgorig');
	  	this.datosactual.onclimggrande=fp_get_contenido(id_div_item+'_onclimggrande');
		this.datosactualcargado=1;
		return true;
		
    };
    this.showdatosactual = function() {
		var id_div_itemactual=this.nomgenerico+"_item_"+ this.elementos[this.elemactual];
		fp_hide(this.nomgenerico+"_titulo");
		fp_hide(this.nomgenerico+"_desc");
		fp_hide(this.nomgenerico+"_titalbum");
		if (!this.datosactualcargado){
			return false;	
		}
		
		fp_modificar_contenido(this.nomgenerico+"_titulo",this.datosactual.titulo );
		fp_modificar_contenido(this.nomgenerico+"_desc",this.datosactual.desc );
		fp_modificar_contenido(this.nomgenerico+"_titalbum",this.datosactual.titalbum );
		
		
		if (this.datosactual.htmlimgespecial){
			fp_modificar_contenido(this.nomgenerico,this.datosactual.htmlimgespecial );	
		}else{
			var htmlimg="<img src='"+this.datosactual.urlimg+"' border='0'>";
			if (this.abririmgoriginalalhacerclick==1){
				if (this.datosactual.urlimgorig.length>0){
					var htmlimga="<a href='"+this.datosactual.urlimgorig+"' target='_blank' ";
					if (this.datosactual.onclimggrande.length>0){
						htmlimga+="onclick=\""+this.datosactual.onclimggrande+"\"";
						
					}
					
					htmlimga+=">";
					htmlimg=htmlimga+htmlimg+"</a>";
				}
			}
			fp_modificar_contenido(this.nomgenerico,htmlimg );
		}
		if(this.datosactual.titulo){
			if (this.datosactual.titulo.length>0){
				fp_show(this.nomgenerico+"_titulo");
			}
		}
		if(this.datosactual.desc){
			if (this.datosactual.desc.length>0){
				fp_show(this.nomgenerico+"_desc");
			}
		}
		if(this.datosactual.titalbum){
			if (this.datosactual.titalbum.length>0){
				fp_show(this.nomgenerico+"_titalbum");
			}
		}
		fp_cambiar_propiedad(id_div_itemactual+'_titulomostrar','className',this.classtitulossel);
		
		this.showmarco();	

		//fp_get_output('img.php?src='+this.datosactual_urlimg,this.nomgenerico,'cont',true);
    };
	this.show_elem = function(itemid) {
		this.show_elem_from_div(this.getelemindexfromid(itemid));
	}
	this.getelemindexfromid=function(itemid){
		return this.elementosids[itemid];
	}
	this.show_elem_from_div = function(actual) {
		this.set_actual(actual);
		this.getdatosactualfromdiv();
		this.showdatosactual();
	}
	this.set_next = function() {
		if ((this.elemactual+1)>=this.nitems){
			var nuevoactual=0;
		}else{
			var nuevoactual=this.elemactual+1;
		}
		this.set_actual(nuevoactual);
	}
	this.set_prev = function() {
		if (this.elemactual<=0){
			var nuevoactual=this.nitems-1;
		}else{
			var nuevoactual=this.elemactual-1;
		}
		
		this.set_actual(nuevoactual);
	}
	this.show_next_from_div = function() {
		this.set_next();
		this.getdatosactualfromdiv();
		this.showdatosactual();
	}
	this.show_prev_from_div = function() {
		this.set_prev();
		this.getdatosactualfromdiv();
		this.showdatosactual();
	}

	this.showmarco= function(){
		if (!this.marcoocultochecked){
			this.checkmarcooculto();	
		}
		if (this.modomostrarenarea){
			if (this.marcooculto){
				this.marcooculto=false;
				if (this.hideshowportransicion==1){
			
					transicion.call(this.areaemergenteobj,0,1,this.hideshowportransicionmseg,this.hideshowportransicionav);
				}else{
					fp_show_obj(this.areaemergenteobj);	
				}
			}
		}else{
			if (this.marcooculto){
				this.marcooculto=false;
				var id_div_marco=this.nomgenerico+"_marco";
				if (this.hideshowportransicion==1){
					fp_show_tr(id_div_marco,this.hideshowportransicionmseg,this.hideshowportransicionav);
				}else{
					fp_show(id_div_marco);
				}
			}
			if (this.areaemergenteobj){
				this.areaemergenteobj.style.display="";	
			}
		}
	}
	this.ocultarmarco= function(){
		if (!this.marcoocultochecked){
			this.checkmarcooculto();	
		}
		if (this.modomostrarenarea){
			if (!this.marcooculto){
				this.marcooculto=true;
				if (this.hideshowportransicion==1){
					transicion.call(this.areaemergenteobj,1,0,this.hideshowportransicionmseg,this.hideshowportransicionav);
				}else{
					fp_hide_obj(this.areaemergenteobj);		
				}
			}
		}else{
			if (!this.marcooculto){
				this.marcooculto=true;
				var id_div_marco=this.nomgenerico+"_marco";
				if (this.hideshowportransicion==1){
					fp_hide_tr(id_div_marco,this.hideshowportransicionmseg,this.hideshowportransicionav);
				}else{
					fp_hide(id_div_marco);
				}
			}
			if (this.areaemergenteobj){
				this.areaemergenteobj.style.display="none";	
			}
		}
		if(this.datosactual){
			if (this.datosactual.htmlimgespecial){
				var htmlimg="<img src='"+this.datosactual.urlimg+"' border='0'>";
				fp_modificar_contenido(this.nomgenerico,htmlimg );
			}
		}
	}
	this.checkmarcooculto= function(){
		if (this.modomostrarenarea){
			if (this.areaemergenteobj.style.display=="none"){
				this.marcooculto=1;	
			}else{
				this.marcooculto=0;		
			}
			
		}else{
			var id_div_marco=this.nomgenerico+"_marco";
			if (fp_get_style(id_div_marco,'display')=="none"){
				this.marcooculto=1;	
			}else{
				this.marcooculto=0;		
			}
			this.marcoocultochecked=1;
		}
	}
	this.set_areaemergenteobj= function(idarea){
		if (areaobj=fp_get_element_by_id_siexiste(idarea)){
			this.areaemergenteobj=areaobj;
		}else{
			this.modomostrarenarea=0;	
		}
	}
	this.set_actual= function(idelem){
		var id_div_itemactual=this.nomgenerico+"_item_"+ this.elementos[this.elemactual];
		fp_cambiar_propiedad(id_div_itemactual+'_titulomostrar','className',this.classtitulos);
		this.elemactual=idelem;
		this.actualizar_hideshow_elems_in_tbl();
	}


}
