// JavaScript Document

// ============================================== RESET DES INPUT ==============================================
	function initialise(champ,valeur)
	{
		if(champ.value == valeur)
		{
			champ.value = "";
		}
		else
		{
		}
	}
	
	function restaure(champ,valeur)
	{
		if(champ.value == "")
		{
			champ.value = valeur;
		}
		else
		{
		}
	}
// ============================================== RESET DES INPUT ==============================================


// ============================================== SLIDESHOW ==============================================
	var numero = 1;
	var laMarge = 0;
	var increment = 690;
	var nbTotal = 0;
	
	function automatikSlideShow(){
		numero = parseInt(numero);
		if(numero < nbTotal){
			numero++;
		}
		else{
			numero = 1;
		}
		laMarge = -((increment*(numero))-increment);
		$("div.slideShowImages").animate({marginLeft:laMarge+"px"}, "normal");
		if((numero) == (nbTotal)){
			numero = 0;
		}
	}
	
	function slideShow(){
		var nbPages = $("div.slideShowImages").children("a").length;
		nbTotal = $("div.slideShowImages").children("a").length;
		var largeurTotale = increment*nbPages;
		$("div.slideShowImages").css("width",largeurTotale+"px");
		var timer=setInterval("automatikSlideShow()", 6000);
		//droite
		$("a.slideShowFlecheDroite").click( function () {
			clearInterval(timer);
			if(numero < nbTotal){
				numero++;
			}
			else{
				numero = 1;
			}
			laMarge = -((increment*numero)-increment);
			$("div.slideShowImages").animate({marginLeft:laMarge+"px"}, "normal");
			timer=setInterval("automatikSlideShow()", 6000);
			return false;
		});
		//gauche
		$("a.slideShowFlecheGauche").click( function () {
			clearInterval(timer);
			if(numero > 1){
				numero--;
			}
			else{
				numero = nbTotal;
			}
			laMarge = -((increment*numero)-increment);
			$("div.slideShowImages").animate({marginLeft:laMarge+"px"}, "normal");
			timer=setInterval("automatikSlideShow()", 6000);
			return false;
		});
	}
	
// ============================================== SLIDESHOW ==============================================
	
	
// ============================================== ENVOI AMI ==============================================
	function envoyerAmi()
	{
		$("li.pageAmi a").click( function () {
			if($(".moduleEnvoiAmi").hasClass("moduleEnvoiAmiActif"))
			{
				$(".moduleEnvoiAmi").slideUp("slow");
				$(".moduleEnvoiAmi").removeClass("moduleEnvoiAmiActif");
			}
			else
			{
				$(".moduleEnvoiAmi").slideDown("slow");
				$(".moduleEnvoiAmi").addClass("moduleEnvoiAmiActif");
				
			}
		  	return false;
		});
		
		$("a.fermerEnvoiAmi").click( function () {
			$(".moduleEnvoiAmi").slideUp("slow");
			$(".moduleEnvoiAmi").removeClass("moduleEnvoiAmiActif");
		  	return false;
		});
	}
// ============================================== ENVOI AMI ==============================================


// ============================================== ENVOI AMI ZOOM ==============================================
	function envoyerAmiZoom()
	{
		$("li.zoomAmi a").click( function () {
			if($(".moduleEnvoiAmiZoom").hasClass("moduleEnvoiAmiActif"))
			{
				$(".moduleEnvoiAmiZoom").slideUp("slow");
				$(".moduleEnvoiAmiZoom").removeClass("moduleEnvoiAmiActif");
			}
			else
			{
				$(".moduleEnvoiAmiZoom").slideDown("slow");
				$(".moduleEnvoiAmiZoom").addClass("moduleEnvoiAmiActif");
				
			}
		  	return false;
		});
		
		$("a.fermerEnvoiAmiZoom").click( function () {
			$(".moduleEnvoiAmiZoom").slideUp("slow");
			$(".moduleEnvoiAmiZoom").removeClass("moduleEnvoiAmiActif");
		  	return false;
		});
	}
// ============================================== ENVOI AMI ZOOM ==============================================


// ============================================== FERMETURE D'UNE ALERTE ==============================================
	function messagesAlerte()
	{
		$("a.fermerAlerte").click( function () {
			$(".masqueAlerte").hide();
			$(".messageAlerte").hide();
		  	return false;
		});
		
		$("div.masqueAlerte").click( function () {
			$(".masqueAlerte").hide();
			$(".messageAlerte").hide();
		  	return false;
		});
	}
// ============================================== FERMETURE D'UNE ALERTE ==============================================


// ============================================== AJOUT COMMENTAIRE ==============================================
	function ajoutCommentaire()
	{
		$("a.btnCommenter").click( function () {
			if($(".moduleCommentaire").hasClass("moduleCommentaireActif"))
			{
				$(".moduleCommentaire").slideUp("slow");
				$(".moduleCommentaire").removeClass("moduleCommentaireActif");
			}
			else
			{
				$(".moduleCommentaire").slideDown("slow");
				$(".moduleCommentaire").addClass("moduleCommentaireActif");
				
			}
		  	return false;
		});
		
		$("a.fermerCommentaires").click( function () {
			$(".moduleCommentaire").slideUp("slow");
			$(".moduleCommentaire").removeClass("moduleCommentaireActif");
		  	return false;
		});
	}
// ============================================== AJOUT COMMENTAIRE ==============================================


