

function MWHierNavNamespace()
{


function HierNav()
{
}


HierNav.config = { autosubmenudisplay:true, hidedelay:50, lazyload:true, submenualignment:["tr", "br"] };

HierNav.onHierMainMenuReady = function()
{
    var oMenuBar = new YAHOO.widget.MenuBar("HierMainMenu", HierNav.config);

    oMenuBar.render();
}


HierNav.onHierSubMenuReady = function()
{
    var oMenuBar = new YAHOO.widget.MenuBar("HierSubMenu", HierNav.config);

    oMenuBar.render();
}


HierNav.onBodyReady = function()
{
    // Create the menus
    HierNav.onHierMainMenuReady();
    HierNav.onHierSubMenuReady();
}



///////////////////////////
// InstallLibrary

function InstallLibrary(target)
{
    // Override the images we'll use to indicate submenus; this affects ALL menus; if anyone else
    // wants to use YUI mmenus on the site, well, you're SOL.
    // YAHOO.widget.MenuItem.prototype.IMG_ROOT = "http://raptor2-dev.marketwatch.com/Images/Nav/";
    YAHOO.widget.MenuItem.prototype.IMG_ROOT = "http://i.mktw.net/mw3/Nav/";
    YAHOO.widget.MenuItem.prototype.IMG_ROOT_SSL = "https://i.mktw.net/mw3/Nav/";

    YAHOO.widget.MenuBarItem.prototype.SUBMENU_INDICATOR_IMAGE_PATH = "nav-arrow.gif";
    YAHOO.widget.MenuBarItem.prototype.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH = "nav-arrow-select.gif";
    YAHOO.widget.MenuBarItem.prototype.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH = "nav-arrow.gif"; // TODO - replace with better version

    // Ugh.  This is a hack to YUI 0.12.2 to prevent setting focus to the menu item.  This
    // may very well break if we switch YUI versions, so beware.  It is basically just the
    // YUI function, copy-and-pasted, with the setFocus call (and function) removed.
    YAHOO.widget.MenuItem.prototype.focus = function()
    {
        var oParent = this.parent,
            oAnchor = this._oAnchor,
            oActiveItem = oParent.activeItem;

        if(!this.cfg.getProperty("disabled") && oParent && oParent.cfg.getProperty("visible") && this.element.style.display != "none")
        {
            if(oActiveItem)
            {
                oActiveItem.blur();
            }
            this.focusEvent.fire();
        }
    }

    // TODO - use the browser detection from YUI once they implement it (or use yui-ext)
    var ua = navigator.userAgent.toLowerCase();
    var isOpera = (ua.indexOf('opera') > -1);
    var isIE = (!isOpera && ua.indexOf('msie') > -1);

    // If the DOM manipulation of menus is triggered when the content is ready, it causes IE
    // to blow up (not always, but enough to make it annoying, as it will refuse to load the
    // page).  On FF, it works fine, and the menus appear faster.
    if (isIE)
    {
        YAHOO.util.Event.addListener(window, "load", HierNav.onBodyReady);
    }
    else
    {
        YAHOO.util.Event.onContentReady("HierMainMenu", HierNav.onHierMainMenuReady);
        YAHOO.util.Event.onContentReady("HierSubMenu", HierNav.onHierSubMenuReady);
    }
};


InstallLibrary();

}


MWHierNavNamespace();