$(document).ready(function()
{
	initDrop();
    $("ul.sf-menu").superfish({ 
            pathClass:  'current' 
        }); 
		
$("ul.sf-menu2").superfish({ 

        }); 		
})

function initDrop()
{
	//Recherche la page courante pour sélectionner le parent dans le menu
	var posDernier = window.location.pathname.lastIndexOf('/');
	var pageCourrante;
	if (posDernier == window.location.pathname.length-1)
	{
		posDernier--;
		pageCourrante = window.location.pathname.substring(window.location.pathname.lastIndexOf('/', posDernier) + 1, posDernier + 1);
	}
	else
	{
		posDernier++;
		pageCourrante = window.location.pathname.substring(posDernier);
	}
	var nodes = document.getElementById("subnav").getElementsByTagName("li");
	var sousNodes, lien, lienParent;
	var trouvePage = 0;

	for (var i=0; i<nodes.length; i++)
	{
		sousNodes = nodes[i].getElementsByTagName("li");
		//met le lien de l'enfant dans le parent
		if (sousNodes.length > 0)
		{
			lien = sousNodes[0].getElementsByTagName("a");
			lienParent = nodes[i].getElementsByTagName("a");
			if (lienParent.length > 0 && lien.length > 0)
			{
				lienParent[0].href = lien[0].href;
			}
		}
		if (trouvePage == 0)
		{
			for (var j=0; j<sousNodes.length; j++)
			{
				lien = sousNodes[j].getElementsByTagName("a");
				if (lien.length > 0)
				{
					//sélectionne le parent de la page courante
					if (lien[0].href.indexOf(pageCourrante) > -1)
					{
						nodes[i].className += " current";
						sousNodes[j].className += " current";
						trouvePage = 1;
						break;
					}
				}
			}
		}
	}
}
