$(document).ready( 
function() 
 {
	var timeout    = 400;
	var closetimer = 0;
	var ddmenuitem = 0;
	function nav_open()
	{  nav_canceltimer();
	   nav_close();
	   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}
	   function nav_close()
		{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}
		   function nav_timer()
			{  closetimer = window.setTimeout(nav_close, timeout);}
				function nav_canceltimer()
				{  if(closetimer)
					{  window.clearTimeout(closetimer);
						closetimer = null;}}
						$(document).ready(function()
						{  
							if( $('#nav').hasClass('nav1'))
							{
								$('.nav1 > li').bind('mouseover', nav_open)
								$('.nav1 > li').bind('mouseout',  nav_timer)
							}
							else
							{
								$('.nav2 > li').bind('mouseover', nav_open)
								$('.nav2 > li').bind('mouseout',  nav_timer)
							}
						});
							
							
						    document.onclick = nav_close;
});

$(document).ready( function () { 
	var pathname = window.location.pathname;
	
	if ( pathname == "/boutique/adm_coordonnees~tag~profil.html")
	{
		$("ul#subMenu1").addClass("open_at_load1");
	}
	
	if ( pathname == "/boutique/adm_boutique~tag~boutique.html" || pathname == "/boutique/adm_theme~tag~boutique.html" || pathname == "/boutique/adm_presentation~tag~boutique.html"
	|| pathname == "/boutique/adm_referencement~tag~boutique.html" || pathname == "/boutique/adm_statistiques_boutique~tag~boutique.html" 
	|| pathname == "/boutique/adm_accesprive~tag~boutique.html")
	{
		$("ul#subMenu2").addClass("open_at_load2");
	}
	
	if ( pathname == "/boutique/adm_produit~tag~produit.html" || pathname == "/boutique/adm_gestion_produit~tag~produit.html" || pathname == "/boutique/adm_produit_ligne~tag~produit.html"
	|| pathname == "/boutique/adm_acceder_exterieur~tag~produit.html")	
	{
		$("ul#subMenu3").addClass("open_at_load3");
	}
	
	if ( pathname == "/boutique/mesventes~tag~vente.html" || pathname == "/boutique/detail_ventes~tag~vente.html" || pathname == "/boutique/detail_commissions~tag~vente.html" 
	|| pathname == "/boutique/statistiques_ventes~tag~vente.html")
	{	
		$("ul#subMenu4").addClass("open_at_load4");
	}
	
	if ( pathname == "/boutique/adm_aide~tag~aide.html")
	{
		$("ul#subMenu5").addClass("open_at_load5");
	}

   // On cache les sous-menus 
	// sauf celui qui porte la classe "open_at_load" : 
	$(".navigation ul#subMenu1:not('.open_at_load1')").hide(); 
	$(".navigation ul#subMenu2:not('.open_at_load2')").hide(); 
	$(".navigation ul#subMenu3:not('.open_at_load3')").hide(); 
	$(".navigation ul#subMenu4:not('.open_at_load4')").hide(); 
	$(".navigation ul#subMenu5:not('.open_at_load5')").hide(); 
 // On sélectionne tous les items de liste portant la classe "menu_compte_boutique"  
	// et on remplace l'élément span qu'ils contiennent par un lien : 
	$("ul.navigation li.menu_compte_boutique span").each( function () { 
		// On stocke le contenu du span : 
		var TexteSpan = $(this).text();
		var Lien = "#"; 		
		if (TexteSpan == "Mon profil") {Lien = "/boutique/adm_coordonnees~tag~profil.html"; }
		if (TexteSpan == "Ma Boutique") {Lien = "/boutique/adm_boutique~tag~boutique.html"; }
		if (TexteSpan == "Mes Produits") {Lien = "/boutique/adm_produit~tag~produit.html";}
		if (TexteSpan == "Mes Ventes") {Lien = "/boutique/mesventes~tag~vente.html";}
		if (TexteSpan == "Aide") {Lien = "/boutique/adm_aide~tag~aide.html";}
		$(this).replaceWith('<a class="compte_boutique" href="'+ Lien +'" title="Afficher le sous-menu">' + TexteSpan + '<\/a>') ; 
	} ) ; 
} ) ;
