var agent = navigator.userAgent.toLowerCase();
var major = parseInt(navigator.appVersion);
var minor = parseFloat(navigator.appVersion);
var ie = (agent.indexOf("msie") != -1);
var ns = ((agent.indexOf('mozilla')!=-1) && (agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1));
var ns4 = (ns && (major >= 4 && major<5));
var ns6 = (ns && (major >= 5));
var ie45 = (ie && (major >= 4));

var menuActif="";
var ValVide=-10000;

function CacherObj(nom) {
  if (ie45) {document.all.item(nom).style.visibility = "hidden";}
  else if (ns6) {document.getElementById(nom).style.visibility = "hidden";}
  else if (ns4) {document.layers[nom].visibility = "hidden";}
}

function VoirObj(nom) {
  if (ie45) {document.all.item(nom).style.visibility = "visible";}
  else if (ns6) {document.getElementById(nom).style.visibility = "visible";}
  else if (ns4) {document.layers[nom].visibility = "visible";}
}

function LargFen () {
  if (ie45) {value=document.body.clientWidth;}
  else if (ns6) {value=window.innerWidth;}
  else if (ns4) {value=window.innerWidth;}
  else value=0;
  return value;
}

function CrObj(nom,lft,tp,tx,ty,visible,zindex,centre,contenu,special,col,bgcol,bgimg,colcadre) {
  if (visible==1) {visi="visible"} else {visi="hidden"};
  if (colcadre!="") {
// Le contenu doit être dans un <p>, sinon il n'est pas visible avec Netscape
    contenu = '<table border=1 bordercolor="'+colcadre+'" width="100%" cellspacing=0 cellpadding=0><tr><td><p>'+contenu+'</p></td></tr></table>';
  }
  if (ns4) {
    chaine='<layer NAME="'+nom+'" visibility='+visi+' z-index='+zindex;
    if (tx!=ValVide) {chaine += ' width='+tx;}
    if (ty!=ValVide) {chaine += ' height='+ty;}
    if (lft!=ValVide) {chaine += ' left='+lft;}
    if (tp!=ValVide) {chaine += ' top='+tp;}
    if (bgcol!="") {chaine += ' bgcolor="'+bgcol+'"';}
    if (bgimg!="") {chaine += ' background="'+bgimg+'"';}
    chaine += ' '+special+'><font face="Arial, Helvetica, sans-serif" point-size=10';
    if (col!="") {chaine += ' color="'+col+'"';}
    chaine += '>';
    if (centre==1) {chaine += '<center>';}
    chaine += contenu;
    if (centre==1) {chaine += '</center>';}
    chaine += '</font></layer>';
  } else if (ns6 || ie45) {
    if (centre == 1) {
      centre = "center";
    } else {
      centre = "left";
    }
    chaine='<div ID="'+nom+'" style="position:absolute;visibility:'+visi+';z-index:'+zindex+';';
    if (tx!=ValVide) {chaine += 'width:'+tx+'px;';}
    if (ty!=ValVide) {chaine += 'height:'+ty+'px;';}
    if (lft!=ValVide) {chaine += 'left:'+lft+'px;';}
    if (tp!=ValVide) {chaine += 'top:'+tp+'px;';}
    if (col!="") {chaine += 'color:'+col+';';}
    if (bgcol!="") {chaine += 'background-color:'+bgcol+';';}
    if (bgimg!="") {chaine += 'background-image:url('+bgimg+');';}
    chaine += 'font-size:10pt;font-family:Arial Helvetica sans-serif;text-align:'+centre+';" '+special+'>'+contenu+'</div>';
  }
  return chaine+'\n';
}

function SupMenuActif() {
  if (menuActif != "") {
    CacherObj(menuActif);
    CacherObj("EffMenu");
    menuActif="";
  }
}

function CreerMenuActif(nom) {
  if (menuActif != "") {SupMenuActif()}
  menuActif=nom;
  VoirObj(menuActif);
  VoirObj("EffMenu");
}

function CrMenusSect(CSect,CSSect,CSSSect) {
// Lors de la création des objets, il faut commencer par ceux affichés et finir par ceux invisibles
  MenusSect="";
  lgmenu=450;
  htmenu=20;
  lgtitre=130;
  httitre=20;
  demiecttitre=10;
  lgwin=LargFen();
  lgtits=lgtitre;
  lft=Math.round((lgwin+190-lgtitre)/2);
  lftm=Math.round((lgwin+190-lgmenu)/2);
  if (CSSect != "") {
    lgtits += lgtitre+2*demiecttitre;
    lft=Math.round((lgwin+190-lgtits)/2);
    if (CSSSect != "") {
      lgtits += lgtitre+2*demiecttitre;
      lft=Math.round((lgwin+190-lgtits)/2);
    }
  }
  if (ns4) {MenusSect += '<P align="left">&nbsp;</P>\n';}
  MenusSect += CrObj("Sect",lft,ValVide,lgtitre,httitre,1,2,1,"Sections","onMouseOver='CreerMenuActif(\"NCSect\")'","#FFFFFF","#18588F","","");
  if (CSSect != "") {
    lft += lgtitre+2*demiecttitre;
    MenusSect += CrObj("SSect",lft,ValVide,lgtitre,httitre,1,2,1,"Sous-sections","onMouseOver='CreerMenuActif(\"NCSSect\")'","#FFFFFF","#18588F","","");
    if (CSSSect != "") {
      lft += lgtitre+2*demiecttitre;
      MenusSect += CrObj("SSSect",lft,ValVide,lgtitre,httitre,1,2,1,"Sous-sous-sections","onMouseOver='CreerMenuActif(\"NCSSSect\")'","#FFFFFF","#18588F","","");
    }
  }
  MenusSect += CrObj("NCSect",lftm,ValVide,lgmenu,htmenu,0,3,0,CSect,"","","","/shared/greige100.gif","#18588F");
  if (CSSect != "") {
    MenusSect += CrObj("NCSSect",lftm,ValVide,lgmenu,htmenu,0,3,0,CSSect,"","","","/shared/greige100.gif","#18588F");
    if (CSSSect != "") {
      MenusSect += CrObj("NCSSSect",lftm,ValVide,lgmenu,htmenu,0,3,0,CSSSect,"","","","/shared/greige100.gif","#18588F");
    }
  }
  if (!ns4) {MenusSect += '<P align="left">&nbsp;</P>';}
  document.write(MenusSect);

  if (ns4) {
    htot=document.NCSect.clip.height;
    if (CSSect != "") {
      tmp=document.NCSSect.clip.height;
      if (tmp > htot) {htot=tmp;}
      if (CSSSect != "") {
        tmp=document.NCSSect.clip.height;
        if (tmp > htot) {htot=tmp;}
      }
    }
    htot+=document.NCSect.pageY+20;
  } else {
    htot=1300;
  }
  MenusSect = CrObj("EffMenu",0,0,lgwin,htot,0,1,0,"","onMouseOver='SupMenuActif()'","","","","");
  document.write(MenusSect);
}

