(function(b){var f={url:"?app=system&controller=category&action=cate&catid=%s",paramId:"catid",paramHaschild:"hasChildren",renderTxt:function(a,c,d){return b('<span id="'+c+'">'+d.name+"</span>")},active:function(a,c){b("#topcategory").hide();b("#subcategory").show();current_catid=c;category.edit(current_catid)}};window.category={add:function(a){if(a){b("#edit").attr("class","");b("#add").attr("class","s_3");b("#category_edit_box").load("?app=system&controller=category&action=add&parentid="+a)}else{b("#topcategory").show();
b("#subcategory").hide();b("#category_edit_box").load("?app=system&controller=category&action=add")}},add_submit:function(a){if(a.state){category.reload(a.catid,a.path);document.getElementById("category_add").reset();ct.ok("\u4fdd\u5b58\u6210\u529f")}else ct.error(a.error)},edit:function(a){b("#add").attr("class","");b("#edit").attr("class","s_3");b("#category_edit_box").load("?app=system&controller=category&action=edit&catid="+a)},edit_submit:function(a){if(a.state){b("#"+a.catid).html(a.name);ct.ok("\u4fdd\u5b58\u6210\u529f")}else ct.error(a.error)},
del:function(a){var c=b("#"+a);ct.confirm('\u786e\u8ba4\u5220\u9664 <span class="c_red">'+c.html()+"</span> \u680f\u76ee\u5417\uff1f",function(){b.getJSON("?app=system&controller=category&action=delete&catid="+a,function(d){if(d.state){d=c.closest("li");var e=d.siblings("li:eq(0)");if(e.length)e.triggerHandler("clk.tree");else{e=d.parent().parent();e[0].nodeName=="LI"?category.reload(e.attr("idv")):category.add()}d.remove();ct.ok("\u680f\u76ee\u5220\u9664\u6210\u529f")}else ct.error(d.error)})},function(){})},
move:function(a){ct.form("\u79fb\u52a8\u680f\u76ee","?app=system&controller=category&action=move&catid="+a,350,300,function(c){if(c.state){category.reload(a);return true}else ct.error(c.error)},function(c){c.find("#category_move").tree({async:false,expanded:true})})},reload:function(a,c){b("#category_tree").empty();b("#category_tree").tree(b.extend({prepared:function(){var d=this;c?d.open(c,true):b.getJSON("?app=system&controller=category&action=path&catid="+a,function(e){d.open(e,true)})}},f))},
repair:function(){b.getJSON("?app=system&controller=category&action=repair",function(a){a.state?ct.alert("\u64cd\u4f5c\u6210\u529f","ok"):ct.error(a.error)})},content_move:function(a){ct.form("\u79fb\u52a8"+b("#"+a).html()+"\u680f\u76ee\u5185\u5bb9\u81f3\uff1a","?app=system&controller=content&action=move&sourceid="+a,350,300,function(c){if(c.state){ct.tips("\u64cd\u4f5c\u6210\u529f");return true}else ct.error(c.error)},function(c){c.find("#category_tree").tree({async:false,expanded:true})})},content_clear:function(a){ct.confirm('\u786e\u8ba4\u6e05\u7a7a <span class="c_red">'+
b("#"+a).html()+"</span> \u680f\u76ee\u5185\u5bb9\u5417\uff1f",function(){b.getJSON("?app=system&controller=content&action=clear&catid="+a,function(c){c.state?ct.ok("\u64cd\u4f5c\u6210\u529f"):ct.error(c.error)})},function(){})}}})(jQuery);
