// Fonctions dreamweaver permattant le rollOver-rollOut des images
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Fonction permettant de gérer le listener de keydown dans les forms pour tous les navigateurs
function onkeydown_enter() {
    if(window.addEventListener){
        window.addEventListener('onkeydown', EventHandler_KeyDown, true);
    } else if(window.attachEvent){
        window.attachEvent('onkeydown', EventHandler_KeyDown);
    }
}
// Fonction permettant de ne pas envoyer de formulaire sur un keydown d'un textarea
function EventHandler_KeyDown()
{
	if( event.keyCode == 13
		&& event.srcElement.type != 'textarea'
		&& event.srcElement.type != 'text'
		&& event.srcElement.type != 'submit')
	{
		return false;
	} else {
		return true;
	}
}

var g_idBloc 

function changeIdBloc(idBloc){
	g_idBloc = idBloc;
}

// Permet de mettre le focus sur le premier input[type="text"] dans la page popup.aspx
function focusCursor() {
	for (var i = 0; i < document.forms.length; ++i) {
		var f = document.forms[i];
		for (var j = 0; j < f.elements.length; ++j) {
			if (f.elements[j].type == 'text' || f.elements[j].type == 'select') {
				try {
					f.elements[j].focus();
					return;	
				} catch (e) { }
				}
			}
		}
}

// Fonction appellée sur les boutons d'aide généraux et permet d'effectuer le DropDownHelp
function wipeRow(elId) {
	($("#"+elId).css("display") == "none") ? $("#"+elId).show() : $("#"+elId).hide();
}

// initialise le menu de lien
// voir les différentes configs : http://www.gmarwaha.com/jquery/jcarousellite/
function initQmenu(id, jsonParams) {
	$(function() {
		$("#"+id + " .axm_qmenu_carousel").jCarouselLite(jsonParams);
	});
}

///Script de redimentionnemnt de la fenêtre selon son contenu
function resizeWin() {
    bod = document.getElementById('BodyId');
	hgth = bod.offsetHeight+90;	
	wdth = bod.offsetWidth+27;
	
	//Le OffsetWidth de Mozilla est différent de IE
	if(navigator.appName == "Microsoft Internet Explorer") {
		wdth = wdth + 2;
	} 
	if (wdth >= 1010) { wdth = 1010; }
	if(hgth >= 768) { hgth = 768; }
	
	if(hgth < 600 || wdth < 660) {
		//Si au moins un div avec la classe 'div_overlay' est présent : on a un overlay panel dans le code
		var elArrayByClassName = getElementsByClassNameAndElementType('div_overlay', 'div');
		if(elArrayByClassName.length > 0) {
			//On ajuste la hauteur minimale
			if(hgth < 600) { hgth = 600; }
			//On ajuste la largeur minimale
			if(wdth < 660) { wdth = 660; }
		}
	}
	
    // DÉBUT : Permet d'aller chercher les paramètres de la querystring
    //         et si action=3,4ou5 affichage complet en hauteur
    var strReturn = ""; 
    var strParamName = "action"; // Paramètre à aller chercher
    var strHref = window.location.href;
    if (strHref.indexOf("?")>-1){
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
            if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
             }
         }
    }
    if (strReturn==3 || strReturn==4 || strReturn==5) { // 3:Supersections, 4:Sections, 5:Pages
        self.moveTo(0,0);
	    hgth=screen.availHeight; // Calcul la hauteur de la fenêtre
    }
    // FIN
    
	try { window.resizeTo(wdth,hgth); } 
	catch(e) { 
		//The window isn't ready
		var cnt = 0;
		if(arguments != null && arguments[0] != null) { 
			//incrementation du compteur
			cnt = arguments[0]+1; 
	} 
		//If its been less than 10 tries we recall the function (10sec)
		if(cnt < 10) { 
			setTimeout("resizeWin("+ cnt +")", 1000); 
		} 
	}
}

//Show hide an item
function toogleDisplay(elName) {
	($("#"+elName).css("display") == "none" || $("#"+elName).css("display") == "" ) ? $("#"+elName).show() : $("#"+elName).hide();
}

