 // On supprime les textes alt des images pour MSIE, sauf si getElementById n'est pas implemente
 // Explication : MSIE affiche les textes alt comme tip (ce que l'on ne veut pas), mais si getElementById
 // n'est pas implemente, alors on veut bien les tips en remplacement du javascript de poplink.
 var detect = navigator.userAgent.toLowerCase();
 if (detect.indexOf("msie") != -1) {
 if(document.getElementById)  window.attachEvent('onload', removeTextAlt);
 }
 
function removeTextAlt() { // suppression des textes alt des images pour MSIE
var imagesArray = document.all.tags("img");
 for(var i = 0; i < imagesArray.length; i++) imagesArray[i].alt = "";  
}


function resizeProportionately(theImage, maxWidth, maxHeight) { // retaille une image proportionnellement
if((maxWidth > 0) && (maxHeight > 0)) {
 var currentWidth=theImage.width;
 var currentHeight=theImage.height;
 if ((currentWidth > maxWidth) || (currentHeight > maxHeight)) {
  var ratio=Math.min(maxWidth/currentWidth,maxHeight/currentHeight);
  theImage.width=ratio*currentWidth;
  theImage.height=ratio*currentHeight;
  }
 }
}

// La fonction change au vol le lien HREF lors du clic afin que le troncon soit affiche dans
// une fenetre ayant certaines caracteristiques. Le lien est change lors du premier clic souris (test conditionnel).
// D'autres liens utilisent aussi cette fonction.
function manageSectionWindow(originalHREF, windowTitle,windowWidth,windowHeight) {
var newHREF=originalHREF;
if(originalHREF.search(/javascript/i)==-1)
newHREF="javascript:window.open('"+originalHREF+"','"+windowTitle+"','width="+windowWidth+",height="+windowHeight+",status=no,toolbar=no,screenX=0,screenY=0,left=0,top=0,scrollbars=yes,resizable=yes');void 0;";
return newHREF;
}

  // ouverture d'une fenetre
  // les parametres status, scrollbars, resizable menubar et toolbar sont optionnels (ce sont des booleens)
function openNewWindow(windowURL,windowName,windowWith,windowHeight,status,scrollbars,resizable,location,toolbar){
 // initialisation des variables recuperant les arguments optionnels
 var statusText = "no";
 var scrollbarsText = "no";
 var resizableText = "no";
 var locationText = "no";
 var toolbarText = "no";
 if(arguments.length > 4) statusText = status ? "yes" : "no";
 if(arguments.length > 5) scrollbarsText = scrollbars ? "yes" : "no";
 if(arguments.length > 6) resizableText = resizable ? "yes" : "no";
 if(arguments.length > 7) locationText = location ? "yes" : "no";
 if(arguments.length > 8) toolbarText = toolbar ? "yes" : "no";
 window.open (windowURL,windowName,"status="+statusText+",scrollbars="+scrollbarsText+",resizable="+resizableText+",location="+locationText+",toolbar="+toolbarText+",width="+(windowWith+2)+",height="+(windowHeight+1));
 }

function initlayer() { 
 if (document.layers) { 
 layerRef="document.layers"; 
 styleSwitch=""; 
 what ="ns4"; 
 } 
 else if(document.all) { 
 layerRef="document.all"; 
 styleSwitch=".style"; 
 what ="ie4"; 
 } 
 else if(document.getElementById) { 
 layerRef="document.getElementById"; 
 styleSwitch=".style"; 
 what="dom1"; 
 } 
 else { 
 what="none"; 
 newbrowser = false; 
 } 
check = true; 

for(var i=0; i<arguments.length; i++)
 hidelayer (arguments[i]);
} 

// Toggles the layer visibility on 
function showlayer(layerName) { 
 if(check) { 
 if (what =="none") { 
 return; 
 } 
 else if (what == "dom1") { 
 document.getElementById(layerName).style.visibility="visible"; 
 } 
 else { 
 eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"'); 
 } 
 } 
 else { 
 return; 
 } 
 } 

// Toggles the layer visibility off 
function hidelayer(layerName) { 
 if(check) { 
 if (what =="none") { 
 return; 
 } 
 else if (what == "dom1") { 
 document.getElementById(layerName).style.visibility="hidden"; 
 } 
 else { 
 eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"'); 
 } 
 } 
 else { 
 return; 
 } 
 } 
 
 // affiche un bloc
 function displayOn(layerName) {
 if(check) { 
 if (what =="none") { 
 return; 
 } 
 else if (what == "dom1") { 
 document.getElementById(layerName).style.display="block"; 
 } 
 else { 
 eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.display="block"'); 
 } 
 } 
 else { 
 return; 
 } 
 } 
 
 // retire un bloc de l'affichage
 function displayOff(layerName) {
 if(check) { 
 if (what =="none") { 
 return; 
 } 
 else if (what == "dom1") { 
 document.getElementById(layerName).style.display="none"; 
 } 
 else { 
 eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.display="none"'); 
 } 
 } 
 else { 
 return; 
 } 
 } 
 
 // retourne la propriete d'un style d'un element connu par son ID
 function getStyleProperty(layerName,property) {
 var theResult = ""; // retourne une chaine vide si l'objet ou le propriete n'existe pas
 if(check) { 
  if (what !="none") {
   if (what == "dom1") { 
    if (document.getElementById(layerName) != null) {
     var theStyle = document.getElementById(layerName).style;
     if (theStyle[property]) theResult = theStyle[property];
    }
    else {
     if (what == "ie4") theResult = document.all[layerName].style[property];
     else  theResult = document[layerName][property];
    }
   }
  }
 }
return theResult;
}

function resizeImageInLayrout (containerStr, maxWidth, maxHeight) { // redimensionne proportionnellement toutes les images d'un calque (containerStr = id du calque, maxWidth = largeur maxi, hauteur maxi)
 var containerObj;
 if(document.all) containerObj = document.all[containerStr];  // IE 4
 else if(document.getElementById) containerObj = document.getElementById(containerStr);
 if (containerObj != null) {
  var imgArray = new Array();
  getChildrenImage(containerObj, imgArray);
  for (var i = 0; i < imgArray.length; i++) {
   resizeProportionately(imgArray[i], maxWidth, maxHeight)
  }
 }
 function getChildrenImage (n, imgArray) {
  if(document.all) { // IE 4
   for (var j = 0; j < n.children.length; j++) {
    var m = n.children[j];
    if(m.tagName.toLowerCase() == "img") imgArray[imgArray.length] = m;
    else getChildrenImage (m, imgArray);
   }
  } 
  else {
   for( var m = n.firstChild; m != null; m = m.nextSibling ) {
    if ((m.nodeType == 1) && (m.tagName.toLowerCase() == "img")) {
     imgArray[imgArray.length] = m;
    }
    else getChildrenImage (m, imgArray);
   }
  }
 }
}