
window.onload = function () {
	genererLiensExternes();
	genererMenuIE();
	
	if ( document.getElementsByTagName && document.getElementById ) {
			activerMenuCourant();
		}
}


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Ouvre les liens de la page qui ne pointent pas au domaine actuel dans une nouvelle page */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
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("javascript:") == -1 && eAncre.href.indexOf("mailto:") != 0 && !eAncre.onclick)
   eAncre.onclick = function () { window.open(this.href); return false; };
 }
}



/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Active menu courant
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function activerMenuCourant () {
	var identifiant = document.URL.substring(document.URL.lastIndexOf("/") + 1, document.URL.lastIndexOf("."));
	var menu;
	var sousMenu;
	
	if ( sousMenu = document.getElementById("smn_" + identifiant) ) {
		menu = sousMenu.parentNode.parentNode;
		menu.className += " actif";
		sousMenu.className += " actif";
	} else if ( menu = document.getElementById("mn_" + identifiant) ) {
		menu.className += " actif";
	}
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Affiche un contenu caché de la page                             */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
var contenuAffiche;
function afficherContenu ( eAncre ) {
	if ( contenuAffiche ) {
		document.getElementById("a_" + contenuAffiche).className = "";
		document.getElementById("b_" + contenuAffiche).style.display = "none";
	}
	
	var identifiant = eAncre.id.substring(eAncre.id.indexOf("_") + 1);
	contenuAffiche = identifiant;
	
	var monDisplay = "block";
	//document.all ? monDisplay = "block" : monDisplay = "table";
	
	document.getElementById("a_" + identifiant).className = "actif";
	document.getElementById("b_" + identifiant).style.display = monDisplay;
}

/* Ouvre page web via popup
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

function OpenNewWindow(winPath, winName, winWidth, winHeight, winScrollable){
  var winLeft = (screen.width - winWidth) / 2;
  var winTop = (screen.height - winHeight ) / 2;
  var theWindow = window.open(winPath, winName, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+winScrollable+',resizable=0,width='+winWidth+',height='+winHeight+',screenX='+winLeft+',screenY='+winTop+',left='+winLeft+',top='+winTop+'');
	  theWindow.opener = self;
	  theWindow.focus();
	  return theWindow;
}

/********************************************
GenererMenuIE
 
Ajoute une classe 'survol' à chacun des éléments LI survolés d'un menu pour Internet Explorer
*********************************************/
 
function genererMenuIE() {

 if ( document.all && document.getElementById ) {
  
  var oMenu;
  
  if ( oMenu = document.getElementById("menu") ) {
   for ( compteurLI = 0; compteurLI < oMenu.getElementsByTagName("LI").length; compteurLI++ ) {
    eLI = oMenu.getElementsByTagName("LI")[compteurLI];
    eLI.getElementsByTagName("ul").length ? eLI.survol = "isOpenSurvol" : eLI.survol = "survol";

    eLI.onmouseover = function () { this.className = this.className + " " + this.survol; };            // Ajoute la classe lorsque le LI est survolé
    eLI.onmouseout = function () { this.className = this.className.replace(" " + this.survol, ""); };  // Enlève la classe lorsque le LI n'est plus survolé
   }
  }
 }
}


/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Writes a Flash Object element with the requested optinal parameters         */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function writeFlashObject( uri, id, iWidth, iHeight, params ) {
	var sObject = new String();
	var sParams = new String();
	var aParams = new Array();
	if ( params ) aParams = params.split(",");
	
	sObject += '<object id="' + id + '" type="application/x-shockwave-flash" data="' + uri + '" width="' + iWidth + '" height="' + iHeight + '">';
	
	sParams += '<param name="movie" value="' + uri + '" />'
	
	for ( var cParams = 0; cParams < aParams.length; cParams++ ) {
		sParams += '<param name="' + aParams[cParams].split("=")[0] + '" value="' + aParams[cParams].split("=")[1] + '" />';
	}
	
	sObject += sParams + "</object>";
	
	document.write(sObject);
}

