// JavaScript Document

window.onload = function() {
		genererMenuIE();
		controlerListeContacts();
		genererLiensExternes();
	}

function genererMenuIE() {
	if ( document.all && document.getElementById ) {
		sSurvol = "survol";
		oMenu = document.getElementById("menu");
		for ( compteurLI = 0; compteurLI < oMenu.getElementsByTagName("LI").length; compteurLI++ ) {
			eLI = oMenu.getElementsByTagName("LI")[compteurLI];
			eLI.onmouseover = function () { this.className = this.className + " " + sSurvol; }        // Ajoute la classe au survol
			eLI.onmouseout = function () { this.className = this.className.replace(" " + sSurvol); }  // Enlève la classe on rollout
		}
	}
}



function controlerListeContacts () {
	if ( document.getElementById ) {
		var eListe;
		if ( eListe = document.getElementById("select_region") ) {
			
			var regionActive = null;
			eListe.onchange = function () {
				if ( regionActive )
					regionActive.style.display = "none";
					
				regionActive = document.getElementById(this.value);
				regionActive.style.display = "block";
			}
			
			eListe.onchange();
		}
	}
}


/*gere et affiche le bloc de contenu selectionne*/

var idContentActif = "ap1";

function showhide(objLien)

{

	if(document.getElementById("divp0"))

	{

		document.getElementById("divp0").style.display = "none";

	}

	lienActif = document.getElementById(idContentActif);

	lienActif.className = "";

	var idDivContent = idContentActif.replace(/a/, "div");

	document.getElementById(idDivContent).style.display = "none";

	var idDivToShow = objLien.id.replace(/a/, "div");

	objLien.className = "actif";

	document.getElementById(idDivToShow).style.display = "block";

	idContentActif = objLien.id;

	return false;

}


function genererLiensExternes() {
	var aAncres = document.getElementsByTagName("a");
	var eAncre; // Parcourt chacune des ancres de la page
	for ( var cAncres = 0; cAncres < aAncres.length; cAncres++ ) {
		eAncre = aAncres[cAncres]; // L'URI de l'ancre ne comporte pas le domaine actuel (et n'est pas un lien de courriel), on l'ouvre donc dans une nouvelle page
		if ( (eAncre.href.indexOf(document.domain) == -1 && eAncre.href.indexOf("mailto:") != 0 ) || eAncre.href.indexOf(".pdf") != -1   ) 
			eAncre.onclick = function () { window.open(this.href); return false; };
	}
}


// Active une section
function activerElements() {
	if ( document.getElementById ) {
		var aElements = activerElements.arguments;
		//alert(aElements.length);
		for ( var cElements = 0; cElements < aElements.length; cElements++ ) {
			var eSection;
			if ( eSection = document.getElementById(aElements[cElements]) )
				eSection.className = "actif";
		}
	}
}