function toogleDisplaySetPermanentState(elName) {
	elementToToogle = document.getElementById(elName);
	if(elementToToogle != null) {
		if(elementToToogle.style.display == 'none' || elementToToogle.style.display == '' ) {
			elementToToogle.style.display = 'block';
			SetCookie(elName, 'True', false, '', '', false);
		} else {
			elementToToogle.style.display = 'none';
			SetCookie(elName, 'False', false, '', '', false);
		}
	}
}


function OpenDocumentsActionsBox(tdDropdown, divDocumentActions) {
	var tdDropdownToOpen = document.getElementById(tdDropdown);
		
	/* Fermeture de tout les Dropdowns ouverts */
	$(".doc_list_dropdown_opened").removeClass("doc_list_dropdown_opened").addClass("doc_list_dropdown");
	$(".doc_list_actions_box").css("display", "none");
			
	/* Ouverture finale du Dropdown et de sa boîte d'actions */
	PositionDocumentBox(divDocumentActions, tdDropdown);
	toogleDisplay(divDocumentActions);
		
	if(tdDropdownToOpen != null) 
			{
		if(tdDropdownToOpen.className == 'doc_list_dropdown')
			tdDropdownToOpen.className = 'doc_list_dropdown_opened';
		else if(tdDropdownToOpen.className == 'doc_list_dropdown_opened')
			tdDropdownToOpen.className = 'doc_list_dropdown';
	}	
}

function getElementsByClassName(findClass) {
	return getElementsByClassNameAndElementType(findClass, '*')
}

function getElementsByClassNameAndElementType(findClass, elmntType) {
	var elArrayByClassName = new Array();
				
	if(elmntType == null || elmntType == "") {
		var aElm = document.body.getElementsByTagName('*');
	} else {
		var aElm = document.body.getElementsByTagName(elmntType);
	}
					
	var x = 0;
	for(var i=0; i<aElm.length; i++) {
		if(aElm[i].className == findClass) {
			elArrayByClassName[x] = aElm[i].id;
			x++;
					}
	}
					
	return elArrayByClassName;
}

function PositionDocumentBox(elName, anchorName) {
	
	//positionnement
	var pos = $("#"+anchorName).position();
	var div = $("#"+elName);
	div.css("top", pos.top+$("#"+anchorName).height() + "px" );
	div.css("left", pos.left - div.width() + $("#"+anchorName).outerWidth()+ "px" );
}

/*Fonction Recherche*/
function setSearchFocus(txtBoxId) { 
	var txtbox = document.getElementById(txtBoxId);
	if(txtbox != null && txtbox.value != '') {
		txtbox.value='';
				}
}

function setSearchDefaultValue(txtBoxId, str) {
	var txtbox = document.getElementById(txtBoxId);
	if(txtbox != null && txtbox.value == '') {
		txtbox.value = str;
				}
}

function showHide(STR_ID,STR_ACTION) {
	document.getElementById(STR_ID).style.display = STR_ACTION;
}

//Permet de cocher ou decoccher tous les checkbox d'un container
function setAllCheckBoxes(areaID, isChecked) {
	var objCheckBoxes = document.getElementById(areaID).getElementsByTagName('input');
	if(!objCheckBoxes) { return; }
	
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes) {
		objCheckBoxes.checked = isChecked;
	} else {
		for(var i = 0; i < countCheckBoxes; i++) {
			objCheckBoxes[i].checked = isChecked;
				}
			}
}

