window.addEvent('domready', function() {
	// Gestion du survol des sous-menu sous IE	
	if(Browser.Engine.trident) {
		IDSubMenu=$$('.submenu');
		for (I=0; I<IDSubMenu.length; I++){
			IDSubMenu[I].addEvent('mouseenter', function(){
					// Changement couleur de fond de la boite
					this.setStyle('background-color' ,'white');
			}.bind(IDSubMenu[I]));
			IDSubMenu[I].addEvent('mouseleave', function(){
					// Changement couleur de fond de la boite
					this.setStyle('background-color' ,'#eeb326');
			}.bind(IDSubMenu[I]));
		}
	}


	Menu = new Class({
		initialize: function(IDObjet) {
			// Init
			this.backheight=77;
			// Récupération des infos et stockage dans la classe
			this.ID=IDObjet;
			this.SSMenu = this.ID.getElement('.ssmenu');
			// Récupération de la hauteur de l'en-tête du menu
			this.h1 = this.ID.getElement('h1');
			this.h1_height=this.h1.getHeight();
			// Correction de la hauteur des menus
			this.ID.setStyle('height',this.backheight+this.h1_height);
			this.FxMenuIn = new Fx.Tween(this.ID,{duration:150,link:'cancel'});
			this.FxMenuOut = new Fx.Tween(this.ID,{duration:450,link:'cancel'});
			//this.FxSSMenuLeave = new Fx.Tween(this.SSMenu,{duration:250,link:'cancel'});
			// Activation des evènements
			this.ID.addEvent('mouseenter', function(){
				// Annulation des effets en cours
				this.FxMenuOut.cancel();
				// Changement couleur de fond de la boite
				this.ID.setStyle('background-color' ,'#eeb326');
				this.h1.setStyle('color','white');
				this.FxMenuIn.start('height',this.backheight+this.h1_height+this.SSMenu.getHeight()+7);
				this.SSMenu.fade('1');
			}.bind(this));
			this.ID.addEvent('mouseleave', function(){
				this.ID.setStyle('background-color' ,'white');
				this.h1.setStyle('color','#780000');
				this.FxMenuOut.start('height',this.backheight+this.h1_height);
				this.SSMenu.fade('0');
			}.bind(this));
		}	
	});
	
	ID_Objets = $$('.menu');
	for (I=0; I<ID_Objets.length; I++) {
		new Menu(ID_Objets[I]);
	}

});