// ============================================== INSCRIPTION EVENEMENT ==============================================
	function inscriptionEvenement()
	{
		$("a.btnSinscrire").click( function () {
			if($(this).parent().parent().children(".moduleEvenement").hasClass("moduleEvenementActif"))
			{
				$(this).parent().parent().children(".moduleEvenement").slideUp("slow");
				$(this).parent().parent().children(".moduleEvenement").removeClass("moduleEvenementActif");
			}
			else
			{
				$(".moduleEvenement").slideUp("slow");
				$(".moduleEvenement").removeClass("moduleEvenementActif");
				
				$(this).parent().parent().children(".moduleEvenement").slideDown("slow");
				$(this).parent().parent().children(".moduleEvenement").addClass("moduleEvenementActif");
				
			}
		  	return false;
		});
		
		$("a.fermerEvenement").click( function () {
			$(this).parent().slideUp("slow");
			$(this).parent().removeClass("moduleEvenementActif");
		  	return false;
		});
	}
// ============================================== INSCRIPTION EVENEMENT ==============================================


// ============================================== SLIDESHOW ZOOM==============================================
	var laMargeZoom = 0;
	var incrementZoom = 500;
	var nbTotalZoom = 0;
	var vignetteRang = 0;
	
	function zoomSlide(){
		
		if($("div.masqueZoom").hasClass("masqueZoomActif"))
		{
			laMargeZoom = -((incrementZoom*numeroZoom)-incrementZoom);
			$("div.zoomSlideshowPhotos").css("marginLeft",laMargeZoom+"px");
			$("div.zoomSlideshowConteneur").addClass("zoomSlideshowConteneurActif");
		}
		
		nbTotalZoom = $("div.zoomSlideshowSlide").children("div.zoomSlideshowPhoto").length;
		var largeurTotaleZoom = increment*nbTotalZoom;
		$("div.zoomSlideshowPhotos").css("width",largeurTotaleZoom+"px");
		//droite
		$("a.zoomSlideSuivant").click( function () {
			if(numeroZoom < nbTotalZoom)
			{
				numeroZoom++;
			}
			else
			{
				numeroZoom = 1;
			}
			laMargeZoom = -((incrementZoom*numeroZoom)-incrementZoom);
			$("div.zoomSlideshowPhotos").animate({marginLeft:laMargeZoom+"px"}, "normal");
			return false;
		});
		//gauche
		$("a.zoomSlidePrecedent").click( function () {
			if(numeroZoom > 1)
			{
				numeroZoom--;
			}
			else
			{
				numeroZoom = nbTotalZoom;
			}
			laMargeZoom = -((incrementZoom*numeroZoom)-incrementZoom);
			$("div.zoomSlideshowPhotos").animate({marginLeft:laMargeZoom+"px"}, "normal");
			return false;
		});
		// click sur vignette et ouverture du slideShow sur le zoom correspondant
		$("div.albumBloc a").click( function () {
			vignetteRang = $(this).attr("rel");
			numeroZoom = vignetteRang;
			laMargeZoom = -((incrementZoom*numeroZoom)-incrementZoom);
			$("div.zoomSlideshowPhotos").css("marginLeft",laMargeZoom+"px");
			$("div.masqueZoom").addClass("masqueZoomActif");
			$("div.zoomSlideshowConteneur").addClass("zoomSlideshowConteneurActif");
			return false;
		});
		// click sur fermeture slideShow
		$("a.zoomSlideshowFermer").click( function () {
			$("div.masqueZoom").removeClass("masqueZoomActif");
			$("div.zoomSlideshowConteneur").removeClass("zoomSlideshowConteneurActif");
			return false;
		});
	}
	
// ============================================== SLIDESHOW ZOOM ==============================================


// ============================================== SLIDE MDP OUBLIE ==============================================
	function mdpOubliSlide()
	{
		$("div.mdpOublie a").click( function () {
			if($("div.moduleMdpOublie").hasClass("moduleMdpOublieActif"))
			{
				$("div.moduleMdpOublie").removeClass("moduleMdpOublieActif");
				$("div.moduleMdpOublie").slideUp("normal");
			}
			else
			{
				$("div.moduleMdpOublie").addClass("moduleMdpOublieActif");
				$("div.moduleMdpOublie").slideDown("normal");
			}
		  	return false;
		});
	}
// ============================================== SLIDE MDP OUBLIE ==============================================


// ============================================== LISTE ECOLES ==============================================

	function listeEcoles()
	{
		$("a.ecoleSelection").click( function () {
		// Si le sous-menu était déjà ouvert, on le referme :
			if ($(this).hasClass(".ecoleSelectionActive"))
			{
				$(this).removeClass(".ecoleSelectionActive");
				$("ul.ecoleListe").slideUp("fast");
			}
			// Si le sous-menu est caché, on l'affiche :
			else
			{
				$(this).addClass(".ecoleSelectionActive");
				$("ul.ecoleListe").slideDown("normal");
			}
			// On empêche le navigateur de suivre le lien :
			return false;
		});
		
		// MISE A JOUR FILTRES RECHERCHE
		$("ul.ecoleListe li a").click( function () {
			// on recupere la valeur de l attribut rel du lien pour la balancer en valeur du champ input hidden
			var inputHidden = $(this).parent().parent().parent().parent().find(".inscriptionEcoleValue").attr("id");
			if(document.getElementById(inputHidden))
			{
				document.getElementById(inputHidden).value = $(this).attr("rel");
			}
			// on affiche la valeur selectionnee dans la liste dans le champ de valeur
			$(this).parent().parent().parent().children("a.ecoleSelection").html($(this).html());
			// on referme la liste
			$("a.ecoleSelection").removeClass(".ecoleSelectionActive");
			$("ul.ecoleListe").slideUp("fast");
			
			// On empêche le navigateur de suivre le lien :
			return false;
		});
	}
// ============================================== LISTE ECOLES ==============================================