//Permet de vérifier la force du mot de passe
function CheckPasswordStrength(sObjId, sLang) {
	var passwd = document.getElementById(sObjId).value;
		
	if(sLang == "fr") {
		var lbl = "S&eacute;curit&eacute; du mot de passe";
		var veryWeak = "Tr&egrave;s faible";
		var weak = "Faible";
		var acceptable = "Acceptable";
		var strong = "Fort";
		var veryStrong = "Tr&egrave;s fort";
	} else {
		var lbl = "Password securtity";
		var veryWeak = "Very weak";
		var weak = "Weak";
		var acceptable = "Acceptable";
		var strong = "Strong";
		var veryStrong = "Very strong";
	}	
			
	var imgPath = "images/ax2006/rel_meter";
	var desc = new Array();
	desc[0] = lbl + " : <img src='"+ imgPath +"_6.gif' alt='"+ veryWeak +"' /> <strong>"+ veryWeak +"</strong>";
	desc[1] = lbl + " : <img src='"+ imgPath +"_5.gif' alt='"+ weak +"' /> <strong>"+ weak +"</strong>";
	desc[2] = lbl + " : <img src='"+ imgPath +"_4.gif' alt='"+ acceptable +"' /> <strong>"+ acceptable +"</strong>";
	desc[3] = lbl + " : <img src='"+ imgPath +"_3.gif' alt='"+ strong +"' /> <strong>"+ strong +"</strong>";
	desc[4] = lbl + " : <img src='"+ imgPath +"_2.gif' alt='"+ veryStrong +"' /> <strong>"+ veryStrong +"</strong>";
	desc[5] = "";

	var intScore   = 0
	var strVerdict = 0

	// length 0
	if (passwd.length==0 || !passwd.length) { intScore = -1 }
	// length between 1 and 4
	else if (passwd.length>0 && passwd.length<5) { intScore = (intScore+3) }
	// length between 5 and 7
	else if (passwd.length>4 && passwd.length<8) {intScore = (intScore+6)}
	// length between 8 and 15
	else if (passwd.length>7 && passwd.length<12){intScore = (intScore+18)}
	// length 16 or more
	else if (passwd.length>11) {intScore = (intScore+20)}
		
    // [verified] at least one lower case letter
	if (passwd.match(/[a-z]/)) {intScore = (intScore+1)}
	// [verified] at least one upper case letter
	if (passwd.match(/[A-Z]/)){intScore = (intScore+5)}
	// [verified] at least one number
	if (passwd.match(/\d+/)){intScore = (intScore+5)}
	// [verified] at least three numbers
	if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/)){intScore = (intScore+5)}
	// [verified] at least one special character
	if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)){intScore = (intScore+5)}
	// [verified] at least two special characters
	if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)){intScore = (intScore+5)}
	// [verified] both upper and lower case
	if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){intScore = (intScore+2)}
	// [FAILED] both letters and numbers, almost works because an additional character is required
	if (passwd.match(/(\d.*\D)|(\D.*\d)/)){intScore = (intScore+2)}
	// [verified] letters, numbers, and special characters
	if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)){intScore = (intScore+2)}
	
	// Results
	if(intScore == -1){strVerdict = desc[5];}
	else if(intScore > -1 && intScore < 16){strVerdict = desc[0];}
	else if (intScore > 15 && intScore < 25){strVerdict = desc[1];}
	else if (intScore > 24 && intScore < 35){strVerdict = desc[2];}
	else if (intScore > 34 && intScore < 45){strVerdict = desc[3];}
	else{strVerdict = desc[4];}
	
	return strVerdict;
}

function setSelectedValues(hidSiteId, valSiteId, hidLangId, valLang, siteComboBoxId, imgArrowId) {
	var hidUnite = $("#"+hidSiteId);
	var hidLang = $("#"+hidLangId);

	hidUnite.attr("value", valSiteId);
	hidLang.attr("value", valLang);
	
	showHideSitesComboBox(siteComboBoxId, imgArrowId);
}

function showHideSitesComboBox(dropDownDivId, imgArrowId) {
	if($("#"+dropDownDivId).css("display") == "block") {
		$("#"+dropDownDivId).slideUp("fast");
		$("#"+imgArrowId).attr("src", "images/btns/sitesComboBoxHeaderArrow.gif");
	} else {
		$("#"+dropDownDivId).slideDown("fast");
		$("#"+imgArrowId).attr("src", "images/btns/sitesComboBoxHeaderArrowOver.gif");
	}
}

function setSize(obj) {
	var el = document.getElementById(obj.id);
	if(el) { el.size = el.value; }
}

