// javascript by posttoast, 2008 (http://www.posttoast.nl)

var slideShow = new Class({
 
  options: {
    slideshow_id: "",
    duration: 3000, // Time between slide in ms
    slidePrefix: "slide_"
  },
 
  initialize: function(options){
    this.setOptions(options);
    this.slideImg = $(this.options.slideshow_id).getElements('div'); 
    this.slideImg.setStyle('display', 'none');
    this.current = 0;
    this.numImg = this.slideImg.length;
    this.start();
  },
 
  initSlideshow: function(){
      this.slideImg[this.current].setStyle('display', 'block');
      this.slideImg[this.current].setStyle('opacity', '0');
      this.slideImg[this.current].fade('in');

    this.slideImg.each(function(el, j){
      if (j != this.current) {
        el.setStyle('display', 'none');
      }
    }.bind(this));
    this.previous = this.current;
    this.current ++;
    if (this.current == this.numImg) this.current = 0;

    this.cycleForward = this.initSlideshow.delay(this.options.duration, this);
  },

  stopSliding: function(){
    $clear(this.cycleForward);
  },

  start: function(){
    this.initSlideshow();
  }

});

slideShow.implement(new Options);