try { 
    document.execCommand("BackgroundImageCache", false, true); 
} catch(err) {} 
// JavaScript Document
function initMenu(menuDirectory, menuFormat) {
    aoUl = document.getElementsByClassName('CGDynamicMenu');
    for(iUl=0;iUl<aoUl.length;iUl++) {
        oUl = aoUl[iUl];
        sFinalDir = oUl.className;                                                     // Get the classes of the element
        sFinalDir = sFinalDir.replace(' CGDynamicMenu', '');                           // Strip the function name from the class
        sFinalDir = sFinalDir.replace('CGDynamicMenu ', '');                           // Strip the function name from the class (again)
        sFinalDir = sFinalDir.replace('CGDynamicMenu', '');                            // Strip the function name from the class (again)

        if (sFinalDir != '') { sPath = menuDirectory + sFinalDir+'/'; }                // Add the class name to the end of the images path
        else { sPath = menuDirectory; }        // Or use the default path

        oUl.style.listStyle = 'none';                                                  // Reset the list-style to none.
        aLi = oUl.getElementsByTagName('li');                                          // Get all the list item
        for(iLi=0;iLi<aLi.length;iLi++) {
            oLi = aLi[iLi];
            if (oLi.parentNode == oUl) {
                oLi.style.position = 'relative';                                       // The the LI relative position
                oA = oLi.getElementsByTagName('a')[0];                                 // Get the link of the LI
                if (oA) {
                    oLi.style.fontSize = 0;
                    sImageOff = sPath+oLi.className+'_0.'+menuFormat;                  // Get the real image_0 path
                    oLi.style.background = 'url('+sImageOff+') top left no-repeat';    // Set that image to the LI's background
                    oA.innerHTML = '';                                                 // Strip the text of the link

                    oImg = document.createElement('img');                              // Create the image_1 element
                    oImg.src=sPath+oLi.className+'_1.'+menuFormat;                     // Set the image_1 path
                    oImg.style.visibility = 'hidden';                                  // Preset the image_1 visibility to hidden
                    oImg.style.border = 'none';                                        // Reset the image border to none
                    oA.appendChild(oImg);

                    Event.observe(oLi, 'mouseover', function (e) {
                        this.style.visibility = 'visible'                              // Make the image_1 visible on mouseover
                    }.bindAsEventListener(oImg));
                    Event.observe(oLi, 'mouseout', function (e) {
                        this.style.visibility = 'hidden'                               // Make the image_1 hidden on mouseout
                    }.bindAsEventListener(oImg));
                }
                oSubUl = oLi.getElementsByTagName('ul')[0];                            // Get the link of the LI
                if (oSubUl) {
                    oSubUl.style.display = 'none';                                     // Preset the submenu display to none
                    oSubUl.style.position = 'absolute';                                // Preset the submenu as absolute position
                    oSubUl.style.zIndex = '2000';                                      // Preset the submenu z-index to 2000
                    Event.observe(oLi, 'mouseover', function (e) {
                        this.style.display = 'block';                                  // Make the submenu visible on mouseover
                    }.bindAsEventListener(oSubUl));
                    Event.observe(oLi, 'mouseout', function (e) {
                        this.style.display = 'none';                                   // Make the submenu visible on mouseover
                    }.bindAsEventListener(oSubUl));
                }
            }
        }
    }
}