$(function(){
	// Ajout d'un div pour la gestion du fondu des a:hover du menu principal
	$("ul#nav li a").append('<div class="hover"><\/div><div class="subclick"><\/div>');

	$("ul#nav li ul.subnav").prepend('<div class="subnavB"></div>');

	// quand on clique sur un bouton pour les menus déroulants
	$("ul#nav li a.main").click(function() {		
		// Effet de fondu sous menu (ou slideUp / slideDown)
		$(this).parent().find("ul.subnav").fadeIn(200).show(); //on affiche le sous menu qd on click
		//$(this).parent().find(".subnavB").fadeIn(400).show();
		
		/* fondu sortant du HOVER */
		$(this).children('.hover').fadeOut(400);
		
		/* fondu entrant du CLICK */
		$(this).children('.hover').fadeIn(400);
		
		$(this).parent().hover(function() {
		}, function (){	/* action lorsque l'on sort du sous menu */
				$(this).parent().find("ul.subnav").fadeOut(400); // quand on sort du ss menu, fondu sortant
				$(this).parent().find('.subclick').fadeOut(400); // fondu btn menu principal
		});
		

		//Mouseover menu principal
		}).hover(
		
		//Mouseover
			function() {	
			// fondu entrant
			$(this).children('.hover').fadeIn(400);	
			
		}, function(){	// on hover out -> fondu sortant
			$(this).children('.hover').fadeOut(400);
		});


	// quand on clique sur un bouton pour les menus déroulants
	$("ul#nav li a.btn-sub").mouseover(function() {		
		// Effet de fondu sous menu (ou slideUp / slideDown)
		$(this).parent().find("ul.subnav").fadeIn(400).show(); //on affiche le sous menu qd on click
		//$(this).parent().find(".subnavB").fadeIn(400).show();
		
		/* fondu sortant du HOVER */
		$(this).children('.hover').fadeOut(400);
		
		/* fondu entrant du CLICK */
		$(this).children('.subclick').fadeIn(400);
		
		$(this).parent().hover(function() {
		}, function (){	/* action lorsque l'on sort du sous menu */
				$(this).parent().find("ul.subnav").fadeOut(400); // quand on sort du ss menu, fondu sortant
				$(this).parent().find('.subclick').fadeOut(400); // fondu btn menu principal
		});
		

		//Mouseover menu principal
		})
		
		/*.hover(
		
		//Mouseover
			function() {	
			// fondu entrant
			$(this).children('.hover').fadeIn(400);	
			
		}, function(){	// on hover out -> fondu sortant
			$(this).children('.hover').fadeOut(400);
		});*/

});

