window.addEvent('domready', function() {
	
	var voscommerces = $('menu-vos-commerces');
	var sousmenu = $('sous-menu-vos-commerces');
	if (window.ie) {
		var height = (sousmenu.getStyle('height').toInt())-15;
	}
	else {
		var height = sousmenu.getStyle('height').toInt();
	}
	if(voscommerces.hasClass("selection")) {
		sousmenu.setStyles({height:height, opacity: 1, display: 'block'});
	}
	else {
		sousmenu.setStyles({height: 0, opacity: 0, display: 'none'});
	}
	
	var list = $$('#menu-principal li.onglet');
	list.each(function(element) {
	 
		var fx = new Fx.Styles(element, {duration:200, wait:false, transition: Fx.Transitions.Sine.easeInOut});
	 
		element.addEvent('mouseenter', function(){
			fx.start({
				'padding-left': 28
			});
		});
	 
		element.addEvent('mouseleave', function(){
			fx.start({
				'padding-left': 15
			});
		});
	 
	});
	voscommerces.addEvent('click', function(event){
		var event = new Event(event).stop();
		var disp = sousmenu.getStyle('display');
		
		if(disp == 'block') {
			sousmenu.effects({duration: 250, onComplete: function(){sousmenu.setStyle('display', 'none')}}).start({height: 0, opacity : 0});
		}
		else {
			sousmenu.setStyle('display', 'block');
			sousmenu.effects({duration: 250}).start({height:height, opacity:1});
		}
	});
});