function addMenu(name, id, position, relativeID) {
        name = StringUtils.htmlEscape(name);
        var $menubar = $("#main-toolbar .nav"),
            menu;

        if (!name || !id) {
            throw new Error("call to addMenu() is missing required parameters");
        }
        
        // Guard against duplicate menu ids
        if (menuMap[id]) {
            console.log("Menu added with same name and id of existing Menu: " + id);
            return null;
        }

        menu = new Menu(id);
        menuMap[id] = menu;

        var $toggle = $("<a href='#' class='dropdown-toggle'>" + name + "</a>"),
            $popUp = $("<ul class='dropdown-menu'></ul>"),
            $newMenu = $("<li class='dropdown' id='" + id + "'></li>").append($toggle).append($popUp);

        // Insert menu
        var $relativeElement = relativeID && $(_getHTMLMenu(relativeID));
        _insertInList($menubar, $newMenu, position, $relativeElement);
        
        // Install ESC key handling
        PopUpManager.addPopUp($popUp, closeAll, false);

        // todo error handling

        return menu;
    }
Adds a top-level menu to the application menu bar which may be native or HTML-based.

@param {!string} name - display text for menu 
@param {!string} id - unique identifier for a menu.
     Core Menus in Brackets use a simple  title as an id, for example "file-menu".
     Extensions should use the following format: "author.myextension.mymenuname". 
@param {?string} position - constant defining the position of new the Menu relative
 to other Menus. Default is LAST (see Insertion position constants).
     
@param {?string} relativeID - id of Menu the new Menu will be positioned relative to. Required
     when position is AFTER or BEFORE, ignored when position is FIRST or LAST

@return {?Menu} the newly created Menu