/* Retrieves an autogenerated, unique identifier for the object. */
var defaultTextColor = new Array();

activateMenu = function(nav, hightlightColor) {
    /* currentStyle restricts the Javascript to IE only */
    if (document.all && document.getElementById(nav).currentStyle) {
        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++) {

            /* Store preset colors for every link. */
            defaultTextColor[ lis[i].getElementsByTagName("A")[0].uniqueID ]
                = '"' + lis[i].getElementsByTagName("A")[0].currentStyle.color + '"';


            /* The following differentiation between item with (folded/unfolded) submenus
               and items without submenus is necessary because the mouseOver/mouseOut event
               can only be defined once and the display property has to be set or not.
               Most of the code is redundant, though */

            /* If the LI has another, folded menu level
               (an unfolded submenu is marked with id "open"!!) */
            if (lis[i].lastChild.tagName == "UL"  &&  lis[i].id != "open") {
                /* assign the function to the LI */

                /* Mouse-over event */
                lis[i].onmouseover = function() {
                    /* Change color and alignment of triggering anchor */
                    this.getElementsByTagName("A")[0].style.setExpression("color", hightlightColor);

                    /* display the inner menu */
                    this.lastChild.style.display = "block";
                }

                /* Mouse-out event */
                lis[i].onmouseout = function() {
                    /* Change color and alignment of triggering anchor */
                    this.getElementsByTagName("A")[0].style.setExpression("color",
                        defaultTextColor[ this.getElementsByTagName("A")[0].uniqueID ] );

                    /* hide the inner menu */
                    this.lastChild.style.display = "none";
                }

            /* a) LI without submenu
             * b) LI with unfolded submenu */
            } else if (lis[i].lastChild.tagName == "UL"  &&  lis[i].id == "open") {
                /* Do nothing */

            } else {
                /* Mouse-over event:
                 * Change color and alignment of first anchor in list item */
                lis[i].onmouseover = function() {
                    /* Change color and alignment of triggering anchor */
                    this.getElementsByTagName("A")[0].style.setExpression("color", hightlightColor);
                }

                /* Mouse-out event:
                 * Restore and alignment of first anchor in list item */
                lis[i].onmouseout = function() {
                    /* Change color and alignment of triggering anchor */
                    this.getElementsByTagName("A")[0].style.setExpression("color",
                        defaultTextColor[ this.getElementsByTagName("A")[0].uniqueID ] );
                }
            }
        } // end loop over all list items
    } // end IE detection
} // end function

