

GW.header = {

  list: [ 'pepp', 'punktgenau', 'roeschitz', 'selektion', 'altereben' ],

  _currentIndex: 0,

  random: function() {
    this._currentIndex = Math.round(Math.random() * (this.list.length - 1));
    this.updateImage();
  },

  next: function() {
    this._currentIndex = (this._currentIndex + 1) % this.list.length;
    this.updateImage();
  },
  
  previous: function() {
    this._currentIndex = this._currentIndex == 0 ? this.list.length - 1 : this._currentIndex - 1;
    this.updateImage();
  },

  updateImage: function() {
    $('c-header').setStyle({ backgroundImage: 'url("assets/images/headers/header.' + this.list[this._currentIndex] + '.jpg")' });
  }
  
};


document.observe('dom:loaded', function() { GW.header.random(); });
