if (!Kwo) var Kwo = {};

Kwo.Ea = {
  
  "overButton" : function(a){
    $(a).removeClassName('ieout');
    $(a).addClassName('ieover');
  },
  
  "outButton" : function(a){
    $(a).removeClassName('ieover');
    $(a).addClassName('ieout');
  },
  
  "Popup" : function(action){
    window.open(action, "_blank","toolbar=0, directories=0, status=0, menubar=0, width=600, height=400, scrollbars=0, location=0, resizable=0" );
  },
  
  "addFavoris" : function() {
    if ( navigator.appName != 'Microsoft Internet Explorer' ){
      window.sidebar.addPanel("Energies et Avenir",document.location.href,"");
    }else { 
      window.external.AddFavorite(document.location.href,"Energies et Avenir");
    } 
  },
  
  "timer" : null,
  "boxOpac0" : 2,
  "oldTextID" : 1,
  "position" : 1,
  
  "startInterval" : function(num){
    if (Kwo.Ea.timer !== null) {
      clearInterval(Kwo.Ea.timer);
    }
    var i = num;
    Kwo.Ea.timer = setInterval(function() {
      if (i == 4) i = 0;
      Kwo.Ea.timerHeader(++i);
    }, 4000); 
  },
  "display": function (id) {
    if (Kwo.Ea.timer !== null) {
      clearInterval(Kwo.Ea.timer);
    }
    Kwo.Ea.timerHeader(id);
  },
  "timerHeader" : function(id){
    var newID = parseInt(id) + 1;
    Kwo.Ea.position = id; 
    if(newID == 5) { newID = 1; };
    $$('.button_pagi_header').each(function(button) {
      button.removeClassName('selected');
    });
    if(Kwo.Ea.boxOpac0 === 2){
      var from = 2, to = 1;
    } else {
      var from = 1, to = 2;
    }
      
    $('menu_bg_box_' + from).className = '';
    $('menu_bg_box_' + from).addClassName('bg_header_' + id);
    
    if (Prototype.Browser.IE) {
      $('menu_bg_box_' + from).setStyle({'filter': 'alpha(opacity=0)'});
      $('menu_bg_box_' + to).setStyle({'filter': 'alpha(opacity=100)'});
    }
    emile('menu_bg_box_' + from, !Prototype.Browser.IE ? 'opacity:1' : 'filter:alpha(opacity=100)', {
      duration: 500
    });
    emile('menu_bg_box_' + to, !Prototype.Browser.IE ? 'opacity:0' : 'filter:alpha(opacity=0)', {
      duration: 500,
      after: function(){
        $('menu_bg_box_' + to).className = '';
        $('menu_bg_box_' + to).addClassName('bg_header_' + newID);
      }
    });
      
    Kwo.Ea.boxOpac0 = to;
    
    if (Prototype.Browser.IE) {
      $('content_header_' + id).setStyle({'filter': 'alpha(opacity=0)'});
      $('content_header_' + Kwo.Ea.oldTextID).setStyle({'filter': 'alpha(opacity=100)'});
    }
    if (id != Kwo.Ea.oldTextID){
      emile('content_header_' + id, !Prototype.Browser.IE ? 'opacity:1' : 'filter:alpha(opacity=100)', {
        duration: 500
      });
      emile('content_header_' + Kwo.Ea.oldTextID, !Prototype.Browser.IE ? 'opacity:0' : 'filter:alpha(opacity=0)', {
        duration: 500
      });
      Kwo.Ea.oldTextID = id;
    }
    $('bg_header_' + id).addClassName('selected');
  }
  
}
