(function(f){function i(){if(typeof i.inst=="undefined"){i.cntr=0;i.inst={};i.drag_drop={isdown:false,drag_node:false,drag_help:false,init_x:false,init_y:false,moving:false,origin_tree:false,marker:false,move_type:false,ref_node:false,appended:false,foreign:false,droppable:[],open_time:false,scroll_time:false};i.mousedown=function(a){var b=f(a.target);if(i.drag_drop.droppable.length&&b.is("."+i.drag_drop.droppable.join(", ."))){i.drag_drop.drag_help=f("<div id='jstree-dragged' class='tree tree-default'><ul><li class='last dragged foreign "+
a.target.className+"'><a href='#'>"+b.text()+"</a></li></ul></div>");i.drag_drop.drag_node=i.drag_drop.drag_help.find("li:eq(0)");i.drag_drop.isdown=true;i.drag_drop.foreign=b;b.blur();a.preventDefault();a.stopPropagation();return false}a.stopPropagation();return true};i.mouseup=function(a){var b=i.drag_drop;b.open_time&&clearTimeout(b.open_time);b.scroll_time&&clearTimeout(b.scroll_time);if(b.foreign===false&&b.drag_node&&b.drag_node.size()){b.drag_help.remove();if(b.move_type){var c=i.inst[b.ref_node.parents(".tree:eq(0)").attr("id")];
if(c)c.moved(b.origin_tree.container.find("li.dragged"),b.ref_node,b.move_type,false,b.origin_tree.settings.rules.drag_copy=="on"||b.origin_tree.settings.rules.drag_copy=="ctrl"&&a.ctrlKey)}b.move_type=false;b.ref_node=false}if(b.drag_node&&b.foreign!==false){b.drag_help.remove();if(b.move_type)(c=i.inst[b.ref_node.parents(".tree:eq(0)").attr("id")])&&c.settings.callback.ondrop.call(null,b.foreign.get(0),c.get_node(b.ref_node).get(0),b.move_type,c);b.foreign=false;b.move_type=false;b.ref_node=false}i.drag_drop.marker.hide();
b.drag_help=false;b.drag_node=false;b.isdown=false;b.init_x=false;b.init_y=false;b.moving=false;b.appended=false;f("li.dragged").removeClass("dragged");b.origin_tree=false;a.preventDefault();a.stopPropagation();return false};i.mousemove=function(a){var b=i.drag_drop;if(b.isdown){if(!b.moving&&Math.abs(b.init_x-a.pageX)<5&&Math.abs(b.init_y-a.pageY)<5){a.preventDefault();a.stopPropagation();return false}else i.drag_drop.moving=true;b.open_time&&clearTimeout(b.open_time);if(!b.appended){if(b.foreign!==
false)b.origin_tree=f.tree_focused();f("body").append(b.drag_help);b.w=b.drag_help.width();b.appended=true}b.drag_help.css({left:a.pageX-(b.origin_tree.settings.ui.rtl?b.w:-5),top:a.pageY+15});if(a.target.tagName=="IMG"&&a.target.id=="marker")return false;var c=f(a.target),d=c.is(".tree")?c:c.parents(".tree:eq(0)");if(d.size()==0||!i.inst[d.attr("id")]){b.scroll_time&&clearTimeout(b.scroll_time);if(b.drag_help.find("IMG").size()==0)b.drag_help.find("li:eq(0)").append("<img style='position:absolute; "+
(b.origin_tree.settings.ui.rtl?"right":"left")+":4px; top:0px; background:white; padding:2px;' src='"+b.origin_tree.settings.ui.theme_path+"remove.png' />");b.move_type=false;b.ref_node=false;i.drag_drop.marker.hide();return false}var e=i.inst[d.attr("id")];e.off_height();if(b.foreign===false&&b.origin_tree.container.get(0)!=e.container.get(0)&&(!b.origin_tree.settings.rules.multitree||!e.settings.rules.multitree)){if(b.drag_help.find("IMG").size()==0)b.drag_help.find("li:eq(0)").append("<img style='position:absolute; "+
(b.origin_tree.settings.ui.rtl?"right":"left")+":4px; top:0px; background:white; padding:2px;' src='"+b.origin_tree.settings.ui.theme_path+"remove.png' />");b.move_type=false;b.ref_node=false;i.drag_drop.marker.hide();return false}b.scroll_time&&clearTimeout(b.scroll_time);b.scroll_time=setTimeout(function(){e.scrollCheck(a.pageX,a.pageY)},50);var g=false;d.scrollTop();if(a.target.tagName=="A"){if(c.is("#jstree-dragged"))return false;if(e.get_node(a.target).hasClass("closed"))b.open_time=setTimeout(function(){e.open_branch(c)},
500);var h=c.offset(),j={x:h.left-1,y:a.pageY-h.top};if(d.children("ul:eq(0)").hasClass("rtl"))j.x+=c.width()-8;var k=[];k=j.y<e.li_height/3+1?["before","inside","after"]:j.y>e.li_height*2/3-1?["after","inside","before"]:j.y<e.li_height/2?["inside","before","after"]:["inside","after","before"];var l=false;f.each(k,function(m,n){if(e.checkMove(b.origin_tree.container.find("li.dragged"),c,n)){g=n;l=true;return false}});if(l){switch(g){case "before":j.y=h.top-2;d.children("ul:eq(0)").hasClass("rtl")?
i.drag_drop.marker.attr("src",e.settings.ui.theme_path+"marker_rtl.gif").width(40):i.drag_drop.marker.attr("src",e.settings.ui.theme_path+"marker.gif").width(40);break;case "after":j.y=h.top-2+e.li_height;d.children("ul:eq(0)").hasClass("rtl")?i.drag_drop.marker.attr("src",e.settings.ui.theme_path+"marker_rtl.gif").width(40):i.drag_drop.marker.attr("src",e.settings.ui.theme_path+"marker.gif").width(40);break;case "inside":j.x-=2;if(d.children("ul:eq(0)").hasClass("rtl"))j.x+=36;j.y=h.top-2+e.li_height/
2;i.drag_drop.marker.attr("src",e.settings.ui.theme_path+"plus.gif").width(11);break}b.move_type=g;b.ref_node=f(a.target);b.drag_help.find("IMG").remove();i.drag_drop.marker.css({left:j.x,top:j.y}).show()}}if((c.is(".tree")||c.is("ul"))&&c.find("li:eq(0)").size()==0){h=c.offset();b.move_type="inside";b.ref_node=d.children("ul:eq(0)");b.drag_help.find("IMG").remove();i.drag_drop.marker.attr("src",e.settings.ui.theme_path+"plus.gif").width(11);i.drag_drop.marker.css({left:h.left+(d.children("ul:eq(0)").hasClass("rtl")?
d.width()-10:10),top:h.top+15}).show()}else if(a.target.tagName!="A"||!l){if(b.drag_help.find("IMG").size()==0)b.drag_help.find("li:eq(0)").append("<img style='position:absolute; "+(b.origin_tree.settings.ui.rtl?"right":"left")+":4px; top:0px; background:white; padding:2px;' src='"+b.origin_tree.settings.ui.theme_path+"remove.png' />");b.move_type=false;b.ref_node=false;i.drag_drop.marker.hide()}a.preventDefault();a.stopPropagation();return false}return true}}return{cntr:++i.cntr,settings:{data:{type:"predefined",
method:"GET",async:false,async_data:function(a){return{id:f(a).attr("id")||0}},url:false,json:false,xml:false},selected:false,opened:[],languages:[],path:false,cookies:false,ui:{dots:true,rtl:false,animation:0,hover_mode:true,scroll_spd:4,theme_path:false,theme_name:"default",context:[{id:"create",label:"Create",icon:"create.png",visible:function(a,b){if(a.length!=1)return false;return b.check("creatable",a)},action:function(a,b){b.create(false,b.get_node(a[0]))}},"separator",{id:"rename",label:"Rename",
icon:"rename.png",visible:function(a,b){if(a.length!=1)return false;return b.check("renameable",a)},action:function(a,b){b.rename(a)}},{id:"delete",label:"Delete",icon:"remove.png",visible:function(a,b){var c=true;f.each(a,function(){if(b.check("deletable",this)==false)c=false;return false});return c},action:function(a,b){f.each(a,function(){b.remove(this)})}}]},rules:{multiple:false,metadata:false,type_attr:"rel",multitree:false,createat:"bottom",use_inline:false,clickable:"all",renameable:"all",
deletable:"all",creatable:"all",draggable:"none",dragrules:"all",drag_copy:false,droppable:[],drag_button:"left"},lang:{new_node:"New folder",loading:"Loading ..."},callback:{beforechange:function(){return true},beforeopen:function(){return true},beforeclose:function(){return true},beforemove:function(){return true},beforecreate:function(){return true},beforerename:function(){return true},beforedelete:function(){return true},onJSONdata:function(a){return a},onselect:function(){},ondeselect:function(){},
onchange:function(){},onrename:function(){},onmove:function(){},oncopy:function(){},oncreate:function(){},ondelete:function(){},onopen:function(){},onopen_all:function(){},onclose:function(){},error:function(){},ondblclk:function(a,b){b.toggle_branch.call(b,a);b.select_branch.call(b,a)},onrgtclk:function(){},onload:function(){},onfocus:function(){},ondrop:function(){}}},init:function(a,b){var c=this;this.container=f(a);if(this.container.size==0)alert("Invalid container node!");else{i.inst[this.cntr]=
this;this.container.attr("id")||this.container.attr("id","jstree_"+this.cntr);i.inst[this.container.attr("id")]=i.inst[this.cntr];i.focused=this.cntr;if((a=f.extend({},b))&&a.cookies){this.settings.cookies=f.extend({},this.settings.cookies,a.cookies);delete a.cookies;if(!this.settings.cookies.opts)this.settings.cookies.opts={}}if(a&&a.callback){this.settings.callback=f.extend({},this.settings.callback,a.callback);delete a.callback}if(a&&a.data){this.settings.data=f.extend({},this.settings.data,a.data);
delete a.data}if(a&&a.ui){this.settings.ui=f.extend({},this.settings.ui,a.ui);delete a.ui}if(a&&a.rules){this.settings.rules=f.extend({},this.settings.rules,a.rules);delete a.rules}if(a&&a.lang){this.settings.lang=f.extend({},this.settings.lang,a.lang);delete a.lang}this.settings=f.extend({},this.settings,a);if(this.settings.path==false){this.path="";f("script").each(function(){if(this.src.toString().match(/tree_component.*?js$/))c.path=this.src.toString().replace(/tree_component.*?js$/,"")})}else this.path=
this.settings.path;this.current_lang=this.settings.languages&&this.settings.languages.length?this.settings.languages[0]:false;if(this.settings.languages&&this.settings.languages.length){this.sn=get_sheet_num("tree_component.css");if(this.sn===false&&document.styleSheets.length)this.sn=document.styleSheets.length;a=false;b=this.container.attr("id")?"#"+this.container.attr("id"):".tree";for(var d=0;d<this.settings.languages.length;d++){a=add_css(b+" ."+this.settings.languages[d],this.sn);if(a!==false)a.style.display=
this.settings.languages[d]==this.current_lang?"":"none"}}if(this.settings.rules.droppable.length){for(var e in this.settings.rules.droppable)typeof this.settings.rules.droppable[e]!="function"&&i.drag_drop.droppable.push(this.settings.rules.droppable[e]);i.drag_drop.droppable=f.unique(i.drag_drop.droppable)}if(this.settings.ui.theme_path===false)this.settings.ui.theme_path=this.path+"themes/";this.theme=this.settings.ui.theme_path;if(c.settings.ui.theme_name){this.theme+=c.settings.ui.theme_name+
"/";if(c.settings.ui.theme_name!="themeroller"&&!i.def_style){add_sheet(c.settings.ui.theme_path+"default/style.css");i.def_style=true}add_sheet(c.theme+"style.css")}this.container.addClass("tree");c.settings.ui.theme_name!="themeroller"&&this.container.addClass("tree-default");this.settings.ui.theme_name&&this.settings.ui.theme_name!="default"&&this.container.addClass("tree-"+c.settings.ui.theme_name);this.settings.ui.theme_name=="themeroller"&&this.container.addClass("ui-widget ui-widget-content");
if(this.settings.rules.multiple)this.selected_arr=[];this.offset=false;this.context_menu();this.locked=this.hovered=false;if(this.settings.rules.draggable!="none"&&i.drag_drop.marker===false){c=this;i.drag_drop.marker=f("<img>").attr({id:"marker",src:c.settings.ui.theme_path+"marker.gif"}).css({height:"5px",width:"40px",display:"block",position:"absolute",left:"30px",top:"30px",zIndex:"1000"}).hide().appendTo("body")}this.refresh();this.attachEvents();this.focus()}},off_height:function(){if(this.offset===
false){this.container.css({position:"relative"});this.offset=this.container.offset();var a=0;if(a=parseInt(f.curCSS(this.container.get(0),"paddingTop",true),10))this.offset.top+=a;if(a=parseInt(f.curCSS(this.container.get(0),"borderTopWidth",true),10))this.offset.top+=a;this.container.css({position:""})}if(!this.li_height){a=this.container.find("ul li.closed, ul li.leaf").eq(0);this.li_height=a.height();if(a.children("ul:eq(0)").size())this.li_height-=a.children("ul:eq(0)").height();if(!this.li_height)this.li_height=
18}},context_menu:function(){this.context=false;if(this.settings.ui.context!=false){var a='<div class="tree-context tree-default-context tree-'+this.settings.ui.theme_name+'-context">';for(var b in this.settings.ui.context)if(typeof this.settings.ui.context[b]!="function")if(this.settings.ui.context[b]=="separator")a+="<span class='separator'>&nbsp;</span>";else{var c="";if(this.settings.ui.context[b].icon)c="background-image:url('"+(this.settings.ui.context[b].icon.indexOf("/")==-1?this.theme+this.settings.ui.context[b].icon:
this.settings.ui.context[b].icon)+"');";a+='<a rel="'+this.settings.ui.context[b].id+'" href="#" style="'+c+'">'+this.settings.ui.context[b].label+"</a>"}a+="</div>";this.context=f(a);this.context.hide();this.context.append=false}},refresh:function(a){if(this.locked)return this.error("LOCKED");var b=this;this.is_partial_refresh=a?true:false;this.opened=Array();if(this.settings.cookies&&f.cookie(this.settings.cookies.prefix+"_open")){var c=f.cookie(this.settings.cookies.prefix+"_open"),d=c.split(",");
f.each(d,function(){this.replace(/^#/,"").length>0&&b.opened.push("#"+this.replace(/^#/,""))});this.settings.opened=false}else if(this.settings.opened!=false){f.each(this.settings.opened,function(){this.replace(/^#/,"").length>0&&b.opened.push("#"+this.replace(/^#/,""))});this.settings.opened=false}else this.container.find("li.open").each(function(){this.id&&b.opened.push("#"+this.id)});if(this.selected){this.settings.selected=Array();if(a)f(a).find("li:has(a.clicked)").each(function(){$this=f(this);
$this.attr("id")&&b.settings.selected.push("#"+$this.attr("id"))});else if(this.selected_arr)f.each(this.selected_arr,function(){this.attr("id")&&b.settings.selected.push("#"+this.attr("id"))});else this.selected.attr("id")&&this.settings.selected.push("#"+this.selected.attr("id"))}else if(this.settings.cookies&&f.cookie(this.settings.cookies.prefix+"_selected")){this.settings.selected=Array();c=f.cookie(this.settings.cookies.prefix+"_selected");d=c.split(",");f.each(d,function(){this.replace(/^#/,
"").length>0&&b.settings.selected.push("#"+this.replace(/^#/,""))})}else if(this.settings.selected!==false){d=Array();if((typeof this.settings.selected).toLowerCase()=="object")f.each(this.settings.selected,function(){this.replace(/^#/,"").length>0&&d.push("#"+this.replace(/^#/,""))});else this.settings.selected.replace(/^#/,"").length>0&&d.push("#"+this.settings.selected.replace(/^#/,""));this.settings.selected=d}if(a&&this.settings.data.async){this.opened=Array();a=this.get_node(a);a.find("li.open").each(function(){b.opened.push("#"+
this.id)});a.hasClass("open")&&a.removeClass("open").addClass("closed");a.hasClass("leaf")&&a.removeClass("leaf");a.children("ul:eq(0)").html("");return this.open_branch(a,true,function(){b.reselect.apply(b)})}if(this.settings.data.type=="xml_flat"||this.settings.data.type=="xml_nested"){this.scrtop=this.container.get(0).scrollTop;c=this.settings.data.type=="xml_flat"?"flat.xsl":"nested.xsl";this.settings.data.xml?this.container.getTransform(this.path+c,this.settings.data.xml,{params:{theme_name:b.settings.ui.theme_name,
theme_path:b.theme},meth:b.settings.data.method,dat:b.settings.data.async_data.apply(b,[a,b]),callback:function(){b.context_menu.apply(b);b.reselect.apply(b)}}):this.container.getTransform(this.path+c,this.settings.data.url,{params:{theme_name:b.settings.ui.theme_name,theme_path:b.theme},meth:b.settings.data.method,dat:b.settings.data.async_data.apply(b,[a,b]),callback:function(){b.context_menu.apply(b);b.reselect.apply(b)}})}else if(this.settings.data.type=="json")if(this.settings.data.json){c="";
if(this.settings.data.json.length)for(a=0;a<this.settings.data.json.length;a++)c+=this.parseJSON(this.settings.data.json[a]);else c=this.parseJSON(this.settings.data.json);this.container.html("<ul>"+c+"</ul>");this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");this.container.find("li").not(".open").not(".closed").addClass("leaf");this.context_menu();this.reselect()}else{b=this;f.ajax({type:this.settings.data.method,url:this.settings.data.url,
data:this.settings.data.async_data(false,this),dataType:"json",success:function(e){e=b.settings.callback.onJSONdata.call(null,e,b);var g="";if(e.length)for(var h=0;h<e.length;h++)g+=b.parseJSON(e[h]);else g=b.parseJSON(e);b.container.html("<ul>"+g+"</ul>");b.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");b.container.find("li").not(".open").not(".closed").addClass("leaf");b.context_menu.apply(b);b.reselect.apply(b)},error:function(e,g,h){b.error(h+
" "+g)}})}else{this.container.children("ul:eq(0)");this.container.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");this.container.find("li").not(".open").not(".closed").addClass("leaf");this.reselect()}},parseJSON:function(a){if(!a||!a.data)return"";var b="";b+="<li ";var c=false;if(a.attributes)for(var d in a.attributes)if(typeof a.attributes[d]!="function")if(d=="class"){b+=" class='"+a.attributes[d]+" ";if(a.state=="closed"||a.state=="open")b+=" "+
a.state+" ";b+="' ";c=true}else b+=" "+d+"='"+a.attributes[d]+"' ";if(!c&&(a.state=="closed"||a.state=="open"))b+=" class='"+a.state+"' ";b+=">";if(this.settings.languages.length)for(d=0;d<this.settings.languages.length;d++){c={};c.href="#";c.style="";c["class"]=this.settings.languages[d];if(a.data[this.settings.languages[d]]&&(typeof a.data[this.settings.languages[d]].attributes).toLowerCase()!="undefined")for(var e in a.data[this.settings.languages[d]].attributes)if(typeof a.data[this.settings.languages[d]].attributes[e]!=
"function")if(e=="style"||e=="class")c[e]+=" "+a.data[this.settings.languages[d]].attributes[e];else c[e]=a.data[this.settings.languages[d]].attributes[e];if(a.data[this.settings.languages[d]]&&a.data[this.settings.languages[d]].icon&&this.settings.theme_name!="themeroller"){var g=a.data[this.settings.languages[d]].icon.indexOf("/")==-1?this.theme+a.data[this.settings.languages[d]].icon:a.data[this.settings.languages[d]].icon;c.style+=" ; background-image:url('"+g+"'); "}b+="<a";for(e in c)if(typeof c[e]!=
"function")b+=" "+e+'="'+c[e]+'" ';b+=">";if(a.data[this.settings.languages[d]]&&a.data[this.settings.languages[d]].icon&&this.settings.theme_name=="themeroller")b+="<ins class='ui-icon "+a.data[this.settings.languages[d]].icon+"'>&nbsp;</ins>";b+=((typeof a.data[this.settings.languages[d]].title).toLowerCase()!="undefined"?a.data[this.settings.languages[d]].title:a.data[this.settings.languages[d]])+"</a>"}else{c={};c.href="#";c.style="";c["class"]="";if((typeof a.data.attributes).toLowerCase()!=
"undefined")for(d in a.data.attributes)if(typeof a.data.attributes[d]!="function")if(d=="style"||d=="class")c[d]+=" "+a.data.attributes[d];else c[d]=a.data.attributes[d];if(a.data.icon&&this.settings.ui.theme_name!="themeroller"){g=a.data.icon.indexOf("/")==-1?this.theme+a.data.icon:a.data.icon;c.style+=" ; background-image:url('"+g+"');"}b+="<a";for(d in c)if(typeof c[e]!="function")b+=" "+d+'="'+c[d]+'" ';b+=">";if(a.data.icon&&this.settings.ui.theme_name=="themeroller")b+="<ins class='ui-icon "+
a.data.icon+"'>&nbsp;</ins>";b+=((typeof a.data.title).toLowerCase()!="undefined"?a.data.title:a.data)+"</a>"}if(a.children&&a.children.length){b+="<ul>";for(d=0;d<a.children.length;d++)b+=this.parseJSON(a.children[d]);b+="</ul>"}b+="</li>";return b},getJSON:function(a,b,c,d){var e=this;a=!a||f(a).size()==0?this.container.children("ul").children("li"):f(a);if(a.size()>1){var g=[];a.each(function(){g.push(e.getJSON(this,b,c,d))});return g}b||(b=["id","rel","class"]);c||(c=[]);var h={attributes:{},
data:false};for(var j in b)if(typeof b[j]!="function"){var k=b[j]=="class"?a.attr(b[j]).replace("last","").replace("leaf","").replace("closed","").replace("open",""):a.attr(b[j]);if(typeof k!="undefined"&&k.replace(" ","").length>0)h.attributes[b[j]]=k;delete k}if(this.settings.languages.length){h.data={};for(j in this.settings.languages)if(typeof this.settings.languages[j]!="function"){var l=a.children("a."+this.settings.languages[j]);if(d||c.length||l.get(0).style.backgroundImage.toString().length){h.data[this.settings.languages[j]]=
{};h.data[this.settings.languages[j]].title=l.text();if(l.get(0).style.backgroundImage.length)h.data[this.settings.languages[j]].icon=l.get(0).style.backgroundImage.replace("url(","").replace(")","");if(this.settings.ui.theme_name=="themeroller"&&l.children("ins").size()){k=l.children("ins").attr("class");var m=false;f.each(k.split(" "),function(p,o){if(o.indexOf("ui-icon-")==0){m=o;return false}});if(m)h.data[this.settings.languages[j]].icon=m}if(c.length){h.data[this.settings.languages[j]].attributes=
{};for(var n in c)if(typeof c[n]!="function"){k=l.attr(c[n]);if(typeof k!="undefined"&&k.replace(" ","").length>0)h.data[this.settings.languages[j]].attributes[c[n]]=k;delete k}}}else h.data[this.settings.languages[j]]=l.text()}}else{l=a.children("a");if(d||c.length||l.get(0).style.backgroundImage.toString().length){h.data={};h.data.title=l.text();if(l.get(0).style.backgroundImage.length)h.data.icon=l.get(0).style.backgroundImage.replace("url(","").replace(")","");if(this.settings.ui.theme_name==
"themeroller"&&l.children("ins").size()){k=l.children("ins").attr("class");m=false;f.each(k.split(" "),function(p,o){if(o.indexOf("ui-icon-")==0){m=o;return false}});if(m)h.data[this.settings.languages[j]].icon=m}if(c.length){h.data.attributes={};for(n in c)if(typeof c[n]!="function"){k=l.attr(c[n]);if(typeof k!="undefined"&&k.replace(" ","").length>0)h.data.attributes[c[n]]=k;delete k}}}else h.data=l.text()}if(a.children("ul").size()>0){h.children=[];a.children("ul").children("li").each(function(){h.children.push(e.getJSON(this,
b,c,d))})}return h},getXML:function(a,b,c,d,e){var g=this;if(a!="flat")a="nested";b=!b||f(b).size()==0?this.container.children("ul").children("li"):f(b);if(b.size()>1){var h="<root>";b.each(function(){h+=g.getXML(a,this,c,d,true)});h+="</root>";return h}c||(c=["id","rel","class"]);d||(d=[]);h="";e||(h="<root>");h+="<item ";if(a=="flat"){var j=b.parents("li:eq(0)").size()?b.parents("li:eq(0)").attr("id"):0;h+=' parent_id="'+j+'" ';delete j}for(var k in c)if(typeof c[k]!="function"){var l=c[k]=="class"?
b.attr(c[k]).replace("last","").replace("leaf","").replace("closed","").replace("open",""):b.attr(c[k]);if(typeof l!="undefined"&&l.replace(" ","").length>0)h+=" "+c[k]+'="'+l+'" ';delete l}h+=">";h+="<content>";if(this.settings.languages.length)for(k in this.settings.languages){if(typeof this.settings.languages[k]!="function"){j=b.children("a."+this.settings.languages[k]);h+="<name ";if(d.length||j.get(0).style.backgroundImage.toString().length||this.settings.ui.theme_name=="themeroller"){if(j.get(0).style.backgroundImage.length)h+=
' icon="'+j.get(0).style.backgroundImage.replace("url(","").replace(")","")+'" ';if(this.settings.ui.theme_name=="themeroller"&&j.children("ins").size()){l=j.children("ins").attr("class");var m=false;f.each(l.split(" "),function(p,o){if(o.indexOf("ui-icon-")==0){m=o;return false}});if(m)h+=' icon="'+m+'" '}if(d.length)for(var n in d)if(typeof d[n]!="function"){l=j.attr(d[n]);if(typeof l!="undefined"&&l.replace(" ","").length>0)h+=" "+d[n]+'="'+l+'" ';delete l}}h+="><![CDATA["+j.text()+"]]\></name>"}}else{j=
b.children("a");h+="<name ";if(d.length||j.get(0).style.backgroundImage.toString().length||this.settings.ui.theme_name=="themeroller"){if(j.get(0).style.backgroundImage.length)h+=' icon="'+j.get(0).style.backgroundImage.replace("url(","").replace(")","")+'" ';if(this.settings.ui.theme_name=="themeroller"&&j.children("ins").size()){l=j.children("ins").attr("class");m=false;f.each(l.split(" "),function(p,o){if(o.indexOf("ui-icon-")==0){m=o;return false}});if(m)h+=' icon="'+m+'" '}if(d.length)for(n in d)if(typeof d[n]!=
"function"){l=j.attr(d[n]);if(typeof l!="undefined"&&l.replace(" ","").length>0)h+=" "+d[n]+'="'+l+'" ';delete l}}h+="><![CDATA["+j.text()+"]]\></name>"}h+="</content>";if(a=="flat")h+="</item>";b.children("ul").size()>0&&b.children("ul").children("li").each(function(){h+=g.getXML(a,this,c,d,true)});if(a=="nested")h+="</item>";e||(h+="</root>");return h},focus:function(){if(this.locked)return false;if(i.focused!=this.cntr){i.focused=this.cntr;this.settings.callback.onfocus.call(null,this)}},show_context:function(a){this.context.show();
var b=f(a).children("a:visible").offset();this.context.css({left:b.left,top:b.top+parseInt(a.children("a:visible").height())+2})},hide_context:function(){this.context.to_remove&&this.context.apply_to&&this.context.apply_to.children("a").removeClass("clicked");this.context.apply_to=false;this.context.hide()},attachEvents:function(){var a=this;this.container.bind("mousedown.jstree",function(b){if(i.drag_drop.isdown){i.drag_drop.move_type=false;b.preventDefault();b.stopPropagation();b.stopImmediatePropagation();
return false}}).bind("mouseup.jstree",function(){setTimeout(function(){a.focus.apply(a)},5)}).bind("click.jstree",function(){return true});f("#"+this.container.attr("id")+" li").live("click",function(b){if(b.target.tagName!="LI")return true;a.off_height();if(b.pageY-f(b.target).offset().top>a.li_height)return true;a.toggle_branch.apply(a,[b.target]);b.stopPropagation();return false});f("#"+this.container.attr("id")+" li a").live("click.jstree",function(b){if(b.which&&b.which==3)return true;if(a.locked){b.preventDefault();
b.target.blur();return a.error("LOCKED")}a.select_branch.apply(a,[b.target,b.ctrlKey||a.settings.rules.multiple=="on"]);a.inp&&a.inp.blur();b.preventDefault();b.target.blur();return false}).live("dblclick.jstree",function(b){if(a.locked){b.preventDefault();b.stopPropagation();b.target.blur();return a.error("LOCKED")}a.settings.callback.ondblclk.call(null,a.get_node(b.target).get(0),a);b.preventDefault();b.stopPropagation();b.target.blur()}).live("contextmenu.jstree",function(b){if(a.locked){b.target.blur();
return a.error("LOCKED")}var c=a.settings.callback.onrgtclk.call(null,a.get_node(b.target).get(0),a,b);if(a.context){if(a.context.append==false){f("body").append(a.context);a.context.append=true;for(var d in a.settings.ui.context)typeof a.settings.ui.context[d]!="function"&&a.settings.ui.context[d]!="separator"&&function(){var h=a.settings.ui.context[d].action;a.context.children("[rel="+a.settings.ui.context[d].id+"]").bind("click",function(j){if(!f(this).hasClass("disabled")){h.call(null,a.context.apply_to||
null,a);a.hide_context()}j.stopPropagation();j.preventDefault();return false}).bind("mouseup",function(j){this.blur();if(f(this).hasClass("disabled")){j.stopPropagation();j.preventDefault();return false}}).bind("mousedown",function(j){j.stopPropagation();j.preventDefault()})}()}var e=a.get_node(b.target);a.inp&&a.inp.blur();if(e){if(e.children("a:eq(0)").hasClass("clicked")){a.context.to_remove=false;a.context.apply_to=a.selected_arr&&a.selected_arr.length>1?a.selected_arr:a.selected}else{a.context.apply_to=
e;a.context.to_remove=true;a.context.apply_to.children("a").addClass("clicked");b.target.blur()}a.context.children("a").removeClass("disabled").show();c=false;for(d in a.settings.ui.context)if(typeof a.settings.ui.context[d]!="function")if(a.settings.ui.context[d]!="separator"){var g=a.settings.ui.context[d].visible.call(null,a.context.apply_to,a);g===false&&a.context.children("[rel="+a.settings.ui.context[d].id+"]").addClass("disabled");if(g===-1)a.context.children("[rel="+a.settings.ui.context[d].id+
"]").hide();else c=true}c==true&&a.show_context(e);b.preventDefault();b.stopPropagation();return false}}return c}).live("mouseover.jstree",function(b){if(a.locked){b.preventDefault();b.stopPropagation();return a.error("LOCKED")}if((a.settings.ui.hover_mode||a.settings.ui.theme_name=="themeroller")&&a.hovered!==false&&b.target.tagName=="A"){a.hovered.children("a").removeClass("hover ui-state-hover");a.hovered=false}a.settings.ui.theme_name=="themeroller"&&a.hover_branch.apply(a,[b.target])});a.settings.ui.theme_name==
"themeroller"&&f("#"+this.container.attr("id")+" li a").live("mouseout",function(){a.hovered&&a.hovered.children("a").removeClass("hover ui-state-hover")});if(this.settings.rules.draggable!="none"){f("#"+this.container.attr("id")+" li a").live("mousedown.jstree",function(b){if(a.settings.rules.drag_button=="left"&&b.which&&b.which!=1)return true;if(a.settings.rules.drag_button=="right"&&b.which&&b.which!=3)return true;a.focus.apply(a);if(a.locked)return a.error("LOCKED");var c=a.get_node(b.target);
if(a.settings.rules.multiple!=false&&a.selected_arr.length>1&&c.children("a:eq(0)").hasClass("clicked")){var d=0;for(var e in a.selected_arr)if(typeof a.selected_arr[e]!="function")if(a.check("draggable",a.selected_arr[e])){a.selected_arr[e].addClass("dragged");i.drag_drop.origin_tree=a;d++}if(d>0){i.drag_drop.drag_node=a.check("draggable",c)?c:a.container.find("li.dragged:eq(0)");i.drag_drop.isdown=true;i.drag_drop.drag_help=f("<div id='jstree-dragged' class='tree "+(a.container.hasClass("tree-default")?
" tree-default":"")+(a.settings.ui.theme_name&&a.settings.ui.theme_name!="default"?" tree-"+a.settings.ui.theme_name:"")+"' />").append("<ul class='"+a.container.children("ul:eq(0)").get(0).className+"' />");d=f(i.drag_drop.drag_node.get(0).cloneNode(true));a.settings.languages.length>0&&d.find("a").not("."+a.current_lang).hide();i.drag_drop.drag_help.children("ul:eq(0)").append(d);i.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last").children("a").html("Multiple selection").end().children("ul").remove()}}else if(a.check("draggable",
c)){i.drag_drop.drag_node=c;i.drag_drop.drag_help=f("<div id='jstree-dragged' class='tree "+(a.container.hasClass("tree-default")?" tree-default":"")+(a.settings.ui.theme_name&&a.settings.ui.theme_name!="default"?" tree-"+a.settings.ui.theme_name:"")+"' />").append("<ul class='"+a.container.children("ul:eq(0)").get(0).className+"' />");d=f(c.get(0).cloneNode(true));a.settings.languages.length>0&&d.find("a").not("."+a.current_lang).hide();i.drag_drop.drag_help.children("ul:eq(0)").append(d);i.drag_drop.drag_help.find("li:eq(0)").removeClass("last").addClass("last");
i.drag_drop.isdown=true;i.drag_drop.foreign=false;i.drag_drop.origin_tree=a;c.addClass("dragged")}i.drag_drop.init_x=b.pageX;i.drag_drop.init_y=b.pageY;c.blur();b.preventDefault();b.stopPropagation();return false});f(document).bind("mousedown.jstree",i.mousedown).bind("mouseup.jstree",i.mouseup).bind("mousemove.jstree",i.mousemove)}a.context&&f(document).bind("mousedown",function(){a.hide_context()})},checkMove:function(a,b,c){if(this.locked)return this.error("LOCKED");var d=this;if(b.parents("li.dragged").size()>
0||b.is(".dragged"))return this.error("MOVE: NODE OVER SELF");if(a.size()==1){var e=a.eq(0);if(i.drag_drop.foreign){if(this.settings.rules.droppable.length==0)return false;if(!e.is("."+this.settings.rules.droppable.join(", .")))return false;var g=false;for(var h in this.settings.rules.droppable)if(typeof this.settings.rules.droppable[h]!="function")if(e.is("."+this.settings.rules.droppable[h])){if(this.settings.rules.metadata){f.metadata.setType("attr",this.settings.rules.metadata);e.attr(this.settings.rules.metadata,
"type: '"+this.settings.rules.droppable[h]+"'")}else e.attr(this.settings.rules.type_attr,this.settings.rules.droppable[h]);g=true;break}if(!g)return false}if(!this.check("dragrules",[e,c,b.parents("li:eq(0)")]))return this.error("MOVE: AGAINST DRAG RULES")}else{g=true;a.each(function(){if(g==false)return false;d.check.apply(d,["dragrules",[f(this),c,b]])||(g=false)});if(g==false)return this.error("MOVE: AGAINST DRAG RULES")}if(this.settings.rules.use_inline&&this.settings.rules.metadata){e=false;
e=c=="inside"?b.parents("li:eq(0)"):b.parents("li:eq(1)");if(e.size()){if(typeof e.metadata().valid_children!="undefined"){var j=e.metadata().valid_children;g=true;a.each(function(){if(g==false)return false;if(f.inArray(d.get_type(this),j)==-1)g=false});if(g==false)return this.error("MOVE: NOT A VALID CHILD")}if(typeof e.metadata().max_children!="undefined")if(e.children("ul:eq(0)").children("li").not(".dragged").size()+a.size()>e.metadata().max_children)return this.error("MOVE: MAX CHILDREN REACHED");
var k=0;a.each(function(){for(var l=1,m=f(this);l<100;){m=m.children("ul").children("li");if(m.size()==0)break;l++}k=Math.max(l,k)});g=true;if((typeof f(e).metadata().max_depth).toLowerCase()!="undefined"&&f(e).metadata().max_depth<k)g=false;else e.parents("li").each(function(l){if(g==false)return false;if((typeof f(this).metadata().max_depth).toLowerCase()!="undefined")if(l+k>=f(this).metadata().max_depth)g=false});if(g==false)return this.error("MOVE: MAX_DEPTH REACHED")}}return true},reselect:function(a){var b=
this;if(a)this.cl_count--;else this.cl_count=0;if(this.opened&&this.opened.length){a=false;for(var c=0;this.opened&&c<this.opened.length;c++)if(this.settings.data.async){if(this.get_node(this.opened[c]).size()>0){a=true;var d=this.opened[c];delete this.opened[c];this.open_branch(d,true,function(){b.reselect.apply(b,[true])});this.cl_count++}}else this.open_branch(this.opened[c],true);if(this.settings.data.async&&a)return;delete this.opened}if(!(this.cl_count>0)){this.settings.ui.rtl?this.container.css("direction",
"rtl").children("ul:eq(0)").addClass("rtl"):this.container.css("direction","ltr").children("ul:eq(0)").addClass("ltr");this.settings.ui.dots==false&&this.container.children("ul:eq(0)").addClass("no_dots");if(this.scrtop){this.container.scrollTop(b.scrtop);delete this.scrtop}if(this.settings.selected!==false){f.each(this.settings.selected,function(e){b.is_partial_refresh?b.select_branch(f(b.settings.selected[e],b.container),b.settings.rules.multiple!==false):b.select_branch(f(b.settings.selected[e],
b.container),b.settings.rules.multiple!==false&&e>0)});this.settings.selected=false}this.settings.ui.theme_name=="themeroller"&&this.container.find("a").addClass("ui-state-default");this.settings.callback.onload.call(null,b)}},get_node:function(a){a=f(a);return a.is("li")?a:a.parents("li:eq(0)")},get_type:function(a){if(a=!a?this.selected:this.get_node(a)){if(this.settings.rules.metadata){f.metadata.setType("attr",this.settings.rules.metadata);var b=a.metadata().type;if(b)return b}return a.attr(this.settings.rules.type_attr)}},
scrollCheck:function(a,b){var c=this,d=c.container,e=c.container.offset(),g=d.scrollTop(),h=d.scrollLeft(),j=d.get(0).scrollWidth>d.width()?40:20;b-e.top<20&&d.scrollTop(Math.max(g-c.settings.ui.scroll_spd,0));d.height()-(b-e.top)<j&&d.scrollTop(g+c.settings.ui.scroll_spd);a-e.left<20&&d.scrollLeft(Math.max(h-c.settings.ui.scroll_spd,0));d.width()-(a-e.left)<40&&d.scrollLeft(h+c.settings.ui.scroll_spd);if(d.scrollLeft()!=h||d.scrollTop()!=g){c.moveType=false;c.moveRef=false;i.drag_drop.marker.hide()}i.drag_drop.scroll_time=
setTimeout(function(){c.scrollCheck(a,b)},50)},check:function(a,b){if(this.locked)return this.error("LOCKED");if(a!="dragrules"&&this.settings.rules.use_inline&&this.settings.rules.metadata){f.metadata.setType("attr",this.settings.rules.metadata);if(typeof this.get_node(b).metadata()[a]!="undefined")return this.get_node(b).metadata()[a]}if(!this.settings.rules[a])return false;if(this.settings.rules[a]=="none")return false;if(this.settings.rules[a]=="all")return true;if(a=="dragrules"){a=[];a[0]=this.get_type(b[0]);
a[1]=b[1];a[2]=this.get_type(b[2]);for(b=0;b<this.settings.rules.dragrules.length;b++){var c=this.settings.rules.dragrules[b],d=c.indexOf("!")===0?false:true;d||(c=c.replace("!",""));c=c.split(" ");for(var e=0;e<3;e++)if(c[e]==a[e]||c[e]=="*")c[e]=true;if(c[0]===true&&c[1]===true&&c[2]===true)return d}return false}else return f.inArray(this.get_type(b),this.settings.rules[a])!=-1?true:false},hover_branch:function(a){if(this.locked)return this.error("LOCKED");if(this.settings.ui.hover_mode==false&&
this.settings.ui.theme_name!="themeroller")return this.select_branch(a);var b=this;a=b.get_node(a);if(!a.size())return this.error("HOVER: NOT A VALID NODE");if(!b.check("clickable",a))return this.error("SELECT: NODE NOT SELECTABLE");this.hovered&&this.hovered.children("A").removeClass("hover ui-state-hover");this.hovered=a;this.hovered.children("a").removeClass("hover ui-state-hover").addClass(this.settings.ui.theme_name=="themeroller"?"hover ui-state-hover":"hover");a=this.hovered.offset().top;b=
this.container.offset().top;var c=b+this.container.height(),d=this.container.get(0).scrollWidth>this.container.width()?40:20;a+5<b&&this.container.scrollTop(this.container.scrollTop()-(b-a+5));a+d>c&&this.container.scrollTop(this.container.scrollTop()+(a+d-c))},select_branch:function(a,b){if(this.locked)return this.error("LOCKED");if(!a&&this.hovered!==false)a=this.hovered;var c=this;a=c.get_node(a);if(!a.size())return this.error("SELECT: NOT A VALID NODE");a.children("a").removeClass("hover ui-state-hover");
if(!c.check("clickable",a))return this.error("SELECT: NODE NOT SELECTABLE");if(c.settings.callback.beforechange.call(null,a.get(0),c)===false)return this.error("SELECT: STOPPED BY USER");if(this.settings.rules.multiple!=false&&b&&a.children("a.clicked").size()>0)return this.deselect_branch(a);this.settings.rules.multiple!=false&&b&&this.selected_arr.push(a);if(this.settings.rules.multiple!=false&&!b){for(var d in this.selected_arr)if(typeof this.selected_arr[d]!="function"){this.selected_arr[d].children("A").removeClass("clicked ui-state-active");
this.settings.callback.ondeselect.call(null,this.selected_arr[d].get(0),c)}this.selected_arr=[];this.selected_arr.push(a);if(this.selected&&this.selected.children("A").hasClass("clicked")){this.selected.children("A").removeClass("clicked ui-state-active");this.settings.callback.ondeselect.call(null,this.selected.get(0),c)}}if(!this.settings.rules.multiple)if(this.selected){this.selected.children("A").removeClass("clicked ui-state-active");this.settings.callback.ondeselect.call(null,this.selected.get(0),
c)}this.selected=a;if((this.settings.ui.hover_mode||this.settings.ui.theme_name=="themeroller")&&this.hovered!==false){this.hovered.children("A").removeClass("hover ui-state-hover");this.hovered=a}this.selected.children("a").removeClass("clicked ui-state-active").addClass(this.settings.ui.theme_name=="themeroller"?"clicked ui-state-active":"clicked").end().parents("li.closed").each(function(){c.open_branch(this,true)});a=this.selected.offset().top;b=this.container.offset().top;d=b+this.container.height();
var e=this.container.get(0).scrollWidth>this.container.width()?40:20;a+5<b&&this.container.scrollTop(this.container.scrollTop()-(b-a+5));a+e>d&&this.container.scrollTop(this.container.scrollTop()+(a+e-d));this.set_cookie("selected");this.settings.callback.onselect.call(null,this.selected.get(0),c);this.settings.callback.onchange.call(null,this.selected.get(0),c)},deselect_branch:function(a){if(this.locked)return this.error("LOCKED");var b=this;a=this.get_node(a);a.children("a").removeClass("clicked ui-state-active");
this.settings.callback.ondeselect.call(null,a.get(0),b);if(this.settings.rules.multiple!=false&&this.selected_arr.length>1){this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){b.selected_arr.push(f(this))});if(a.get(0)==this.selected.get(0)){this.selected=this.selected_arr[0];this.set_cookie("selected")}}else{if(this.settings.rules.multiple!=false)this.selected_arr=[];this.selected=false;this.set_cookie("selected")}this.selected?this.settings.callback.onchange.call(null,
this.selected.get(0),b):this.settings.callback.onchange.call(null,false,b)},toggle_branch:function(a){if(this.locked)return this.error("LOCKED");a=this.get_node(a);if(a.hasClass("closed"))return this.open_branch(a);if(a.hasClass("open"))return this.close_branch(a)},open_branch:function(a,b,c){if(this.locked)return this.error("LOCKED");a=this.get_node(a);if(!a.size())return this.error("OPEN: NO SUCH NODE");if(a.hasClass("leaf"))return this.error("OPEN: OPENING LEAF NODE");if(this.settings.data.async&&
a.find("li").size()==0){if(this.settings.callback.beforeopen.call(null,a.get(0),this)===false)return this.error("OPEN: STOPPED BY USER");var d=this;a.children("ul:eq(0)").remove().end().append("<ul><li class='last'><a class='loading' href='#'>"+(d.settings.lang.loading||"Loading ...")+"</a></li></ul>");a.removeClass("closed").addClass("open");if(this.settings.data.type=="xml_flat"||this.settings.data.type=="xml_nested"){b=this.settings.data.type=="xml_flat"?"flat.xsl":"nested.xsl";a.children("ul:eq(0)").getTransform(this.path+
b,this.settings.data.url,{params:{theme_path:d.theme},meth:this.settings.data.method,dat:this.settings.data.async_data(a,this),repl:true,callback:function(e){e.length<15?a.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove():d.open_branch.apply(d,[a]);c&&c.call()},error:function(){a.removeClass("open").addClass("closed").children("ul:eq(0)").remove()}})}else f.ajax({type:this.settings.data.method,url:this.settings.data.url,data:this.settings.data.async_data(a,this),dataType:"json",
success:function(e){e=d.settings.callback.onJSONdata.call(null,e,d);if(!e||e.length==0)a.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove();else{var g="";if(e.length)for(var h=0;h<e.length;h++)g+=d.parseJSON(e[h]);else g=d.parseJSON(e);if(g.length>0){a.children("ul:eq(0)").replaceWith("<ul>"+g+"</ul>");a.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");a.find("li").not(".open").not(".closed").addClass("leaf");d.open_branch.apply(d,
[a])}else a.removeClass("closed").removeClass("open").addClass("leaf").children("ul").remove()}c&&c.call()},error:function(e,g,h){a.removeClass("open").addClass("closed").children("ul:eq(0)").remove();d.error(h+" "+g)}})}else{if(!this.settings.data.async)if(this.settings.callback.beforeopen.call(null,a.get(0),this)===false)return this.error("OPEN: STOPPED BY USER");this.settings.ui.theme_name=="themeroller"&&a.find("a").not(".ui-state-default").addClass("ui-state-default");if(parseInt(this.settings.ui.animation)>
0&&!b){a.children("ul:eq(0)").css("display","none");a.removeClass("closed").addClass("open");a.children("ul:eq(0)").slideDown(parseInt(this.settings.ui.animation),function(){f(this).css("display","");c&&c.call()})}else{a.removeClass("closed").addClass("open");c&&c.call()}this.set_cookie("open");this.settings.callback.onopen.call(null,a.get(0),this)}return true},close_branch:function(a,b){if(this.locked)return this.error("LOCKED");var c=this;a=this.get_node(a);if(!a.size())return this.error("CLOSE: NO SUCH NODE");
if(c.settings.callback.beforeclose.call(null,a.get(0),c)===false)return this.error("CLOSE: STOPPED BY USER");if(parseInt(this.settings.ui.animation)>0&&!b&&a.children("ul:eq(0)").size()==1)a.children("ul:eq(0)").slideUp(parseInt(this.settings.ui.animation),function(){a.hasClass("open")&&a.removeClass("open").addClass("closed");c.set_cookie("open");f(this).css("display","")});else{a.hasClass("open")&&a.removeClass("open").addClass("closed");this.set_cookie("open")}if(this.selected&&a.children("ul:eq(0)").find("a.clicked").size()>
0){a.find("li:has(a.clicked)").each(function(){c.deselect_branch(this)});a.children("a.clicked").size()==0&&this.select_branch(a,this.settings.rules.multiple!=false&&this.selected_arr.length>0)}this.settings.callback.onclose.call(null,a.get(0),this)},open_all:function(a,b){if(this.locked)return this.error("LOCKED");var c=this;a=a?this.get_node(a).parent():this.container;var d=a.find("li.closed").size();if(b)this.cl_count--;else this.cl_count=0;if(d>0){this.cl_count+=d;a.find("li.closed").each(function(){var e=
this;c.open_branch.apply(c,[this,true,function(){c.open_all.apply(c,[e,true])}])})}else this.cl_count==0&&this.settings.callback.onopen_all.call(null,this)},close_all:function(){if(this.locked)return this.error("LOCKED");var a=this;this.container.find("li.open").each(function(){a.close_branch(this,true)})},show_lang:function(a){if(this.locked)return this.error("LOCKED");if(this.settings.languages[a]==this.current_lang)return true;var b=false,c=this.container.attr("id")?"#"+this.container.attr("id"):
".tree";b=get_css(c+" ."+this.current_lang,this.sn);if(b!==false)b.style.display="none";b=get_css(c+" ."+this.settings.languages[a],this.sn);if(b!==false)b.style.display="";this.current_lang=this.settings.languages[a];return true},cycle_lang:function(){if(this.locked)return this.error("LOCKED");var a=f.inArray(this.current_lang,this.settings.languages);a++;if(a>this.settings.languages.length-1)a=0;this.show_lang(a)},create:function(a,b,c){if(this.locked)return this.error("LOCKED");var d=false;if(b==
-1){d=true;b=this.container}else b=b?this.get_node(b):this.selected;if(!d&&(!b||!b.size()))return this.error("CREATE: NO NODE SELECTED");var e=c,g=b;if(c=="before"){c=b.parent().children().index(b);b=b.parents("li:eq(0)")}if(c=="after"){c=b.parent().children().index(b)+1;b=b.parents("li:eq(0)")}if(!d&&b.size()==0){d=true;b=this.container}if(!d){if(!this.check("creatable",b))return this.error("CREATE: CANNOT CREATE IN NODE");if(b.hasClass("closed"))if(this.settings.data.async&&b.children("ul").size()==
0){var h=this;return this.open_branch(b,true,function(){h.create.apply(h,[a,b,c])})}else this.open_branch(b,true)}var j=false;a=a?f.extend(true,{},a):{};if(!a.attributes)a.attributes={};if(this.settings.rules.metadata)a.attributes[this.settings.rules.metadata]||(a.attributes[this.settings.rules.metadata]='{ "type" : "'+(this.get_type(g)||"")+'" }');else a.attributes[this.settings.rules.type_attr]||(a.attributes[this.settings.rules.type_attr]=this.get_type(g)||"");if(this.settings.languages.length){if(!a.data){a.data=
{};j=true}for(g=0;g<this.settings.languages.length;g++)a.data[this.settings.languages[g]]||(a.data[this.settings.languages[g]]=(typeof this.settings.lang.new_node).toLowerCase()!="string"&&this.settings.lang.new_node[g]?this.settings.lang.new_node[g]:this.settings.lang.new_node)}else if(!a.data){a.data=this.settings.lang.new_node;j=true}g=f(this.parseJSON(a));if(g.children("ul").size())g.is(".open")||g.addClass("closed");else g.addClass("leaf");g.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");
g.find("li").not(".open").not(".closed").addClass("leaf");if(!d&&this.settings.rules.use_inline&&this.settings.rules.metadata){var k=this.get_type(g)||"";f.metadata.setType("attr",this.settings.rules.metadata);if(typeof b.metadata().valid_children!="undefined")if(f.inArray(k,b.metadata().valid_children)==-1)return this.error("CREATE: NODE NOT A VALID CHILD");if(typeof b.metadata().max_children!="undefined")if(b.children("ul:eq(0)").children("li").size()+1>b.metadata().max_children)return this.error("CREATE: MAX_CHILDREN REACHED");
var l=true;if((typeof f(b).metadata().max_depth).toLowerCase()!="undefined"&&f(b).metadata().max_depth===0)l=false;else b.parents("li").each(function(m){if(f(this).metadata().max_depth)if(m+1>=f(this).metadata().max_depth)return l=false});if(!l)return this.error("CREATE: MAX_DEPTH REACHED")}if((typeof c).toLowerCase()=="undefined"||c=="inside")c=this.settings.rules.createat=="top"?0:b.children("ul:eq(0)").children("li").size();if((b.children("ul").size()==0||d==true&&b.children("ul").children("li").size()==
0?d?this.moved(g,this.container.children("ul:eq(0)"),"inside",true):this.moved(g,b.children("a:eq(0)"),"inside",true):e=="before"&&b.children("ul:eq(0)").children("li:nth-child("+(c+1)+")").size()?this.moved(g,b.children("ul:eq(0)").children("li:nth-child("+(c+1)+")").children("a:eq(0)"),"before",true):e=="after"&&b.children("ul:eq(0)").children("li:nth-child("+c+")").size()?this.moved(g,b.children("ul:eq(0)").children("li:nth-child("+c+")").children("a:eq(0)"),"after",true):b.children("ul:eq(0)").children("li:nth-child("+
(c+1)+")").size()?this.moved(g,b.children("ul:eq(0)").children("li:nth-child("+(c+1)+")").children("a:eq(0)"),"before",true):this.moved(g,b.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",true))===false)return this.error("CREATE: ABORTED");if(j){this.select_branch(g.children("a:eq(0)"));this.rename()}return g},rename:function(a){if(this.locked)return this.error("LOCKED");a=a?this.get_node(a):this.selected;var b=this;if(!a||!a.size())return this.error("RENAME: NO NODE SELECTED");
if(!this.check("renameable",a))return this.error("RENAME: NODE NOT RENAMABLE");if(!this.settings.callback.beforerename.call(null,a.get(0),b.current_lang,b))return this.error("RENAME: STOPPED BY USER");a.parents("li.closed").each(function(){b.open_branch(this)});a=this.current_lang?a.find("a."+this.current_lang).get(0):a.find("a:first").get(0);last_value=a.innerHTML;b.inp=f("<input type='text' autocomplete='off' />");b.inp.val(last_value.replace(/&amp;/g,"&").replace(/&gt;/g,">").replace(/&lt;/g,"<")).bind("mousedown",
function(e){e.stopPropagation()}).bind("mouseup",function(e){e.stopPropagation()}).bind("click",function(e){e.stopPropagation()}).bind("keyup",function(e){e=e.keyCode||e.which;if(e==27){this.value=last_value;this.blur()}else e==13&&this.blur()});var c={};c[this.container.attr("id")]=this.get_rollback();b.inp.blur(function(){if(this.value=="")this.value=last_value;f(a).text(f(a).parent().find("input").eq(0).attr("value")).get(0).style.display="";f(a).prevAll("span").remove();b.settings.callback.onrename.call(null,
b.get_node(a).get(0),b.current_lang,b,c);b.inp=false});var d=f("<span />").addClass(a.className).append(b.inp);d.attr("style",f(a).attr("style"));a.style.display="none";f(a).parent().prepend(d);b.inp.get(0).focus();b.inp.get(0).select()},remove:function(a){if(this.locked)return this.error("LOCKED");var b={};b[this.container.attr("id")]=this.get_rollback();if(a&&(!this.selected||this.get_node(a).get(0)!=this.selected.get(0))){a=this.get_node(a);if(a.size()){if(!this.check("deletable",a))return this.error("DELETE: NODE NOT DELETABLE");
if(!this.settings.callback.beforedelete.call(null,a.get(0),e))return this.error("DELETE: STOPPED BY USER");$parent=a.parent();a=a.remove();$parent.children("li:last").addClass("last");if($parent.children("li").size()==0){$li=$parent.parents("li:eq(0)");$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove();this.set_cookie("open")}this.settings.callback.ondelete.call(null,a.get(0),this,b)}}else if(this.selected){if(!this.check("deletable",this.selected))return this.error("DELETE: NODE NOT DELETABLE");
if(!this.settings.callback.beforedelete.call(null,this.selected.get(0),e))return this.error("DELETE: STOPPED BY USER");$parent=this.selected.parent();a=this.selected;if(this.settings.rules.multiple==false||this.selected_arr.length==1)var c=true,d=this.selected.prev("li:eq(0)").size()?this.selected.prev("li:eq(0)"):this.selected.parents("li:eq(0)");a=a.remove();$parent.children("li:last").addClass("last");if($parent.children("li").size()==0){$li=$parent.parents("li:eq(0)");$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove();
this.set_cookie("open")}this.settings.callback.ondelete.call(null,a.get(0),this,b);c&&d&&this.select_branch(d);if(this.settings.rules.multiple!=false&&!c){var e=this;this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){e.selected_arr.push(f(this))});if(this.selected_arr.length>0){this.selected=this.selected_arr[0];this.remove()}}}else return this.error("DELETE: NO NODE SELECTED")},next:function(a,b){a=this.get_node(a);if(!a.size())return false;if(b)return a.nextAll("li").size()>
0?a.nextAll("li:eq(0)"):false;return a.hasClass("open")?a.find("li:eq(0)"):a.nextAll("li").size()>0?a.nextAll("li:eq(0)"):a.parents("li").next("li").eq(0)},prev:function(a,b){a=this.get_node(a);if(!a.size())return false;if(b)return a.prevAll("li").size()>0?a.prevAll("li:eq(0)"):false;if(a.prev("li").size()){for(a=a.prev("li").eq(0);a.hasClass("open");)a=a.children("ul:eq(0)").children("li:last");return a}else return a.parents("li:eq(0)").size()?a.parents("li:eq(0)"):false},parent:function(a){a=this.get_node(a);
if(!a.size())return false;return a.parents("li:eq(0)").size()?a.parents("li:eq(0)"):false},children:function(a){a=this.get_node(a);if(!a.size())return false;return a.children("ul:eq(0)").children("li")},get_next:function(a){var b=this.hovered||this.selected;return a?this.select_branch(this.next(b)):this.hover_branch(this.next(b))},get_prev:function(a){var b=this.hovered||this.selected;return a?this.select_branch(this.prev(b)):this.hover_branch(this.prev(b))},get_left:function(a,b){if(this.settings.ui.rtl&&
!b)return this.get_right(a,true);if(b=this.hovered||this.selected)if(b.hasClass("open"))this.close_branch(b);else return a?this.select_branch(this.parent(b)):this.hover_branch(this.parent(b))},get_right:function(a,b){if(this.settings.ui.rtl&&!b)return this.get_left(a,true);if(b=this.hovered||this.selected)if(b.hasClass("closed"))this.open_branch(b);else return a?this.select_branch(b.find("li:eq(0)")):this.hover_branch(b.find("li:eq(0)"))},toggleDots:function(){if(this.settings.ui.dots){this.settings.ui.dots=
false;this.container.children("ul:eq(0)").addClass("no_dots")}else{this.settings.ui.dots=true;this.container.children("ul:eq(0)").removeClass("no_dots")}},toggleRTL:function(){if(this.settings.ui.rtl){this.settings.ui.rtl=false;this.container.css("direction","ltr").children("ul:eq(0)").removeClass("rtl").addClass("ltr")}else{this.settings.ui.rtl=true;this.container.css("direction","rtl").children("ul:eq(0)").removeClass("ltr").addClass("rtl")}},set_cookie:function(a){if(this.settings.cookies===false)return false;
if(this.settings.cookies[a]===false)return false;switch(a){case "selected":if(this.settings.rules.multiple!=false&&this.selected_arr.length>1){var b=Array();f.each(this.selected_arr,function(){this.attr("id")&&b.push(this.attr("id"))});b=b.join(",")}else b=this.selected?this.selected.attr("id"):false;f.cookie(this.settings.cookies.prefix+"_selected",b,this.settings.cookies.opts);break;case "open":var c="";this.container.find("li.open").each(function(){if(this.id)c+=this.id+","});f.cookie(this.settings.cookies.prefix+
"_open",c.replace(/,$/ig,""),this.settings.cookies.opts);break}},get_rollback:function(){var a={};this.context.to_remove&&this.context.apply_to&&this.context.apply_to.children("a").removeClass("clicked");a.html=this.container.html();this.context.to_remove&&this.context.apply_to&&this.context.apply_to.children("a").addClass("clicked");a.selected=this.selected?this.selected.attr("id"):false;return a},moved:function(a,b,c,d,e,g){a=f(a);var h=f(a).parents("ul:eq(0)"),j=f(b);if(!g){g={};g[this.container.attr("id")]=
this.get_rollback();if(!d){var k=a.size()>1?a.eq(0).parents(".tree:eq(0)"):a.parents(".tree:eq(0)");if(k.get(0)!=this.container.get(0)){k=i.inst[k.attr("id")];g[k.container.attr("id")]=k.get_rollback()}delete k}}if(c=="inside"&&this.settings.data.async&&this.get_node(j).hasClass("closed")){var l=this;return this.open_branch(this.get_node(j),true,function(){l.moved.apply(l,[a,b,c,d,e,g])})}if(a.size()>1){l=this;k=this.moved(a.eq(0),b,c,false,e,g);a.each(function(o){if(o!=0)if(k)k=l.moved(this,k.children("a:eq(0)"),
"after",false,e,g)})}else{if(e){_what=a.clone();_what.each(function(){this.id+="_copy";f(this).find("li").each(function(){this.id+="_copy"});f(this).removeClass("dragged").find("a.clicked").removeClass("clicked ui-state-active").end().find("li.dragged").removeClass("dragged")})}else _what=a;if(d){if(!this.settings.callback.beforecreate.call(null,this.get_node(a).get(0),this.get_node(b).get(0),c,this))return false}else if(!this.settings.callback.beforemove.call(null,this.get_node(a).get(0),this.get_node(b).get(0),
c,this))return false;if(!d){k=a.parents(".tree:eq(0)");if(k.get(0)!=this.container.get(0)){k=i.inst[k.attr("id")];if(k.settings.languages.length){var m=[];if(this.settings.languages.length==0)m.push("."+k.current_lang);else for(var n in this.settings.languages)if(typeof this.settings.languages[n]!="function")for(var p in k.settings.languages)typeof k.settings.languages[p]!="function"&&this.settings.languages[n]==k.settings.languages[p]&&m.push("."+this.settings.languages[n]);if(m.length==0)return this.error("MOVE: NO COMMON LANGUAGES");
a.find("a").not(m.join(",")).remove()}a.find("a.clicked").removeClass("clicked ui-state-active")}}a=_what;switch(c){case "before":j.parents("ul:eq(0)").children("li.last").removeClass("last");j.parent().before(a.removeClass("last"));j.parents("ul:eq(0)").children("li:last").addClass("last");break;case "after":j.parents("ul:eq(0)").children("li.last").removeClass("last");j.parent().after(a.removeClass("last"));j.parents("ul:eq(0)").children("li:last").addClass("last");break;case "inside":if(j.parent().children("ul:first").size())this.settings.rules.createat==
"top"?j.parent().children("ul:first").prepend(a.removeClass("last")).children("li:last").addClass("last"):j.parent().children("ul:first").children(".last").removeClass("last").end().append(a.removeClass("last")).children("li:last").addClass("last");else{a.addClass("last");j.parent().append("<ul/>").removeClass("leaf").addClass("closed");j.parent().children("ul:first").prepend(a)}j.parent().hasClass("closed")&&this.open_branch(j);break;default:break}if(h.find("li").size()==0){h=h.parent();h.removeClass("open").removeClass("closed").addClass("leaf");
h.is(".tree")||h.children("ul").remove();h.parents("ul:eq(0)").children("li.last").removeClass("last").end().children("li:last").addClass("last");this.set_cookie("open")}else{h.children("li.last").removeClass("last");h.children("li:last").addClass("last")}if(e)this.settings.callback.oncopy.call(null,this.get_node(a).get(0),this.get_node(b).get(0),c,this,g);else d?this.settings.callback.oncreate.call(null,this.get_node(a).get(0),j.is("ul")?-1:this.get_node(b).get(0),c,this,g):this.settings.callback.onmove.call(null,
this.get_node(a).get(0),this.get_node(b).get(0),c,this,g);return a}},error:function(a){this.settings.callback.error.call(null,a,this);return false},lock:function(a){(this.locked=a)?this.container.children("ul:eq(0)").addClass("locked"):this.container.children("ul:eq(0)").removeClass("locked")},cut:function(a){if(this.locked)return this.error("LOCKED");a=a?this.get_node(a):this.container.find("a.clicked").filter(":first-child").parent();if(!a||!a.size())return this.error("CUT: NO NODE SELECTED");this.copy_nodes=
false;this.cut_nodes=a},copy:function(a){if(this.locked)return this.error("LOCKED");a=a?this.get_node(a):this.container.find("a.clicked").filter(":first-child").parent();if(!a||!a.size())return this.error("COPY: NO NODE SELECTED");this.copy_nodes=a;this.cut_nodes=false},paste:function(a,b){if(this.locked)return this.error("LOCKED");var c=false;if(a==-1){c=true;a=this.container}else a=a?this.get_node(a):this.selected;if(!c&&(!a||!a.size()))return this.error("PASTE: NO NODE SELECTED");if(!this.copy_nodes&&
!this.cut_nodes)return this.error("PASTE: NOTHING TO DO");var d=this,e=b;if(b=="before"){b=a.parent().children().index(a);a=a.parents("li:eq(0)")}else if(b=="after"){b=a.parent().children().index(a)+1;a=a.parents("li:eq(0)")}else if((typeof b).toLowerCase()=="undefined"||b=="inside")b=this.settings.rules.createat=="top"?0:a.children("ul:eq(0)").children("li").size();if(!c&&a.size()==0){c=true;a=this.container}if(this.copy_nodes&&this.copy_nodes.size()){var g=true;if(!g)return this.error("Invalid paste");
if(!c&&!this.checkMove(this.copy_nodes,a.children("a:eq(0)"),"inside"))return false;var h=a.children("ul").size()==0||c==true&&a.children("ul").children("li").size()==0?c?this.moved(this.copy_nodes,this.container.children("ul:eq(0)"),"inside",false,true):this.moved(this.copy_nodes,a.children("a:eq(0)"),"inside",false,true):e=="before"&&a.children("ul:eq(0)").children("li:nth-child("+(b+1)+")").size()?this.moved(this.copy_nodes,a.children("ul:eq(0)").children("li:nth-child("+(b+1)+")").children("a:eq(0)"),
"before",false,true):e=="after"&&a.children("ul:eq(0)").children("li:nth-child("+b+")").size()?this.moved(this.copy_nodes,a.children("ul:eq(0)").children("li:nth-child("+b+")").children("a:eq(0)"),"after",false,true):a.children("ul:eq(0)").children("li:nth-child("+(b+1)+")").size()?this.moved(this.copy_nodes,a.children("ul:eq(0)").children("li:nth-child("+(b+1)+")").children("a:eq(0)"),"before",false,true):this.moved(this.copy_nodes,a.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",
false,true);this.copy_nodes=false}if(this.cut_nodes&&this.cut_nodes.size()){g=true;a.parents().andSelf().each(function(){if(d.cut_nodes.index(this)!=-1)return g=false});if(!g)return this.error("Invalid paste");if(!c&&!this.checkMove(this.cut_nodes,a.children("a:eq(0)"),"inside"))return false;h=a.children("ul").size()==0||c==true&&a.children("ul").children("li").size()==0?c?this.moved(this.cut_nodes,this.container.children("ul:eq(0)"),"inside"):this.moved(this.cut_nodes,a.children("a:eq(0)"),"inside"):
e=="before"&&a.children("ul:eq(0)").children("li:nth-child("+(b+1)+")").size()?this.moved(this.cut_nodes,a.children("ul:eq(0)").children("li:nth-child("+(b+1)+")").children("a:eq(0)"),"before"):e=="after"&&a.children("ul:eq(0)").children("li:nth-child("+b+")").size()?this.moved(this.cut_nodes,a.children("ul:eq(0)").children("li:nth-child("+b+")").children("a:eq(0)"),"after"):a.children("ul:eq(0)").children("li:nth-child("+(b+1)+")").size()?this.moved(this.cut_nodes,a.children("ul:eq(0)").children("li:nth-child("+
(b+1)+")").children("a:eq(0)"),"before"):this.moved(this.cut_nodes,a.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after");this.cut_nodes=false}},search:function(a){var b=this;if(!a||this.srch&&a!=this.srch){this.srch="";this.srch_opn=false;this.container.find("a.search").removeClass("search ui-state-highlight")}if(this.srch=a)if(this.settings.data.async)if(this.srch_opn)if(this.srch_opn.length){if(this.srch_opn&&this.srch_opn.length){for(var c=false,d=0;d<this.srch_opn.length;d++)if(this.get_node("#"+
this.srch_opn[d]).size()>0){c=true;var e="#"+this.srch_opn[d];delete this.srch_opn[d];this.open_branch(e,true,function(){b.search.apply(b,[a])})}if(!c){this.srch_opn=[];b.search.apply(b,[a])}}}else{c="a";if(this.settings.languages.length)c+="."+this.current_lang;this.container.find(c+":contains('"+a+"')").addClass(this.settings.ui.theme_name=="themeroller"?"search ui-state-highlight":"search");this.srch_opn=false}else{c=f.extend({search:a},this.settings.data.async_data(false,this));f.ajax({type:this.settings.data.method,
url:this.settings.data.url,data:c,dataType:"text",success:function(g){b.srch_opn=f.unique(g.split(","));b.search.apply(b,[a])}})}else{c="a";if(this.settings.languages.length)c+="."+this.current_lang;this.container.find(c+":contains('"+a+"')").addClass(this.settings.ui.theme_name=="themeroller"?"search ui-state-highlight":"search").parents("li.closed").each(function(){b.open_branch(this,true)})}},destroy:function(){this.hide_context();this.container.unbind(".jstree");f("#"+this.container.attr("id")).die("click.jstree").die("dblclick.jstree").die("contextmenu.jstree").die("mouseover.jstree").die("mouseout.jstree").die("mousedown.jstree");
this.container.removeClass("tree ui-widget ui-widget-content tree-default tree-"+this.settings.ui.theme_name).children("ul").removeClass("no_dots rtl ltr locked").find("li").removeClass("leaf").removeClass("open").removeClass("closed").removeClass("last").children("a").removeClass("clicked hover search ui-state-active ui-state-hover ui-state-highlight ui-state-default");if(this.cntr==i.focused)for(var a in i.inst)if(a!=this.cntr&&a!=this.container.attr("id")){i.inst[a].focus();break}i.inst[this.cntr]=
false;i.inst[this.container.attr("id")]=false;delete i.inst[this.cntr];delete i.inst[this.container.attr("id")];i.cntr--}}}f.fn.tree=function(a){return this.each(function(){var b=f.extend({},a);i.inst&&i.inst[f(this).attr("id")]&&i.inst[f(this).attr("id")].destroy();if(b!==false){this.tree1=new i;this.tree1.init(this,b)}})};f.tree_create=function(){return new i};f.tree_focused=function(){return i.inst[i.focused]};f.tree_reference=function(a){return i.inst[a]||null};f.tree_rollback=function(a){for(var b in a)if(typeof a[b]!=
"function"){var c=i.inst[b],d=!c.locked;d&&c.lock(true);c.inp&&c.inp.val("").blur();c.context.append=false;c.container.html(a[b].html).find(".dragged").removeClass("dragged").end().find("div.context").remove();if(a[b].selected){c.selected=f("#"+a[b].selected);c.selected_arr=[];c.container.find("a.clicked").each(function(){c.selected_arr.push(c.get_node(this))})}d&&c.lock(false);delete d;delete c}}})(jQuery);