if (typeof (AG) == "undefined") {
    AG = {};

};

AG.Menu =
{
    tabPathActive: '',
    tabActiveLevel1: '',
    tabActiveLevel2: '',

    DisplayMenu2Degree: function (strUrl, moduleId, language) {
        var tabhover = 0;
        var iTabAciveL0_711 = 0;

        $.ajax({
            type: "Get",
            url: strUrl,
            async: false,
            dataType: "xml",
            success: function (xml) {
                //Lấy ra đường dẫn của trang hiện tại
                $(xml).find("SiteMap").each(function () {
                    if (($(this).find("Url").text()) == ("/TabId/" + tabid711 + "/Default.aspx")) {
                        AG.Menu.tabPathActive = $(this).find("TabPath").text();
                        document.title = $(this).find("Title").text();
                    }
                });
                //Từ đường dẫn của trang hiện tại lấy ra đường dẫn của cấp Level 0 và đường dẫn của cấp Level 1
                ArrayActive = AG.Menu.tabPathActive.split('//');
                tabPathActiveLevel1 = '//' + ArrayActive[1];
                tabPathActiveLevel2 = '//' + ArrayActive[1] + '//' + ArrayActive[2];
                tabPathActiveLevel2 = '//' + ArrayActive[1] + '//' + ArrayActive[2] + '//' + ArrayActive[3];

                //Từ đường dẫn của các cấp Level 0 và Level 1 lấy ra được TabId của các cấp Level 0 và Level 1 dùng để active
                $(xml).find("SiteMap").each(function () {
                    if ($(this).find('Level').text() == 0) {
                        var tabname = $(this).find("TabName").text();
                        if (tabname == ArrayActive[1]) {
                            iTabAciveL0_711 = $(this).find("TabId").text();
                        }
                        tabname2 = tabname;
                        tabname2 = tabname2.replace(/\-/g, '');
                        ArrayActive[1] = ArrayActive[1].replace(/\-/g, '');
                        if (tabname2 == ArrayActive[1]) {
                            iTabAciveL0_711 = $(this).find("TabId").text();

                        }

                    }
                });
                var strHtml = "";
                strHtml += "<div class='MenuMain'>";
                $(xml).find("SiteMap").each(function () {
                    if ($(this).find("Level").text() == 0) {
                        var title = $(this).find("Title").text();
                        var url = $(this).find("Url").text();
                        var tabid = $(this).find("TabId").text();
                        strHtml += "<a href=" + url + " class='Rootmenu' id='Rootmenu" + tabid + "' >" + title + "</a>";

                    }
                });
                strHtml += "</div>";
                $('#divSiteMap711').html(strHtml);
                $(document).ready(function () {
                    $('#Rootmenu' + iTabAciveL0_711).addClass('RootmenuA');
                    $('.MenuMain a').hover(function () {
                        $('.RootmenuA').removeClass('RootmenuA');
                        $('.MenuMain a').addClass('Rootmenu');
                        $(this).removeClass('Rootmenu');
                        $(this).addClass('RootmenuA');
                    });
                    $('.MenuMain a').mouseout(function () {
                        $('.RootmenuA').removeClass('RootmenuA');
                        $('.MenuMain a').addClass('Rootmenu');
                        $('#Rootmenu' + iTabAciveL0_711).addClass('RootmenuA');
                    });

                });
                if (agLanguageName == 'en-US') {
                    $('.MenuMain a ').css('padding', '0 27px')
                    $('.MenuMain a#Rootmenu147').css('padding', '0 18px')
                }
            }
        });
    }

}
AG.Menu.DisplayMenu2Degree("/DesktopModules/AG.Menu/Xml/711_" + agLanguageName + ".xml", 711, agLanguageName);

