var activeMenu=0;
window.addEvent("domready", function(){
  $$('div#content_droite_accueil').removeClass('content_droite_accueil');
  if ($('content_droite_accueil')) {
    var lesli = $('content_droite_accueil').getChildren();  
    var xl = yl = 0;
    for (xl=1; xl<=lesli.length; xl++){ 
      var emballage = new Element('div', {'class':'emballage'});
      var clearer = new Element('div', {'class':'clr'});
      var pickwraped = lesli[xl-1].getChildren().dispose();
      emballage.adopt(pickwraped);
      emballage.adopt(clearer);
      lesli[xl-1].adopt(emballage);
      lesli[xl-1].addEvent("mouseenter", function(){
        for (yl=1; yl<=lesli.length; yl++){                
            lesli[yl-1].morph('.menu2short',{duration:'short'});
        }
        this.morph('.menu2hover',{duration:'short'});        
      });
      lesli[xl-1].addEvent("mouseleave", function(){
        for (yl=1; yl<=lesli.length; yl++){
          lesli[yl-1].morph('.menu2normal',{duration:'short'});        
        }
      });
    }
  }
  // patch menus
  $$('#menu_principal li').each(function(unli){  
    unli.addEvent('mouseenter', function(){
      this.addClass('hover');
    });
    unli.addEvent('mouseleave', function(){
      this.removeClass('hover');
    });
  });
  // slideshow actualités
  sshow = new slideShow( $$('.roknewsflash li') ); 
  sshow.next.periodical( 3000, sshow );
  // flash d'accueil
  if ($('diagramme')) {
    var lea = $$('#diagramme a')[0];
    var flashvars = {
      clickTag: lea.href,
      innerText: lea.get('text'),
      langa: $$('html')[0].getAttribute('lang')
    };  
    // pour l'instant on n'a pas de flash
	if (typeof(swfobject) !='undefined') {
		swfobject.embedSWF("flash/accueil.swf", "diagramme", "310", "265", "9.0.0","",flashvars,{},{});
	}
  } 
});

function slideShow( Obj ){   
    var pass = this;    
    this.curLi = 0;  
    this.slides = Obj;  
    this.slides.each( function( leli, index ){   
        if( index > 0 ) leli.fade();   
        leli.set('morph', { duration: 'long' });  
    }, this);  
    this.next = function(){  
        pass.curLi++;  
        this.slides.each( function( leli, index ){   
            leli.morph({ opacity: 0 });  
        }, this);  
        if( pass.curLi == this.slides.length ) pass.curLi = 0;  
        this.slides[ pass.curLi ].morph({ opacity: 1 });  
    }  
    this.prev = function(){  
        pass.curLi--;  
        this.slides.each( function( leli, index ){   
            leli.morph({ opacity: 0 });  
        }, this);  
        if( pass.curLi < 0 ) pass.curLi = this.slides.length - 1;  
        this.slides[ pass.curLi ].morph({ opacity: 1 });  
    }  
}

