var noFlash = {
	actual:-1,//guarda la posición del listado visible en cada momento, teniedo en cuenta que actual = 0, es la pagina 1
	anterior:-1,//guarda la ultima posición del listado visible
	intervalo:10500,//intervalo de tiempo que transcurre entre los cambios
	obj_retardo:null,//objeto sobre el que se realiza el intervalo
	objs:null,//objeto que contiene los "li" con cada una de las imágenes a mostrar
	objsPage:null,//objeto que contiene cada uno de los "li" de la paginacion
	objs_size:0,//numero de elementos del listado
	animacion:true,//variable de control para dar una animacion al cambio de imagenes o no
	transition:1000,//tiempo del fadeIn y fadeOut
	iniciar_animacion:true,//variable que indica si la barra pequeña tiene derechos para seguir animando
	ancho_barra:0,//tamaño del ancho de la barra de carga en pixeles
	ancho_barra_test:0,
	primer:true,
	load:function(qItem){
		noFlash.actual=qItem;
		noFlash.anterior=qItem;
		var $noflash = jQuery("#noflash");
		noFlash.objs = jQuery("#noflash li");
		noFlash.objs_size = jQuery(noFlash.objs).size();
		jQuery($noflash).addClass("noflashActive");
		if(noFlash.animacion) jQuery(noFlash.objs).eq(noFlash.actual).css("display","block")
		else jQuery(noFlash.objs).eq(noFlash.actual).addClass("selected")
		if(noFlash.objs_size>1){
			var html_insertar = '<div id="noFlashPaginate"><ul>';
			jQuery(noFlash.objs).each(function(e){
				//if (e==noFlash.actual)
				//	html_insertar+='<li class="selected"><a href="" title="accede a pÃ¡gina '+(e+1)+'"><span class="hidden">'+(e+1)+'</span></a></li>';
				//else html_insertar+='<li><a href="" title="accede a pÃ¡gina '+(e+1)+'"><span class="hidden">'+(e+1)+'</span></a></li>'
				if (e==noFlash.actual)
					html_insertar+='<div id="cubo_gris"></div><li class="selected"><a href="" title="'+jQuery(this).find("img").attr("alt")+'"><span class="hidden">'+jQuery(this).find("img").attr("alt")+'</span></a></li>';
				else html_insertar+='<li><a href="" title="'+jQuery(this).find("img").attr("alt")+'"><span class="hidden">'+jQuery(this).find("img").attr("alt")+'</span></a></li>';
			})
			html_insertar += '</ul><div id="playerNoflash"><a class="prev" href="#" title="acceda a la pÃ¡gina anterior"><span class="hidden">PÃ¡gina anterior</span></a><a class="stop" href="#" title="Pulse para parar"><span class="hidden">Parar</span></a><a class="play" href="#" title="Pulse para reproducir"><span class="hidden">Reproducir</span></a><a class="next" href="#" title="acceda a la pÃ¡gina siguiente"><span class="hidden">PÃ¡gina siguiente</span></a></div></div>';
						
			jQuery($noflash).after(html_insertar);
			noFlash.objsPage=jQuery("#noFlashPaginate ul li");
			
			noFlash.ancho_barra = jQuery("#noFlashPaginate ul li a").width() * jQuery("#noflash li").length;

			noFlash.obj_retardo = window.setInterval("noFlash.ciclo()",noFlash.intervalo);
			noFlash.llenabarra();

			jQuery("#msg_test").text(noFlash.ancho_barra_test + ".");

			jQuery(noFlash.objsPage).find("a").bind("click",function(e){
				noFlash.anterior = noFlash.actual;
				noFlash.actual = jQuery(noFlash.objsPage).find("a").index(this);
				noFlash.desplaza();
				noFlash.llenabarra();
				return false;
			})
			jQuery("#playerNoflash a").bind("click",function(){
				var typebutton = jQuery(this).attr("class");
				switch (typebutton){
					case 'prev':
						noFlash.anterior = noFlash.actual;
						noFlash.actual = (noFlash.actual+noFlash.objs_size-1)%noFlash.objs_size;
						noFlash.desplaza();
						noFlash.llenabarra();
					break;
					case 'stop':
						clearInterval(noFlash.obj_retardo);
						jQuery(this).css("display","none");
						jQuery("#playerNoflash a.play").css("display","block");
						noFlash.iniciar_animacion = false;						
						noFlash.llenabarra(true);

					break;
					case 'play':
						jQuery(this).css("display","none");
						jQuery("#playerNoflash a.stop").css("display","block");
						noFlash.obj_retardo = window.setInterval("noFlash.ciclo()",noFlash.intervalo);
						noFlash.iniciar_animacion = true;
						noFlash.llenabarra();

					break;
					case 'next':
						noFlash.anterior = noFlash.actual;
						noFlash.actual = (noFlash.actual+1)%noFlash.objs_size;
						noFlash.desplaza();
						noFlash.llenabarra();
					break;
				}
				return false;
			})
		}
		jQuery(noFlash.objs).find("a").bind("click",function(){
			if(jQuery(this).hasClass("newwindow")){
				var _url = jQuery(this).attr("href")
				var tamanios = jQuery(this).attr("id").split("_");
				var w_win = parseInt(tamanios[0].split('w')[1]);
				var h_win = parseInt(tamanios[1].split('h')[1]);
				return noFlash.abrir(_url,'newwindow','width='+w_win+',height='+h_win+',scrollbars=yes',1,2,2);
			}
		})
	},
	ciclo:function(){
		noFlash.anterior = noFlash.actual;
		noFlash.actual = (noFlash.actual+1)%noFlash.objs_size;
		noFlash.desplaza();
		noFlash.llenabarra();
				
		if(noFlash.primer){
			noFlash.primer=false;
			clearInterval(noFlash.obj_retardo);
			noFlash.intervalo=10000;
			noFlash.obj_retardo = window.setInterval("noFlash.ciclo()",noFlash.intervalo);
		}
	},
	desplaza:function(){

		//jQuery("#cubo_gris").css('width','0');
		//jQuery("#cubo_gris").animate({width: 65, opacity: 0.8}, { duration: noFlash.intervalo});

		jQuery(noFlash.objsPage).eq(noFlash.anterior).removeClass("selected");
		jQuery(noFlash.objsPage).eq(noFlash.actual).addClass("selected");

		if(noFlash.animacion){
			jQuery(noFlash.objs).eq(noFlash.anterior).fadeOut(noFlash.transition);
			jQuery(noFlash.objs).eq(noFlash.actual).fadeIn(noFlash.transition);
		}
		else {
			jQuery(noFlash.objs).eq(noFlash.anterior).removeClass("selected");
			jQuery(noFlash.objs).eq(noFlash.actual).addClass("selected");
		}
	},
	llenabarra:function(desaparecer){
		if(desaparecer == null && noFlash.iniciar_animacion == true){
			jQuery("#cubo_gris").css('width','0');
			jQuery("#cubo_gris").animate({width: noFlash.ancho_barra, opacity: 1}, { duration: noFlash.intervalo, queue: false });
		}else if(desaparecer == true){
				jQuery("#cubo_gris").stop();;
			}
	},
	abrir:function(){
		var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16;v11=new Array("width,left,"+v4,"height,top,"+v5);for (i=0;i<v11.length;i++){v12=v11[i].split(",");l_iTarget=parseInt(v12[2]);if (l_iTarget>1||v1[2].indexOf("%")>-1){v13=eval("screen."+v12[0]);for (v6=0;v6<v2.length;v6++){v10=v2[v6].split("=");if (v10[0]==v12[0]){v14=parseInt(v10[1]);if (v10[1].indexOf("%")>-1){v14=(v14/100)*v13;v2[v6]=v12[0]+"="+v14;}}if (v10[0]==v12[1]){v16=parseInt(v10[1]);v15=v6;}}if (l_iTarget==2){v7=(v13-v14)/2;v15=v2.length;}else if (l_iTarget==3){v7=v13-v14-v16;}v2[v15]=v12[1]+"="+v7;}}v8=v2.join(",");v9=window.open(v1[0],v1[1],v8);if (v3){v9.focus();}document.MM_returnValue=false;return false;
	}
}
