﻿function SetMenu(path) {
    $(document).ready(
            function() { InitMenu(path); }
    );
}



function InitMenu(openPath) {

    var splitPath = openPath.split(':');

    $("div.level_2_wrapper").hide();
    $("div.level_3_wrapper").hide();
    $("div.level_3_wrapper").hide();

    $("div.menu_level_1").click(
        function() {
            var subNav = $(this).next();

            if (subNav.attr("class") == "menu_level_2" || subNav.attr("class") == "menu_level_1") { return; }

            ToggleItem(subNav);

        }
    );

    $("div.menu_level_2").click(
        function() {
            var subNav = $(this).next();

            if (subNav.attr("class") == "menu_level_2" || subNav.attr("class") == "menu_level_1") { return; }

            ToggleItem(subNav);
        }
    );

    for (i = 0; i < splitPath.length; i++) {
        
        $("#" + splitPath[i]).show();   
    }

    
};



function ToggleItem(item) {
    if (item.is(":visible")) {
        item.animate({ height: "toggle" }, 300);
    }
    else {
        item.animate({ height: "toggle" }, 300);
    }
}
