activateMenu = function(nav) {
    if(document.all && document.getElementById(nav).currentStyle){
        // only MSIE supports document.all
        var navroot = document.getElementById(nav);
        // Get all the list items within the menu 
        var lis=navroot.getElementsByTagName("LI");
        for(i=0;i<lis.length;i++){
            // don't want to overwrite any existing mouse over or mouse out evets
            lis[i].oldonmouseover = lis[i].onmouseover;
            lis[i].oldonmouseout = lis[i].onmouseout;

            // If the LI has other menu levels
            var myChildren=lis[i].children;
            for(j=0;j<myChildren.length;j++){
                if(myChildren[j].tagName=="UL"){
                    // assign the function to the LI
                    lis[i].onmouseover=function(evt){
                        // display the inner menu
                        if(this.oldonmouseover){
                            this.oldonmouseover(evt);
                        }
                        this.lastChild.style.display="block";
                    }
                    lis[i].onmouseout=function(evt){
                        if(this.oldonmouseout){
                            this.oldonmouseout(evt);
                        }
                        this.lastChild.style.display="none";
                    }
                }
            }
        }
    }
}
window.onload=function(){
    // pass the function the id of the top level UL
    // remove one, when only using one menu
    activateMenu('dmenu');
}
