Slideshow = Class.create();
Slideshow.prototype = {
  initialize: function(slides, options) {
    this.options = $H({ delay: 5, duration: 1, fade: true }).update(options);
    this.slides = slides;
    this.slides.slice(1).invoke('hide');
    this.current = 0
  },
  
  start: function() {
    setInterval((function() { this.next(); }).bind(this), (this.options.get('delay') + this.options.get('duration')) * 1000.0);
  },
  
  next: function() {
    previous = this.current
    this.current += 1;
    if (this.current >= this.slides.size()) {
      this.current = 0;
    }
    if (this.options.get('fade')) {
      new Effect.Fade(this.slides[previous], {duration: this.options.get('duration'), fps: 15});
      new Effect.Appear(this.slides[this.current], {duration: this.options.get('duration'), fps: 15});
    } else {
      this.slides[previous].hide();
      this.slides[this.current].show();
    }
  }
};

