/*
 * JQuery zTree core 3.1
 * http://code.google.com/p/jquerytree/
 *
 * Copyright (c) 2010 Hunter.z (baby666.cn)
 *
 * Licensed same as jquery - MIT License
 * http://www.opensource.org/licenses/mit-license.php
 *
 * email: hunter.z@263.net
 * Date: 2012-02-14
 */
(function(l){var D,E,F,G,H,I,p={},J={},s={},M=0,K={treeId:"",treeObj:null,view:{addDiyDom:null,autoCancelSelected:!0,dblClickExpand:!0,expandSpeed:"fast",fontCss:{},nameIsHTML:!1,selectedMulti:!0,showIcon:!0,showLine:!0,showTitle:!0},data:{key:{children:"children",name:"name",title:""},simpleData:{enable:!1,idKey:"id",pIdKey:"pId",rootPId:null},keep:{parent:!1,leaf:!1}},async:{enable:!1,contentType:"application/x-www-form-urlencoded",type:"post",dataType:"text",url:"",autoParam:[],otherParam:[],dataFilter:null},
callback:{beforeAsync:null,beforeClick:null,beforeRightClick:null,beforeMouseDown:null,beforeMouseUp:null,beforeExpand:null,beforeCollapse:null,onAsyncError:null,onAsyncSuccess:null,onNodeCreated:null,onClick:null,onRightClick:null,onMouseDown:null,onMouseUp:null,onExpand:null,onCollapse:null}},t=[function(b){var a=b.treeObj,c=f.event;a.unbind(c.NODECREATED);a.bind(c.NODECREATED,function(a,c,h){k.apply(b.callback.onNodeCreated,[a,c,h])});a.unbind(c.CLICK);a.bind(c.CLICK,function(a,c,h,j){k.apply(b.callback.onClick,
[a,c,h,j])});a.unbind(c.EXPAND);a.bind(c.EXPAND,function(a,c,h){k.apply(b.callback.onExpand,[a,c,h])});a.unbind(c.COLLAPSE);a.bind(c.COLLAPSE,function(a,c,h){k.apply(b.callback.onCollapse,[a,c,h])});a.unbind(c.ASYNC_SUCCESS);a.bind(c.ASYNC_SUCCESS,function(a,c,h,j){k.apply(b.callback.onAsyncSuccess,[a,c,h,j])});a.unbind(c.ASYNC_ERROR);a.bind(c.ASYNC_ERROR,function(a,c,h,j,g,f){k.apply(b.callback.onAsyncError,[a,c,h,j,g,f])})}],q=[function(b){var a=g.getCache(b);a||(a={},g.setCache(b,a));a.nodes=[];
a.doms=[]}],v=[function(b,a,c,d,e,h){if(c){var j=b.data.key.children;c.level=a;c.tId=b.treeId+"_"+ ++M;c.parentTId=d?d.tId:null;if(c[j]&&c[j].length>0){if(typeof c.open=="string")c.open=k.eqs(c.open,"true");c.open=!!c.open;c.isParent=!0;c.zAsync=!0}else{c.open=!1;if(typeof c.isParent=="string")c.isParent=k.eqs(c.isParent,"true");c.isParent=!!c.isParent;c.zAsync=!c.isParent}c.isFirstNode=e;c.isLastNode=h;c.getParentNode=function(){return g.getNodeCache(b,c.parentTId)};c.getPreNode=function(){return g.getPreNode(b,
c)};c.getNextNode=function(){return g.getNextNode(b,c)};c.isAjaxing=!1;g.fixPIdKeyValue(b,c)}}],w=[function(b){var a=b.target,c=p[b.data.treeId],d="",e=null,h="",j="",i=null,o=null,l=null;if(k.eqs(b.type,"mousedown"))j="mousedown";else if(k.eqs(b.type,"mouseup"))j="mouseup";else if(k.eqs(b.type,"contextmenu"))j="contextmenu";else if(k.eqs(b.type,"click"))if(k.eqs(a.tagName,"button")&&a.blur(),k.eqs(a.tagName,"button")&&a.getAttribute("treeNode"+f.id.SWITCH)!==null)d=a.parentNode.id,h="switchNode";
else{if(l=k.getMDom(c,a,[{tagName:"a",attrName:"treeNode"+f.id.A}]))d=l.parentNode.id,h="clickNode"}else if(k.eqs(b.type,"dblclick")&&(j="dblclick",l=k.getMDom(c,a,[{tagName:"a",attrName:"treeNode"+f.id.A}])))d=l.parentNode.id,h="switchNode";if(j.length>0&&d.length==0&&(l=k.getMDom(c,a,[{tagName:"a",attrName:"treeNode"+f.id.A}])))d=l.parentNode.id;if(d.length>0)switch(e=g.getNodeCache(c,d),h){case "switchNode":e.isParent?k.eqs(b.type,"click")||k.eqs(b.type,"dblclick")&&k.apply(c.view.dblClickExpand,
[c.treeId,e],c.view.dblClickExpand)?i=D:h="":h="";break;case "clickNode":i=E}switch(j){case "mousedown":o=F;break;case "mouseup":o=G;break;case "dblclick":o=H;break;case "contextmenu":o=I}return{stop:!1,node:e,nodeEventType:h,nodeEventCallback:i,treeEventType:j,treeEventCallback:o}}],x=[function(b){var a=g.getRoot(b);a||(a={},g.setRoot(b,a));a.children=[];a.expandTriggerFlag=!1;a.curSelectedList=[];a.noSelection=!0;a.createdNodes=[]}],y=[],z=[],A=[],B=[],C=[],g={addNodeCache:function(b,a){g.getCache(b).nodes[a.tId]=
a},addAfterA:function(b){z.push(b)},addBeforeA:function(b){y.push(b)},addInnerAfterA:function(b){B.push(b)},addInnerBeforeA:function(b){A.push(b)},addInitBind:function(b){t.push(b)},addInitCache:function(b){q.push(b)},addInitNode:function(b){v.push(b)},addInitProxy:function(b){w.push(b)},addInitRoot:function(b){x.push(b)},addNodesData:function(b,a,c){var d=b.data.key.children;a[d]||(a[d]=[]);if(a[d].length>0)a[d][a[d].length-1].isLastNode=!1,i.setNodeLineIcos(b,a[d][a[d].length-1]);a.isParent=!0;
a[d]=a[d].concat(c)},addSelectedNode:function(b,a){var c=g.getRoot(b);g.isSelectedNode(b,a)||c.curSelectedList.push(a)},addCreatedNode:function(b,a){(b.callback.onNodeCreated||b.view.addDiyDom)&&g.getRoot(b).createdNodes.push(a)},addZTreeTools:function(b){C.push(b)},exSetting:function(b){l.extend(!0,K,b)},fixPIdKeyValue:function(b,a){b.data.simpleData.enable&&(a[b.data.simpleData.pIdKey]=a.parentTId?a.getParentNode()[b.data.simpleData.idKey]:b.data.simpleData.rootPId)},getAfterA:function(b,a,c){for(var d=
0,e=z.length;d<e;d++)z[d].apply(this,arguments)},getBeforeA:function(b,a,c){for(var d=0,e=y.length;d<e;d++)y[d].apply(this,arguments)},getInnerAfterA:function(b,a,c){for(var d=0,e=B.length;d<e;d++)B[d].apply(this,arguments)},getInnerBeforeA:function(b,a,c){for(var d=0,e=A.length;d<e;d++)A[d].apply(this,arguments)},getCache:function(b){return s[b.treeId]},getNextNode:function(b,a){if(!a)return null;var c=b.data.key.children,d=a.parentTId?a.getParentNode():g.getRoot(b);if(!a.isLastNode)if(a.isFirstNode)return d[c][1];
else for(var e=1,h=d[c].length-1;e<h;e++)if(d[c][e]===a)return d[c][e+1];return null},getNodeByParam:function(b,a,c,d){if(!a||!c)return null;for(var e=b.data.key.children,h=0,j=a.length;h<j;h++){if(a[h][c]==d)return a[h];var f=g.getNodeByParam(b,a[h][e],c,d);if(f)return f}return null},getNodeCache:function(b,a){if(!a)return null;var c=s[b.treeId].nodes[a];return c?c:null},getNodes:function(b){return g.getRoot(b)[b.data.key.children]},getNodesByParam:function(b,a,c,d){if(!a||!c)return[];for(var e=
b.data.key.children,h=[],j=0,f=a.length;j<f;j++)a[j][c]==d&&h.push(a[j]),h=h.concat(g.getNodesByParam(b,a[j][e],c,d));return h},getNodesByParamFuzzy:function(b,a,c,d){if(!a||!c)return[];for(var e=b.data.key.children,h=[],j=0,f=a.length;j<f;j++)typeof a[j][c]=="string"&&a[j][c].indexOf(d)>-1&&h.push(a[j]),h=h.concat(g.getNodesByParamFuzzy(b,a[j][e],c,d));return h},getPreNode:function(b,a){if(!a)return null;var c=b.data.key.children,d=a.parentTId?a.getParentNode():g.getRoot(b);if(!a.isFirstNode)if(a.isLastNode)return d[c][d[c].length-
2];else for(var e=1,h=d[c].length-1;e<h;e++)if(d[c][e]===a)return d[c][e-1];return null},getRoot:function(b){return b?J[b.treeId]:null},getSetting:function(b){return p[b]},getSettings:function(){return p},getTitleKey:function(b){return b.data.key.title===""?b.data.key.name:b.data.key.title},getZTreeTools:function(b){return(b=this.getRoot(this.getSetting(b)))?b.treeTools:null},initCache:function(b){for(var a=0,c=q.length;a<c;a++)q[a].apply(this,arguments)},initNode:function(b,a,c,d,e,h){for(var j=
0,f=v.length;j<f;j++)v[j].apply(this,arguments)},initRoot:function(b){for(var a=0,c=x.length;a<c;a++)x[a].apply(this,arguments)},isSelectedNode:function(b,a){for(var c=g.getRoot(b),d=0,e=c.curSelectedList.length;d<e;d++)if(a===c.curSelectedList[d])return!0;return!1},removeNodeCache:function(b,a){var c=b.data.key.children;if(a[c])for(var d=0,e=a[c].length;d<e;d++)arguments.callee(b,a[c][d]);delete g.getCache(b).nodes[a.tId]},removeSelectedNode:function(b,a){for(var c=g.getRoot(b),d=0,e=c.curSelectedList.length;d<
e;d++)if(a===c.curSelectedList[d]||!g.getNodeCache(b,c.curSelectedList[d].tId))c.curSelectedList.splice(d,1),d--,e--},setCache:function(b,a){s[b.treeId]=a},setRoot:function(b,a){J[b.treeId]=a},setZTreeTools:function(b,a){for(var c=0,d=C.length;c<d;c++)C[c].apply(this,arguments)},transformToArrayFormat:function(b,a){if(!a)return[];var c=b.data.key.children,d=[];if(k.isArray(a))for(var e=0,h=a.length;e<h;e++)d.push(a[e]),a[e][c]&&(d=d.concat(g.transformToArrayFormat(b,a[e][c])));else d.push(a),a[c]&&
(d=d.concat(g.transformToArrayFormat(b,a[c])));return d},transformTozTreeFormat:function(b,a){var c,d,e=b.data.simpleData.idKey,h=b.data.simpleData.pIdKey,j=b.data.key.children;if(!e||e==""||!a)return[];if(k.isArray(a)){var f=[],g=[];for(c=0,d=a.length;c<d;c++)g[a[c][e]]=a[c];for(c=0,d=a.length;c<d;c++)g[a[c][h]]&&a[c][e]!=a[c][h]?(g[a[c][h]][j]||(g[a[c][h]][j]=[]),g[a[c][h]][j].push(a[c])):f.push(a[c]);return f}else return[a]}},m={bindEvent:function(b){for(var a=0,c=t.length;a<c;a++)t[a].apply(this,
arguments)},bindTree:function(b){var a={treeId:b.treeId},b=b.treeObj;b.unbind("click",m.proxy);b.bind("click",a,m.proxy);b.unbind("dblclick",m.proxy);b.bind("dblclick",a,m.proxy);b.unbind("mouseover",m.proxy);b.bind("mouseover",a,m.proxy);b.unbind("mouseout",m.proxy);b.bind("mouseout",a,m.proxy);b.unbind("mousedown",m.proxy);b.bind("mousedown",a,m.proxy);b.unbind("mouseup",m.proxy);b.bind("mouseup",a,m.proxy);b.unbind("contextmenu",m.proxy);b.bind("contextmenu",a,m.proxy)},doProxy:function(b){for(var a=
[],c=0,d=w.length;c<d;c++){var e=w[c].apply(this,arguments);a.push(e);if(e.stop)break}return a},proxy:function(b){var a=g.getSetting(b.data.treeId);if(!k.uCanDo(a,b))return!0;for(var c=m.doProxy(b),d=!0,e=!1,h=0,j=c.length;h<j;h++){var f=c[h];f.nodeEventCallback&&(e=!0,d=f.nodeEventCallback.apply(f,[b,f.node])&&d);f.treeEventCallback&&(e=!0,d=f.treeEventCallback.apply(f,[b,f.node])&&d)}try{e&&l("input:focus").length==0&&k.noSel(a)}catch(i){}return d}};D=function(b,a){var c=p[b.data.treeId];if(a.open){if(k.apply(c.callback.beforeCollapse,
[c.treeId,a],!0)==!1)return!0}else if(k.apply(c.callback.beforeExpand,[c.treeId,a],!0)==!1)return!0;g.getRoot(c).expandTriggerFlag=!0;i.switchNode(c,a);return!0};E=function(b,a){var c=p[b.data.treeId],d=c.view.autoCancelSelected&&b.ctrlKey&&g.isSelectedNode(c,a)?0:c.view.autoCancelSelected&&b.ctrlKey&&c.view.selectedMulti?2:1;if(k.apply(c.callback.beforeClick,[c.treeId,a,d],!0)==!1)return!0;d===0?i.cancelPreSelectedNode(c,a):i.selectNode(c,a,d===2);c.treeObj.trigger(f.event.CLICK,[c.treeId,a,d]);
return!0};F=function(b,a){var c=p[b.data.treeId];k.apply(c.callback.beforeMouseDown,[c.treeId,a],!0)&&k.apply(c.callback.onMouseDown,[b,c.treeId,a]);return!0};G=function(b,a){var c=p[b.data.treeId];k.apply(c.callback.beforeMouseUp,[c.treeId,a],!0)&&k.apply(c.callback.onMouseUp,[b,c.treeId,a]);return!0};H=function(b,a){var c=p[b.data.treeId];k.apply(c.callback.beforeDblClick,[c.treeId,a],!0)&&k.apply(c.callback.onDblClick,[b,c.treeId,a]);return!0};I=function(b,a){var c=p[b.data.treeId];k.apply(c.callback.beforeRightClick,
[c.treeId,a],!0)&&k.apply(c.callback.onRightClick,[b,c.treeId,a]);return typeof c.callback.onRightClick!="function"};var k={apply:function(b,a,c){return typeof b=="function"?b.apply(L,a?a:[]):c},canAsync:function(b,a){var c=b.data.key.children;return a&&a.isParent&&!(a.zAsync||a[c]&&a[c].length>0)},clone:function(b){var a;if(b instanceof Array){a=[];for(var c=b.length;c--;)a[c]=arguments.callee(b[c]);return a}else if(typeof b=="function")return b;else if(b instanceof Object){a={};for(c in b)a[c]=
arguments.callee(b[c]);return a}else return b},eqs:function(b,a){return b.toLowerCase()===a.toLowerCase()},isArray:function(b){return Object.prototype.toString.apply(b)==="[object Array]"},getMDom:function(b,a,c){if(!a)return null;for(;a&&a.id!==b.treeId;){for(var d=0,e=c.length;a.tagName&&d<e;d++)if(k.eqs(a.tagName,c[d].tagName)&&a.getAttribute(c[d].attrName)!==null)return a;a=a.parentNode}return null},noSel:function(b){if(g.getRoot(b).noSelection)try{window.getSelection?window.getSelection().removeAllRanges():
document.selection.empty()}catch(a){}},uCanDo:function(){return!0}},i={addNodes:function(b,a,c,d){if(!b.data.keep.leaf||!a||a.isParent)if(k.isArray(c)||(c=[c]),b.data.simpleData.enable&&(c=g.transformTozTreeFormat(b,c)),a){var e=l("#"+a.tId+f.id.SWITCH),h=l("#"+a.tId+f.id.ICON),j=l("#"+a.tId+f.id.UL);if(!a.open)i.replaceSwitchClass(a,e,f.folder.CLOSE),i.replaceIcoClass(a,h,f.folder.CLOSE),a.open=!1,j.css({display:"none"});g.addNodesData(b,a,c);i.createNodes(b,a.level+1,c,a);d||i.expandCollapseParentNode(b,
a,!0)}else g.addNodesData(b,g.getRoot(b),c),i.createNodes(b,0,c,null)},appendNodes:function(b,a,c,d,e,h){if(!c)return[];for(var j=[],l=b.data.key.children,o=b.data.key.name,m=g.getTitleKey(b),p=0,N=c.length;p<N;p++){var n=c[p],u=(d?d:g.getRoot(b))[l].length==c.length&&p==0,r=p==c.length-1;e&&(g.initNode(b,a,n,d,u,r,h),g.addNodeCache(b,n));u=[];n[l]&&n[l].length>0&&(u=i.appendNodes(b,a+1,n[l],n,e,h&&n.open));if(h){var r=i.makeNodeUrl(b,n),s=i.makeNodeFontCss(b,n),t=[],q;for(q in s)t.push(q,":",s[q],
";");j.push("<li id='",n.tId,"' class='level",n.level,"' treenode>","<button type='button' hidefocus='true'",n.isParent?"":"disabled"," id='",n.tId,f.id.SWITCH,"' title='' class='",i.makeNodeLineClass(b,n),"' treeNode",f.id.SWITCH,"></button>");g.getBeforeA(b,n,j);j.push("<a id='",n.tId,f.id.A,"' class='level",n.level,"' treeNode",f.id.A,' onclick="',n.click||"",'" ',r!=null&&r.length>0?"href='"+r+"'":""," target='",i.makeNodeTarget(n),"' style='",t.join(""),"'");k.apply(b.view.showTitle,[b.treeId,
n],b.view.showTitle)&&n[m]&&j.push("title='",n[m].replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"'");j.push(">");g.getInnerBeforeA(b,n,j);r=b.view.nameIsHTML?n[o]:n[o].replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");j.push("<button type='button' hidefocus='true' id='",n.tId,f.id.ICON,"' title='' treeNode",f.id.ICON," class='",i.makeNodeIcoClass(b,n),"' style='",i.makeNodeIcoStyle(b,n),"'></button><span id='",n.tId,f.id.SPAN,"'>",r,"</span>");g.getInnerAfterA(b,n,
j);j.push("</a>");g.getAfterA(b,n,j);n.isParent&&n.open&&i.makeUlHtml(b,n,j,u.join(""));j.push("</li>");g.addCreatedNode(b,n)}}return j},appendParentULDom:function(b,a){var c=[],d=l("#"+a.tId),e=l("#"+a.tId+f.id.UL),h=i.appendNodes(b,a.level+1,a[b.data.key.children],a,!1,!0);i.makeUlHtml(b,a,c,h.join(""));!d.get(0)&&a.parentTId&&(i.appendParentULDom(b,a.getParentNode()),d=l("#"+a.tId));e.get(0)&&e.remove();d.append(c.join(""));i.createNodeCallback(b)},asyncNode:function(b,a,c,d){var e,h;if(a&&!a.isParent)return k.apply(d),
!1;else if(a&&a.isAjaxing)return!1;else if(k.apply(b.callback.beforeAsync,[b.treeId,a],!0)==!1)return k.apply(d),!1;if(a)a.isAjaxing=!0,l("#"+a.tId+f.id.ICON).attr({style:"","class":"ico_loading"});var j=b.async.contentType=="application/json",g=j?"{":"",o="";for(e=0,h=b.async.autoParam.length;a&&e<h;e++){var m=b.async.autoParam[e].split("="),p=m;m.length>1&&(p=m[1],m=m[0]);j?(o=typeof a[m]=="string"?'"':"",g+='"'+p+('":'+o+a[m]).replace(/'/g,"\\'")+o+","):g+=p+("="+a[m]).replace(/&/g,"%26")+"&"}if(k.isArray(b.async.otherParam))for(e=
0,h=b.async.otherParam.length;e<h;e+=2)j?(o=typeof b.async.otherParam[e+1]=="string"?'"':"",g+='"'+b.async.otherParam[e]+('":'+o+b.async.otherParam[e+1]).replace(/'/g,"\\'")+o+","):g+=b.async.otherParam[e]+("="+b.async.otherParam[e+1]).replace(/&/g,"%26")+"&";else for(var q in b.async.otherParam)j?(o=typeof b.async.otherParam[q]=="string"?'"':"",g+='"'+q+('":'+o+b.async.otherParam[q]).replace(/'/g,"\\'")+o+","):g+=q+("="+b.async.otherParam[q]).replace(/&/g,"%26")+"&";g.length>1&&(g=g.substring(0,
g.length-1));j&&(g+="}");l.ajax({contentType:b.async.contentType,type:b.async.type,url:k.apply(b.async.url,[b.treeId,a],b.async.url),data:g,dataType:b.async.dataType,success:function(e){var h=[];try{h=!e||e.length==0?[]:typeof e=="string"?eval("("+e+")"):e}catch(g){}if(a)a.isAjaxing=null,a.zAsync=!0;i.setNodeLineIcos(b,a);h&&h!=""?(h=k.apply(b.async.dataFilter,[b.treeId,a,h],h),i.addNodes(b,a,k.clone(h),!!c)):i.addNodes(b,a,[],!!c);b.treeObj.trigger(f.event.ASYNC_SUCCESS,[b.treeId,a,e]);k.apply(d)},
error:function(c,d,e){i.setNodeLineIcos(b,a);if(a)a.isAjaxing=null;b.treeObj.trigger(f.event.ASYNC_ERROR,[b.treeId,a,c,d,e])}});return!0},cancelPreSelectedNode:function(b,a){for(var c=g.getRoot(b).curSelectedList,d=c.length-1;d>=0;d--)if(!a||a===c[d])if(l("#"+c[d].tId+f.id.A).removeClass(f.node.CURSELECTED),i.setNodeName(b,c[d]),a){g.removeSelectedNode(b,a);break}if(!a)g.getRoot(b).curSelectedList=[]},createNodeCallback:function(b){if(b.callback.onNodeCreated||b.view.addDiyDom)for(var a=g.getRoot(b);a.createdNodes.length>
0;){var c=a.createdNodes.shift();k.apply(b.view.addDiyDom,[b.treeId,c]);b.callback.onNodeCreated&&b.treeObj.trigger(f.event.NODECREATED,[b.treeId,c])}},createNodes:function(b,a,c,d){if(c&&c.length!=0){var e=g.getRoot(b),h=b.data.key.children,h=!d||d.open||!!l("#"+d[h][0].tId).get(0);e.createdNodes=[];a=i.appendNodes(b,a,c,d,!0,h);d?(d=l("#"+d.tId+f.id.UL),d.get(0)&&d.append(a.join(""))):b.treeObj.append(a.join(""));i.createNodeCallback(b)}},expandCollapseNode:function(b,a,c,d,e){var h=g.getRoot(b),
j=b.data.key.children;if(a){if(h.expandTriggerFlag){var m=e,e=function(){m&&m();a.open?b.treeObj.trigger(f.event.EXPAND,[b.treeId,a]):b.treeObj.trigger(f.event.COLLAPSE,[b.treeId,a])};h.expandTriggerFlag=!1}if(a.open==c)k.apply(e,[]);else{!a.open&&a.isParent&&(!l("#"+a.tId+f.id.UL).get(0)||a[j]&&a[j].length>0&&!l("#"+a[j][0].tId).get(0))&&i.appendParentULDom(b,a);var c=l("#"+a.tId+f.id.UL),h=l("#"+a.tId+f.id.SWITCH),o=l("#"+a.tId+f.id.ICON);a.isParent?(a.open=!a.open,a.iconOpen&&a.iconClose&&o.attr("style",
i.makeNodeIcoStyle(b,a)),a.open?(i.replaceSwitchClass(a,h,f.folder.OPEN),i.replaceIcoClass(a,o,f.folder.OPEN),d==!1||b.view.expandSpeed==""?(c.show(),k.apply(e,[])):a[j]&&a[j].length>0?c.slideDown(b.view.expandSpeed,e):(c.show(),k.apply(e,[]))):(i.replaceSwitchClass(a,h,f.folder.CLOSE),i.replaceIcoClass(a,o,f.folder.CLOSE),d==!1||b.view.expandSpeed==""?(c.hide(),k.apply(e,[])):c.slideUp(b.view.expandSpeed,e))):k.apply(e,[])}}else k.apply(e,[])},expandCollapseParentNode:function(b,a,c,d,e){a&&(a.parentTId?
(i.expandCollapseNode(b,a,c,d),a.parentTId&&i.expandCollapseParentNode(b,a.getParentNode(),c,d,e)):i.expandCollapseNode(b,a,c,d,e))},expandCollapseSonNode:function(b,a,c,d,e){var h=g.getRoot(b),f=b.data.key.children,h=a?a[f]:h[f],f=a?!1:d,k=g.getRoot(b).expandTriggerFlag;g.getRoot(b).expandTriggerFlag=!1;if(h)for(var l=0,m=h.length;l<m;l++)h[l]&&i.expandCollapseSonNode(b,h[l],c,f);g.getRoot(b).expandTriggerFlag=k;i.expandCollapseNode(b,a,c,d,e)},makeNodeFontCss:function(b,a){var c=k.apply(b.view.fontCss,
[b.treeId,a],b.view.fontCss);return c&&typeof c!="function"?c:{}},makeNodeIcoClass:function(b,a){var c=["ico"];a.isAjaxing||(c[0]=(a.iconSkin?a.iconSkin+"_":"")+c[0],a.isParent?c.push(a.open?f.folder.OPEN:f.folder.CLOSE):c.push(f.folder.DOCU));return c.join("_")},makeNodeIcoStyle:function(b,a){var c=[];if(!a.isAjaxing){var d=a.isParent&&a.iconOpen&&a.iconClose?a.open?a.iconOpen:a.iconClose:a.icon;d&&c.push("background:url(",d,") 0 0 no-repeat;");(b.view.showIcon==!1||!k.apply(b.view.showIcon,[b.treeId,
a],!0))&&c.push("width:0px;height:0px;")}return c.join("")},makeNodeLineClass:function(b,a){var c=[];b.view.showLine?a.level==0&&a.isFirstNode&&a.isLastNode?c.push(f.line.ROOT):a.level==0&&a.isFirstNode?c.push(f.line.ROOTS):a.isLastNode?c.push(f.line.BOTTOM):c.push(f.line.CENTER):c.push(f.line.NOLINE);a.isParent?c.push(a.open?f.folder.OPEN:f.folder.CLOSE):c.push(f.folder.DOCU);return i.makeNodeLineClassEx(a)+c.join("_")},makeNodeLineClassEx:function(b){return"level"+b.level+" switch "},makeNodeTarget:function(b){return b.target||
"_blank"},makeNodeUrl:function(b,a){return a.url?a.url:null},makeUlHtml:function(b,a,c,d){c.push("<ul id='",a.tId,f.id.UL,"' class='level",a.level," ",i.makeUlLineClass(b,a),"' style='display:",a.open?"block":"none","'>");c.push(d);c.push("</ul>")},makeUlLineClass:function(b,a){return b.view.showLine&&!a.isLastNode?f.line.LINE:""},replaceIcoClass:function(b,a,c){if(a&&!b.isAjaxing&&(b=a.attr("class"),b!=void 0)){b=b.split("_");switch(c){case f.folder.OPEN:case f.folder.CLOSE:case f.folder.DOCU:b[b.length-
1]=c}a.attr("class",b.join("_"))}},replaceSwitchClass:function(b,a,c){if(a){var d=a.attr("class");if(d!=void 0){d=d.split("_");switch(c){case f.line.ROOT:case f.line.ROOTS:case f.line.CENTER:case f.line.BOTTOM:case f.line.NOLINE:d[0]=i.makeNodeLineClassEx(b)+c;break;case f.folder.OPEN:case f.folder.CLOSE:case f.folder.DOCU:d[1]=c}a.attr("class",d.join("_"));c!==f.folder.DOCU?a.removeAttr("disabled"):a.attr("disabled","disabled")}}},selectNode:function(b,a,c){c||i.cancelPreSelectedNode(b);l("#"+a.tId+
f.id.A).addClass(f.node.CURSELECTED);g.addSelectedNode(b,a)},setNodeFontCss:function(b,a){var c=l("#"+a.tId+f.id.A),d=i.makeNodeFontCss(b,a);d&&c.css(d)},setNodeLineIcos:function(b,a){if(a){var c=l("#"+a.tId+f.id.SWITCH),d=l("#"+a.tId+f.id.UL),e=l("#"+a.tId+f.id.ICON),h=i.makeUlLineClass(b,a);h.length==0?d.removeClass(f.line.LINE):d.addClass(h);c.attr("class",i.makeNodeLineClass(b,a));a.isParent?c.removeAttr("disabled"):c.attr("disabled","disabled");e.removeAttr("style");e.attr("style",i.makeNodeIcoStyle(b,
a));e.attr("class",i.makeNodeIcoClass(b,a))}},setNodeName:function(b,a){var c=b.data.key.name,d=g.getTitleKey(b),e=l("#"+a.tId+f.id.SPAN);e.empty();b.view.nameIsHTML?e.html(a[c]):e.text(a[c]);k.apply(b.view.showTitle,[b.treeId,a],b.view.showTitle)&&a[d]&&l("#"+a.tId+f.id.A).attr("title",a[d])},setNodeTarget:function(b){l("#"+b.tId+f.id.A).attr("target",i.makeNodeTarget(b))},setNodeUrl:function(b,a){var c=l("#"+a.tId+f.id.A),d=i.makeNodeUrl(b,a);d==null||d.length==0?c.removeAttr("href"):c.attr("href",
d)},switchNode:function(b,a){a.open||!k.canAsync(b,a)?i.expandCollapseNode(b,a,!a.open):b.async.enable?i.asyncNode(b,a)||i.expandCollapseNode(b,a,!a.open):a&&i.expandCollapseNode(b,a,!a.open)}};l.fn.zTree={consts:{event:{NODECREATED:"ztree_nodeCreated",CLICK:"ztree_click",EXPAND:"ztree_expand",COLLAPSE:"ztree_collapse",ASYNC_SUCCESS:"ztree_async_success",ASYNC_ERROR:"ztree_async_error"},id:{A:"_a",ICON:"_ico",SPAN:"_span",SWITCH:"_switch",UL:"_ul"},line:{ROOT:"root",ROOTS:"roots",CENTER:"center",
BOTTOM:"bottom",NOLINE:"noline",LINE:"line"},folder:{OPEN:"open",CLOSE:"close",DOCU:"docu"},node:{CURSELECTED:"curSelectedNode"}},_z:{tools:k,view:i,event:m,data:g},getZTreeObj:function(b){return(b=g.getZTreeTools(b))?b:null},init:function(b,a,c){var d=k.clone(K);l.extend(!0,d,a);d.treeId=b.attr("id");d.treeObj=b;d.treeObj.empty();p[d.treeId]=d;if(l.browser.msie&&parseInt(l.browser.version)<7)d.view.expandSpeed="";g.initRoot(d);b=g.getRoot(d);a=d.data.key.children;c=c?k.clone(k.isArray(c)?c:[c]):
[];b[a]=d.data.simpleData.enable?g.transformTozTreeFormat(d,c):c;g.initCache(d);m.bindTree(d);m.bindEvent(d);c={setting:d,cancelSelectedNode:function(a){i.cancelPreSelectedNode(this.setting,a)},expandAll:function(a){a=!!a;i.expandCollapseSonNode(this.setting,null,a,!0);return a},expandNode:function(a,b,c,m,o){if(!a||!a.isParent)return null;b!==!0&&b!==!1&&(b=!a.open);if((o=!!o)&&b&&k.apply(d.callback.beforeExpand,[d.treeId,a],!0)==!1)return null;else if(o&&!b&&k.apply(d.callback.beforeCollapse,[d.treeId,
a],!0)==!1)return null;b&&a.parentTId&&i.expandCollapseParentNode(this.setting,a.getParentNode(),b,!1);if(b===a.open&&!c)return null;g.getRoot(d).expandTriggerFlag=o;c?i.expandCollapseSonNode(this.setting,a,b,!0,function(){m!==!1&&l("#"+a.tId+f.id.ICON).focus().blur()}):(a.open=!b,i.switchNode(this.setting,a),m!==!1&&l("#"+a.tId+f.id.ICON).focus().blur());return b},getNodes:function(){return g.getNodes(this.setting)},getNodeByParam:function(a,b,c){return!a?null:g.getNodeByParam(this.setting,c?c[this.setting.data.key.children]:
g.getNodes(this.setting),a,b)},getNodeByTId:function(a){return g.getNodeCache(this.setting,a)},getNodesByParam:function(a,b,c){return!a?null:g.getNodesByParam(this.setting,c?c[this.setting.data.key.children]:g.getNodes(this.setting),a,b)},getNodesByParamFuzzy:function(a,b,c){return!a?null:g.getNodesByParamFuzzy(this.setting,c?c[this.setting.data.key.children]:g.getNodes(this.setting),a,b)},getNodeIndex:function(a){if(!a)return null;for(var b=d.data.key.children,c=a.parentTId?a.getParentNode():g.getRoot(this.setting),
f=0,i=c[b].length;f<i;f++)if(c[b][f]==a)return f;return-1},getSelectedNodes:function(){for(var a=[],b=g.getRoot(this.setting).curSelectedList,c=0,d=b.length;c<d;c++)a.push(b[c]);return a},isSelectedNode:function(a){return g.isSelectedNode(this.setting,a)},reAsyncChildNodes:function(a,b,c){if(this.setting.async.enable){var d=!a;d&&(a=g.getRoot(this.setting));b=="refresh"&&(a[this.setting.data.key.children]=[],d?this.setting.treeObj.empty():l("#"+a.tId+f.id.UL).empty());i.asyncNode(this.setting,d?null:
a,!!c)}},refresh:function(){this.setting.treeObj.empty();var a=g.getRoot(this.setting),b=a[this.setting.data.key.children];g.initRoot(this.setting);a[this.setting.data.key.children]=b;g.initCache(this.setting);i.createNodes(this.setting,0,a[this.setting.data.key.children])},selectNode:function(a,b){a&&k.uCanDo(this.setting)&&(b=d.view.selectedMulti&&b,a.parentTId?i.expandCollapseParentNode(this.setting,a.getParentNode(),!0,!1,function(){l("#"+a.tId+f.id.ICON).focus().blur()}):l("#"+a.tId+f.id.ICON).focus().blur(),
i.selectNode(this.setting,a,b))},transformTozTreeNodes:function(a){return g.transformTozTreeFormat(this.setting,a)},transformToArray:function(a){return g.transformToArrayFormat(this.setting,a)},updateNode:function(a){a&&l("#"+a.tId).get(0)&&k.uCanDo(this.setting)&&(i.setNodeName(this.setting,a),i.setNodeTarget(a),i.setNodeUrl(this.setting,a),i.setNodeLineIcos(this.setting,a),i.setNodeFontCss(this.setting,a))}};b.treeTools=c;g.setZTreeTools(d,c);b[a]&&b[a].length>0?i.createNodes(d,0,b[a]):d.async.enable&&
d.async.url&&d.async.url!==""&&i.asyncNode(d);return c}};var L=l.fn.zTree,f=L.consts})(jQuery);
