var slideshow = { 
	
  startup: function() {
    images = $("slideshow").select('li');
    current_image = images.first();
    i = 0;
    new PeriodicalExecuter(slideshow.cycle, 15) // change image every 15 seconds 
  },

  cycle: function() {
    new Effect.Fade(current_image, { // the current image 
      duration: 1, 
      fps: 50
    });
      // afterFinish: function() { 
        slideshow.check_next();
        new Effect.Appear(next_image, { // the new image 
          duration: 1,
          fps: 50
        });
      // } 
    // }) 
  },
  
  check_next: function(){
    i++
    if( current_image == images.last()){
      next_image = images.first();
      i = 0;
    } else {
      next_image = images[i];
    }
    current_image = next_image;
  }
   
} 
  
window.onload = slideshow.startup;