function initNav(category,currentItem){

	try {
	// Affichage de la nav
	$('nav5').style.display = "block";	
	
	// on masque tous les éléments
	$$('#nav5 ul').each(function(elmt,i){
		elmt.hide();				
	});
	}catch(e){}
	
	try {
	// Affichage de la nav
	$('nav8').style.display = "block";
	
	// on masque tous les éléments
	$$('#nav8 ul').each(function(elmt,i){
		elmt.hide();
	});
	}catch(e) {}

/*
if(currentItem == 'videopap'){
	$(currentItem).ancestors()[1].addClassName('aqua');
	$(currentItem).ancestors()[1].show();
}
*/	// si on a passé le menu à déplier en paramètre
	if(category){
		
		// on déplie la catégorie
		$$('#'+category).each(function(elmt,i){
				
			if((currentItem)&&($(currentItem))&&($(currentItem).ancestors()[4].descendants()[0].id == category)){ elmt.ancestors()[0].addClassName("open"); // si l'item "allumé" est différent de rien, s'il existe effectivement dans le DOM et si son ancêtre est bien la catégorie passée en paramètre, alors on met l'ancêtre à "open"
			} else { 				
				if(currentItem =="")
					elmt.ancestors()[0].addClassName("on"); 
			}

			if (elmt.next('ul')) elmt.next('ul').show();
			
			if($(currentItem) && $(currentItem).descendants()[1]){
				$(currentItem).descendants()[1].show();
			}
			
		});
		//if(currentItem !='videopap'){
		// gestion des clicks
		$$('ul.withArrows li a').each(function(elmt,i){
			elmt.valClick = 0;
			if(elmt.next('ul')){
				if(elmt.id !='PAP2'){
					elmt.onclick = function() {return false;}
				}
				Event.observe(elmt, 'click', function(){
					$$('ul.withArrows li').each(function(elmt2,i){
						// tous les éléments à off
						elmt2.removeClassName("on");
					});
					elmt.ancestors()[2].removeClassName("on");
					elmt.ancestors()[2].addClassName("open");
					elmt.valClick++;

					if(elmt.valClick%2 != 0){
						// ouverture
						$$('ul.withArrows li a').each(function(elmt2,i){
							// cachage des autres éléments
							if(elmt2.next('ul')){
								elmt2.ancestors()[0].removeClassName("on");
								elmt2.ancestors()[0].removeClassName("open");
								elmt2.valClick = 0;
								elmt2.next('ul').hide();
							}
						});
						// ouverture du bon
						elmt.valClick = 1;
						elmt.ancestors()[0].addClassName("on");
						elmt.next('ul').show();						
					}
					else{
						// fermeture
						elmt.ancestors()[0].removeClassName("on");
						elmt.ancestors()[0].removeClassName("open");
						elmt.ancestors()[2].removeClassName("open");
						elmt.ancestors()[2].addClassName("on");
						elmt.next('ul').hide();
					}
					return false;
				});
			}
		});
		//}
		// ouverture du bon élément s'il est passé en parametre

		if((currentItem)&&($(currentItem))&&(
			($(currentItem).ancestors()[4].descendants()[0].id == category) || // ancêtre niveau 2
			($(currentItem).ancestors()[2].descendants()[0].id == category) // ancêtre niveau 1			
		)){			

			$(currentItem).ancestors()[2].addClassName("open");
			$(currentItem).ancestors()[2].descendants()[0].valClick = 1;
			$(currentItem).ancestors()[0].addClassName("on");
			$(currentItem).ancestors()[1].show();
			
			if($(currentItem).id =='PAP2'){
				$(currentItem).next('ul').show();
			}	
		}
		
	}
}

// gestion des pictos "sacs" gérés en théorie uniquement via CSS
// script pour pallier à une insuffisance CSS de IE6
function rollPictosSacs(){
	if((navigator.appName=="Microsoft Internet Explorer")&&(navigator.userAgent.indexOf("MSIE 6") != -1)){
		$$('#rolloverPictos ul li a').each(function(elmt,i){
			if(elmt.descendants()[0]){
				Event.observe(elmt, 'mouseover', function(){
					elmt.descendants()[0].style.display = 'block';
				});
				Event.observe(elmt, 'mouseout', function(){
					elmt.descendants()[0].style.display = 'none';
				});
			}
		})
	}
}

// gestion des pictos "lignes"
function rollPictosLignes(){
	if ($('rollOverLignes')){
		// on masque les images au load
		$('rollOverLignes').hide();
		$$('#rollOverLignes img').each(function(elmt,i){
			elmt.hide();
		});
		$$('#rolloverPictosLignes li a, #rolloverPictosLignes2 li a, #rolloverPictosLignes3 li a, #rolloverPictosLignes4 li a').each(function(elmt,i){
			Event.observe(elmt, 'mouseover', function(){
				$$('#rollOverLignes img').each(function(elmt2,i){
					elmt2.hide();
				});
				
				if ($('imgligne'+elmt.ancestors()[0].id)){ $('imgligne'+elmt.ancestors()[0].id).show();}
				else if($('img'+elmt.ancestors()[0].id)){ $('img'+elmt.ancestors()[0].id).show();}
				else{ $('imgligne00').show();}
				//Affichage de l'image
				$('rollOverLignes').show();
			});
			Event.observe(elmt, 'mouseout', function(){
				//Masquage de l'image
				$('rollOverLignes').hide();
			});
		})
		
		$('rollOverLignes').style.visibility = 'visible';
	}
	
	
	if ($('rollOverLignesWide')){
		// on masque les images au load
		$('rollOverLignesWide').hide();
		$$('#rollOverLignesWide img').each(function(elmt,i){
			elmt.hide();
		});
		// on rajoute les événements de roll
		Event.observe($('rolloverPictosLignes'), 'mouseover', function(){
			$('rollOverLignesWide').show();
		});
		Event.observe($('rolloverPictosLignes'), 'mouseout', function(){
			$('rollOverLignesWide').hide();
		});
		
		$$('#rolloverPictosLignes li a').each(function(elmt,i){
			Event.observe(elmt, 'mouseover', function(){
				$$('#rollOverLignesWide img').each(function(elmt2,i){
					elmt2.hide();
				});
				if ($('imgligne'+elmt.ancestors()[0].id)){ $('imgligne'+elmt.ancestors()[0].id).show();}
				else if($('img'+elmt.ancestors()[0].id)){ $('img'+elmt.ancestors()[0].id).show();}
				else{ $('imgligne00').show();}
			});
		})
		$('rollOverLignesWide').style.visibility = 'visible';
	}
	
}

function initNavItem(){}

Event.observe(window,"load",function() {
	if (nav5opened == "articles") rollPictosSacs();
	//else if ((nav5opened == "lignes")||(nav5opened == "produits")) rollPictosLignes();
	else rollPictosLignes();
	initNav(nav5opened,currentNav5Item);	
})