var Slideshow = new Class({

    Implements: [Options,Events],

    options: {
        slideSelector: '#rotator li img'
    },

    initialize: function(options) {
        this.setOptions(options);
        this.timer = $clear(this.timer);
        this.currentImage = 0;
        this.setSlides();
    },

    setSlides: function() {
        this.slides = $$(this.options.slideSelector);
        this.showSlide();
    },

    showSlide: function() {
        for (var i = 0; i < this.slides.length; i++) {
            if (i == this.currentImage) {
                this.slides[i].fade('in');
            } else {
                this.slides[i].fade('out');
            }
        }
        // go to the next image - if we're on the last one, go back to first one
        if (this.currentImage == this.slides.length-1) {
            this.currentImage = 0;
        } else {
            this.currentImage = this.currentImage+1;
        }
        this.timer = this.showSlide.delay(5000, this);
    }

});