var SlideShow = Class.create();
SlideShow.prototype = 
{
  i: 0,
  cyclelen: 2,
  slidelen: 2,
  
  initialize: function(id, cyclelen, slidelen)
  {
  		this.id = id;
  		this.cyclelen = cyclelen;
  		this.slidelen = slidelen;
  		
  		this.fotos = document.getElementsByClassName("slide", $(id));
  		this.length = this.fotos.length;
  		
	    new PeriodicalExecuter(this.cycle.bind(this), this.cyclelen);
  },
  
  cycle: function()
  {
    oldel = this.fotos[this.i];

    this.i++;
	if (this.i == this.length) this.i = 0;
    
	newel = this.fotos[this.i];

    //alert("Changing "+oldid+" to "+newid);
    
  	new Effect.Fade(oldel, {
      duration: this.slidelen,
      fps: 50
     });

    new Effect.Appear(newel, {
              duration: this.slidelen,
              fps: 50
    });
  }
}
