function changerLangue(tagLangue) {
	var liste = dojo.query(".lng") ;
	var nombreChamps = liste.length ;
	// on cache tout les champs ayant la double langue
	for(var i=0; i< nombreChamps; i++) {
		dojo.style(liste[i], 'display', 'none') ;
	}
	var listeLng = dojo.query("."+tagLangue.toLowerCase()) ;
	nombreChamps = listeLng.length ;
	for(var i=0; i< nombreChamps; i++) {
		dojo.style(listeLng[i], 'display', '') ;
	}
}

function changerPeriode(tagPeriode){
	var liste = dojo.query(".periode") ;
	var nombreChamps = liste.length ;
	for(var i=0; i< nombreChamps; i++) {
		dojo.style(liste[i], 'display', 'none') ;
	}
	
	var listeLng = dojo.query("."+tagPeriode.toLowerCase()) ;
	nombreChamps = listeLng.length ;
	for(var i=0; i< nombreChamps; i++) {
		dojo.style(listeLng[i], 'display', '') ;
	}
	
	// Requete ajax pour mettre en session la période choisie
	var xhrArgs = {
		url: '/fr/periode/periode/'+tagPeriode,
		handleAs: "text",
		load: function(data) {
			return;
		}
	}
	// Appel AJAX
	dojo.xhrGet(xhrArgs) ;
	var SelectObject = document.getElementById('liste_periode_1') ;
	if(SelectObject != null)
		for(index = 0; index < SelectObject.length; index++) {
			if(SelectObject[index].value == tagPeriode)
				SelectObject.selectedIndex = index;
		}
	var SelectObject = document.getElementById('liste_periode_2') ;
	if(SelectObject != null)
		for(index = 0; index < SelectObject.length; index++) {
			if(SelectObject[index].value == tagPeriode)
				SelectObject.selectedIndex = index;
		}
}

function fmaShowdetail(tagID, suffixe) {
	var bloc = dojo.byId(tagID+suffixe);
	var test = dojo.style(bloc, 'display');
	var btn = dojo.byId('btn_'+tagID+suffixe);
	
	if(test != 'none'){
		dojo.style(bloc, 'display', 'none') ;
		dojo.removeClass(btn, 'redepli_on') ;
		dojo.addClass(btn, 'redepli_off') ;
	}else{
		dojo.style(bloc, 'display', '') ;
		dojo.removeClass(btn, 'redepli_off') ;
		dojo.addClass(btn, 'redepli_on') ;
	}
}

function scroll(node, index, sens, max) {
	var duree = 1000 ; // Durée de l'animation
	var taille = 211 ; // Définit la taille d'une zone et en même temps l'offset à appliquer au déplacement
	var left = dojo.style(node, 'left') ; // Récupère la position actuelle
	var go_to = 0 ; // Variable définissant la position 'left' finale
	
	var nde_prec = dojo.query('.media_prec'); // Array des boutons précédents
	var nde_suiv = dojo.query('.media_suiv'); // Array des boutons suivants
	
	if(sens == 'left') {
		// Offset de mouvement
		go_to = left - taille ;
		// On masque systématiquement le bouton pour éviter les double clique
		var checkDisplay = dojo.style(nde_suiv[index], 'visibility') ;
		if(checkDisplay == 'visible') dojo.style(nde_suiv[index], 'visibility', 'hidden') ;
		// Incrémentation du nombre de photos
		arrIndexMedias[index] ++;
	}else if(sens == 'right'){
		// Offset de mouvement
		go_to = left + taille ;
		// On masque systématiquement le bouton pour éviter les double clique
		var checkDisplay = dojo.style(nde_prec[index], 'visibility') ;
		if(checkDisplay == 'visible') dojo.style(nde_prec[index], 'visibility', 'hidden') ;
		// Décrémentation du nombre de photos
		arrIndexMedias[index] --;
	}
	
	dojo.animateProperty({
            node : node,
            properties: {
                left:go_to
            },
			onEnd: function(){
				// Si max est inférieur à 2, on masque les boutons
				if(max <=2) {
					var checkDisplay = dojo.style(nde_prec[index], 'visibility') ;
					if(checkDisplay == 'visible') dojo.style(nde_prec[index], 'visibility', 'hidden') ;
					var checkDisplay = dojo.style(nde_suiv[index], 'visibility') ;
					if(checkDisplay == 'visible') dojo.style(nde_suiv[index], 'visibility', 'hidden') ;
					return;
				}
				
				if(arrIndexMedias[index] >= max) { // Si on atteint le nombre de photo maximum
					// Masquage du bouton suivant
					var checkDisplaySuiv = dojo.style(nde_suiv[index], 'visibility') ;
					if(checkDisplaySuiv == 'visible') dojo.style(nde_suiv[index], 'visibility', 'hidden') ;
					// Si le max est <= 2, pas de bouton
					if(arrIndexMedias[index] <= 2) {
						// Masquage du bouton précédent
						var checkDisplayPrec = dojo.style(nde_prec[index], 'visibility') ;
						if(checkDisplayPrec == 'visible') dojo.style(nde_prec[index], 'visibility', 'hidden') ;
					}else{
						// Affichage du bouton précédent
						var checkDisplayPrec = dojo.style(nde_prec[index], 'visibility') ;
						if(checkDisplayPrec == 'hidden') dojo.style(nde_prec[index], 'visibility', 'visible') ;
					}
				}else if(arrIndexMedias[index] <= 2) { // Si on atteint le nombre de photo minimum
					// Affichage du bouton suivant
					var checkDisplaySuiv = dojo.style(nde_suiv[index], 'visibility') ;
					if(checkDisplaySuiv == 'hidden') dojo.style(nde_suiv[index], 'visibility', 'visible') ;
					// Masquage du bouton précédent
					var checkDisplayPrec = dojo.style(nde_prec[index], 'visibility') ;
					if(checkDisplayPrec == 'visible') dojo.style(nde_prec[index], 'visibility', 'hidden') ;
				}else{ // Quand nous somme au milieu
					// Affichage des 2 boutons
					var checkDisplayPrec = dojo.style(nde_prec[index], 'visibility') ;
					if(checkDisplayPrec == 'hidden') dojo.style(nde_prec[index], 'visibility', 'visible') ;
					var checkDisplaySuiv = dojo.style(nde_suiv[index], 'visibility') ;
					if(checkDisplaySuiv == 'hidden') dojo.style(nde_suiv[index], 'visibility', 'visible') ;
				}
			},
            duration:duree
    }).play();
}

