$(function(){  
  $("#menu_container").jstree({
    "plugins" : [ "themes", "json_data", "ui", "cookies" ],
    "themes" : {
      "theme" : "sl_menu",
      "icons": false,
      "dots" : false
    },
    "cookies" : {
      "save_opened" : "menu_container_jstree_open",
      "save_selected" : "menu_container_jstree_select"
    },
    "json_data" : {
      "ajax" : {
        "type" : "POST",
        "url" : "/ajax_server/db_json/svr_menu.php?",
        "data" : function (n) {
          return {
            id : n.attr ? n.attr("id") : 0,
            SLPageID: SLPageID,
            SLPageName: SLPageName,
            oper: 'get_menu_JSON'
          };
        }
      }
    }
  });
  $("#menu_container").bind("reselect.jstree", function () {
    $("#menu_container").bind("select_node.jstree", function (e, data) {
      $("#menu_container").jstree("open_node",data.rslt.obj);
      var href = data.rslt.obj.children("a").attr("href");
      var target = data.rslt.obj.children("a").attr("target");
      var MenuUseAjax = data.rslt.obj.attr("MenuUseAjax");
      if ( MenuUseAjax == "1" ) {
        var Data = {
          "ajax" : true,
          SLPageID: SLPageID,
          SLPageName: SLPageName,
          Action: 'AjaxContent'
        };
        $.ajax({
          type : "POST",
          url  : href,
          data : Data,
          cache : false,
          success : function(html){
            $("#SL_Content").html(html);
          }
        });
        $("#SL_Page_Properties").remove();
        return true;
      }
      else {
        if (target){
          window.open(href,target);
          return true;
        }
        else{
          document.location.href = href;
          return true;
        }
      }
    })
  });
});
