var SlideShow = function() {
    var index = 0;
    var timer;

    return {
        init: function() {
            var slides = $$('#slideshow li');

            for (var i = 1; i < slides.length; i++) {
                Element.hide(slides[i]);
            }

            SlideShow.start();
        },
        start: function() { timer = window.setTimeout('SlideShow.nextSlide()', 5000); },
        nextSlide: function() {
            var slides = $$('#slideshow li');
            var nextSlideIndex = (index + 1) % (slides.length);

            new Effect.toggle(
				slides[index], 'appear', {
				    duration: 0.75,
				    afterFinish: function() {
				        new Effect.toggle(
							slides[nextSlideIndex], 'appear', { duration: 0.3 });
				    }
				});

            index = nextSlideIndex;
            timer = window.setTimeout('SlideShow.nextSlide()', 5000);
        },
        stop: function() { window.clearTimeout(timer); index = 0; }
    };
} ();