var intCount = 0;

//-Fonction de création de menu dynamique------------------------- 
function TreeDynamicMenu() {
    var id = "Menu" + intCount++;
    document.write('<DIV Id="' + id + '"></DIV>');

    this.div = document.getElementById(id);
    this.addChild = DynamicMenu_addChild;
}

//-Fonction de création d'un bloc déroulant-----------------------
function TreePopupMenu(strName, parentMenu) {    
    var strID = 'ID' + intCount++; 

    var strTemp = '<DIV CLASS="TreeParent" onClick="expandCollapse(this);cancelBubble(arguments[0]);">';
    strTemp    +=     '<IMG SRC="' + WEB_SITE_ROOT + '/Images/Right.gif" Height="12">&nbsp;' + strName ;
    strTemp    +=     '<DIV ID="' + strID + '" STYLE="display: none" CLASS="TreeChild"></DIV>';
    strTemp    += '</DIV>';

    parentMenu.div.innerHTML += strTemp;
    this.div = document.getElementById(strID);
    this.addChild = DynamicMenu_addChild;
}


//-Fonction d'ajout de liens dans le menu-------------------------
function DynamicMenu_addChild(strName,strURL) {
    var strTemp = '<A HREF="' + strURL + '" onClick="cancelBubble(arguments[0]);">' + strName + '</A><BR>';
    this.div.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 = WEB_SITE_ROOT + "/Images/Bottom.gif" ;
    } else {
        objElement.style.display = "none" ;
        imgIcon.src = WEB_SITE_ROOT + "/Images/Right.gif" ;
    }
}

