if(!console) {
	var console={
		log: function(oObj) {alert(oObj);}
	};
}
MenuHaut = Base.extend({
	constructor: function(oConfig) {
		this.config = oConfig;

		this.aLi = $$(this.config.menuitems);
		this.aLi.each(function(oLi, i) {
			li = oLi.select('ul').first();
			if(li != undefined){
				oLi.Savedheight = li.getHeight();
				new Effect.BlindUp(li,{
					duration : 0.4,
					afterFinish:function(){
						this.setStyle({
							left: '0px'	
						});
					}.bind(li)
				});
				Event.observe(
					oLi,
					"mouseenter",
					function(event) {
						subMenu = this.select('ul').first();
						//console.log('enter');
						//console.log(this.Savedheight);
						if(this.oEffectUp != undefined){
							this.oEffectUp.cancel();
							subMenu.setStyle({
								height: ''+this.Savedheight+'px'
							});
						}
						this.oEffectDown = new Effect.BlindDown(subMenu,{
							duration : 0.4
						});
					}.bindAsEventListener(oLi)
				);

				Event.observe(
					oLi,
					"mouseleave",
					function(event) {
						subMenu = this.select('ul').first();
						//console.log('leave');
						//console.log(this.Savedheight);
						if(this.oEffectDown != undefined){
							this.oEffectDown.cancel();
							subMenu.setStyle({
								height: ''+this.Savedheight+'px'
							});
						}
						this.oEffectUp = new Effect.BlindUp(subMenu,{
							duration : 0.3
						});
					}.bindAsEventListener(oLi)
			);
			}
		});
	}
});

$(document).observe("dom:loaded", function() {
	new MenuHaut({
		"menuitems": "#menu_niv1 > LI"
	});
});