// Corrige les problemes de URL rewrite / base tag pour les ancre
$(document).ready( function(){
	$("a[href^='#']").each( function(){
		$(this).attr("href", window.location + $(this).attr("href"));
	});
	
	// Appel de la gestion de la navigation virtuelle
	if ($(".navigationVirtuelle").length>0){
	    NavigationVirtuelle();
	}
	
});

//<RadControls>
//Obtient tous les input type file 
function getFileInputElementsOnPageWithValues() {
    var fileInputElements = []; 
    var inputElements = document.getElementsByTagName("input"); 
    for (var i = 0; i < inputElements.length; i++) { 
        if (inputElements[i].type.toLowerCase() == "file" && inputElements[i].value) { 
            fileInputElements[fileInputElements.length] = inputElements[i]; 
        } 
    } 
    return fileInputElements; 
} 
//Cache la progressbar si il n'y a aucun fichier
function hideRadProgressIfNoFiles(sender, args) { 
    if (getFileInputElementsOnPageWithValues().length == 0) { 
        args.set_cancel(true); 
    } 
} 
//</RadControls>

/*<Callback handler>*/
var UmenHandlers = {}
UmenHandlers.callbackHandler = function()
{
	this.source = null;
	this.method = null;
}
UmenHandlers.callbackHandler.prototype.setCallback = function(source, method){this.source=source; this.method=method;}
UmenHandlers.callbackHandler.prototype.invoke = function(args){return this.method.call(this.source, args);}
/*</Callback handler>*/

/* <submenu> */

/* </submenu> */


// Ajout icon sur les liens externe
if (typeof jQuery != 'undefined') {$(document).ready(function(){externalLinks();});}
function externalLinks(){$('a[target|=_blank]').each(function(){$(this).addClass("lienSortant");});}

// Offset la valeur dans le champ texte idTarget de n puis appelle Page_ClientValidate
UmenHandlers.offsetQty = function(idTarget,n,valGroup,positiveOnly)
{
	try
	{
		var ctrl = $("#"+idTarget);
		var val = ctrl.val().replace(/\s+/,'');
		if(val.length == 0) val = "0";
		if(val.match(/^-{0,1}\d+$/))
		{
			n = parseInt(val) + parseInt(n);
			if(n > 0 || !positiveOnly)
			{
				ctrl.val(n);
		}
			else ctrl.val(1);
		}
	}
	catch(e)
		{
		}
	if(Page_ClientValidate)
		Page_ClientValidate(valGroup);
}

// valide la quantite dans un champ texte
UmenHandlers.validateQuantityPositive = function(source,args)
{
	if(source.controltovalidate)
	{
		var val = $("#"+source.controltovalidate).val();
		args.IsValid = val.match(/^\s*\d+\s*$/) && parseInt(val) > 0
	}
	else
		{
		args.IsValid = true;
		}
}

// valide la quantite dans un champ texte
UmenHandlers.validateQuantity = function(source,args)
{
	if(source.controltovalidate)
	{
		var val = $("#"+source.controltovalidate).val();
		args.IsValid = val.match(/^\s*-{0,1}\d+\s*$/)
	}
		else
		{
		args.IsValid = true;
		}
}

UmenHandlers.setControlToValidate = function(validatorId, controlToValidateId)
{
	if(document.getElementById(validatorId))
	{
		document.getElementById(validatorId).controltovalidate = controlToValidateId;
	}
}

UmenHandlers.Dialog = function(nodeId, options)
{
	this.nodeId = nodeId;
	this.options = options;
	if(!this.options)
		this.options = {}
	this.handle = null;
	var me = this;
	this.options.close = function(){me.close();}
	if(this.options.autoOpen)
		this.open();
}

UmenHandlers.Dialog.prototype.open = function(titre, param)
{
	this.close();
	if(titre) this.options.title = titre;
	this.options.param = param;
	this.handle = $("#" + this.nodeId).dialog(this.options);
	this.handle.parent().appendTo($("form:first"))
	this.handle.dialog("open");
}

UmenHandlers.Dialog.prototype.close = function()
{
	if(this.handle)
	{
		this.handle.dialog("destroy");
		this.handle = null;
	}
}

