!function(e){e.extend(e.tree.plugins,{checkbox:{defaults:{three_state:!0},get_checked:function(n){return n||(n=e.tree.focused()),n.container.find("a.checked").parent()},get_undeterminded:function(n){return n||(n=e.tree.focused()),n.container.find("a.undetermined").parent()},get_unchecked:function(n){return n||(n=e.tree.focused()),n.container.find("a:not(.checked, .undetermined)").parent()},check:function(n){if(!n)return!1;var c=e.tree.reference(n);if((n=c.get_node(n)).children("a").hasClass("checked"))return!0;return e.extend(!0,{},e.tree.plugins.checkbox.defaults,c.settings.plugins.checkbox).three_state?(n.find("li").andSelf().children("a").removeClass("unchecked undetermined").addClass("checked"),n.parents("li").each(function(){if(e(this).children("ul").find("a:not(.checked):eq(0)").size()>0)return e(this).parents("li").andSelf().children("a").removeClass("unchecked checked").addClass("undetermined"),!1;e(this).children("a").removeClass("unchecked undetermined").addClass("checked")})):n.children("a").removeClass("unchecked").addClass("checked"),!0},uncheck:function(n){if(!n)return!1;var c=e.tree.reference(n);if((n=c.get_node(n)).children("a").hasClass("unchecked"))return!0;return e.extend(!0,{},e.tree.plugins.checkbox.defaults,c.settings.plugins.checkbox).three_state?(n.find("li").andSelf().children("a").removeClass("checked undetermined").addClass("unchecked"),n.parents("li").each(function(){if(e(this).find("a.checked, a.undetermined").size()-1>0)return e(this).parents("li").andSelf().children("a").removeClass("unchecked checked").addClass("undetermined"),!1;e(this).children("a").removeClass("checked undetermined").addClass("unchecked")})):n.children("a").removeClass("checked").addClass("unchecked"),!0},toggle:function(n){if(!n)return!1;(n=e.tree.reference(n).get_node(n)).children("a").hasClass("checked")?e.tree.plugins.checkbox.uncheck(n):e.tree.plugins.checkbox.check(n)},callbacks:{onchange:function(n,c){e.tree.plugins.checkbox.toggle(n)}}}})}(jQuery);