
PeriodicalExecuter.prototype.registerCallback = function() {
	this.intervalID = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
}

PeriodicalExecuter.prototype.stop = function() {
	clearInterval(this.intervalID);
}

var pe = null;
var album = {
  startup: function() { 
    pe = new PeriodicalExecuter(album.cycle, 5) // change image every 5 seconds 
  }, 
  start: function() {
      if (pe != null) { pe.registerCallback(); }
  },
  cycle: function() {
    pe.stop();
    new Effect.Fade('picture-thumbnail-img', { // the id of the <DIV> containing the photos 
      duration: 1, 
      fps: 50, 
      afterFinish: function() { 
          new Ajax.Updater('picture-thumbnail-img','/authors/get_next_thumbnail', {
          asynchronous: true }) 
      } 
    }) 
  },
  stop: function() { 
    pe.stop(); // stop the slideshow 
  }
} 
