/**
 * Header
 */
var Header = Class.create({
  /**
   * Init Header
   */
  initialize: function(containerElem) {
    this.containerElem = containerElem; 

		this.arrText = new Array();
		this.nText = -1;
    
    var textElements = this.containerElem.select(".headertext");
    for (var nText = 0; nText < textElements.length; nText++) {
      textElements[nText].setOpacity(0);
      this.arrText.push(textElements[nText]);
    }
  },
  
  startup: function() {
    this.showText();    
  },
  
  showText: function() {
	  if (this.nText > -1) {
	    var effectOff = new Effect.Opacity(this.arrText[this.nText], { from: 0.99, to: 0, duration: 2 });
	  }
    if (this.nText+1 > this.arrText.length-1) {
      this.nText = 0;
    }
    else {
      this.nText++;
    }
    
    this.arrText[this.nText].style.display = "inline";    
	  var effectOn = new Effect.Opacity(this.arrText[this.nText], { from: 0, to: 0.99, duration: 2, afterFinish: this.textReady.bind(this) });    
  },
  
  textReady: function() {
    this.showText.bind(this).delay(3);
  }
  
});
