function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function HabilitarCarrusel(){	
		window.addEvent('domready', function(){
		//Primero cargamos la foto grande que se verá al cargar la página
      var strURL = location.href;
  		var cnt = strURL.indexOf("fotog");       
      var preliminar = 'carruselImg1';   		
  		if (cnt==-1){  			
  			var strFotos = document.fotos.nomFotos.value;
  			var arrayNomFotos = strFotos.split(",")			
  			this.total = document.fotos.total.value;
  			if (total > 0){
  				//se asigna la primera imagen a la capa que se esta viendo
  				$(preliminar).style.backgroundImage = "url(../dokumentuak/irudiak/"+arrayNomFotos[0]+")";          
  			}else{
  				//se asigna la primera imagen a la capa que se esta viendo
  				$(preliminar).style.backgroundImage = "url(../dokumentuak/irudiak/vacio.jpg)";
  			}	 
  		}      
   /*});	
	
		window.addEvent('domready', function(){*/
			//var strURL = location.href;
			//var cnt = strURL.indexOf("fotog");
		
			if ((document.fotos.total.value <= 1) || (cnt!=-1)){
			}else{			
				var anim = new Animacion('../dokumentuak/irudiak');
				anim.inicia();
			}
		});
		
		function Animacion(base) {
			this.base = base;
			this.cont = 0;
			this.carruselImg1 = true;			
			var strFotos = document.fotos.nomFotos.value; 
			var arrayNomFotos = strFotos.split(",");
			var strPies = document.fotos.nomPies.value; 
			var arrayNomPies = strPies.split(",");
			this.maximo = arrayNomFotos.length;
			this.inicia = function(){
											(function(){
													//Se incrementa el contador
													this.cont++;
													//al llegar al maximo, la animacion se inicia
													if (this.cont > this.maximo-1)
														this.cont = 0;
													var im = 'carruselImg1';												
													var prefix = arrayNomFotos[this.cont];
													var nPie = arrayNomPies[this.cont];
													if (this.carruselImg1) {
														this.carruselImg1 = false;
														im = 'carruselImg2';
													}else{
														this.carruselImg1 = true;
                          }
													//se asigna la nueva imagen a la capa que no se esta viendo
													$(im).style.backgroundImage = 'url('+this.base+'/'+prefix+')';
													if ((nPie != "") && (nPie != "<br>")){
														$(im).innerHTML = "<div class='pie'><span>"+nPie+"</span></div>";
													}
													//se desaparece la capa con la nueva imagen
													new Fx.Style(im, 'opacity').set(0);
													
													//esta funcion espera un segundo antes de hacer la transicion
													(function(){
													          //crea el efecto para las 2 capas
																		var x = new Fx.Style('carruselImg1', 'opacity');
																		var y = new Fx.Style('carruselImg2', 'opacity');
																		//aparece y desaparece las capas
																		if (this.carruselImg1) {
																			x.start(0,1);
																			y.start(1,0);
																		}else{
																			x.start(1,0);
																			y.start(0,1);
																		}
													}
											).delay(1000,this);
											}
										//este es el temporizador, se ejecutará cada 3 segundos
										).periodical(3000,this); 
			
									}
		}		
}
