// JavaScript Document

$(document).ready(function(){
	
	// Changement images bleues, grises pour les menus
	$("img.a").hover(
		function() {
			$(this).stop().animate({"opacity": "0"}, "slow");
		},
		function() {
			$(this).stop().animate({"opacity": "1"}, "slow");
		});
	
	// Clicks sur les éléments du menu principal
	$("img.a.main_menu_link").bind("click",
		function(evt) {		
			// Déplacement de la flèche
			$("img.a.main_menu_link:hidden").show();
			$(this).hide();
			var top = $(this).attr("rel") + "px";
			$("#main_menu_arrow").stop().animate({"top": top}, 500);
			// Disparition de l'ancien sous menu et apparition du nouveau sous menu
			submenu_id = $(this).attr("id").split("_")[1];
			$(".submenu").not("#"+submenu_id).fadeOut(250,function() {
				$(".wrap").not("#wrap_"+submenu_id).fadeOut(250, function() {
					$("#wrap_"+submenu_id).fadeIn(250);
					$("#wrap_"+submenu_id+" .wrap_content").not("#wrap_"+submenu_id+"_fadehover").fadeOut(250,function() {
						$("#wrap_"+submenu_id+"_fadehover").fadeIn(1000);
					});
				});
				$("#"+submenu_id+" img.a").show();
				$("#"+submenu_id+" img.a:first").css("display","none");
				$("#submenu_arrow").css("top",0);
				$("#"+submenu_id).fadeIn(1000);
			});
																	  
			
		});
	
	// Clicks sur les éléments du sous menu
	$("img.a.submenu_link").bind("click",
		function(evt) {		
			// Déplacement de la flèche
			$("img.a.submenu_link:hidden").show();
			$(this).hide();
			var top = $(this).attr("rel") + "px";
			$("#submenu_arrow").stop().animate({"top": top}, 500);
			fadehover_id = $(this).parent().parent().attr("class");
			submenu_id = $(this).parent().parent().parent().attr("id");
			$(".wrap_"+submenu_id).not("#wrap_"+submenu_id+"_"+fadehover_id).hide(); // (1500,function() {
				$("#wrap_"+submenu_id+"_"+fadehover_id).fadeIn(1000);
			//});
			
		});
});

