/*--------------------------------------------------------------------------
 *  Banner Rotation, version 1
 *  (c) 2008 David Gutierrez
 *
 *  Banner Rotation is freely distributable under the terms of an .
 *  MIT-style license
 *
 *--------------------------------------------------------------------------*/

var Banner_Rotation = Class.create();
Banner_Rotation.prototype = {
  list: [],
  count: 0,
  time: 1,

  initialize: function(banner_id, time){
    this.list = $(banner_id).getElementsBySelector('li');
    time > 0 ? this.time = time : ""; 
    this.list.invoke('hide');
    this.list[0].show();
  },

  start: function(){
    new PeriodicalExecuter(this.showBanner.bind(this),this.time);
  },

  showBanner: function(el){
    this.list.invoke('hide');
    this.list[this.count].show();
    this.count >= this.list.length - 1 ? this.count = 0 : this.count++;
  }
};

/*

var banner = new Banner_Rotation('<Element ID>', <# of Seconds>);
banner.start();

*/

