var carousels = new Array();

document.observe("dom:loaded", function(){
	$$(".carousel").each(function(element){
		var car = new UI.Carousel(element);
		carousels.push(car);
	});
	new PeriodicalExecuter(switchSlide, 4);
	
});

function switchSlide(){
	carousels.each(function(element){
		if(!element.animating && !element.clickUsed){
			if(element.currentIndex()==(element.elements.length-1)){
				element.scrollTo(0);
			}else{
				element.scrollTo(element.currentIndex()+1);
			}
		}
	});
}