UmenHandlers.Dialog.getDefaultModalOptions = function(ltitre, lresizable, onOpen)
{
	if(onOpen && onOpen.f)
	{
		var o = onOpen;
		onOpen = function(){o.f.apply(null,o.a);}
	}
	return {
		autoOpen: false, title: ltitre, resizable: lresizable, modal: true, open: onOpen
	};
}

UmenHandlers.rebindCtrlToHf = function(ddl, hf, evtName)
{
	$("#"+ddl).die(evtName);
	$("#"+ddl).live(evtName,
		function()
		{
				$("#"+hf).val($("#"+ddl).val());
		}
	);
}

UmenHandlers.validateEmail = function(source, args)
{
	args.IsValid = new RegExp(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/i).test(args.Value);
}


// 
// Navigation Virtuelle
var navigationChargement = 0
function NavigationVirtuelle(){
	$(window)._scrollable();
	navigationChargement++;
	
	// Pour éviter plusieurs passages
	if (navigationChargement==1){
		var modeaffichage = $.getUrlVar('modeaffichage');
		
		// Mode édition on affiche tous les blocs
		if (modeaffichage == "2"){
			$(".navigationVirtuelle").show();
			$(".navigationBlocSuivant").show();
			$(".navigationBlocPrecedent").show();
		}else{
			
			// Initialisation du plugin jquery history			
			$.history.init(function(url) {
				NavigationVirtuelleLoad(url);
            });
			
		}
	}
}


function NavigationVirtuelleLoad(hash) {
	
        // On va chercher le bloc et l'indice => appel depuis ancre
		if (hash.indexOf("_")>=0){
			tabHash = hash.split('_');
			
			// On charge les blocs si appel au chargement de la page
			if ($(".navigationVirtuelleLien").length==0){
				
				// On traite chaque element
				$(".pageListeBloc").each(function(i){
					
					// On initialise les liens de navigation si aucune navigation n'est en cours
					if ($(this).find(".navigationVirtuelleLien").length==0){
						
						// On initialise la pagination
						var navigationClone = $(this).clone()
						navigationClone.removeClass("pageListeBloc");
						NavigationVirtuelleInitialisationLien($(this), navigationClone.attr("class"));
						
						// Dans le cas d'un chargement de page on affiche les autres blocs
						if (tabHash[0] != navigationClone.attr("class")){
							NavigationVirtuelleAfficherBloc($(".pageListeBloc." + navigationClone.attr("class")),1);
	}
					}
				});
	
		}
			NavigationVirtuelleAfficherBloc($(".pageListeBloc." + tabHash[0]),tabHash[1]);
		}else{
			
			// Initialisation
			if ($(".pageListeBloc").length>0){
				// On traite chaque element
				$(".pageListeBloc").each(function(i){
				
					// On initialise les liens de navigation si aucune navigation n'est en cours
					if ($(this).find(".navigationVirtuelleLien").length==0){
						// On initialise la pagination
						var navigationClone = $(this).clone()
						navigationClone.removeClass("pageListeBloc");
						NavigationVirtuelleInitialisationLien($(this), navigationClone.attr("class"));
	}
	
					// Affichage du bon bloc
					NavigationVirtuelleAfficherBloc($(this),1);
					
					
				});
			}
		}

    }
