var i = 2;
var activeImage = 'slide1';
var nroImages = 3;
var tiempoCambio = 7000;
var valocidadOpacidad = 1100;

window.addEvent('domready', function(){

	var initialise = $(activeImage).setStyles({display:'block',opacity: 0});
	new Fx.Style(initialise, 'opacity', {duration: valocidadOpacidad} ).set(1);
	setInterval("cambiaSlide()", tiempoCambio);
	
});

function transitionImage(oldImage,newImage){

	var fadeOut = function(){
	
		var div = $(oldImage).setStyles({opacity: 1});
		new Fx.Style(div, 'opacity', {duration: valocidadOpacidad}).start(0);
		fadeIn();
		
	};	
	
	var fadeIn = function(){
	
		var div2 = $(newImage).setStyles({display:'block',opacity: 0});
		new Fx.Style(div2, 'opacity', {duration: valocidadOpacidad}).start(1);
		
	};
	
	if(newImage != activeImage){
	
		fadeOut();
		activeImage = newImage;
		
	}
	
}
function cambiaSlide(){	
	var newImage = 'slide'+i;
	transitionImage(activeImage,newImage);
	i==nroImages?i=1:i++;
};	
