var TAFELTREE_WRONG_BRANCH_STRUCTURE="La structure de la branche n'est pas correcte. Il faut au moins un id et un texte";var TAFELTREE_NO_BODY_TAG="Il n'y a pas de balise BODY!";var TAFELTREE_DEBUG=false;var TafelTree=Class.create();TafelTree.version="1.9.1";TafelTree.lastUpdate="2007-07-21";TafelTree.scriptFragment=/[\s]*<[/]?[ul|li].*>.*/ig;TafelTree.debugReturn="<br />";TafelTree.debugTab="&nbsp;&nbsp;&nbsp;&nbsp;";TafelTree.prefixAttribute="T";TafelTree.textAttributes=[TafelTree.prefixAttribute+"img",TafelTree.prefixAttribute+"imgopen",TafelTree.prefixAttribute+"imgclose",TafelTree.prefixAttribute+"imgselect",TafelTree.prefixAttribute+"imgselectopen",TafelTree.prefixAttribute+"imgselectclose",TafelTree.prefixAttribute+"style",TafelTree.prefixAttribute+"droplink",TafelTree.prefixAttribute+"openlink",TafelTree.prefixAttribute+"editlink",TafelTree.prefixAttribute+"tooltip",TafelTree.prefixAttribute+"title"];TafelTree.numericAttributes=[TafelTree.prefixAttribute+"canhavechildren",TafelTree.prefixAttribute+"acceptdrop",TafelTree.prefixAttribute+"draggable",TafelTree.prefixAttribute+"editable",TafelTree.prefixAttribute+"open",TafelTree.prefixAttribute+"check",TafelTree.prefixAttribute+"checkbox",TafelTree.prefixAttribute+"select",TafelTree.prefixAttribute+"last"];TafelTree.functionAttributes=[TafelTree.prefixAttribute+"onbeforecheck",TafelTree.prefixAttribute+"oncheck",TafelTree.prefixAttribute+"onclick",TafelTree.prefixAttribute+"ondblclick",TafelTree.prefixAttribute+"onbeforeopen",TafelTree.prefixAttribute+"onopen",TafelTree.prefixAttribute+"onedit",TafelTree.prefixAttribute+"oneditajax",TafelTree.prefixAttribute+"onmouseover",TafelTree.prefixAttribute+"onmouseout",TafelTree.prefixAttribute+"onmousedown",TafelTree.prefixAttribute+"onmouseup",TafelTree.prefixAttribute+"ondrop",TafelTree.prefixAttribute+"ondragstarteffect",TafelTree.prefixAttribute+"ondragendeffect",TafelTree.prefixAttribute+"onerrorajax",TafelTree.prefixAttribute+"ondropajax",TafelTree.prefixAttribute+"onopenpopulate"];TafelTree.loadFromUL=function(id,imgBase,width,height,options,debug){if(typeof(imgBase)=="object"){options=imgBase;debug=width;imgBase=(options.imgBase)?options.imgBase:"imgs/";width=(options.width)?options.width:"100%";height=(options.height)?options.height:"auto"}var obj=$(id);var load=document.createElement("img");load.setAttribute("title","load");load.setAttribute("alt","load");load.src=((imgBase)?imgBase:"imgs/")+"load.gif";obj.parentNode.insertBefore(load,obj);Element.hide(obj);var tab="";var tabModel=(debug)?TafelTree.debugTab:"";var rt=(debug)?TafelTree.debugReturn:"";var virgule="";var str=(debug)?"var struct = [":"([";for(var i=0;i<obj.childNodes.length;i++){if(obj.childNodes[i].nodeName.toLowerCase()=="li"){str+=this._loadFromUL(obj.childNodes[i],virgule,rt,tab,tabModel);virgule=","}}str+=rt+((debug)?"];":"])");var div=document.createElement("div");div.id=obj.id;obj.id+="____todelete";obj.parentNode.insertBefore(div,obj);if(!debug){var m=TafelTree.prefixAttribute;var struct=eval(str);var _tree=new TafelTree(id,struct,options)}else{div.innerHTML=str.replace(/</img,"&lt;");var _tree=str}obj.parentNode.removeChild(load);obj.parentNode.removeChild(obj);return _tree};TafelTree._loadFromUL=function(e,k,c,b,a){b+=a;var g=TafelTree.trim(e.innerHTML.replace(TafelTree.scriptFragment,""));var h=k+c+b+"{"+c;h+=b+"'id' : '"+e.id+"'";if(g){h+=","+c+b+"'txt' : '"+g+"'"}TafelTree.textAttributes.each(function(i){if(e.getAttribute(i)){h+=","+c+b+"'"+i.replace(TafelTree.prefixAttribute,"")+"' : '"+e.getAttribute(i)+"'"}});TafelTree.numericAttributes.each(function(i){if(e.getAttribute(i)){h+=","+c+b+"'"+i.replace(TafelTree.prefixAttribute,"")+"' : "+e.getAttribute(i)}});TafelTree.functionAttributes.each(function(i){if(e.getAttribute(i)){h+=","+c+b+"'"+i.replace(TafelTree.prefixAttribute,"")+"' : "+e.getAttribute(i)}});for(var f=0;f<e.childNodes.length;f++){if(e.childNodes[f].nodeName.toLowerCase()=="ul"){k="";h+=","+c+b+"'items' : [";for(var d=0;d<e.childNodes[f].childNodes.length;d++){if(e.childNodes[f].childNodes[d].nodeName.toLowerCase()=="li"){h+=this._loadFromUL(e.childNodes[f].childNodes[d],k,c,b,a);k=","}}h+=c+b+"]"}}h+=c+b+"}";return h};TafelTree.trim=function(a){return a.replace(/(^\s*)|(\s*$)|\n|\r|\t/g,"")};TafelTree.prototype={initialize:function(h,f,e,d,a,c){if(typeof(e)=="object"){c=e;e=(c.imgBase)?c.imgBase:"imgs/";d=(c.width)?c.width:"100%";a=(c.height)?c.height:"auto"}this.imgBase=(e)?e:"imgs/";this.setLineStyle("line");this.options=(c)?c:{};this.copyName=" (%n)";this.copyNameBreak="_";this.classTree="tafelTree";this.classTreeRoot=this.classTree+"_root";this.classTreeBranch=this.classTree+"_row";this.classCopy=(this.options.copyCSS)?this.options.copyCSS:null;this.classCut=(this.options.cutCSS)?this.options.cutCSS:null;this.classDrag="tafelTreedrag";this.classSelected="tafelTreeselected";this.classEditable="tafelTreeeditable";this.classContent="tafelTreecontent";this.classCanevas="tafelTreecanevas";this.classDragOver="tafelTreedragOver";this.classTooltip="tafelTreetooltip";this.classOpenable="tafelTreeopenable";this.defaultStruct=[];this.idTree=0;this.behaviourDrop=0;this.durationTooltipShow=1000;this.durationTooltipHide=100;this.baseStruct=f;this.width=(d)?d:"100%";this.height=(a)?a:"auto";this.div=$(h);this.div.style.width=this.width;this.div.style.height=this.height;this.id=this.div.id;this.isTree=true;this.dropALT=true;this.openAll=false;this.rtlMode=false;this.dropCTRL=true;this.multiline=false;this.checkboxes=false;this.propagation=true;this.dragRevert=true;this.dragGhosting=true;this.bigTreeLoading=-1;this.dropAsSibling=true;this.onlyOneOpened=false;this.openedAfterAdd=true;this.editableBranches=true;this.reopenFromServer=true;this.selectedBranchShowed=true,this.checkboxesThreeState=false;this.roots=[];this.icons=[null,null,null];this.iconsSelected=[null,null,null];this.otherTrees=[];this.cuttedBranches=[];this.copiedBranches=[];this.checkedBranches=[];this.selectedBranches=[];this.idTreeBranch=this.classTree+"_"+this.id+"_id_";this.loaded=false;Element.addClassName(this.div,this.classTree);this.useCookie=true;this.cookieSeparator="|";this.cookieCheckSeparator="[check]";this.cookieOpened=null;this.cookieChecked=null;this.setOptions(this.options);var g=this.getCookie(this.classTree+this.id);if(g){var b=g.split(this.cookieCheckSeparator);this.cookieOpened=[];this.cookieOpened=b[0].split(this.cookieSeparator);this.cookieOpened.shift();this.cookieChecked=[];if(b.length>1){this.cookieChecked=b[1].split(this.cookieSeparator)}}this.debugObj=document.createElement("div");this.debugObj.setAttribute("id",this.classTree+"_debug");Element.hide(this.debugObj);this.div.appendChild(this.debugObj);this.ajaxObj=document.createElement("div");this.ajaxObj.setAttribute("id",this.classTree+"_ajax");Element.hide(this.ajaxObj);this.div.appendChild(this.ajaxObj);Event.observe(this.div,"mousedown",this.evt_setAsCurrent.bindAsEventListener(this),false);Event.observe(this.div,"focus",this.evt_setAsCurrent.bindAsEventListener(this),false);if(!this.serverCookie){if(this.options.generate){this.generate()}if(this.options.generateBigTree){this.generate(true)}}TafelTreeManager.add(this)},evt_setAsCurrent:function(a){var b=Event.element(a);TafelTreeManager.setCurrentTree(this)},orderListBranches:function(f){var a=[];var g=[];var e=100;var c=0;var b=0;for(var d=0;d<f.length;d++){b=f[d].getLevel();if(typeof(g[b])=="undefined"){g[b]=[]}g[b].push(f[d]);if(b>c){c=b}if(b<e){e=b}}for(var d=e;d<=c;d++){if(g[d]){a.push(g[d])}}return a},getCopiedBranches:function(){var a=this.copiedBranches;if(a.length==0){for(var b=0;b<this.otherTrees.length;b++){a=this.otherTrees[b].copiedBranches;if(a.length>0){break}}}return a},getCuttedBranches:function(){var a=this.cuttedBranches;if(a.length==0){for(var b=0;b<this.otherTrees.length;b++){a=this.otherTrees[b].cuttedBranches;if(a.length>0){break}}}return a},cut:function(){this.unsetCut();this.unsetCopy();var d=this.orderListBranches(this.selectedBranches);var c=null;for(var b=0;b<d.length;b++){for(var a=0;a<d[b].length;a++){c=d[b][a];this._cut(c);this.cuttedBranches.push(c)}}return true},copy:function(){this.unsetCut();this.unsetCopy();var c=this.orderListBranches(this.selectedBranches);var b=null;for(var a=0;a<this.selectedBranches.length;a++){b=this.selectedBranches[a];this._copy(b);this.copiedBranches[a]=b}return true},paste:function(){if(this.selectedBranches.length!=1){return false}var g=this.selectedBranches[0];var c=this.getCopiedBranches();var f=this.getCuttedBranches();var d=c.length;var h=f.length;if(d>0){var j=c;var a=null;for(var e=0;e<j.length;e++){if(this._okForPaste(g,j,e)){a=g.insertIntoLast(j[e].clone())}}}if(h>0){var j=f;for(var e=0;e<j.length;e++){if(this._okForPaste(g,j,e)){j[e].move(g)}}}this.unsetCut();return true},_okForPaste:function(d,e,c){var b=true;if(!d.isChild(e[c])){for(var a=0;a<c;a++){if(e[c].isChild(e[a])){b=false;break}}}else{b=false}return b},unsetCut:function(){var e=null;var a=null;for(var c=0;c<this.otherTrees.length;c++){e=this.otherTrees[c];a=e.cuttedBranches;for(var b=0;b<a.length;b++){e._unsetCut(a[b])}e.cuttedBranches=[]}var d=null;for(var c=0;c<this.cuttedBranches.length;c++){d=this.cuttedBranches[c];this._unsetCut(d)}this.cuttedBranches=[]},unsetCopy:function(){var d=null;var a=null;for(var c=0;c<this.otherTrees.length;c++){d=this.otherTrees[c];a=d.copiedBranches;for(var b=0;b<a.length;b++){d._unsetCopy(a[b])}d.copiedBranches=[]}var e=null;for(var c=0;c<this.copiedBranches.length;c++){e=this.copiedBranches[c];this._unsetCopy(e)}this.copiedBranches=[]},undo:function(){},_cut:function(b){if(!this.classCut){new Effect.Opacity(b.txt,{duration:0.1,transition:Effect.Transitions.linear,from:1,to:0.4});new Effect.Opacity(b.img,{duration:0.1,transition:Effect.Transitions.linear,from:1,to:0.4})}else{Element.addClassName(b.txt,this.classCut);Element.addClassName(b.img,this.classCut)}if(b.hasChildren()){for(var a=0;a<b.children.length;a++){this._cut(b.children[a])}}},_unsetCut:function(b){if(!this.classCut){new Effect.Opacity(b.txt,{duration:0.1,transition:Effect.Transitions.linear,from:0.4,to:1});new Effect.Opacity(b.img,{duration:0.1,transition:Effect.Transitions.linear,from:0.4,to:1})}else{Element.removeClassName(b.txt,this.classCut);Element.removeClassName(b.img,this.classCut)}if(b.hasChildren()){for(var a=0;a<b.children.length;a++){this._unsetCut(b.children[a])}}},_copy:function(b){if(this.classCopy){Element.addClassName(b.txt,this.classCopy);Element.addClassName(b.img,this.classCopy)}if(b.hasChildren()){for(var a=0;a<b.children.length;a++){this._copy(b.children[a])}}},_unsetCopy:function(b){if(this.classCopy){Element.removeClassName(b.txt,this.classCopy);Element.removeClassName(b.img,this.classCopy)}if(b.hasChildren()){for(var a=0;a<b.children.length;a++){this._unsetCopy(b.children[a])}}},enableMultiline:function(a){this.multiline=(a)?true:false},enableRTL:function(a){this.rtlMode=(a)?true:false;if(this.rtlMode){this.div.style.textAlign="right";this.div.style.direction="rtl"}else{this.div.style.textAlign="left";this.div.style.direction="ltr"}this.setLineStyle(this.lineStyle)},isRTL:function(){return this.rtlMode},disableDropALT:function(a){this.dropALT=(a)?true:false},disableDropCTRL:function(a){this.dropCTRL=(a)?true:false},enableCheckboxes:function(a){this.checkboxes=(a)?true:false},enableCheckboxesThreeState:function(a){this.enableCheckboxes(a);this.checkboxesThreeState=(a)?true:false},enableCookies:function(a,b){this.useCookie=(a)?true:false;if(typeof(b)!="undefined"){this.cookieSeparator=b}},openOneAtOnce:function(a){this.onlyOneOpened=(a)?true:false},openAfterAdd:function(a){this.openedAfterAdd=(a)?true:false},reopenFromServerAfterLoad:function(a){this.reopenFromServer=(a)?true:false},openAtLoad:function(a){this.openAll=(a)?true:false},showSelectedBranch:function(a){this.selectedBranchShowed=(a)?true:false},setBehaviourDrop:function(a){switch(a){case"sibling":this.behaviourDrop=1;break;case"childcopy":this.behaviourDrop=2;break;case"siblingcopy":this.behaviourDrop=3;break;case"child":default:this.behaviourDrop=0}},setIcons:function(b,c,a){this.icons[0]=b;this.icons[1]=(c)?c:b;this.icons[2]=(a)?a:b},setIconsSelected:function(b,c,a){this.iconsSelected[0]=b;this.iconsSelected[1]=(c)?c:null;this.iconsSelected[2]=(a)?a:null},setLineStyle:function(a){this.lineStyle=a;switch(a){case"none":this.imgLine0="empty.gif";this.imgLine1="empty.gif";this.imgLine2="empty.gif";this.imgLine3="empty.gif";this.imgLine4="empty.gif";this.imgLine5="empty.gif";this.imgWait="wait.gif";this.imgEmpty="empty.gif";this.imgMinus1="minus0.gif";this.imgMinus2="minus0.gif";this.imgMinus3="minus0.gif";this.imgMinus4="minus0.gif";this.imgMinus5="minus0.gif";this.imgPlus1="plus0.gif";this.imgPlus2="plus0.gif";this.imgPlus3="plus0.gif";this.imgPlus4="plus0.gif";this.imgPlus5="plus0.gif";this.imgCheck1="check1.gif";this.imgCheck2="check2.gif";this.imgCheck3="check3.gif";this.imgMulti1="empty.gif";this.imgMulti2="empty.gif";this.imgMulti3="";this.imgMulti4="";break;case"full":if(this.isRTL()){this.imgLine0="rtl_linefull0.gif";this.imgLine1="rtl_linefull1.gif";this.imgLine2="rtl_linefull2.gif";this.imgLine3="rtl_linefull3.gif";this.imgLine4="rtl_linefull4.gif";this.imgLine5="rtl_linefull5.gif";this.imgWait="wait.gif";this.imgEmpty="empty.gif";this.imgMinus1="rtl_minusfull1.gif";this.imgMinus2="rtl_minusfull2.gif";this.imgMinus3="rtl_minusfull3.gif";this.imgMinus4="rtl_minusfull4.gif";this.imgMinus5="rtl_minusfull5.gif";this.imgPlus1="rtl_plusfull1.gif";this.imgPlus2="rtl_plusfull2.gif";this.imgPlus3="rtl_plusfull3.gif";this.imgPlus4="rtl_plusfull4.gif";this.imgPlus5="rtl_plusfull5.gif";this.imgCheck1="check1.gif";this.imgCheck2="check2.gif";this.imgCheck3="check3.gif";this.imgMulti1="rtl_linebgfull.gif";this.imgMulti2="rtl_linebgfull2.gif";this.imgMulti3="multiline";this.imgMulti4="multiline2"}else{this.imgLine0="linefull0.gif";this.imgLine1="linefull1.gif";this.imgLine2="linefull2.gif";this.imgLine3="linefull3.gif";this.imgLine4="linefull4.gif";this.imgLine5="linefull5.gif";this.imgWait="wait.gif";this.imgEmpty="empty.gif";this.imgMinus1="minusfull1.gif";this.imgMinus2="minusfull2.gif";this.imgMinus3="minusfull3.gif";this.imgMinus4="minusfull4.gif";this.imgMinus5="minusfull5.gif";this.imgPlus1="plusfull1.gif";this.imgPlus2="plusfull2.gif";this.imgPlus3="plusfull3.gif";this.imgPlus4="plusfull4.gif";this.imgPlus5="plusfull5.gif";this.imgCheck1="check1.gif";this.imgCheck2="check2.gif";this.imgCheck3="check3.gif";this.imgMulti1="linebgfull.gif";this.imgMulti2="linebgfull2.gif";this.imgMulti3="multiline";this.imgMulti4="multiline2"}break;case"line":default:if(this.isRTL()){this.imgLine0="rtl_line0.gif";this.imgLine1="rtl_line1.gif";this.imgLine2="rtl_line2.gif";this.imgLine3="rtl_line3.gif";this.imgLine4="rtl_line4.gif";this.imgLine5="rtl_line5.gif";this.imgWait="wait.gif";this.imgEmpty="empty.gif";this.imgMinus1="rtl_minus1.gif";this.imgMinus2="rtl_minus2.gif";this.imgMinus3="rtl_minus3.gif";this.imgMinus4="rtl_minus4.gif";this.imgMinus5="rtl_minus5.gif";this.imgPlus1="rtl_plus1.gif";this.imgPlus2="rtl_plus2.gif";this.imgPlus3="rtl_plus3.gif";this.imgPlus4="rtl_plus4.gif";this.imgPlus5="rtl_plus5.gif";this.imgCheck1="check1.gif";this.imgCheck2="check2.gif";this.imgCheck3="check3.gif";this.imgMulti1="rtl_linebg.gif";this.imgMulti2="rtl_linebg2.gif";this.imgMulti3="multiline";this.imgMulti4="multiline2"}else{this.imgLine0="line0.gif";this.imgLine1="line1.gif";this.imgLine2="line2.gif";this.imgLine3="line3.gif";this.imgLine4="line4.gif";this.imgLine5="line5.gif";this.imgWait="wait.gif";this.imgEmpty="empty.gif";this.imgMinus1="minus1.gif";this.imgMinus2="minus2.gif";this.imgMinus3="minus3.gif";this.imgMinus4="minus4.gif";this.imgMinus5="minus5.gif";this.imgPlus1="plus1.gif";this.imgPlus2="plus2.gif";this.imgPlus3="plus3.gif";this.imgPlus4="plus4.gif";this.imgPlus5="plus5.gif";this.imgCheck1="check1.gif";this.imgCheck2="check2.gif";this.imgCheck3="check3.gif";this.imgMulti1="linebg.gif";this.imgMulti2="linebg2.gif";this.imgMulti3="multiline";this.imgMulti4="multiline2"}}},setTooltipDuration:function(a,b){this.durationTooltipShow=a;this.durationTooltipHide=b},propagateRestriction:function(a){this.propagation=(typeof(a)=="undefined")?true:a},getSelectedBranches:function(){return this.selectedBranches},setContextMenu:function(a){var b=document.createElement("div");b.innerHTML=a;this.div.appendChild(b)},generate:function(d){if(!d){var c=false;var a=false;for(var b=0;b<this.baseStruct.length;b++){c=(b>0)?true:false;a=(b<this.baseStruct.length-1)?true:false;this.roots[b]=new TafelTreeRoot(this,this.baseStruct[b],0,c,a,b);this.div.appendChild(this.roots[b].obj)}this.loadComplete()}else{this.bigTreeLoading=0;setTimeout(this._checkLoad.bind(this),100);setTimeout(this._generateBigTree.bind(this),10)}},setOptions:function(c){if(c.onLoad){this.setOnLoad(c.onLoad)}if(c.onDebug){this.setOnDebug(c.onDebug)}if(c.onCheck){this.setOnCheck(c.onCheck)}if(c.onBeforeCheck){this.setOnBeforeCheck(c.onBeforeCheck)}if(c.onClick){this.setOnClick(c.onClick)}if(c.onMouseDown){this.setOnMouseDown(c.onMouseDown)}if(c.onMouseUp){this.setOnMouseUp(c.onMouseUp)}if(c.onDblClick){this.setOnDblClick(c.onDblClick)}if(c.onBeforeOpen){this.setOnBeforeOpen(c.onBeforeOpen)}if(c.onOpen){this.setOnOpen(c.onOpen)}if(c.onMouseOver){this.setOnMouseOver(c.onMouseOver)}if(c.onMouseOut){this.setOnMouseOut(c.onMouseOut)}if(c.onDrop){this.setOnDrop(c.onDrop)}if(c.onDragStartEffect){this.setOnDragStartEffect(c.onDragStartEffect)}if(c.onDragEndEffect){this.setOnDragEndEffect(c.onDragEndEffect)}if(c.onErrorAjax){this.setOnDropAfter(c.onErrorAjax)}if(c.onEdit){this.setOnEdit(c.onEdit)}if(c.onEditAjax){this.setOnEditAjax(c.onEditAjax[0],c.onEditAjax[1])}if(c.onDropAjax){this.setOnDropAjax(c.onDropAjax[0],c.onDropAjax[1])}if(c.onOpenPopulate){this.setOnOpenPopulate(c.onOpenPopulate[0],c.onOpenPopulate[1])}if(typeof(c.rtlMode)!="undefined"){this.enableRTL(c.rtlMode)}if(typeof(c.dropALT)!="undefined"){this.disableDropALT(c.dropALT)}if(typeof(c.dropCTRL)!="undefined"){this.disableDropCTRL(c.dropCTRL)}if(typeof(c.multiline)!="undefined"){this.enableMultiline(c.multiline)}if(typeof(c.checkboxes)!="undefined"){this.enableCheckboxes(c.checkboxes)}if(typeof(c.checkboxesThreeState)!="undefined"){this.enableCheckboxesThreeState(c.checkboxesThreeState)}if(typeof(c.cookies)!="undefined"){this.enableCookies(c.cookies)}if(typeof(c.openOneAtOnce)!="undefined"){this.openOneAtOnce(c.openOneAtOnce)}if(typeof(c.openAtLoad)!="undefined"){this.openAtLoad(c.openAtLoad)}if(typeof(c.openAfterAdd)!="undefined"){this.openAfterAdd(c.openAfterAdd)}if(typeof(c.showSelectedBranch)!="undefined"){this.showSelectedBranch(c.showSelectedBranch)}if(typeof(c.reopenFromServer)!="undefined"){this.reopenFromServerAfterLoad(c.reopenFromServer)}if(typeof(c.propagateRestriction)!="undefined"){this.propagateRestriction(c.propagateRestriction)}if(c.lineStyle){this.setLineStyle(c.lineStyle)}if(c.behaviourDrop){this.setBehaviourDrop(c.behaviourDrop)}if(c.contextMenu){this.setContextMenu(c.contextMenu)}if(c.bind){for(var d=0;d<c.bind.length;d++){this.bind(c.bind[d])}}if(c.bindAsUnidirectional){for(var d=0;d<c.bindAsUnidirectional.length;d++){this.bind(c.bindAsUnidirectional[d])}}if(c.defaultImg){var e=(c.defaultImgOpen)?c.defaultImgOpen:c.defaultImg;var a=(c.defaultImgClose)?c.defaultImgClose:c.defaultImg;this.setIcons(c.defaultImg,e,a)}if(c.defaultImgSelected||c.defaultImgOpenSelected||c.defaultImgCloseSelected){var b=(c.defaultImgSelected)?c.defaultImgSelected:null;var e=(c.defaultImgOpenSelected)?c.defaultImgOpenSelected:null;var a=(c.defaultImgCloseSelected)?c.defaultImgCloseSelected:null;this.setIconsSelected(b,e,a)}this.serverCookie=(c.serverCookie)?c.serverCookie:false},loadComplete:function(){this._adjustOpening();this._adjustCheck();this.setCookie(this.classTree+this.id);this.loaded=true;if(typeof(this.onLoad)=="function"){this.onLoad()}},loadRunning:function(a){if(typeof(this.onLoading)=="function"){this.onLoading(a)}},replace:function(c,a,d){var b=this.getBranchById(c);if(!b){return false}return b.replace(a,d)},switchBranches:function(b,a){var b=this.getBranchById(b);if(!b){return false}b.switchWith(a)},restoreDefault:function(b){var a=this.defaultStruct;this._restaureDefault(a,b)},_restaureDefault:function(g,f){var a=null;var d=false;var c=0;for(var e=0;e<g.length;e++){a=this.getBranchById(g[e].id);if(a){d=(g[e].open)?true:this.openAll;c=(g[e].check==1)?1:0;switch(f){case"open":if(a.hasChildren()){a.openIt(d)}break;case"check":a.check(c);a._adjustParentCheck();break;case"all":default:if(a.hasChildren()){a.openIt(d)}a.check(c);a._adjustParentCheck()}if(typeof(g[e].items)!="undefined"){this._restaureDefault(g[e].items,f)}}}},bind:function(){var a=this.bind.arguments;for(var b=0;b<a.length;b++){if(!this.isBindedWith(a[b])){this.otherTrees.push(a[b]);if(!a[b].isBindedWith(this)){a[b].bind(this)}}}},bindAsUnidirectional:function(){var a=this.bindAsUnidirectional.arguments;for(var b=0;b<a.length;b++){if(!this.isBindedWith(a[b])){this.otherTrees.push(a[b])}}},isBindedWith:function(c){var b=false;for(var a=0;a<this.otherTrees.length;a++){if(this.otherTrees[a].id==c.id){b=true;break}}return b},unselect:function(){var b=null;for(var a=0;a<this.selectedBranches.length;a++){b=this.selectedBranches[a];Element.removeClassName(b.txt,this.classSelected);if(b.getIconSelected()||b.getOpenIconSelected()||b.getCloseIconSelected()){if(b.hasChildren()){b.img.src=(b.isOpened())?b.tree.imgBase+b.struct.imgopen:b.tree.imgBase+b.struct.imgclose}else{b.img.src=b.tree.imgBase+b.struct.img}}}this.selectedBranches=[]},getBranchesBetween:function(c,a){var c=this.getBranchById(c);var a=this.getBranchById(a);if(!c||!a){return false}if(c.tree.id!=a.tree.id){return false}var g=false;var f=[];var e=c.getWithinOffset();var b=a.getWithinOffset();var d=(e[1]<=b[1])?true:false;branch=(d)?c.getNextBranch():c.getPreviousBranch();while(branch){f.push(branch);if(branch.getId()==a.getId()){g=true;break}branch=(d)?branch.getNextBranch():branch.getPreviousBranch()}return(g)?f:false},countBranches:function(){var a=this.roots.length;for(var b=0;b<this.roots.length;b++){a+=this.roots[b].countBranches()}return a},getBranches:function(c){var a=[];for(var b=0;b<this.roots.length;b++){if(typeof(c)=="function"){if(c(this.roots[b])){a.push(this.roots[b])}}else{a.push(this.roots[b])}a=this.roots[b].getBranches(c,a)}return a},getOpenedBranches:function(){var b=[];for(var a=0;a<this.roots.length;a++){if(this.roots[a].isOpened()&&this.roots[a].hasChildren()){b.push(this.roots[a])}b=this.roots[a].getOpenedBranches(b)}return b},getCheckedBranches:function(){var a=[];for(var b=0;b<this.roots.length;b++){if(this.roots[b].isChecked()==1){a.push(this.roots[b])}a=this.roots[b].getCheckedBranches(a)}return a},getUnCheckedBranches:function(){var b=[];for(var a=0;a<this.roots.length;a++){if(this.roots[a].isChecked()==0){b.push(this.roots[a])}b=this.roots[a].getUnCheckedBranches(b)}return b},getPartCheckedBranches:function(){var b=[];for(var a=0;a<this.roots.length;a++){if(this.roots[a].isChecked()==-1){b.push(this.roots[a])}b=this.roots[a].getPartCheckedBranches(b)}return b},getParentBranches:function(){var a=[];for(var b=0;b<this.roots.length;b++){if(this.roots[b].hasChildren()){a.push(this.roots[b])}a=this.roots[b].getParentBranches(a)}return a},getLeafBranches:function(){var a=[];for(var b=0;b<this.roots.length;b++){if(!this.roots[b].hasChildren()){a.push(this.roots[b])}a=this.roots[b].getLeafBranches(a)}return a},expend:function(){for(var a=0;a<this.roots.length;a++){this.roots[a].expend()}},collapse:function(){for(var a=0;a<this.roots.length;a++){this.roots[a].collapse()}},insertBranch:function(b,d,c,a){var b=this.getBranchById(b);if(!b){return false}if(!c){if(!a){b.insertIntoLast(d)}else{b.insertIntoFirst(d)}}else{if(!a){b.insertAfter(d)}else{b.insertBefore(d)}}},moveBranch:function(b,d,c,a){var b=this.getBranchById(b);if(!b){return false}if(!c){if(!a){b.moveIntoLast(d)}else{b.moveIntoFirst(d)}}else{if(!a){b.moveAfter(d)}else{b.moveBefore(d)}}},removeBranch:function(a){try{var a=this.getBranchById(a);if(!a){return false}if(a.objDrag){a.removeDragDrop()}if(!a.isRoot){a.parent.obj.removeChild(a.obj);a.parent.children.splice(a.pos,1);a.parent.struct.items.splice(a.pos,1);if(a.parent.children.length==0){a.parent.setOpenableIcon(false);if(a.tree.multiline){a._manageMultiline(a.parent.tdImg,2,false)}}a.parent._manageLine()}else{this.div.removeChild(a.obj);this.roots.splice(a.pos,1);if(this.roots[a.pos-1]){this.roots[a.pos-1]._manageAfterRootInsert()}}a=null}catch(b){throw new Error("remove(base) : "+b.message)}},getBranchByIdObj:function(d){try{var c=null;for(var b=0;b<this.roots.length;b++){c=this._getBranchByIdObj(d,this.roots[b]);if(c){break}}return c}catch(a){throw new Error("getBranchByIdObj(func) : "+a.message)}},getBranchById:function(f){try{if(typeof(f)=="object"){return f}var e=null;for(var d=0;d<this.roots.length;d++){e=this._getBranchById(f,this.roots[d]);if(e){break}}if(!e){var c=null;for(var a=0;a<this.otherTrees.length;a++){c=this.otherTrees[a].roots;for(var d=0;d<c.length;d++){e=this.otherTrees[a]._getBranchById(f,c[d]);if(e){break}}if(e){break}}}return e}catch(b){throw new Error("getBranchById(func) : "+b.message)}},debug:function(b){try{this.debugObj.style.display="block";if(typeof(this.onDebug)=="function"){this.onDebug(this,this.debugObj,(b)?b:"")}else{this.debugObj.innerHTML+=b}}catch(a){throw new Error("debug(func) : "+a.message)}},toString:function(){var b={id:this.id,width:this.div.offsetWidth,height:this.div.offsetHeight,imgPath:this.imgBase,roots:this.roots.length};var c="TafelTree {";for(var a in b){c+=TafelTree.debugReturn+TafelTree.debugTab+a+" : "+b[a]}c+=TafelTree.debugReturn+"}";return c},serialize:function(b){var a=(b)?TafelTree.debugReturn:"";var d=(b)?"TafelTree ("+this.id+") [":"[";for(var c=0;c<this.roots.length;c++){d+=this.roots[c].serialize(b,true);if(c<this.roots.length-1){d+=","}}d+=a+((b)?"];":"]");if(b){return d}else{return encodeURIComponent(d)}},getURLParams:function(c){var e=[];if(c.indexOf("?")>-1){var b=c.split("?");var a=b[1].split("&");var f="";for(var d=0;d<a.length;d++){f=a[d].split("=");if(f.length==2){e.push({name:f[0],value:f[1]})}}}return e},_generateBigTree:function(){var b=this.bigTreeLoading;var c=false;var a=false;if(b<this.baseStruct.length){c=(b>0)?true:false;a=(b<this.baseStruct.length-1)?true:false;this.roots[b]=new TafelTreeRoot(this,this.baseStruct[b],0,c,a,b);this.div.appendChild(this.roots[b].obj);this.loadRunning(this.roots[b]);this.bigTreeLoading++;setTimeout(this._generateBigTree.bind(this),10)}else{this.loaded=true}},_checkLoad:function(){var a=true;if(this.loaded){for(var b=0;b<this.roots.length;b++){if(!this.roots[b].loaded||!this._checkLoadChildren(this.roots[b])){a=false;break}}}else{a=false}if(!a){setTimeout(this._checkLoad.bind(this),100)}else{this.loadComplete()}},_checkLoadChildren:function(c){var a=true;if(c.loaded){for(var b=0;b<c.children.length;b++){if(!c.children[b].loaded||!this._checkLoadChildren(c.children[b])){a=false;break}}}else{a=false}return a},_adjustOpening:function(){if(this.useCookie&&this.cookieOpened){var b=null;for(var a=0;a<this.cookieOpened.length;a++){b=this.getBranchById(this.cookieOpened[a]);if(typeof(b)=="object"&&b.hasChildren()){if(b.children.length>0){b.openIt(true)}else{if(typeof(b.struct.onopenpopulate)=="function"&&b.eventable){b._openPopulate();b.openIt(true)}}}}}},_adjustCheck:function(){var b=null;if(this.checkboxes&&this.useCookie&&this.cookieChecked){for(var a=0;a<this.cookieChecked.length;a++){b=this.getBranchById(this.cookieChecked[a]);if(typeof(b)=="object"){b.check(1)}}}if(this.checkboxes&&this.checkboxesThreeState){var c=this.getCheckedBranches();for(var a=0;a<c.length;a++){c[a]._adjustParentCheck()}}},_getBranchByIdObj:function(f,d){try{var a="";if(d.idObj==f){return d}if(typeof(d.children)=="object"){for(var e=0;e<d.children.length;e++){a=this._getBranchByIdObj(f,d.children[e]);if(a){return a}}}return a}catch(b){throw new Error("_getBranchByIdObj(func) : "+b.message)}},_getBranchById:function(f,d){try{var a="";if(d.getId()==f){return d}if(typeof(d.children)=="object"){for(var e=0;e<d.children.length;e++){a=this._getBranchById(f,d.children[e]);if(a){return a}}}return a}catch(b){throw new Error("_getBranchById(func) : "+b.message)}},_changeStruct:function(a){try{while(typeof(a.parent)!="undefined"){a.parent.struct.items.splice(a.pos,1,a.struct);if(typeof(a.parent)!="undefined"){a=a.parent}}}catch(b){throw new Error("_changeStruct(func) : "+b.message)}},_addTree:function(){var a=document.createElement("div");a.className=this.classTree;return a},setCookie:function(b){try{var e="cookieactivate"+this.cookieSeparator;var a=this.getOpenedBranches();for(var c=0;c<a.length;c++){e=e+a[c].getId()+this.cookieSeparator}e+=this.cookieCheckSeparator;var a=this.getCheckedBranches();for(var c=0;c<a.length;c++){e=e+a[c].getId()+this.cookieSeparator}if(!this.serverCookie){this._saveCookie(b,e,"","/","","")}else{if(this.loaded){new Ajax.Request(this.serverCookie,{method:"post",parameters:"type=set&cookieString="+e,onComplete:this._cookieSend.bind(this),onFailure:this._cookieFailure.bind(this)})}}}catch(d){throw new Error("setCookie(func) : "+d.message)}},getCookie:function(c){try{if(!this.serverCookie){if(c!=""){var e=document.cookie.indexOf(c+"=");var a=e+c.length+1;if((!e)&&(c!=document.cookie.substring(0,c.length))){return null}if(e==-1){return null}var b=document.cookie.indexOf(";",a);if(b==-1){b=document.cookie.length}return unescape(document.cookie.substring(a,b))}}else{new Ajax.Request(this.serverCookie,{method:"post",parameters:"type=get",onComplete:this._getCookieComplete.bind(this),onFailure:this._cookieFailure.bind(this)})}return null}catch(d){throw new Error("getCookie(func) : "+d.message)}},_cookieSend:function(a){alert("ok")},_getCookieComplete:function(b){var c=b.responseText;if(c){var a=c.split(this.cookieCheckSeparator);this.cookieOpened=[];this.cookieOpened=a[0].split(this.cookieSeparator);this.cookieOpened.shift();this.cookieChecked=[];if(a.length>1){this.cookieChecked=a[1].split(this.cookieSeparator)}}if(this.options.generate){this.generate()}if(this.options.generateBigTree){this.generate(true)}},_cookieFailure:function(a){},deleteCookie:function(a,d,c){try{if(get_cookie(a)){document.cookie=a+"="+((d)?";path="+d:"")+((c)?";domain="+c:"")+";expires=Thu, 01-Jan-1970 00:00:01 GMT"}}catch(b){throw new Error("deleteCookie(func) : "+b.message)}},_saveCookie:function(b,g,c,i,e,a){try{var f=new Date();f.setTime(f.getTime());if(c){c=c*1000*60*60*24}var h=new Date(f.getTime()+(c));document.cookie=b+"="+escape(g)+((c)?";expires="+h.toGMTString():"")+((i)?";path="+i:"")+((e)?";domain="+e:"")+((a)?";secure":"")}catch(d){throw new Error("_saveCookie(func) : "+d.message)}},setOnLoad:function(func){this.onLoad=eval(func)},setOnLoading:function(func){this.onLoading=eval(func)},setOnOpen:function(func){this.onOpen=eval(func)},setOnBeforeOpen:function(func){this.onBeforeOpen=eval(func)},setOnMouseOver:function(func){this.onMouseOver=eval(func)},setOnMouseOut:function(func){this.onMouseOut=eval(func)},setOnClick:function(func){this.onClick=eval(func)},setOnMouseDown:function(func){this.onMouseDown=eval(func)},setOnMouseUp:function(func){this.onMouseUp=eval(func)},setOnDblClick:function(func){this.onDblClick=eval(func)},setOnEdit:function(func,link){if(link){this.onEditAjax={func:eval(func),link:link}}else{this.onEdit=eval(func)}this.editableBranches=true},setOnBeforeCheck:function(func){this.onBeforeCheck=eval(func)},setOnCheck:function(func){this.onCheck=eval(func)},setOnDrop:function(func){this.onDrop=eval(func)},setOnDropAfter:function(func){this.onErrorAjax=eval(func)},setOnDropAjax:function(func,link){this.onDropAjax={func:eval(func),link:link}},setOnOpenPopulate:function(func,link){this.onOpenPopulate={func:eval(func),link:link}},setOnEditAjax:function(func,link){this.onEditAjax={func:eval(func),link:link};this.editableBranches=true},setOnDragStartEffect:function(func){this.onDragStartEffect=eval(func)},setOnDragEndEffect:function(func){this.onDragEndEffect=eval(func)}};var TafelTreeBaseBranch=Class.create();TafelTreeBaseBranch.prototype={initialize:function(){},getId:function(){return this.struct.id},getText:function(){return this.struct.txt},getLevel:function(){return this.level},getTree:function(){return this.tree},getParent:function(){return(this.isRoot)?null:this.parent},getAncestor:function(){return(this.isRoot)?null:this.root},getParents:function(){var a=[];var b=this;while(b.parent){a.push(b.parent);b=b.parent}return a},getChildren:function(){return this.children},getIcon:function(){return this.struct.img},getOpenIcon:function(){return this.struct.imgopen},getCloseIcon:function(){return this.struct.imgclose},getIconSelected:function(){return this.struct.imgselected},getOpenIconSelected:function(){return this.struct.imgopenselected},getCloseIconSelected:function(){return this.struct.imgcloseselected},getCurrentIcon:function(){var a=this._getImgInfo(this.img);return a.fullName},setText:function(a){this.struct.txt=a;this.txt.innerHTML=a},setIcons:function(b,c,a){this.struct.img=b;this.struct.imgopen=(c)?c:b;this.struct.imgclose=(a)?a:b;if(this.hasChildren()){this.img.src=(this.isOpened())?this.tree.imgBase+this.struct.imgopen:this.tree.imgBase+this.struct.imgclose}else{this.img.src=this.tree.imgBase+this.struct.img}},setIconsSelected:function(b,c,a){this.struct.imgselected=b;this.struct.imgopenselected=(c)?c:null;this.struct.imgcloseselected=(a)?a:null;if(this.isSelected()){if(this.hasChildren()){this.img.src=(this.isOpened())?this.tree.imgBase+this.struct.imgopenselected:this.tree.imgBase+this.struct.imgcloseselected}else{this.img.src=this.tree.imgBase+this.struct.imgselected}}},changeId:function(a){var b=this.tree.getBranchById(a);if(!b){this.struct.id=a;this.tree._changeStruct(this);return true}else{return false}},hasChildren:function(){return(this.struct.items.length>0||this.struct.canhavechildren)?true:false},isOpened:function(){return(this.struct.open)?true:false},isAlwaysLast:function(){return(this.struct.last)?true:false},isOpenedInCookie:function(){if(this.tree.useCookie&&this.tree.cookieOpened){for(var a=0;a<this.tree.cookieOpened.length;a++){if(this.getId()==this.tree.cookieOpened[a]){return true}}}return false},isVisible:function(){var b=true;var a=this;while(a.parent){if(a.parent.isOpened()){a=a.parent}else{b=false;break}}return b},isSelected:function(){return(Element.hasClassName(this.txt,this.tree.classSelected))?true:false},refreshChildren:function(){this.removeChildren();this._openPopulate()},clone:function(withDefaultFunc){var struct={};for(var property in this.struct){if(property!="items"){if(!withDefaultFunc&&typeof(this.struct[property])=="function"){if(!eval("this."+property+"Default")){struct[property]=this.struct[property]}}else{struct[property]=this.struct[property]}}}if(this.hasChildren()){struct.items=[];for(var i=0;i<this.children.length;i++){struct.items.push(this.children[i].clone(withDefaultFunc))}}this.copiedTimes++;struct.id=struct.id+this.tree.copyNameBreak+this.tree.idTree;struct.txt=struct.txt+this.tree.copyName.replace("%n",this.copiedTimes);return struct},getFirstBranch:function(){return(this.children.length>0)?this.children[0]:null},getLastBranch:function(){var a=this.children.length-1;return(a>=0)?this.children[a]:null},getPreviousSibling:function(){var b=this.pos-1;var a=null;if(this.isRoot){if(b>=0){a=this.tree.roots[b]}}else{if(b>=0){a=this.parent.children[b]}}return a},getNextSibling:function(){var b=this.pos+1;var a=null;if(this.isRoot){if(b<this.tree.roots.length){a=this.tree.roots[b]}}else{if(b<this.parent.children.length){a=this.parent.children[b]}}return a},getPreviousBranch:function(){var a=null;var b=this.getPreviousSibling();if(b){if(b.hasChildren()){while(b.hasChildren()){b=b.getLastBranch()}a=b}else{a=b}}else{if(this.parent){a=this.parent}}return a},getNextBranch:function(){var c=null;c=this.getFirstBranch();if(!c){c=this.getNextSibling();if(!c){var a=null;c=this.parent;while(!a&&c){a=c.getNextSibling();c=c.parent}c=a}}return c},getPreviousOpenedBranch:function(){var a=null;var b=this.getPreviousSibling();if(b){if(b.hasChildren()&&b.isOpened()){while(b.hasChildren()&&b.isOpened()){b=b.getLastBranch()}a=b}else{a=b}}else{if(this.parent){a=this.parent}}return a},getNextOpenedBranch:function(){var b=null;if(this.hasChildren()&&this.isOpened()){b=this.getFirstBranch()}else{var a=this;while(!b){b=a.getNextSibling();a=a.parent;if(!a){break}}}return b},removeChildren:function(){var b=this.children.concat();for(var a=0;a<b.length;a++){this.tree.removeBranch(b[a])}},isChild:function(a){var a=this.tree.getBranchById(a);if(!a){return false}return this._isChild(this,a)},openIt:function(a){try{if(!a){this._closeChild();if(this.tree.multiline){this._manageMultiline(this.tdImg,2,false)}}else{if(this.tree.onlyOneOpened){this.closeSiblings()}this._openChild();if(this.tree.multiline){this._manageMultiline(this.tdImg,2,true)}}if(this.tree.useCookie){this.tree.setCookie(this.tree.classTree+this.tree.id)}}catch(b){throw new Error("openIt(base) : "+b.message)}},insert:function(a){return this.insertIntoLast(a)},insertIntoLast:function(b){var c=this.children.length;var a=(this.hasChildren())?true:false;this.children[c]=new TafelTreeBranch((this.isRoot)?this:this.root,this,b,this.level+1,a,false,c);this.struct.items[c]=b;this.obj.appendChild(this.children[c].obj);this._manageAfterInsert(c);return this.children[c]},insertIntoFirst:function(d){var e=0;var b=1;var a=(this.hasChildren())?false:true;this._movePartStruct(e);this.struct.items[e]=d;this.children[e]=new TafelTreeBranch((this.isRoot)?this:this.root,this,d,this.level+1,false,a,e);try{this.obj.insertBefore(this.children[e].obj,this.children[b].obj)}catch(c){this.obj.appendChild(this.children[e].obj)}this._manageAfterInsert(e);return this.children[e]},closeSiblings:function(){var b=null;if(this.parent){for(var a=0;a<this.parent.children.length;a++){b=this.parent.children[a];if(b.idObj!=this.idObj&&b.hasChildren()){b.openIt(false)}}}else{if(this.isRoot){for(var a=0;a<this.tree.roots.length;a++){b=this.tree.roots[a];if(b.idObj!=this.idObj&&b.hasChildren()){b.openIt(false)}}}}},addClass:function(a){Element.addClassName(this.txt,a)},removeClass:function(a){Element.removeClassName(this.txt,a)},getImgBeforeIcon:function(){try{var a=this.beforeIcon.getElementsByTagName("img")[0];return this._getImgInfo(a)}catch(b){throw new Error("getImgBeforeIcon(base) : "+b.message)}},setOpenableIcon:function(c){var a=this.getImgBeforeIcon();var b=a.img;if(c){this.struct.open=true;this.img.src=this.tree.imgBase+this.struct.imgopen;if(!this.isRoot){b.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgMinus3:this.tree.imgBase+this.tree.imgMinus2}else{if(this.hasSiblingsBefore){b.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgMinus3:this.tree.imgBase+this.tree.imgMinus2}else{b.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgMinus4:this.tree.imgBase+this.tree.imgMinus5}}Event.observe(b,"click",this.setOpen.bindAsEventListener(this),false);Event.observe(b,"mouseover",this.evt_openMouseOver.bindAsEventListener(this),false);Event.observe(b,"mouseout",this.evt_openMouseOut.bindAsEventListener(this),false)}else{this.struct.open=false;this.struct.canhavechildren=false;this.img.src=this.tree.imgBase+this.struct.img;var e=b.parentNode;var d=document.createElement("img");e.removeChild(b);if(!this.isRoot){d.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgLine3:this.tree.imgBase+this.tree.imgLine2}else{if(this.hasSiblingsBefore){d.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgLine3:this.tree.imgBase+this.tree.imgLine2}else{d.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgLine4:this.tree.imgBase+this.tree.imgLine5}}e.appendChild(d)}},toString:function(){var c=(this.isRoot)?"TafelTreeRoot {":"TafelTreeBranch {";var b="";for(var a in this.struct){if(a!="items"){b=(typeof(this.struct[a])!="function")?this.struct[a]:true;c+=TafelTree.debugReturn+TafelTree.debugTab+a+" : "+b}}c+=TafelTree.debugReturn+TafelTree.debugTab+"children : "+this.children.length;c+=TafelTree.debugReturn+"}";return c},isChecked:function(a){if(this.tree.checkboxes&&this.checkbox){var b=this._getImgInfo(this.checkbox);if(b.fullName.replace("_over","")==this.tree.imgCheck2){return 1}if(b.fullName.replace("_over","")==this.tree.imgCheck3){return -1}return 0}return 0},getCheckbox:function(){return(this.checkbox)?this.checkbox:false},check:function(a){if(this.checkbox){if(a==-1){this.checkbox.src=this.tree.imgBase+this.tree.imgCheck3;this.struct.check=-1}else{if(a){this.checkbox.src=this.tree.imgBase+this.tree.imgCheck2;this.struct.check=1;if(this.tree.useCookie){this.tree.setCookie(this.tree.classTree+this.tree.id)}}else{this.checkbox.src=this.tree.imgBase+this.tree.imgCheck1;this.struct.check=0;if(this.tree.useCookie){this.tree.setCookie(this.tree.classTree+this.tree.id)}}}}},hasAllChildrenChecked:function(){var a=false;var c=false;for(var b=0;b<this.children.length;b++){if(this.children[b].isChecked()==-1){a=true;c=true;break}if(this.children[b].isChecked()==1){a=true}else{c=true}}if(a&&c){return -1}if(a){return 1}else{return 0}},switchWith:function(b){var j=this.tree.getBranchById(b);if(!j){return false}var c=this.copiedTimes;var d=this.clone();var k=this.getText();var i=this.getId();var h=j.copiedTimes;var l=j.clone();var e=j.getText();var a=j.getId();this.changeId("temp_switch_change_"+this.tree.idTree);var g=j.insertBefore(d);this.tree.removeBranch(j);g.setText(k);g.changeId(i);g.copiedTimes=c;var f=this.insertBefore(l);this.tree.removeBranch(this);f.setText(e);f.changeId(a);f.copiedTimes=copyBranch},replace:function(d,g){var c=this.tree.getBranchById(d);if(!c){return false}var f=this.copiedTimes;var e=this.clone();var b=c.insertBefore(e);this.tree.removeBranch(c);if(!g){var a=this.getId();b.setText(this.getText());this.tree.removeBranch(this);b.changeId(a);b.copiedTimes=f}return b},expend:function(){if(this.isOpened()!=true&&this.hasChildren()){this.openIt(true)}for(var a=0;a<this.children.length;a++){this.children[a].expend()}},collapse:function(){if(this.isOpened()!=false&&this.hasChildren()){this.openIt(false)}for(var a=0;a<this.children.length;a++){this.children[a].collapse()}},getBranches:function(c,a){if(!a){a=[]}for(var b=0;b<this.children.length;b++){if(typeof(c)=="function"){if(c(this.children[b])){a.push(this.children[b])}}else{a.push(this.children[b])}a=this.children[b].getBranches(c,a)}return a},getParentBranches:function(a){if(!a){a=[]}for(var b=0;b<this.children.length;b++){if(this.children[b].hasChildren()){a.push(this.children[b])}a=this.children[b].getParentBranches(a)}return a},getLeafBranches:function(a){if(!a){a=[]}for(var b=0;b<this.children.length;b++){if(!this.children[b].hasChildren()){a.push(this.children[b])}a=this.children[b].getLeafBranches(a)}return a},countBranches:function(){var a=this.children.length;for(var b=0;b<this.children.length;b++){a+=this.children[b].countBranches()}return a},getOpenedBranches:function(b){if(!b){b=[]}for(var a=0;a<this.children.length;a++){if(this.children[a].isOpened()&&this.children[a].hasChildren()){b.push(this.children[a])}b=this.children[a].getOpenedBranches(b)}return b},getCheckedBranches:function(a){return this._getCheckedBranches(a,1)},getUnCheckedBranches:function(a){return this._getCheckedBranches(a,0)},getPartCheckedBranches:function(a){return this._getCheckedBranches(a,-1)},select:function(d){var f=(d)?TafelTreeManager.ctrlOn(d):false;var a=(d)?TafelTreeManager.shiftOn(d):false;if(f){this.tree.selectedBranches.push(this)}else{if(a&&this.tree.selectedBranches.length>0){var c=this.tree.selectedBranches.length-1;var e=this.tree.getBranchesBetween(this.tree.selectedBranches[c],this);for(var b=0;b<e.length;b++){this.tree.selectedBranches.push(e[b]);Element.addClassName(e[b].txt,this.tree.classSelected)}}else{this.tree.unselect();this.tree.selectedBranches.push(this)}}Element.addClassName(this.txt,this.tree.classSelected);if(this.isOpened()&&this.hasChildren()&&this.getOpenIconSelected()){this.img.src=this.tree.imgBase+this.getOpenIconSelected()}else{if(!this.isOpened()&&this.hasChildren()&&this.getCloseIconSelected()){this.img.src=this.tree.imgBase+this.getCloseIconSelected()}else{if(!this.hasChildren()&&this.getIconSelected()){this.img.src=this.tree.imgBase+this.getIconSelected()}}}if(d){Event.stop(d)}},unselect:function(){var b=this.tree.selectedBranches.length;if(b>0){for(var a=0;a<b;a++){if(this.tree.selectedBranches[a].getId()==this.getId()){this.tree.selectedBranches.splice(a,1);Element.removeClassName(this.txt,this.tree.classSelected);if(this.hasChildren()){this.img.src=(this.isOpened())?this.tree.imgBase+this.struct.imgopen:this.tree.imgBase+this.struct.imgclose}else{this.img.src=this.tree.imgBase+this.struct.img}return true}}}return false},getWithinOffset:function(){var b=Position.positionedOffset(this.txt);var a=Position.positionedOffset(this.tree.div);var c=[b[0]-a[0],b[1]-a[1]];return c},getAbsoluteOffset:function(){return Position.positionedOffset(this.txt)},serialize:function(d,b){var f="";var c="";if(d){c=TafelTree.debugReturn;for(var e=0;e<this.level;e++){f+=TafelTree.debugTab}}var g="";var h=c+f+"{"+c;h+=f+'"id":"'+this._encode(this.struct.id)+'"';for(var a in this.struct){if(a!="items"&&a!="id"){g=(typeof(this.struct[a])!="function")?this.struct[a]:true;if(this.isBool(g)){h+=","+c+f+'"'+a+'":'+this._encode(g)}else{h+=","+c+f+'"'+a+'":"'+this._encode(g)+'"'}}}if(this.hasChildren()){h+=","+c+f+'"items":[';for(var e=0;e<this.children.length;e++){h+=this.children[e].serialize(d,true);if(e<this.children.length-1){h+=","}}h+=c+f+"]"}h+=c+f+"}";if(!b){return encodeURIComponent(h)}else{return h}},isBool:function(a){switch(a){case"true":case"false":case true:case false:case"1":case"0":case 1:case 0:return true;default:return false}},showTooltip:function(){if(this.displayTooltip){this.tooltip.style.display="block"}},hideTooltip:function(){if(!this.displayTooltip){Element.hide(this.tooltip)}},removeDragDrop:function(){if(this.objDrag){this.objDrag.destroy()}Droppables.remove(this.txt);for(var a=0;a<this.children.length;a++){this.children[a].removeDragDrop()}},_manageMultiline:function(a,b,c){switch(b){case 2:if(!c){Element.removeClassName(a,this.tree.imgMulti4);a.style.background="none"}else{Element.addClassName(a,this.tree.imgMulti4);a.style.background='url("'+this.tree.imgBase+this.tree.imgMulti2+'")';a.style.backgroundRepeat="repeat-y"}break;case 1:default:if(!c){Element.removeClassName(a,this.tree.imgMulti3);a.style.background="none"}else{Element.addClassName(a,this.tree.imgMulti3);a.style.background='url("'+this.tree.imgBase+this.tree.imgMulti1+'")';a.style.backgroundRepeat="repeat-y"}}},_createTooltip:function(){var a=document.createElement("div");a.className=this.tree.classTooltip;a.innerHTML=(this.struct.tooltip)?this.struct.tooltip:"&nbsp;";Event.observe(a,"mouseover",this.showTooltip.bindAsEventListener(this),false);return a},_manageAfterInsert:function(a){this.tree._changeStruct(this);this._manageLine();if(this.tree.checkboxes&&this.tree.checkboxesThreeState){this.children[a]._adjustParentCheck()}if(this.children.length==1&&!this.struct.canhavechildren){this.setOpenableIcon(true)}this.openIt((!this.tree.openedAfterAdd&&!this.isOpened())?false:true)},_movePartStruct:function(d){var a=this.struct.items.length-1;var c=0;for(var b=a;b>=d;b--){c=b+1;this.struct.items[c]=this.struct.items[b];this.children[c]=this.children[b];this.children[c].pos=c}},_getCheckedBranches:function(a,c){if(!a){a=[]}for(var b=0;b<this.children.length;b++){if(this.children[b].isChecked()==c){a.push(this.children[b])}a=this.children[b]._getCheckedBranches(a,c)}return a},_generate:function(){var a=this.bigTreeLoading;if(a<this.struct.items.length){if(this.tree.checkboxesThreeState&&this.struct.check&&typeof(this.struct.items[a].check)=="undefined"){this.struct.items[a].check=1}isNotFirst=(a>0)?true:false;isNotLast=(a<this.struct.items.length-1)?true:false;this.children[a]=new TafelTreeBranch((this.isRoot)?this:this.root,this,this.struct.items[a],this.level+1,isNotFirst,isNotLast,a);this.obj.appendChild(this.children[a].obj);this.openIt((this.tree.useCookie)?this.isOpenedInCookie:this.struct.open);this.tree.loadRunning(this.children[a]);this.bigTreeLoading++;setTimeout(this._generate.bind(this),10)}else{this.loaded=true}},_getPos:function(){pos=this.children.length;for(var a=0;a<this.children.length;a++){if(this.children[a].isAlwaysLast()){pos--}}if(pos<0){pos=0}return pos},_adjustParentCheck:function(b){if(this.parent){var a=(!b)?this.parent:this;while(a&&a.checkbox){a.check(a.hasAllChildrenChecked());a=a.parent}}},_manageCheckThreeState:function(b,c){for(var a=0;a<b.children.length;a++){if(b.tree.checkboxes&&b.children[a].checkbox){b.children[a].check(c);b._manageCheckThreeState(b.children[a],c)}}},_getImgInfo:function(a){var c=a.src.split("/");var b=c[c.length-1].split(".");var d={img:a,number:b[0].charAt(b[0].length-1),type:b[0].substr(0,b[0].length-1),name:b[0],fullName:c[c.length-1]};return d},_encode:function(b){var a=(b===null)?"":b;return a.toString().replace(/\"/g,'\\"')},_closeChild:function(a){try{a=this.getImgBeforeIcon().img;this.struct.open=false;if(this.isSelected()&&this.getCloseIconSelected()){this.img.src=this.tree.imgBase+this.getCloseIconSelected()}else{this.img.src=this.tree.imgBase+this.struct.imgclose}for(var b=0;b<this.obj.childNodes.length;b++){if(this.obj.childNodes[b].nodeName.toLowerCase()=="div"){Element.hide(this.obj.childNodes[b])}}if(!this.isRoot){a.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgPlus3:this.tree.imgBase+this.tree.imgPlus2}else{if(this.hasSiblingsBefore){a.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgPlus3:this.tree.imgBase+this.tree.imgPlus2}else{a.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgPlus4:this.tree.imgBase+this.tree.imgPlus5}}}catch(c){throw new Error("_closeChild(base) : "+c.message)}},_openChild:function(a){try{a=this.getImgBeforeIcon().img;this.struct.open=true;if(this.isSelected()&&this.getOpenIconSelected()){this.img.src=this.tree.imgBase+this.getOpenIconSelected()}else{this.img.src=this.tree.imgBase+this.struct.imgopen}for(var b=0;b<this.obj.childNodes.length;b++){if(this.obj.childNodes[b].nodeName.toLowerCase()=="div"){this.obj.childNodes[b].style.display=""}}if(!this.isRoot){a.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgMinus3:this.tree.imgBase+this.tree.imgMinus2}else{if(this.hasSiblingsBefore){a.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgMinus3:this.tree.imgBase+this.tree.imgMinus2}else{a.src=(this.hasSiblingsAfter)?this.tree.imgBase+this.tree.imgMinus4:this.tree.imgBase+this.tree.imgMinus5}}}catch(c){throw new Error("_openChild(base) : "+c.message)}},_manageLine:function(){try{for(var a=0;a<this.children.length;a++){this.children[a].pos=a;if(a==this.children.length-1&&this.children[a].hasSiblingsAfter){this.children[a].hasSiblingsAfter=false;this._manageMultiline(this.children[a].beforeIcon,1,false);this._clearLine(this.children[a],this.level)}if(a<this.children.length-1&&!this.children[a].hasSiblingsAfter){this.children[a].hasSiblingsAfter=true;this._manageMultiline(this.children[a].beforeIcon,1,true);this._addLine(this.children[a],this.level)}}this.tree._changeStruct(this)}catch(b){throw new Error("_manageLine(base) : "+b.message)}},_manageLineForRoot:function(c){for(var b=0;b<this.children.length;b++){this.children[b]._manageLineForRoot(c)}var d=this.table.getElementsByTagName("td")[0];var a=d.getElementsByTagName("img")[0];if(c){a.src=this.tree.imgBase+this.tree.imgLine1}else{a.src=this.tree.imgBase+this.tree.imgEmpty}},_clearLine:function(f,g,d){try{for(var c=0;c<f.children.length;c++){this._clearLine(f.children[c],g,true)}var b=f.table.getElementsByTagName("img")[g+1];if(d){b.src=this.tree.imgBase+this.tree.imgEmpty;if(this.tree.multiline){this._manageMultiline(b.parentNode,1,false)}}else{var a=f.getImgBeforeIcon();switch(a.fullName.replace("_over","")){case this.tree.imgLine1:case this.tree.imgLine3:newImg=this.tree.imgLine2;break;case this.tree.imgPlus1:case this.tree.imgPlus3:newImg=this.tree.imgPlus2;break;case this.tree.imgMinus1:case this.tree.imgMinus3:newImg=this.tree.imgMinus2;break;default:newImg=f.fullName}b.src=this.tree.imgBase+newImg}}catch(e){throw new Error("_clearLine(base) : "+e.message)}},_addLine:function(f,g,d){try{for(var c=0;c<f.children.length;c++){this._addLine(f.children[c],g,true)}var b=f.table.getElementsByTagName("img")[g+1];if(d){b.src=this.tree.imgBase+this.tree.imgLine1;if(this.tree.multiline){this._manageMultiline(b.parentNode,1,true)}}else{var a=f.getImgBeforeIcon();switch(a.fullName.replace("_over","")){case this.tree.imgLine1:case this.tree.imgLine2:newImg=this.tree.imgLine3;break;case this.tree.imgPlus1:case this.tree.imgPlus2:newImg=this.tree.imgPlus3;break;case this.tree.imgMinus1:case this.tree.imgMinus2:newImg=this.tree.imgMinus3;break;default:newImg=f.fullName}b.src=this.tree.imgBase+newImg}}catch(e){throw new Error("_addLine(base) : "+e.message)}},_isChild:function(c,a){try{if(a.idObj==c.idObj){return true}if(c.parent){return this._isChild(c.parent,a)}return false}catch(b){throw new Error("_isChild(base) : "+b.message)}},_setProperties:function(){if((typeof(this.struct.img)=="undefined")){this.struct.img=(this.tree.icons[0])?this.tree.icons[0]:this.tree.imgLine0}if((typeof(this.struct.imgopen)=="undefined")){this.struct.imgopen=(this.tree.icons[1])?this.tree.icons[1]:this.struct.img}if((typeof(this.struct.imgclose)=="undefined")){this.struct.imgclose=(this.tree.icons[2])?this.tree.icons[2]:this.struct.img}if((typeof(this.struct.imgselected)=="undefined")){this.struct.imgselected=(this.tree.iconsSelected[0])?this.tree.iconsSelected[0]:null}if((typeof(this.struct.imgopenselected)=="undefined")){this.struct.imgopenselected=(this.tree.iconsSelected[1])?this.tree.iconsSelected[1]:null}if((typeof(this.struct.imgcloseselected)=="undefined")){this.struct.imgcloseselected=(this.tree.iconsSelected[2])?this.tree.iconsSelected[2]:null}if(typeof(this.struct.open)=="undefined"){this.struct.open=(this.tree.useCookie&&this.tree.cookieOpened)?false:this.tree.openAll}else{if(this.tree.useCookie&&this.tree.cookieOpened){this.struct.open=false}}if(typeof(this.struct.check)=="undefined"||(this.tree.useCookie&&this.tree.cookieChecked)){this.struct.check=0}if(typeof(this.struct.items)=="undefined"){this.struct.items=[]}if(typeof(this.struct.canhavechildren)=="undefined"){this.struct.canhavechildren=false}if(typeof(this.struct.id)=="undefined"){this.struct.id=this.idObj}if(typeof(this.struct.acceptdrop)=="undefined"){this.struct.acceptdrop=true}if(typeof(this.struct.last)=="undefined"){this.struct.last=false}if(typeof(this.struct.editable)=="undefined"){this.struct.editable=this.tree.editableBranches}if(typeof(this.struct.checkbox)=="undefined"){this.struct.checkbox=true}},_setFunctions:function(){if(typeof(this.struct.ondragstarteffect)=="undefined"){if(typeof(this.tree.onDragStartEffect)=="function"){this.struct.ondragstarteffect=this.tree.onDragStartEffect;this.ondragstarteffectDefault=true}}else{this.struct.ondragstarteffect=eval(this.struct.ondragstarteffect)}if(typeof(this.struct.ondragendeffect)=="undefined"){if(typeof(this.tree.onDragEndEffect)=="function"){this.struct.ondragendeffect=this.tree.onDragEndEffect;this.ondragendeffectDefault=true}}else{this.struct.ondragendeffect=eval(this.struct.ondragendeffect)}if(typeof(this.struct.onerrorajax)=="undefined"){if(typeof(this.tree.onErrorAjax)=="function"){this.struct.onerrorajax=this.tree.onErrorAjax;this.onerrorajaxDefault=true}}else{this.struct.onerrorajax=eval(this.struct.onerrorajax)}if(typeof(this.struct.oneditajax)=="undefined"){if(this.tree.onEditAjax&&typeof(this.tree.onEditAjax.func)=="function"){this.struct.oneditajax=this.tree.onEditAjax.func;this.struct.editlink=this.tree.onEditAjax.link;this.oneditajaxDefault=true}}else{this.struct.oneditajax=eval(this.struct.oneditajax)}if(typeof(this.struct.onopenpopulate)=="undefined"){if(this.tree.onOpenPopulate&&typeof(this.tree.onOpenPopulate.func)=="function"){this.struct.onopenpopulate=this.tree.onOpenPopulate.func;this.struct.openlink=this.tree.onOpenPopulate.link;this.onopenpopulateDefault=true}}else{this.struct.onopenpopulate=eval(this.struct.onopenpopulate)}if(typeof(this.struct.onedit)=="undefined"){if(typeof(this.tree.onEdit)=="function"){this.struct.onedit=this.tree.onEdit;this.oneditDefault=true}}else{this.struct.onedit=eval(this.struct.onedit)}if(typeof(this.struct.oncheck)=="undefined"){if(typeof(this.tree.onCheck)=="function"){this.struct.oncheck=this.tree.onCheck;this.oncheckDefault=true}}else{this.struct.oncheck=eval(this.struct.oncheck)}if(typeof(this.struct.onbeforecheck)=="undefined"){if(typeof(this.tree.onBeforeCheck)=="function"){this.struct.onbeforecheck=this.tree.onBeforeCheck;this.onbeforecheckDefault=true}}else{this.struct.onbeforecheck=eval(this.struct.onbeforecheck)}if(typeof(this.struct.onopen)=="undefined"){if(typeof(this.tree.onOpen)=="function"){this.struct.onopen=this.tree.onOpen;this.onopenDefault=true}}else{this.struct.onopen=eval(this.struct.onopen)}if(typeof(this.struct.onbeforeopen)=="undefined"){if(typeof(this.tree.onBeforeOpen)=="function"){this.struct.onbeforeopen=this.tree.onBeforeOpen;this.onbeforeopenDefault=true}}else{this.struct.onbeforeopen=eval(this.struct.onbeforeopen)}if(typeof(this.struct.onmouseover)=="undefined"){if(typeof(this.tree.onMouseOver)=="function"){this.struct.onmouseover=this.tree.onMouseOver;this.onmouseoverDefault=true}}else{this.struct.onmouseover=eval(this.struct.onmouseover)}if(typeof(this.struct.onmouseout)=="undefined"){if(typeof(this.tree.onMouseOut)=="function"){this.struct.onmouseout=this.tree.onMouseOut;this.onmouseoutDefault=true}}else{this.struct.onmouseout=eval(this.struct.onmouseout)}if(typeof(this.struct.onmousedown)=="undefined"){if(typeof(this.tree.onMouseDown)=="function"){this.struct.onmousedown=this.tree.onMouseDown;this.onmousedownDefault=true}}else{this.struct.onmousedown=eval(this.struct.onmousedown)}if(typeof(this.struct.onmouseup)=="undefined"){if(typeof(this.tree.onMouseUp)=="function"){this.struct.onmouseup=this.tree.onMouseUp;this.onmouseupDefault=true}}else{this.struct.onmouseup=eval(this.struct.onmouseup)}if(typeof(this.struct.onclick)=="undefined"){if(typeof(this.tree.onClick)=="function"){this.struct.onclick=this.tree.onClick;this.onclickDefault=true}}else{this.struct.onclick=eval(this.struct.onclick)}if(typeof(this.struct.ondblclick)=="undefined"){if(typeof(this.tree.onDblClick)=="function"){this.struct.ondblclick=this.tree.onDblClick;this.ondblclickDefault=true}}else{this.struct.ondblclick=eval(this.struct.ondblclick)}},_setActions:function(){if(this.struct.select){this.select()}},_setEvents:function(b,c){Event.observe(this.txt,"mousedown",this.setMouseDown.bindAsEventListener(this),false);Event.observe(this.txt,"mouseup",this.setMouseUp.bindAsEventListener(this),false);if(typeof(this.struct.onclick)=="function"){Event.observe(b,"click",this.setClick.bindAsEventListener(this),false)}if(typeof(this.struct.ondblclick)=="function"||this.struct.editable){Event.observe(b,"dblclick",this.setDblClick.bindAsEventListener(this),false)}if(typeof(this.struct.onmouseover)=="function"){Event.observe(b,"mouseover",this.setMouseOver.bindAsEventListener(this),false)}if(typeof(this.struct.onmouseout)=="function"){Event.observe(b,"mouseout",this.setMouseOut.bindAsEventListener(this),false)}if(this.struct.editable&&(typeof(this.struct.onedit)=="function"||typeof(this.struct.oneditajax)=="function")){this.editableInput=document.createElement("input");this.editableInput.setAttribute("type","text");this.editableInput.setAttribute("autocomplete","off");this.editableInput.className=this.tree.classEditable;b.appendChild(this.editableInput);Event.observe(this.editableInput,"blur",this.hideEditable.bindAsEventListener(this),false)}if(!this.isRoot){if(this.struct.draggable&&(typeof(this.struct.ondrop)=="function"||typeof(this.struct.ondropajax)=="function")){this.objDrag=new Draggable(this.txt,{revert:this.tree.dragRevert,starteffect:this.ondragstarteffect.bindAsEventListener(this),endeffect:this.ondragendeffect.bindAsEventListener(this)});Element.addClassName(this.txt,this.tree.classDrag)}}if(this.struct.acceptdrop){Droppables.add(this.txt,{hoverclass:this.tree.classDragOver,onDrop:this.setDrop.bindAsEventListener(this)})}if(this.struct.tooltip){Event.observe(b,"mouseover",this.evt_showTooltip.bindAsEventListener(this),false);Event.observe(b,"mouseout",this.evt_hideTooltip.bindAsEventListener(this),false)}if(this.tree.checkboxes&&this.struct.checkbox){if(this.struct.check==1){imgc=this.tree.imgCheck2}else{if(this.struct.check==-1){imgc=this.tree.imgCheck3}else{imgc=this.tree.imgCheck1}}this.checkbox=document.createElement("img");this.checkbox.src=this.tree.imgBase+imgc;c.appendChild(this.checkbox);Event.observe(this.checkbox,"click",this.checkOnClick.bindAsEventListener(this),false);Event.observe(this.checkbox,"mouseover",this.evt_openMouseOver.bindAsEventListener(this),false);Event.observe(this.checkbox,"mouseout",this.evt_openMouseOut.bindAsEventListener(this),false)}else{if(this.tree.checkboxes){var a=document.createElement("img");a.src=this.tree.imgBase+this.tree.imgEmpty;c.appendChild(a)}}},_getImgBeforeIcon:function(){try{var c=document.createElement("td");var a=document.createElement("img");Element.addClassName(a,this.tree.classOpenable);if(this.hasSiblingsAfter){if(!this.hasChildren()){if(this.isRoot){a.src=this.tree.imgBase+((this.hasSiblingsBefore)?this.tree.imgLine3:this.tree.imgLine4)}else{a.src=this.tree.imgBase+this.tree.imgLine3}}else{Event.observe(a,"click",this.setOpen.bindAsEventListener(this),false);Event.observe(a,"mouseover",this.evt_openMouseOver.bindAsEventListener(this),false);Event.observe(a,"mouseout",this.evt_openMouseOut.bindAsEventListener(this),false);if(this.isRoot){a.src=this.tree.imgBase+((this.hasSiblingsBefore)?this.tree.imgMinus3:this.tree.imgMinus4)}else{a.src=this.tree.imgBase+this.tree.imgMinus3}}if(this.tree.multiline){this._manageMultiline(c,(this.isRoot?2:1),true)}}else{if(!this.hasChildren()){if(this.isRoot){a.src=this.tree.imgBase+((this.hasSiblingsBefore)?this.tree.imgLine2:this.tree.imgEmpty)}else{a.src=this.tree.imgBase+this.tree.imgLine2}}else{Event.observe(a,"click",this.setOpen.bindAsEventListener(this),false);Event.observe(a,"mouseover",this.evt_openMouseOver.bindAsEventListener(this),false);Event.observe(a,"mouseout",this.evt_openMouseOut.bindAsEventListener(this),false);if(this.isRoot){a.src=this.tree.imgBase+((this.hasSiblingsBefore)?this.tree.imgMinus2:this.tree.imgMinus5)}else{a.src=this.tree.imgBase+this.tree.imgMinus2}}}c.appendChild(a);return c}catch(b){throw new Error("_getImgBeforeIcon(base) : "+b.message)}},_setChildren:function(a){if(this.hasChildren()){if(this.tree.bigTreeLoading>=0){this.loaded=false;this.bigTreeLoading=0;setTimeout(this._generate.bind(this),10)}else{for(var b=0;b<this.struct.items.length;b++){if(this.tree.checkboxesThreeState&&this.struct.check&&typeof(this.struct.items[b].check)=="undefined"){this.struct.items[b].check=1}isNotFirst=(b>0)?true:false;isNotLast=(b<this.struct.items.length-1)?true:false;this.children[b]=new TafelTreeBranch(a,this,this.struct.items[b],this.level+1,isNotFirst,isNotLast,b);this.obj.appendChild(this.children[b].obj)}this.openIt(this.struct.open)}}},_setWaitImg:function(b,d,e){try{this.inProcess=d;if(d){b.oldImgSrc=b.img.src;b.img.src=b.tree.imgBase+b.tree.imgWait;b.eventable=false}else{b.eventable=true;b.img.src=b.oldImgSrc}if(this.tree.propagation&&!e){for(var a=0;a<b.children.length;a++){this._setWaitImg(b.children[a],d)}}}catch(c){throw new Error("_setWaitImg(base) : "+c.message)}},_openPopulate:function(d){try{this._setWaitImg(this,true);var e="branch="+this.serialize()+"&branch_id="+this.getId()+"&tree_id="+this.tree.id;var a=this.tree.getURLParams(this.struct.openlink);for(var b=0;b<a.length;b++){e+="&"+a[b].name+"="+a[b].value}new Ajax.Updater(this.tree.ajaxObj,this.struct.openlink,{method:"post",parameters:e,evalScripts:true,onComplete:function(f){this._completeOpenPopulate(f)}.bind(this),onFailure:function(f){this._failureOpenPopulate(f)}.bind(this)})}catch(c){this._setWaitImg(this,false);throw ("_openPopulate(base) : "+c.message)}},_failureOpenPopulate:function(){this._setWaitImg(this,false);if(typeof(this.struct.onerrorajax)=="function"){this.struct.onerrorajax("open","failure request",this)}},_completeOpenPopulate:function(response){try{this._setWaitImg(this,false);var rep=this.struct.onopenpopulate(this,response.responseText);if(rep){rep=(rep===true)?response.responseText:rep;var items=eval(rep);if(items){var ok=[];for(var i=0;i<items.length;i++){if(this.tree.getBranchById(items[i].id)){continue}if(typeof(items[i].id)=="undefined"||typeof(items[i].txt)=="undefined"){throw new Error(TAFELTREE_WRONG_BRANCH_STRUCTURE)}ok.push(this.insertIntoLast(items[i]))}if(this.tree.useCookie&&this.tree.cookieOpened&&this.tree.reopenFromServer){var okay=false;for(var o=0;o<ok.length;o++){okay=false;for(var i=0;i<this.tree.cookieOpened.length;i++){if(this.tree.cookieOpened[i]==ok[o].getId()){okay=true;break}}if(okay){if(typeof(ok[o].struct.onopenpopulate)=="function"&&ok[o].eventable){ok[o]._openPopulate();ok[o].openIt(true)}}}}}}}catch(err){this._setWaitImg(this,false);if(typeof(this.struct.onerrorajax)=="function"){this.struct.onerrorajax("open",response.responseText,this)}else{alert("_completeOpenPopulate("+response.responseText+") : "+err.message)}}},_setDropAjax:function(d,l,e,f){try{this._setWaitImg(this,true);var h=(l)?1:0;var j=(e)?1:0;var b="drag="+this.serialize()+"&drag_id="+this.getId()+"&drop="+d.serialize()+"&drop_id="+d.getId();b+="&treedrag_id="+this.tree.id+"&treedrop_id="+d.tree.id+"&sibling="+h+"&copydrag="+j;if(j){var g=this.id+this.tree.copyNameBreak+this.tree.idTree;b+="&copydrag_id="+g}var k=this.tree.getURLParams(this.struct.droplink);for(var c=0;c<k.length;c++){b+="&"+k[c].name+"="+k[c].value}this.newParent=d;this.asSibling=l;this.copyDrag=j;new Ajax.Updater(this.tree.ajaxObj,this.struct.droplink,{method:"post",parameters:b,evalScripts:true,onComplete:function(i){this._completeDropAjax(i)}.bind(this),onFailure:function(i){this._failureDropAjax(i)}.bind(this)})}catch(a){this._setWaitImg(this,false);throw ("_setDropAjax(base) : "+a.message)}},_failureDropAjax:function(){this._setWaitImg(this,false);if(typeof(this.struct.onerrorajax)=="function"){this.struct.onerrorajax("drop","failure request",this,this.newParent)}},_completeDropAjax:function(a){try{if(this.struct.ondropajax(this,this.newParent,a.responseText,false,null)){var c=null;if(!this.asSibling){if(!this.copyDrag){this.move(this.newParent)}else{c=this.newParent.insertIntoLast(this.clone())}}else{if(!this.copyDrag){this.moveBefore(this.newParent)}else{c=this.newParent.insertBefore(this.clone())}}this.struct.ondropajax(this,this.newParent,a.responseText,true,c)}this._setWaitImg(this,false)}catch(b){if(typeof(this.struct.onerrorajax)=="function"){this.struct.onerrorajax("drop",a.responseText,this,this.newParent)}else{alert("_completeDropAjax(base) : "+b.message)}}},_editAjax:function(f,b,e){try{this._setWaitImg(this,true,true);var g="branch="+this.serialize()+"&branch_id="+this.getId()+"&tree_id="+this.tree.id;g+="&new_value="+f+"&old_value="+b;var a=this.tree.getURLParams(this.struct.editlink);for(var c=0;c<a.length;c++){g+="&"+a[c].name+"="+a[c].value}new Ajax.Updater(this.tree.ajaxObj,this.struct.editlink,{method:"post",parameters:g,evalScripts:true,onComplete:function(h){this._completeEditAjax(h)}.bind(this),onFailure:function(h){this._failureEditAjax(h)}.bind(this)})}catch(d){this._setWaitImg(this,false,true);throw ("_editAjax(base) : "+d.message)}},_failureEditAjax:function(){this._setWaitImg(this,false);if(typeof(this.struct.onerrorajax)=="function"){this.struct.onerrorajax("edit","failure request",this)}},_completeEditAjax:function(a){try{this._setWaitImg(this,false,true);var c=this.struct.oneditajax(this,a.responseText,this.txt.innerHTML);if(c){this.setText((c===true?a.responseText:c))}this.hideEditableElement()}catch(b){this._setWaitImg(this,false,true);if(typeof(this.struct.onerrorajax)=="function"){this.struct.onerrorajax("edit",a.responseText,this)}else{alert("_completeOpenPopulate("+a.responseText+") : "+b.message)}}},evt_openMouseOver:function(b){if(Event.element){var c=Event.element(b);var a=this._getImgInfo(c);c.src=this.tree.imgBase+a.type+"_over"+a.number+".gif"}},evt_openMouseOut:function(b){if(Event.element){var c=Event.element(b);var a=this._getImgInfo(c);c.src=this.tree.imgBase+a.type.replace(/_over/g,"")+a.number+".gif"}},evt_showTooltip:function(a){this.displayTooltip=true;setTimeout(this.showTooltip.bind(this),this.tree.durationTooltipShow)},evt_hideTooltip:function(a){this.displayTooltip=false;setTimeout(this.hideTooltip.bind(this),this.tree.durationTooltipHide)},setMouseOver:function(a){if(typeof(this.struct.onmouseover)=="function"){return this.struct.onmouseover(this,a)}},setMouseOut:function(a){if(typeof(this.struct.onmouseout)=="function"){return this.struct.onmouseout(this,a)}},setMouseDown:function(a){this.tree.evt_setAsCurrent(a);if(this.tree.selectedBranchShowed){if(!this.isSelected()){this.select(a);this.okayForUnselect=false}else{this.okayForUnselect=true}}if(this.tooltip){this.displayTooltip=false;this.hideTooltip()}if(typeof(this.struct.onmousedown)=="function"){this.struct.onmousedown(this,a)}},setMouseUp:function(a){if(this.tree.lastEdited){this.tree.lastEdited.hideEditable(a)}if(this.isSelected()&&this.okayForUnselect){return true}this.okayForUnselect=true;if(typeof(this.struct.onmouseup)=="function"){this.struct.onmouseup(this,a)}},setClick:function(a){if(this.tree.lastEdited){return false}if(typeof(this.struct.onclick)=="function"){return this.struct.onclick(this,a)}},checkOnClick:function(c){if(this.tree.checkboxes&&this.checkbox){var b=(this.isChecked()>0)?0:1;var a=true;if(typeof(this.struct.onbeforecheck)=="function"){a=this.struct.onbeforecheck(this,b,c)}if(a){this.check(b);if(this.tree.checkboxesThreeState){this._manageCheckThreeState(this,b);this._adjustParentCheck()}if(typeof(this.struct.oncheck)=="function"){this.struct.oncheck(this,b,c)}}}},setOpen:function(b){if(!this.hasChildren()){return false}var a=true;if(typeof(this.struct.onbeforeopen)=="function"){a=this.struct.onbeforeopen(this,this.struct.open,b)}if(!a){return false}if(typeof(this.struct.onopenpopulate)=="function"&&!this.eventable){return false}this.openIt((this.isOpened())?false:true);if(typeof(this.struct.onopen)=="function"){return this.struct.onopen(this,this.struct.open,b)}else{if(typeof(this.struct.onopenpopulate)=="function"&&this.isOpened()&&this.children.length==0){if(!this.eventable){return false}return this._openPopulate(b)}}return true},ondragstarteffect:function(d,a){var e=this.tree.getBranchByIdObj(d.id);if(!e){for(var c=0;c<this.tree.otherTrees.length;c++){e=this.tree.otherTrees[c].getBranchByIdObj(d.id);if(e){break}}if(!e){return false}}if(typeof(e.struct.ondragstarteffect)=="function"){var b=e.struct.ondragstarteffect(e)}},ondragendeffect:function(d,a){var e=this.tree.getBranchByIdObj(d.id);if(!e){for(var c=0;c<this.tree.otherTrees.length;c++){e=this.tree.otherTrees[c].getBranchByIdObj(d.id);if(e){break}}if(!e){return false}}if(typeof(e.struct.ondragendeffect)=="function"){var b=e.struct.ondragendeffect(e)}},setDrop:function(f,g,h,k){var c=this.tree.getBranchByIdObj(f.id);if(!c){for(var d=0;d<this.tree.otherTrees.length;d++){c=this.tree.otherTrees[d].getBranchByIdObj(f.id);if(c){break}}if(!c){return false}}var e=(c.tree.dropALT)?TafelTreeManager.altOn(k):false;var b=(c.tree.dropCTRL)?TafelTreeManager.ctrlOn(k)||TafelTreeManager.metaOn(k):false;var j=true;if((this.tree.id==c.tree.id&&this.isChild(c))||!c.eventable||!this.eventable){return false}if(typeof(c.struct.ondrop)=="function"){j=c.struct.ondrop(c,this,false,null,k)}if(j){var m=((c.tree.behaviourDrop==1||c.tree.behaviourDrop==3)&&!e||(c.tree.behaviourDrop==0||c.tree.behaviourDrop==2)&&e)?true:false;var a=((c.tree.behaviourDrop==2||c.tree.behaviourDrop==3)&&!b||(c.tree.behaviourDrop==0||c.tree.behaviourDrop==1)&&b)?true:false;if(!m&&typeof(this.struct.onopenpopulate)=="function"&&!this.isOpened()&&this.children.length==0){this._openPopulate(k)}if(typeof(c.struct.ondropajax)=="function"){c._setDropAjax(this,m,a,k)}else{var l=null;if(!m){if(!a){c.move(this)}else{l=this.insertIntoLast(c.clone())}}else{if(!a){c.moveBefore(this)}else{l=this.insertBefore(c.clone())}}if(typeof(c.struct.ondrop)=="function"){j=c.struct.ondrop(c,this,true,l,k)}}}},setDblClick:function(a){if(this.tree.lastEdited){return false}if(typeof(this.struct.ondblclick)=="function"){this.struct.ondblclick(this,a)}if(this.struct.editable&&this.editableInput){if(!this.tree.lastEdited||this.tree.lastEdited.getId()!=this.getId()){this.editableInput.style.width=(this.txt.offsetWidth+20)+"px"}Element.hide(this.txt);this.editableInput.value=this.txt.innerHTML;this.editableInput.style.display="block";this.editableInput.focus();this.tree.lastEdited=this}},hideEditable:function(a){if(this.editableInput&&this.struct.editable){var c=this.editableInput;var b=c.value;if(this.struct.oneditajax){if(!this.eventable){return false}this._editAjax(c.value,this.txt.innerHTML,a)}else{if(typeof(this.struct.onedit)=="function"){b=this.struct.onedit(this,c.value,this.txt.innerHTML,a)}this.setText(b);this.hideEditableElement()}return true}return false},hideEditableElement:function(){Element.hide(this.editableInput);this.editableInput.value=this.getText();this.txt.style.display="block";this.tree.lastEdited=null}};var TafelTreeRoot=Class.create();TafelTreeRoot.prototype=Object.extend(new TafelTreeBaseBranch,{initialize:function(a,c,f,b,d,e){this.isRoot=true;this.tree=a;this.pos=e;this.level=f;this.struct=c;this.tree.idTree++;this.idObj=this.tree.idTreeBranch+this.tree.idTree;this.hasSiblingsBefore=b;this.hasSiblingsAfter=d;this.eventable=true;this.loaded=true;this.children=[];this.copiedTimes=0;this._setProperties();this._setFunctions();this.obj=this._addRoot();this.content=this._addContent();this.obj.appendChild(this.table);this._setChildren(this);this._setActions()},insertBefore:function(c){if(this.parent){return false}var d=this.pos;var a=d+1;var b=(d==0)?false:true;this._movePartStructRoot(d);this.tree.roots[d]=new TafelTreeRoot(this.tree,c,this.level,b,true,d);this.tree.div.insertBefore(this.tree.roots[d].obj,this.obj);this._manageAfterRootInsert(d);return this.tree.roots[d]},insertAfter:function(d){if(this.parent){return false}var e=this.pos+1;var b=e+1;var a=(e==this.tree.roots.length)?false:true;this._movePartStructRoot(e);this.tree.roots[e]=new TafelTreeRoot(this.tree,d,this.level,true,a,e);try{this.tree.div.insertBefore(this.tree.roots[e].obj,this.tree.roots[b].obj)}catch(c){this.tree.div.appendChild(this.tree.roots[e].obj)}this._manageAfterRootInsert(e);return this.tree.roots[e]},_manageAfterRootInsert:function(b){for(var a=0;a<this.tree.roots.length;a++){if(a<this.tree.roots.length-1){this.tree.roots[a].hasSiblingsAfter=true}if(a>0){this.tree.roots[a].hasSiblingsBefore=true}}for(var a=0;a<this.children.length;a++){this.children[a]._manageLineForRoot(this.hasSiblingsAfter)}},_movePartStructRoot:function(d){var a=this.tree.roots.length-1;var c=0;for(var b=a;b>=d;b--){c=b+1;this.tree.roots[c]=this.tree.roots[b];this.tree.roots[c].pos=c}},_addRoot:function(){var a=document.createElement("div");a.className=this.tree.classTreeRoot;return a},_addContent:function(){var e=document.createElement("table");var c=document.createElement("tbody");var g=document.createElement("tr");var h=document.createElement("td");var f=document.createElement("td");var b=document.createElement("img");var d=document.createElement("div");var a=document.createTextNode(a);b.src=this.tree.imgBase+this.struct.img;d.innerHTML=this.struct.txt;if(this.struct.title){d.setAttribute("title",this.struct.title)}d.setAttribute("id",this.idObj);Element.addClassName(d,this.tree.classContent);Element.addClassName(f,this.tree.classCanevas);f.appendChild(d);h.appendChild(b);if(this.struct.tooltip){this.tooltip=this._createTooltip();f.appendChild(this.tooltip)}this.tdImg=h;this.beforeIcon=this._getImgBeforeIcon();g.appendChild(this.beforeIcon);g.appendChild(h);g.appendChild(f);c.appendChild(g);e.appendChild(c);if(this.tree.multiline){f.style.whiteSpace="normal";if(this.hasChildren()){this._manageMultiline(this.tdImg,2,true)}}if(this.struct.style){Element.addClassName(f,this.struct.style)}this.txt=d;this.img=b;this.table=e;this._setEvents(f,h);return c}});var TafelTreeBranch=Class.create();TafelTreeBranch.prototype=Object.extend(new TafelTreeBaseBranch,{initialize:function(root,parent,struct,level,before,after,pos){this.tree=root.tree;this.root=root;this.level=level;this.pos=pos;this.parent=parent;this.tree.idTree++;this.idObj=this.tree.idTreeBranch+this.tree.idTree;this.hasSiblingsBefore=before;this.hasSiblingsAfter=after;this.struct=struct;this.eventable=true;this.loaded=true;this.inProcess=false;this.children=[];this.copiedTimes=0;if(typeof(this.struct.draggable)=="undefined"){this.struct.draggable=1}this._setProperties();if(typeof(this.struct.ondrop)=="undefined"){if(typeof(this.tree.onDrop)=="function"){this.struct.ondrop=this.tree.onDrop;this.ondropDefault=true}}else{this.struct.ondrop=eval(this.struct.ondrop)}if(typeof(this.struct.ondropajax)=="undefined"){if(this.tree.onDropAjax&&typeof(this.tree.onDropAjax.func)=="function"){this.struct.ondropajax=this.tree.onDropAjax.func;this.struct.droplink=this.tree.onDropAjax.link;this.ondropajaxDefault=true}}else{this.struct.ondropajax=eval(this.struct.ondropajax)}this._setFunctions();this.obj=this._addBranch();this.content=this._addContent();this.obj.appendChild(this.table);this._setChildren(root);this._setActions()},insertBefore:function(c){if(!this.parent){return false}var d=this.pos;var a=d+1;var b=(d==0)?false:true;this.parent._movePartStruct(d);this.parent.struct.items[d]=c;this.parent.children[d]=new TafelTreeBranch(this.root,this.parent,c,this.level,b,true,d);this.parent.obj.insertBefore(this.parent.children[d].obj,this.obj);this.parent._manageAfterInsert(d);return this.parent.children[d]},insertAfter:function(d){if(!this.parent){return false}var e=this.pos+1;var b=e+1;var a=(e==this.parent.children.length)?false:true;this.parent._movePartStruct(e);this.parent.struct.items[e]=d;this.parent.children[e]=new TafelTreeBranch(this.root,this.parent,d,this.level,true,a,e);try{this.parent.obj.insertBefore(this.parent.children[e].obj,this.parent.children[b].obj)}catch(c){this.parent.obj.appendChild(this.parent.children[e].obj)}this.parent._manageAfterInsert(e);return this.parent.children[e]},move:function(a){return this.moveIntoLast(a)},moveIntoLast:function(b){var c=this.tree.getBranchById(b);if(!c){return false}var e=c._getPos();var d=this.getId();var a=this.getText();if(e==c.children.length){obj=c.insertIntoLast(this.struct)}else{obj=c.children[e].insertBefore(this.struct)}this.tree.removeBranch(this);return obj},moveIntoFirst:function(b){var c=this.tree.getBranchById(b);if(!c){return false}var e=this.getId();var a=this.getText();var d=c.insertIntoFirst(this.struct);this.tree.removeBranch(this);return d},moveBefore:function(b){var c=this.tree.getBranchById(b);if(!c){return false}var e=this.getId();var a=this.getText();var d=c.insertBefore(this.struct);this.tree.removeBranch(this);return d},moveAfter:function(b){var c=this.tree.getBranchById(b);if(!c){return false}var e=this.getId();var a=this.getText();var d=c.insertAfter(this.struct);this.tree.removeBranch(this);return d},_addBranch:function(){var a=document.createElement("div");a.className=this.tree.classTreeBranch;return a},_addContent:function(){var k=document.createElement("table");var e=document.createElement("tbody");var h=document.createElement("tr");var f=document.createElement("img");var g=this._addImgs();var a=g.length;for(var d=a-1;d>=0;d--){h.appendChild(g[d])}this.beforeIcon=this._getImgBeforeIcon();h.appendChild(this.beforeIcon);var c=document.createElement("td");var b=document.createElement("td");var f=document.createElement("img");var j=document.createElement("div");j.innerHTML=this.struct.txt;if(this.struct.title){j.setAttribute("title",this.struct.title)}j.setAttribute("id",this.idObj);Element.addClassName(j,this.tree.classContent);Element.addClassName(b,this.tree.classCanevas);f.src=this.tree.imgBase+this.struct.img;this.tdImg=c;if(this.tree.multiline){b.style.whiteSpace="normal";if(this.hasChildren()){this._manageMultiline(this.tdImg,2,true)}}if(this.struct.style){Element.addClassName(b,this.struct.style)}b.appendChild(j);if(this.struct.tooltip){this.tooltip=this._createTooltip();b.appendChild(this.tooltip)}c.appendChild(f);h.appendChild(c);h.appendChild(b);e.appendChild(h);k.appendChild(e);this.tdImg=c;this.txt=j;this.img=f;this.table=k;this._setEvents(b,c);return e},_addImgs:function(){var c=this.parent;var b=0;var e=[];var a=null;var d=null;while(c.parent){d=document.createElement("td");a=document.createElement("img");if(!c.hasSiblingsAfter){a.src=this.tree.imgBase+this.tree.imgEmpty}else{a.src=this.tree.imgBase+this.tree.imgLine1;if(this.tree.multiline){this._manageMultiline(d,1,true)}}d.appendChild(a);e[b]=d;b++;c=c.parent}d=document.createElement("td");a=document.createElement("img");if(!this.root.hasSiblingsAfter){a.src=this.tree.imgBase+this.tree.imgEmpty}else{a.src=this.tree.imgBase+this.tree.imgLine1;if(this.tree.multiline){this._manageMultiline(d,1,true)}}d.appendChild(a);e[b]=d;return e}});var TafelTreeManager={stopEvent:true,keyboardEvents:true,keyboardStructuralEvents:true,trees:[],currentTree:null,userKeys:[],setKeys:function(a){this.userKeys=a},add:function(a){this.trees.push(a)},disableKeyboardEvents:function(){this.keyboardEvents=false},disableKeyboardStructuralEvents:function(){this.keyboardStructuralEvents=false},getCurrentTree:function(){return this.currentTree},setCurrentTree:function(a){this.currentTree=a},metaOn:function(b){var a=false;if(b&&(b.metaKey)){a=true}return a},ctrlOn:function(b){var a=false;if(b&&(b.ctrlKey||b.modifier==2)){a=true}return a},altOn:function(b){var a=false;if(b&&(b.altKey||b.modifier==1)){a=true}return a},shiftOn:function(b){var a=false;if(b&&(b.shiftKey||b.modifier==3)){a=true}return a},getCode:function(a){return(a.which)?a.which:a.keyCode},setControlEvents:function(){Event.observe(document,"keypress",this.evt_keyPress.bindAsEventListener(this),false);var a=document.getElementsByTagName("body");if(!a||!a[0]){throw new Error(TAFELTREE_NO_BODY_TAG)}else{Event.observe(a[0],"mouseup",this.evt_unselect.bindAsEventListener(this),false)}},evt_unselect:function(a){var c=Event.element(a);var b=this.getCurrentTree();if(b){if(!Element.hasClassName(c,b.classSelected)&&!Element.hasClassName(c,b.classOpenable)){b.unselect();this.setCurrentTree(null)}}},enter:function(a,d,c,b){if(a.lastEdited){a.lastEdited.editableInput.blur();if(this.stopEvent){Event.stop(b)}}},escape:function(a,f,e,d){var b=a.getSelectedBranches();var g=b.length-1;var c=false;if(g==0&&a.lastEdited){if(a.lastEdited.hideEditable(d)){c=true}}if(!c){a.unselect()}a.unsetCut();a.unsetCopy();if(this.stopEvent){Event.stop(d)}},moveStart:function(a,e,d,c){if(!a.lastEdited){a.unselect();if(a.roots.length>0){var b=a.roots[0];b.select()}if(this.stopEvent){Event.stop(c)}}},moveEnd:function(a,f,e,d){if(!a.lastEdited){a.unselect();if(a.roots.length>0){var c=a.roots.length-1;var b=a.roots[c];while(b.hasChildren()){b=b.getLastBranch()}b.select()}if(this.stopEvent){Event.stop(d)}}},moveUp:function(a,f,e,d){var c=a.getSelectedBranches();var g=c.length-1;if(!a.lastEdited){if(g>=0){var b=c[g].getPreviousOpenedBranch();if(b){b.select(d)}}else{if(typeof(a.roots[0])!="undefined"){a.roots[0].select()}}if(this.stopEvent){Event.stop(d)}}},moveDown:function(a,f,e,d){var c=a.getSelectedBranches();var g=c.length-1;if(!a.lastEdited){if(g>=0){var b=c[g].getNextOpenedBranch();if(b){b.select(d)}}else{if(typeof(a.roots[0])!="undefined"){a.roots[0].select()}}if(this.stopEvent){Event.stop(d)}}},moveRight:function(a,f,e,d){var c=a.getSelectedBranches();var h=c.length-1;if(!a.lastEdited){if(h>=0){var b=c[h];if(b.hasChildren()&&!b.isOpened()){b.setOpen(d)}else{if(b.hasChildren()){var g=b.getFirstBranch();var g=g.select(d)}}}else{if(typeof(a.roots[0])!="undefined"){a.roots[0].select()}}if(this.stopEvent){Event.stop(d)}}},moveLeft:function(a,f,e,d){var c=a.getSelectedBranches();var g=c.length-1;if(!a.lastEdited){if(g>=0){var b=c[g];if(g==0&&b.hasChildren()&&b.isOpened()){b.openIt(false)}else{if(!b.isRoot){b.parent.select(d)}}}else{if(typeof(a.roots[0])!="undefined"){a.roots[0].select()}}if(this.stopEvent){Event.stop(d)}}},edit:function(a,e,d,c){var b=a.getSelectedBranches();var f=b.length-1;if(f==0){b[f].setDblClick(c)}if(this.stopEvent){Event.stop(c)}},remove:function(a,f,e,d){if(!a.lastEdited){var c=a.getSelectedBranches();for(var b=0;b<c.length;b++){a.removeBranch(c[b])}if(this.stopEvent){Event.stop(d)}}},cut:function(a,d,c,b){if(c.ctrlKey||c.metaKey){a.cut();if(this.stopEvent){Event.stop(b)}}},copy:function(a,d,c,b){if(c.ctrlKey||c.metaKey){a.copy();if(this.stopEvent){Event.stop(b)}}},paste:function(a,d,c,b){if(c.ctrlKey||c.metaKey){a.paste();if(this.stopEvent){Event.stop(b)}}},undo:function(a,d,c,b){if(c.ctrlKey||c.metaKey){a.undo();if(this.stopEvent){Event.stop(b)}}},evt_keyPress:function(d){var e=this.getCurrentTree();if(e&&this.keyboardEvents){var c={ctrlKey:this.ctrlOn(d),metaKey:this.metaOn(d),altKey:this.altOn(d),shiftKey:this.shiftOn(d)};var b=this.getCode(d);for(var a=0;a<this.userKeys.length;a++){if(b==this.userKeys[a].key&&typeof(this.userKeys[a].func)=="function"){if(!this.userKeys[a].func(e,b,c,d)){return false}break}}switch(b){case Event.KEY_HOME:this.moveStart(e,b,c,d);break;case Event.KEY_END:this.moveEnd(e,b,c,d);break;case Event.KEY_UP:this.moveUp(e,b,c,d);break;case Event.KEY_DOWN:this.moveDown(e,b,c,d);break;case Event.KEY_RIGHT:this.moveRight(e,b,c,d);break;case Event.KEY_LEFT:this.moveLeft(e,b,c,d);break}if(this.keyboardStructuralEvents){switch(b){case Event.KEY_RETURN:this.enter(e,b,c,d);break;case Event.KEY_ESC:this.escape(e,b,c,d);break;case Event.KEY_DELETE:this.remove(e,b,c,d);break;case 113:this.edit(e,b,c,d);break;case 120:case 88:this.cut(e,b,c,d);break;case 99:case 67:this.copy(e,b,c,d);break;case 118:case 86:this.paste(e,b,c,d);break;case 122:case 90:this.undo(e,b,c,d);break}}}}};function TafelTreeInitBase(a){TafelTreeManager.setControlEvents();if(typeof(TafelTreeInit)=="function"){TafelTreeInit()}}Event.observe(window,"load",TafelTreeInitBase,false);