// Fonction permettant de gérer la navigation (modification des liens en fonction des indices)
function NavigationVirtuelleInitialisationLien(bloc, idBloc){
		
	var navigationBloc = bloc.find(".navigationVirtuelle .axm_navigation_bloc");
	var lnavigationBloc = navigationBloc.length-1;
	
	var idBloc = idBloc;
	
	// Traitement de chaque bloc de navigation
	navigationBloc.each(function(i){
		indiceBlocSuivant = i + 2;
		indiceBlocPrecedent = i;
	
		// Traitement particulier pour la première et la dernière navigation
		if (i==0){
			$(this).find(".navigationBlocSuivant").show();
		}else if (i==lnavigationBloc){
			$(this).find(".navigationBlocPrecedent").show();
		}else {
			$(this).find(".navigationBlocPrecedent").show();
			$(this).find(".navigationBlocSuivant").show()
		}
		
		if ($(this).parents(".navigationVirtuelle").next(".navigationVirtuelle").length>0){
			$(this).find(".navigationBlocSuivant").show();
		}
		
		
	   	
	   	// Modification des liens suivants / précédent
	   	hrefSuivant = NavigationVirtuelleModifierHref($(this).find(".navigationBlocSuivant").attr("href"));
	   	hrefPrecedent = NavigationVirtuelleModifierHref($(this).find(".navigationBlocPrecedent").attr("href"));
	   	if (!$(this).find(".navigationBlocSuivant").hasClass("lienModifie")){
	   		$(this).find(".navigationBlocSuivant").attr("href", hrefSuivant + idBloc + "_" + indiceBlocSuivant);   
	   		$(this).find(".navigationBlocPrecedent").attr("href", hrefPrecedent + idBloc + "_" + indiceBlocPrecedent);
		   	
	   		$(this).find(".navigationBlocSuivant").addClass("lienModifie");
	   		$(this).find(".navigationBlocPrecedent").addClass("lienModifie");
	   	}
	   	
	   	// Ancre
	   	//$(this).parents(".navigationVirtuelle").before("<a name='" + idBloc + "_" + indiceBlocSuivant + "'></a>");
	});
	
	// On ajoute une class pour les liens
	$(bloc.find(".navigationVirtuelle .axm_navigation_bloc")).parents(".navigationVirtuelle").addClass("navigationVirtuelleLien");
	
	// Evenement au clic sur suivant / precedent
	bloc.find(".navigationVirtuelleLien a").click(function () {
            var url = $(this).attr('href');
            url = url.replace(/^.*#/, '');
            //$.historyLoad(hash);
            $.history.load(url);
            
            //window.scrollTo(0,0);
            $.scrollTo(bloc,{offset:-50});
            //return false;
        });            
}


// Fonction permettant d'afficher les bons blocs (correspondant à indice)
function NavigationVirtuelleAfficherBloc(bloc, indice){
	
	// On cache tous les blocs
	bloc.find(".navigationVirtuelle").hide();
	bloc.find(".navigationVirtuelle").removeClass("navigationVirtuelleCachee");
	
	// On va chercher et on affiche le bloc de navigation correspondant
	var myNavigation = bloc.find(".navigationVirtuelle .axm_navigation_bloc").get(indice-1);
	
	// Pas de dernière navigation => on affiche le dernier bloc
	if(bloc.find(".navigationVirtuelle .axm_navigation_bloc").length<indice){
		var myNavigationLast = bloc.find(".navigationVirtuelle .axm_navigation_bloc").last();
		var myBlocLast = $(myNavigationLast).parents(".navigationVirtuelle");
		myBlocLast.nextAll(".navigationVirtuelle").show();
	}else{
	
		var myBloc = $(myNavigation).parents(".navigationVirtuelle");
		$(myNavigation).parents(".navigationVirtuelle").show();
		
		// Premier bloc => On affiche tous les éléments precedents
		if (indice==1){
			myBloc.prevAll(".navigationVirtuelle").show();
		}else{
			
		
			// Bloc de navigation précédent => pour les cacher
			var myNavigationPrec = bloc.find(".navigationVirtuelle .axm_navigation_bloc").get(indice-2);
			var myBlocPrec = $(myNavigationPrec).parents(".navigationVirtuelle");
			
			// On ajoute une class sur les blocs de navigation précédent
			myBlocPrec.prevAll(".navigationVirtuelle").addClass("navigationVirtuelleCachee");
			
			// On affiche les blocs précédents sauf ceux de l'autre navigation
			myBloc.prevAll(".navigationVirtuelle:not(.navigationVirtuelleCachee, .navigationVirtuelleLien)").show();
			}
			}
}

// Fonction permettant de retirer l'ancre d'un lien
function NavigationVirtuelleModifierHref(href){
	if (href.indexOf("#")>=0){
		tabHref = href.split('#');
		href = tabHref[0] + "#";
          }
	return href;
}


// Récupération paramètre url
$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
	}
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
	}
});
