﻿//Category tree
var treeLoaded = false;
$(function () {
    if ($('#demo1').length > 0) {
        $("#demo1").jstree({
            "themes": { "theme": "tree", "dots": true, "icons": false, "url": 'styles/tree/style.css' },
            "plugins": ["themes", "html_data", "ui", "crrm", "hotkeys"]

        }).bind("loaded.jstree", function (event, data) {
            if (typeof (setTreeNode) != 'undefined') { setTreeNode(); }
            treeLoaded = true;
            $('#treeLoader').hide();
            $('#demo1').show();
            $('#bbBox').css('height', '100%');

        }).bind("select_node.jstree", function (event, data) {
            if (treeLoaded && data.args[0].href != null) {

                window.location.href = data.args[0].href; return;
                $('.mainLoader').css('height', $('#aside').height());
                $('#siteContent').fadeOut(450);
                $('.mainLoader').fadeIn(450);

                $.get(data.args[0].href + '?ajax=1', function (data) {
                    $('#siteContent').html(data);
                    $('#siteContent').fadeIn(450);
                    $('.mainLoader').fadeOut(450);

                });
            }
        });
    }
});

