﻿// Lnb Set
$(document).ready(function() {
    try {
        var currentLocation = location.pathname;
        var tempArray = currentLocation.split("/");
        var filePath = currentLocation.substring(0, currentLocation.lastIndexOf("/") + 1).toLowerCase();
        var fileName = tempArray[tempArray.length - 1].toLowerCase();
        if (fileName == null || fileName == "") {
            fileName = "default.aspx";
        }
        var xmlNode = "menu";
        var xmlFile = "/common/xml/lnb.xml";


        //alert(tempmenu.indexOf('/Menu/list.aspx?Type1=3'));


        $.ajax({
            url: xmlFile,
            type: 'GET',
            dataType: 'xml',
            error: function(response) {
                //alert(response.responseText);
                return "0";
            },
            success: function(xml) {
                $(xml).find(xmlNode).each(function() {
                    var $entry = $(this);
                    if (filePath == "/menu/") {
                        filePath = currentLocation.toLowerCase() + location.search.toLowerCase();
                        if (filePath.indexOf('/menu/list.aspx?type1=1') > -1) {
                            initSubmenu(1, 1);
                        } else if (filePath.indexOf('/menu/list.aspx?type1=2') > -1) {
                            initSubmenu(2, 1);
                        }
                        else if (filePath.indexOf('/menu/list.aspx?type1=3') > -1) {
                            initSubmenu(3, 1);
                        }
                        else if (filePath.indexOf('/menu/list.aspx?type1=4') > -1) {
                            initSubmenu(4, 1);
                        }
                    } else {
                        if (filePath == $entry.attr("link").substring(0, $entry.attr("link").lastIndexOf("/") + 1).toLowerCase()) {
                            var filegroup = $entry.attr("filegroup").split(',');
                            for (var i = 0; i < filegroup.length; i++) {
                                if (filegroup[i].toLowerCase() == fileName) {
                                    var depth = $entry.attr("depth").split(',');
                                    var d1 = depth[0];
                                    var d2 = depth[1];
                                    var d3 = depth[2];
                                    initSubmenu(d2, d3);
                                }

                            }
                        }
                    }
                });
            }
        });
    } catch (e) { }
});

