﻿/* 
################################################################
	@description : Gestion du menu dŽroulant horizontal css
################################################################
*/

function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('sousmenu'+i)) {document.getElementById('sousmenu'+i).style.display='none';	}
	}
if (d) {d.style.display='block';}
}


/* 
################################################################
	@description : Gestion du menu déroulant vertical moo.fx
################################################################
*/
var divset;
var cats;
var arg; // savoir quel sous menu on ouvre.

//the main function, call to the effect object
function init(arg){
	cats = document.getElementsByClassName('stretcher'); //div that stretches
	var catheads = document.getElementsByClassName('display'); //h2s where I click on

	divset = new fx.Accordion
	(
		catheads, cats, {opacity: true, duration: 420}
	);

	function checkHash(){
		var found = false;
		
		catheads.each(function(h2, i){
			if (window.location.href.indexOf(h2.title) > 0) {
				//divset.showThisHideOpen(cats[i]);
				divset.showThisHideOpen(cats[arg]); // support sur 1 élément.
				found = true;
			}
		});
		return found;
	}
	
	switch (arg) // ajout config ouverture sur élément ciblé.
	{
	case 0 : if (!checkHash()) divset.showThisHideOpen(cats[0]);	break;
	case 1 : if (!checkHash()) divset.showThisHideOpen(cats[1]);	break;
	case 2 : if (!checkHash()) divset.showThisHideOpen(cats[2]);	break;
	case 3 : if (!checkHash()) divset.showThisHideOpen(cats[3]);	break;
	}
	
	// document.write(document.URL);
}


/* 
################################################################
	@description : 	Fonction d'activation, 
				désactivation des liens 
				du menu vertical
################################################################
*/
function showtitle(rub,nb_rub) {
	// dans un premier temps on désactive les liens
	for (var i = 1; i<= nb_rub; i++ ) 
	{
		document.getElementById("rub"+i).className ="";		
	}
	// dans un second temps on active le lien.
	document.getElementById(rub).className ="actif";		
}


/* 
################################################################
	@description : 	Fonction de validation formulaire newsletter
################################################################
*/
function verifValideMail(formulaire){
	
	  if( formulaire.news_mail.value !== ""){
		if( formulaire.news_mail.value.indexOf('@',0)==-1 ){
			alert("Attention, votre e-mail "+formulaire.news_mail.value+" est invalide.");
			ok = 0;
			return false;
		}else if(formulaire.adr_mail.value.indexOf('.',0)==-1){
			alert("Attention, Votre e-mail "+formulaire.news_mail.value+" est invalide.");
			ok = 0;
			return false;
		}
		else
			ok = 1;
   	 }else{
	 	alert("Attention, Vous n'avez pas saisi d'e-mail.");
	 }
	 
}

/* 
################################################################
	@description : 	Fonction de réinit des champs du formulaire.
################################################################
*/
function reinitChpMail(formulaire){
	formulaire.news_mail.value = "";
}




