// JavaScript Document

var intCount = 0;

//-Fonction d'ajout d'entrées principales-------------------------
function DynamicMenu_addParent(strName) {
  var strID = 'ID' + intCount++;
  var strTemp = '<SPAN ID="' + strID + '" CLASS="parent"';
        strTemp += ' onClick="expandCollapse(this);">';
        strTemp += ' ' + strName ;
        strTemp += '<IMG SRC="../__images/menu_gauche/pix.gif">';
        strTemp += '<DIV STYLE="display: none" CLASS="child" id="toto" style="background-color:#B3D1ED"></DIV>';
        strTemp += '</SPAN>';
  this.div.innerHTML += strTemp;
        this.currentChild = document.getElementById(strID);
}

//-Fonction d'ajout de liens dans le menu-------------------------
function DynamicMenu_addChild(strName,strURL,strTitre,strName2,strURL2,strTitre2,strName3,strURL3,strTitre3,strName4,strURL4,strTitre4) {
	var toto = intCount -1;
  var strTemp = '<A HREF="?aff=ID'+toto+'&titre='+strTitre+'&titre2='+strName+'&loc=' + strURL + '"' + ' onClick="cancelBubble(arguments[0]);" id="liens">' + strName + '</A>';
  if (strName2 != "") {
	    strTemp += '<A HREF="?aff=ID'+toto+'&titre='+strTitre2+'&titre2='+strName2+'&loc=' + strURL2 + '"' + ' onClick="cancelBubble(arguments[0]);" id="ssmenu">' + strName2 + '</A>';
  }
  else {
	   strTemp += ' ';
  }
  if (strName3 != "") {
	    strTemp += '<A HREF="?aff=ID'+toto+'&titre='+strTitre3+'&titre2='+strName3+'&loc=' + strURL3 + '"' + ' onClick="cancelBubble(arguments[0]);" id="ssmenu">' + strName3 + '</A>';
  }
    else {
	   strTemp += ' ';
  }
  if (strName4 != "") {
	    strTemp += '<A HREF="?aff=ID'+toto+'&titre='+strTitre4+'&titre2='+strName4+'&loc=' + strURL4 + '"' + ' onClick="cancelBubble(arguments[0]);" id="ssmenu">' + strName4 + '</A>';
  }
    else {
	   strTemp += ' ';
  }

if (document.all) {
          this.currentChild.children[1].innerHTML += strTemp;
  } else {
          this.currentChild.childNodes[2].innerHTML += strTemp;
  }
}

//-inhibe la cascade d'évènements au DIV conteneur----------------
function cancelBubble(netEvent) {
  if (document.all) {
    window.event.cancelBubble = true;
  } else {
          netEvent.cancelBubble = true;
  }
}

//-Contracte ou expanse le menu-----------------------------------
function expandCollapse(objElement) {
  if (document.all) {
          var imgIcon = objElement.children[0];
                objElement = objElement.children[1];
  } else {
          var imgIcon = objElement.childNodes[0];
                objElement = objElement.childNodes[2];
  }
  if (objElement.style.display == "none") {
          objElement.style.display = "block" ;
                imgIcon.src = "../__images/menu_gauche/pix.gif" ;
  } else {
          objElement.style.display = "none" ;
                imgIcon.src = "../__images/menu_gauche/pix.gif" ;
  }
}

//-Fonction de création de menu dynamique-------------------------
function DynamicMenu() {
  var id = "Menu" + intCount++;
        document.write('<SPAN Id="' + id + '"></SPAN>');
  this.div = document.getElementById(id);
        this.currentChild = null;
  this.addParent = DynamicMenu_addParent;
        this.addChild = DynamicMenu_addChild;
}