window.addEvent('domready', function(){ 
									 
	var lista = document.getElementById("carrusel-lista");
	
	if(lista){
		var elem_lista = lista.getElementsByTagName("li");
		var imagenes = lista.getElementsByTagName("img");
		var len = 0;
		var imagen_margen = 16;
		var imagen_width = 0;
		var n_imagenes = 0;
		
		for(var i=0; i < imagenes.length; i++){
			len += parseInt(imagenes[i].width);		
			len += parseInt(imagen_margen);
			imagen_width = imagenes[i].width;
			n_imagenes++;
		}
		
		len += (imagen_width) + 34;	
		lista.style.width = len + "px";
	
		  var totIncrement		= 0;
		  var increment			= imagen_width+imagen_margen;
		  var maxRightIncrement	= increment*(-5);
		  var fx = new Fx.Style('carrusel-lista', 'margin-left', {
					duration: 500,
					transition: Fx.Transitions.Back.easeInOut,
					wait: true
		   });
		   
		   //-------------------------------------
		  // EVENTS for the button "previous"
		  $('previous').addEvents({ 
			  'click' : function(event){ 
			  if(totIncrement<0){
						totIncrement = totIncrement+increment;
						fx.stop()
						fx.start(totIncrement);
					}
				}			  	  
		  }); 
		 
		   //-------------------------------------
		  // EVENTS for the button "next"
		  $('next').addEvents({ 
			  'click' : function(event){ 
				 if(totIncrement>maxRightIncrement){
					 totIncrement = totIncrement-increment;
					fx.stop()
					fx.start(totIncrement);
				}
			  }		  		  
		  })

	}
});

