/// class PD.Manage.ManageMenu
// using PD.Web.UI.Control

PD.Manage.ManageMenu = PD.Web.UI.Controls.Control.extend({

    //===================================
    // EVENT HANDLERS
    //===================================

    onActivate: function (e) {

        var that = this;

        PD.ajax({
            url: PD.Path.resolve("~/Manage/Home/Menu"),
            success: function (e) {
                that.get_node().find(".-pd-manage-menu-title").html(e.applicationName);
                that._renderMenu(e);
            }
        });

    },

    //===================================
    // PUBLIC METHODS
    //===================================

    template: function (data) {

        return [
            "<div class='-pd-manage-menu'>",
                "<a href='#/module/overview' class='-pd-manage-menu-item -pd-manage-menu-button -pd-manage-menu-home'></a>",
                "<div class='-pd-manage-menu-item -pd-manage-menu-title'>Prospect Director</div>",
                "<a href='#' class='-pd-manage-menu-item -pd-manage-menu-button -pd-manage-menu-user'></a>",
                "<a href='" + PD.Path.resolve("~/Home") + "' class='-pd-manage-menu-item -pd-manage-menu-button -pd-manage-menu-main' target='_blank'></a>",
            "</div>"
        ];

    },

    //===================================
    // PRIVATE METHODS
    //===================================

    _renderMenu: function (e) {

        var $filter = this.get_node().find(".-pd-manage-menu-user"),
            $content = $("<div class='-pd-site-menu'></div>");

        $content.append("<div class='-pd-site-menu-item -pd-site-menu-head'>" + e.userDisplayName + "</div>");

        if (PD.ENVIRONMENT.AUTH_MODE === "Local") {
            $content.append("<a href='" + PD.Path.resolve("~/Shared/Account/LogOut") + "' class='-pd-site-menu-item -pd-selectable'>Sign Out</a>");
        }

        Tipped.create($filter[0], $content[0].outerHTML, {
            skin: "white",
            stem: false
        });

    }

});