window.addEvent('domready',function() {
	prepareCarousel();
});

var prepareCarousel = function()
{
	var carousel = $$('.carousel')[0];
	
	if (carousel)
	{
		var buttonList = new Element('ul').addClass('carousel-buttons');
		buttonList.inject( carousel );
		
		var slides = $$('.carousel .carousel-slide');
		slides.each(
			function(slide,slidenum)
			{
				slide.setStyles({
					'position': 'absolute',
					'top': '0',
					'left': '0'
				});
				var buttonnum = slidenum+1;
				var button = new Element('li',{'html': '<span>'+buttonnum+'</span>','class': 'carousel-button'});
				if (slidenum===0) { button.addClass('carousel-button-first'); }
				button.inject( buttonList );
			}
		);
		
		new SimpleCarousel( carousel, slides, buttonList.getChildren(), {
			rotateAction: 'click',
			transitionDuration: 1000,
			slideInterval: 6000,
			rotateActionDuration: 300
		});
		
	}
}


/*

OLD
---

function old_startSlideshow() {
	
	var container	= $$('.slideshow ul')[0];
	var slides		= $$('.slideshow ul li');
	var buttons		= slides;
	var options		= {
		'slideInterval':		4000,
		'transitionDuration':	2000
	};
	
	if (container && slides.length>1) {
		new SimpleCarousel(container, slides, buttons, options);
	}
	
}

*/
