NG.AJAX=function(c,d){this.responseHandlers={};this.url=c;if(arguments.length>1){this.setResponseHandler(d)}this.method="GET";this.requestHeaders={};this.async=true;this.lastState=null};NG.AJAX.UNITIALIZED=0;NG.AJAX.LOADING=1;NG.AJAX.LOADED=2;NG.AJAX.INTERACTIVE=3;NG.AJAX.COMPLETE=4;NG.AJAX.prototype.setRequestHeader=function(d,c){this.requestHeaders[d]=c};NG.AJAX.prototype.setResponseHandler=function(e,d,f){if(arguments.length<2){d=200}if(arguments.length<3){f=NG.AJAX.COMPLETE}if(!isDef(typeof this.responseHandlers[f])){this.responseHandlers[f]={}}this.responseHandlers[f][d]=e};NG.AJAX.prototype.send=function(i){if(arguments<1){i=""}var j=null;if(window.XMLHttpRequest){try{j=new XMLHttpRequest()}catch(e){j=null}}else{if(window.ActiveXObject){try{j=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{j=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){j=null}}}}if(j){this.req=j;var l=this;j.onreadystatechange=function(){if(j&&isFunc(isDef)){try{var a=j.readyState}catch(d){return}try{var b=j.status}catch(d){return}l.lastState=a;if(!isDef(typeof l.responseHandlers[a])&&isDef(typeof l.responseHandlers[""])){a=""}if(a==NG.AJAX.COMPLETE){NG.delClass(document.body,"ngcursor-progress")}if(isDef(typeof l.responseHandlers[a])){if(isDef(typeof l.responseHandlers[a][b])){l.responseHandlers[a][b](j)}else{if(isDef(typeof l.responseHandlers[a][""])){l.responseHandlers[a][""](j)}}}}};j.open(this.method,this.url,this.async);for(var k in this.requestHeaders){if(!isFunc(this.requestHeaders[k])){j.setRequestHeader(k,this.requestHeaders[k])}}NG.addClass(document.body,"ngcursor-progress");var c=i;setTimeout(function(){j.send(c)},0)}else{throw ("Could not create AJAX request")}};NG.AJAX.prototype.cancel=function(){if(this.req&&this.lastState!=NG.AJAX.COMPLETE){this.req.abort()}};NG.AJAX.send=function(e,f,d){new NG.AJAX(e,f).send(d)};NG._zdisregard=0;NG.hideZdisregard=function(){if(NG._zdisregard==0){var c=document.getElementsByTagName("embed");for(var d=0;d<c.length;d++){c[d].style.display="none"}var c=document.getElementsByTagName("object");for(var d=0;d<c.length;d++){c[d].style.visibility="hidden"}if(NG.ua.isEng("MSIE","6.0","<=")){var c=document.getElementsByTagName("select");for(var d=0;d<c.length;d++){c[d].style.visibility="hidden"}}}NG._zdisregard++};NG.showZdisregard=function(){if(NG._zdisregard>0){NG._zdisregard--}if(NG._zdisregard==0){var c=document.getElementsByTagName("embed");for(var d=0;d<c.length;d++){c[d].style.display="block"}var c=document.getElementsByTagName("object");for(var d=0;d<c.length;d++){c[d].style.visibility="visible"}if(NG.ua.isEng("MSIE","6.0","<=")){var c=document.getElementsByTagName("select");for(var d=0;d<c.length;d++){c[d].style.visibility="visible"}}}};NG.addClass=function(h,c){var g=(h.className+"").split(/ +/);for(var f=1;f<arguments.length;f++){if(g.search(arguments[f])==-1){h.className+=" "+arguments[f]}}};NG.delClass=function(c,g){var h,j=(c.className+"").split(/ +/);for(var i=1;i<arguments.length;i++){if(arguments[i].constructor==RegExp){for(var h=0;h<j.length;h++){if(g.test(j[h])){j.splice(h,1);break}}}else{if((h=j.search(arguments[i]))>=0){j.splice(h,1)}}}c.className=j.join(" ")};NG.replaceClass=function(c,h,i){var g,j=(c.className+"").split(/ +/);if(h.constructor==RegExp){for(var g=0;g<j.length;g++){if(h.test(j[g])){j.splice(g,1)}}}else{if((g=j.search(h))>=0){j.splice(g,1)}}if((g=j.search(i))<0){j.push(i)}c.className=j.join(" ")};NG.hasClass=function(c,g){if(c.nodeType!=1){return false}var h,j=(c.className+"").split(/ +/);for(var i=1;i<arguments.length;i++){if(arguments[i].constructor==RegExp){for(var h=0;h<j.length;h++){if(g.test(j[h])){return true}}}else{if((h=j.search(arguments[i]))>=0){return true}}}return false};NG.addStyleRule=function(l,h,g){if(document.styleSheets.length>0){var i=document.styleSheets[0];if(arguments.length<3){g=0}else{if(g<0){g=(isDef(typeof i.cssRules)?i.cssRules:i.rules).length+g+1}}if(isDef(typeof i.insertRule)){i.insertRule(l+" { "+h+" }",g)}else{if(isDef(typeof i.addRule)){var j=l.split(/, */);for(var k=0;k<j.length;k++){i.addRule(j[k],h,g)}}}}};NG.getComputedStyle=function(b){if(window.getComputedStyle){return window.getComputedStyle(b,"")}if(b.currentStyle){return b.currentStyle}return{}};NG.getComputedStylePx=function(h,g){var f,e=NG.getComputedStyle(h)[g];if(f=/^([0-9]+(\.[0-9]+)?)px$/.exec(e)){return parseInt(f[1])}return 0};NG.setNodeHeight=function(d,f){if(isNaN(f)){return}var e=f-NG.getComputedStylePx(d,"paddingTop")-NG.getComputedStylePx(d,"paddingBottom");e-=NG.getComputedStylePx(d,"borderTopWidth")+NG.getComputedStylePx(d,"borderBottomWidth");if(e>=0){d.style.height=e+"px"}};NG.drag=function(b){NG.drag.cancel();NG.drag.tentativeItem=b;NG.addEventListener(document,"mouseup",NG.drag.cancel);NG.addEventListener(document,"mousemove",NG.drag.begin)};NG.drag.cursorMap={"can-drop":"Drop here","move-drop":"Drop here to move","copy-drop":"Drop here to copy","link-drop":"Drop here to link","bad-drop":"Not permitted to drop here","no-drop":"Cannot drop here"};NG.drag.hasRunOnce=false;NG.drag.runOnce=function(){if(!NG.drag.hasRunOnce){NG.drag.hasRunOnce=true;NG.addStyleRule(".ng-drop","position:absolute; padding:2px; padding-left:4px; padding-right:4px; z-Index:100; color:white;");NG.addStyleRule(".ng-can-drop, .ng-move-drop, .ng-copy-drop, .ng-link-drop","background-color:#129301;");NG.addStyleRule(".ng-bad-drop","background-color:#d00000; padding:2px; z-Index:100; color:white;");NG.addStyleRule(".ng-no-drop","background-color:#dcdcdc;")}};NG.drag.curItem=NG.drag.curZone=NG.drag.tentativeItem=null;NG.drag.setCursor=function(b){NG.drag.runOnce();if(arguments.length==0){if(NG.drag.setCursor.node&&NG.drag.setCursor.node.parentNode){NG.drag.setCursor.node.parentNode.removeChild(NG.drag.setCursor.node)}NG.removeEventListener(document,"mousemove",NG.drag.updateCursor);return}if(!NG.drag.setCursor.node){NG.drag.setCursor.node=document.createElement("div");NG.drag.setCursor.node.appendChild(document.createTextNode(" "));NG.drag.setCursor.node.className="no-drop"}NG.drag.setCursor.node.firstChild.nodeValue=NG.drag.cursorMap[b];NG.drag.setCursor.node.className="ng-drop ng-"+b;if(!NG.drag.setCursor.node.offsetParent){document.body.appendChild(NG.drag.setCursor.node);NG.addEventListener(document,"mousemove",NG.drag.updateCursor)}};NG.drag.updateCursor=function(b){if(!b){b=window.event}if(NG.drag.setCursor.node){NG.drag.setCursor.node.style.top=(b.clientY+5)+"px";NG.drag.setCursor.node.style.left=(b.clientX+8)+"px"}};NG.drag.setCursor.node=null;NG.drag.begin=function(b){if(NG.drag.tentativeItem){NG.drag.curItem=NG.drag.tentativeItem;NG.drag.setCursor("no-drop");NG.drag.curItem.ondragstart(b)}if(document.selection){document.selection.empty()}NG.removeEventListener(document,"mousemove",NG.drag.begin)};NG.drag.enterZone=function(d,c){if(!NG.drag.curItem){return}if(!c){c=window.event}if(d.canDrop(c)){if(NG.drag.curZone&&d!=NG.drag.curZone){NG.drag.curZone.out(c)}NG.drag.setCursor("can-drop");NG.drag.curZone=d;NG.drag.overCurZone=function(a){d.over(a)};NG.addEventListener(document,"keydown",NG.drag.overCurZone);NG.addEventListener(document,"keyup",NG.drag.overCurZone);d.over(c)}else{NG.drag.setCursor("bad-drop")}NG.stopPropagation(c)};NG.drag.leaveZone=function(d,c){if(!NG.drag.curItem){return}if(NG.drag.curZone==d){if(!c){c=window.event}NG.removeEventListener(document,"keydown",NG.drag.overCurZone);NG.removeEventListener(document,"keyup",NG.drag.overCurZone);NG.drag.overCurZone=function(){};d.out(c);NG.drag.curZone=null;NG.drag.setCursor("no-drop")}};NG.drag.dropInZone=function(d,c){if(!c){c=window.event}if(NG.drag.curItem&&d.canDrop(c)){NG.drag.curZone=d;NG.drag.curZone.drop(c);NG.drag.curItem.ondrop(c)}NG.drag.cancel(c);NG.stopPropagation(c)};NG.drag.cancel=function(b){if(!b){b=window.event}if(NG.drag.curZone){NG.drag.curZone.out(b)}if(NG.drag.curItem){NG.drag.curItem.ondragend(b)}NG.removeEventListener(document,"mouseup",NG.drag.cancel);NG.removeEventListener(document,"mousemove",NG.drag.begin);NG.removeEventListener(document,"keydown",NG.drag.overCurZone);NG.removeEventListener(document,"keyup",NG.drag.overCurZone);NG.drag.setCursor();NG.drag.curItem=NG.drag.curZone=NG.drag.tentativeItem=null};NG.drag.item=function(b){this.type=b;this.ondragstart=function(a){};this.ondragend=function(a){};this.ondrop=function(a){}};NG.drag.zone=function(){};NG.drag.zone.prototype.canDrop=function(b){return false};NG.drag.zone.prototype.over=function(b){};NG.drag.zone.prototype.out=function(b){};NG.drag.zone.prototype.drop=function(b){};NG.drag.zone.prototype.attach=function(d){var c=this;NG.addEventListener(d,"mouseover",function(a){NG.drag.enterZone(c,a)});NG.addEventListener(d,"mouseout",function(a){NG.drag.leaveZone(c,a)});NG.addEventListener(d,"mouseup",function(a){NG.drag.dropInZone(c,a)})};NG.tree=function(){this.collections={};this.newCollections=this.instructions=this.canDropList=[];this.node=this.focusedItem=this.editingItem=null;this.layers=[NG.tree.layers.toggle,NG.tree.layers.label];this.hooks={};this.isEditable=this.isDraggable=this.canAppearMultipleTimesInParent=false;this.canCreate=this.isCopyable=this.isMoveable=this.isLinkable=this.canMultiFocus=false;this.linkOnNotCopyable=false;this.deepCopy=true;this.dragName="NG.tree.item";this.dataurl=null;this.saveurl=null;this.ajaxq=[];this.ajaxqp=false};NG.tree.prototype.qajax=function(b){if(this.saveurl===null){return}this.ajaxq.push(b);this.flush_ajaxq()};NG.tree.prototype.flush_ajaxq=function(){if(!this.ajaxqp&&this.ajaxq.length>0){this.ajaxqp=true;var a=["pk","apk","rpk","cpk"];var m=["pos","label"];var f=this.ajaxq[0];var i=new NGUrl(isDef(typeof f.url)?f.url:this.saveurl);for(var k=0;k<a.length;k++){if(isDef(typeof f[a[k]])){i.addArgument(a[k],ifnull(f[a[k]].pk,"\\N"))}}for(var k=0;k<m.length;k++){if(isDef(typeof f[m[k]])){i.addArgument(m[k],f[m[k]])}}var l=new NG.AJAX(i.toString());var n=this;l.setResponseHandler(function(b){n.flush_ajaxq_success(b)},200);l.setResponseHandler(function(b){n.flush_ajaxq_failure(b)},"");l.send()}};NG.tree.prototype.flush_ajaxq_success=function(d){var a=this.ajaxq.shift();if(isDef(typeof a.response)){a.response(d)}this.ajaxqp=false;this.flush_ajaxq()};NG.tree.prototype.flush_ajaxq_failure=function(h){this.ajaxq.shift();this.ajaxqp=false;this.reload();var e=[];if(h&&h.responseXML){var g=h.responseXML.getElementsByTagName("error");for(var f=0;f<g.length;f++){if(g[f].firstChild.nodeType==3){e.push(g[f].firstChild.nodeValue)}}}if(e.length==0){e.push("We were unable to update the server with your changes due to an unknown problem")}alert("- "+e.join("\n- "))};NG.tree.prototype.addCollection=function(c,g,h){var j=new NG.tree.collection(c,g,h);if(j.pk!==null){this.collections[c]=j}else{this.newCollections[(j.newOffset=this.newCollections.length)]=j}var i=this;j.getTree=function(){return i};return j};NG.tree.prototype.getRootItem=function(){if(!this.rootItem){var d=this;var c=new NG.tree.collection(null,null);c.isComplete=false;c.getTree=function(){return d};this.rootItem=new NG.tree.item(c);this.rootItem.getLayers=function(){return d.layers};this.rootItem.refresh=function(){d.refresh()};this.rootItem.expand=this.rootItem.collapse=this.rootItem.focus=this.rootItem.blur=function(){};this.rootItem.isVisible=function(){return true};this.rootItem.isExpanded=true}return this.rootItem};NG.tree.prototype.getNode=function(){if(!this.node){this.node=document.createElement("ul");for(var b=0;b<this.getRootItem().children.length;b++){this.node.appendChild(this.getRootItem().children[b].getNode())}this.node.onselectstart=function(){return false}}return this.node};NG.tree.prototype.addHook=function(c,d){if(!isDef(typeof this.hooks[c])){this.hooks[c]=[]}this.hooks[c].push(d)};NG.tree.prototype.applyHooks=function(g,h,f){if(isDef(typeof this.hooks[h])){for(var e=0;e<this.hooks[h].length;e++){this.hooks[h][e].apply(g,f)}}};NG.tree.prototype.refresh=function(){if(!this.node){return}var b=this.node.parentNode;b.removeChild(this.node);this.node=null;this.attach(b)};NG.tree.prototype.focusItem=function(b){if(this.focusedItem===b){return}if(this.editingItem){this.editingItem.stopEdit()}this.editingItem=null;if(this.focusedItem){this.focusedItem.blur()}if(b===this.getRootItem()){if(b.children.length==0){return}b=b.children[0]}b.focus();this.focusedItem=b;b.applyHooks("focus");NG.ContextMenu.closeAll()};NG.tree.prototype.editItem=function(b){if(this.editingItem){this.editingItem.stopEdit()}this.editingItem=b;if(b){b.startEdit()}};NG.tree.prototype.i=function(d,e,f){this.addCollection(d,e,f)};NG.tree.prototype.l=function(e){var d=this.getRootItem().getCollection();if(e!==null&&isDef(typeof this.collections[e])){d=this.collections[e]}for(var f=1;f<arguments.length;f++){if(isDef(typeof this.collections[arguments[f]])){d.linkChild(this.collections[arguments[f]])}}};NG.tree.prototype.addNew=function(){if(this.focusedItem&&this.focusedItem.isExpanded){return this.focusedItem.addNew()}if(this.focusedItem){return this.focusedItem.getParent().addNew(this.focusedItem.parentOffset+1)}return this.getRootItem().addNew()};NG.tree.prototype.add=function(d,e,f){return this.getRootItem().add(d,e,f)};NG.tree.prototype.attach=function(b){b.appendChild(this.getNode())};NG.tree.prototype.reattach=function(){if(NG.ua.isEng("MSIE")){var b=this.getNode();b.parentNode.appendChild(b.parentNode.removeChild(b))}};NG.tree.prototype.reload=function(){this.getRootItem().reload()};NG.tree.prototype.setAutoReload=function(b){this.getRootItem().setAutoReload(b)};NG.tree.collection=function(d,e,f){this.pk=d;this.newOffset=null;this.label=e;this.items=[];this.state=0;this.dataurl=null;this.autoReload=null;this.autoReloadSecs=null;this.options=(arguments.length>2&&isObj(f)?f:{});this.isComplete=(!isDef(typeof this.options.complete)||this.options.complete?true:false)};NG.tree.collection.prototype.getTree=function(){return null};NG.tree.collection.prototype.getDataUrl=function(){this.applyHooks("dataurl");var b=new NGUrl(this.dataurl===null?this.getTree().dataurl:this.dataurl);if(this.pk!==null){b.addArgument("pk",this.pk,true)}return b.toString()};NG.tree.collection.prototype.hasAncestor=function(c){if(this===c){return true}for(var d=0;d<this.items.length;d++){if(this.items[d].getParent()&&this.items[d].getParent().getCollection().hasAncestor(c)){return true}}return false};NG.tree.collection.prototype.copyChild=function(e,d,f){if(this.hasAncestor(e)){return false}if(arguments.length<3){var f="Copy of "}return this._copyChild(e,d,f)};NG.tree.collection.prototype._copyChild=function(g,j,h){if(this.items.length==0||g.items.length==0){return true}var c=this.getTree().addCollection(null,h+g.label);if(this.linkChild(c,j)){if(this.getTree().deepCopy){for(var i=0;i<g.items[0].children.length;i++){c.copyChild(g.items[0].children[i].getCollection(),i,"")}}else{for(var i=0;i<g.items[0].children.length;i++){c.linkChild(g.items[0].children[i].getCollection(),i)}}return true}return false};NG.tree.collection.prototype.linkChild=function(e,d){this.isComplete=true;if(this.items.length==0){return true}if(arguments.length<2){var d=this.items[0].children.length}if(this.hasAncestor(e)){return false}for(var f=0;f<this.items.length;f++){this.items[f].attachCollection(e,d)}return true};NG.tree.collection.prototype.removeChild=function(c){if(this.items.length==0){return}for(var d=0;d<this.items.length;d++){this.items[d].detachCollection(c)}};NG.tree.collection.prototype.startDrag=function(){for(var c=0;c<this.items.length;c++){NG.addClass(this.items[c].getNode(),"drag");if(this.items[c].isExpanded){for(var d=0;d<this.items[c].children.length;d++){this.items[c].children[d].getCollection().startDrag()}}}};NG.tree.collection.prototype.stopDrag=function(){for(var c=0;c<this.items.length;c++){NG.delClass(this.items[c].getNode(),"drag");if(this.items[c].isExpanded){for(var d=0;d<this.items[c].children.length;d++){this.items[c].children[d].getCollection().stopDrag()}}}};NG.tree.collection.prototype.refresh=function(){for(var b=0;b<this.items.length;b++){this.items[b].refresh()}};NG.tree.collection.prototype.select=function(c){if(arguments.length==0){c=(this.state+1)%2}for(var d=0;d<this.items.length;d++){this.items[d].select(c)}};NG.tree.collection.prototype.setLabel=function(b){if(b==this.label||b.length==0){return}this.label=b;this.refresh();this.getTree().qajax({pk:this,label:b});this.applyHooks("changed")};NG.tree.collection.prototype.applyHooks=function(c,d){if(arguments.length<2){var d=[]}this.getTree().applyHooks(this,c,d)};NG.tree.item=function(e){this.children=[];this.isExpanded=(isDef(typeof e.options.exp)?e.options.exp:false);var c=e;this.getCollection=function(){return c};this.getParent=function(){return null};this.node=this.parentOffset=this.last=this.editNode=this.loadNode=null;if(c.items.length>0){for(var f=0;f<c.items[0].children.length;f++){this.attachCollection(c.items[0].children[f].getCollection(),f)}}if(c){c.items.push(this)}this._isfound=false;this.focusTeam=[]};NG.tree.item.prototype.getValues=function(){var d=[this.getValue()];for(var c=0;c<this.focusTeam.length;c++){d.push({value:this.focusTeam[c].pk,label:this.focusTeam[c].label})}return d};NG.tree.item.prototype.getValue=function(){var b=this.getCollection();return{value:b.pk,label:b.label}};NG.tree.item.prototype.copyChild=function(d,c){if(arguments.length<2||c>this.children.length){var c=this.children.length}if(this.getCollection().copyChild(d.getCollection(),c)){return this.last}return false};NG.tree.item.prototype.linkChild=function(d,c){if(arguments.length<2||c>this.children.length){var c=this.children.length}if(this.getCollection().linkChild(d.getCollection(),c)){return this.last}return false};NG.tree.item.prototype.moveChild=function(d,c){if(arguments.length<2||c>this.children.length){var c=this.children.length}if(this.getCollection().linkChild(d.getCollection(),c)){d.getParent().detachCollection(d.getCollection(),this.last);return this.last}return false};NG.tree.item.prototype.removeChild=function(b){this.getCollection().removeChild(b.getCollection())};NG.tree.item.prototype.getLayers=function(){return(this.layers?this.layers:this.getParent().getLayers())};NG.tree.item.prototype.getTree=function(){return this.getCollection().getTree()};NG.tree.item.prototype.applyHooks=function(c,d){if(arguments.length<2){var d=[]}this.getTree().applyHooks(this,c,d)};NG.tree.item.prototype.attachCollection=function(h,g){for(var e=g;e<this.children.length;e++){this.children[e].parentOffset++}var f=this;this.last=new NG.tree.item(h);this.last.getParent=function(){return f};this.children.splice(g,0,this.last);this.last.parentOffset=g;if(!this.canAppearMultipleTimesInParent){this.detachCollection(h,this.last)}this.refresh();return this.last};NG.tree.item.prototype.detachCollection=function(g,f){for(var h=g.items.length-1;h>=0;h--){if(g.items[h].getParent()==this&&g.items[h]!==f){this.children.splice(g.items[h].parentOffset,1);for(var e=g.items[h].parentOffset;e<this.children.length;e++){this.children[e].parentOffset--}g.items.splice(h,1)}}this.refresh()};NG.tree.item.prototype.setAutoReload=function(e){if(this.getCollection().autoReload){clearInterval(this.getCollection().autoReload)}if(arguments.length>0&&e>0){var f=this;var d=function(){if(!f.getTree().ajaxqp&&f.isVisible()){f.reload()}};if(!this.getCollection().isComplete){setTimeout(d,0)}this.getCollection().autoReload=setInterval(d,e*1000)}};NG.tree.item.prototype.reload=function(){var d=this.getCollection().getDataUrl();if(d===null){return}var j=this;var a=new NG.AJAX(d);var i=function(c){var b=c.responseXML.getElementsByTagName("tree")[0];j.hideLoading();if(b){j.load(b)}if(j.getCollection().isComplete){j.expand()}if(j.getCollection().autoReloadSecs>0){j.setAutoReload(j.getCollection().autoReloadSecs);j.getCollection().autoReloadSecs=null}};a.setResponseHandler(i,200);a.setResponseHandler(function(){j.hideLoading()},null);this.hideLoading();if(!this.getCollection().isComplete){var f=(this.getTree().getRootItem()==this?this.getTree().getNode().parentNode:this.getNode());f.appendChild(this.loadNode=document.createElement("div"));f.lastChild.className="ngcms-tree-loading";f.lastChild.appendChild(document.createTextNode("Loading..."))}a.send()};NG.tree.item.prototype.hideLoading=function(){if(this.loadNode&&this.loadNode.parentNode){this.loadNode.parentNode.removeChild(this.loadNode)}this.loadNode=null};NG.tree.item.prototype.load=function(u){var s=this.getCollection();for(var c=0;c<this.children.length;c++){this.children[c]._isfound=false}for(var f,r,j=0,o,t,i,n,v=0;v<u.childNodes.length;v++){i=u.childNodes[v];if(i.nodeType==1&&i.nodeName=="item"){t=false;f=i.getAttribute("pk");r=i.getAttribute("label");n=[];if(i.getAttribute("theme")){n.theme=i.getAttribute("theme")}for(var c=0;t==false&&c<this.children.length;c++){if(this.children[c].getCollection().pk==f){if(r!=this.children[c].getCollection().label){this.children[c].getCollection().label=r;this.children[c].getCollection().refresh()}if(this.children[c].parentOffset!=j){this.linkChild(this.children[c],j)}t=true}}if(!t){if(!isDef(typeof this.getTree().collections[f])){this.getTree().addCollection(f,r,n)}this.getCollection().linkChild(this.getTree().collections[f],j);if(this.getTree().focusedItem==this){this.expand()}}if(i.getAttribute("focus")){this.getTree().focusItem(this.children[j])}this.children[j].load(i);this.children[j]._isfound=true;if(i.getAttribute("exp")){this.children[j].expand()}j++}}for(var c=0;c<this.children.length;c++){if(!this.children[c]._isfound){this.getCollection().removeChild(this.children[c].getCollection())}}s.isComplete=(u.getAttribute("complete")=="no"?false:true);if(isStr(u.getAttribute("src"))){s.dataurl=u.getAttribute("src")}if(u.getAttribute("interval")>0){s.autoReloadSecs=u.getAttribute("interval")}};NG.tree.item.prototype.add=function(g,e,f){var h=this.getTree();if(!isDef(typeof h.collections[g])){this.getTree().addCollection(g,e,f)}this.getCollection().linkChild(h.collections[g],this.children.length);return this.last};NG.tree.item.prototype.addNew=function(g){if(!this.getTree().canCreate){return}if(arguments.length==0){var g=this.children.length}var h=this.getTree().addCollection(null,"New item");this.getCollection().linkChild(h,g);var c=function(a){try{var b=a.responseXML.getElementsByTagName("pkalloc")[0].getAttribute("pk")}catch(d){return}h.pk=b;h.getTree().collections[b]=h};this.getTree().qajax({apk:this.getCollection(),pos:g,response:c});this.last.applyHooks("changed");this.getTree().focusItem(this.last);var f=h.label;h.label="";this.last.startEdit();h.label=f};NG.tree.item.prototype.getNode=function(){if(!this.node){this.node=document.createElement("li");var c=this.getCollection();var d,k=this.getLayers();this.node.appendChild(d=document.createElement("div"));for(var j=0;j<k.length;j++){d.appendChild(document.createElement("div"));d=d.lastChild;NG.addClass(d,"layer"+j);k[j].apply(this,[d])}if(this.children.length>0||!c.IsComplete){if(this.isExpanded){this.isExpanded=false;this.expand()}else{if(this.children.length>0){NG.addClass(this.node.firstChild,"collapsed")}}}NG.addClass(this.node.firstChild,"state"+c.state);if(isStr(c.options.theme)){NG.addClass(this.node.firstChild,"tree-theme-"+c.options.theme)}var l=this;var i=new NG.tree.dropZone();i.getItem=function(){return l};i.attach(this.node.firstChild);this.applyHooks("node")}return this.node};NG.tree.item.prototype.refresh=function(){if(!this.node||!this.node.parentNode){return}var c=this.getNode().parentNode;var d=this.getNode().nextSibling;c.removeChild(this.getNode());this.node=this.editNode=null;if(d){c.insertBefore(this.getNode(),d)}else{c.appendChild(this.getNode())}if(this.getTree().focusedItem===this){this.focus()}};NG.tree.item.prototype.expand=function(){if(this.isExpanded||(this.children.length==0&&this.getCollection().isComplete==true)){return}if(!this.getCollection().isComplete){return this.reload()}this.getNode().appendChild(document.createElement("ul"));for(var b=0;b<this.children.length;b++){this.getNode().lastChild.appendChild(this.children[b].getNode())}NG.replaceClass(this.getNode().firstChild,"collapsed","expanded");this.getTree().reattach();this.isExpanded=true;this.applyHooks("expand")};NG.tree.item.prototype.collapse=function(){if(!this.isExpanded||this.children.length==0){return}this.getNode().removeChild(this.getNode().lastChild);NG.replaceClass(this.getNode().firstChild,"expanded","collapsed");this.getTree().reattach();this.isExpanded=false;this.applyHooks("collapse")};NG.tree.item.prototype.toggle=function(){if(this.isExpanded){this.collapse()}else{this.expand()}};NG.tree.item.prototype.makeVisible=function(){this.getParent().makeVisible();this.getParent().expand()};NG.tree.item.prototype.isVisible=function(){return this.getParent().isExpanded&&this.getParent().isVisible()};NG.tree.item.prototype.focus=function(e){NG.addClass(this.getNode().firstChild,(e?"focused-ancestor":"focused"));if(!e){var c=this.getCollection();for(var f=0;f<c.items.length;f++){if(c.items[f]!==this){NG.addClass(c.items[f].getNode().firstChild,"focused-instance")}}}this.getParent().focus(true);this.getParent().expand()};NG.tree.item.prototype.onFocusTeam=function(e){var c=e.getCollection();for(var f=0;f<this.focusTeam.length;f++){if(c.pk==this.focusTeam[f].pk){return f}}return false};NG.tree.item.prototype.teamFocus=function(){var e=this.getTree().focusedItem;if(e){if(e.onFocusTeam(this)!==false){this.teamBlur();return false}else{var c=this.getCollection();NG.addClass(this.getNode().firstChild,"teamfocused");for(var f=0;f<c.items.length;f++){if(c.items[f]!==this){NG.addClass(c.items[f].getNode().firstChild,"teamfocused-instance")}}e.focusTeam.push(c)}}else{this.getTree().focusItem(this)}return true};NG.tree.item.prototype.teamBlur=function(){var h,c=this.getTree().focusedItem;if(c&&(h=c.onFocusTeam(this))!==false){var g=this.getCollection();for(var f=0;f<g.items.length;f++){NG.delClass(g.items[f].getNode().firstChild,"teamfocused","teamfocused-instance")}c.focusTeam.splice(h,1)}};NG.tree.item.prototype.blur=function(){NG.delClass(this.getNode().firstChild,"focused","focused-ancestor");var g=this.getCollection();for(var h=0;h<g.items.length;h++){if(g.items[h]!==this){NG.delClass(g.items[h].getNode().firstChild,"focused-instance")}for(var c=0;c<g.items[h].focusTeam.length;c++){for(var f=0;f<g.items[h].focusTeam[c].items.length;f++){NG.delClass(g.items[h].focusTeam[c].items[f].getNode().firstChild,"teamfocused","teamfocused-instance")}}g.items[h].focusTeam=[]}this.getParent().blur();this.applyHooks("blur")};NG.tree.item.prototype.select=function(e){this.getCollection().state=e;var d=this.getParent();var f=(d?this.getSiblingState():e);if(f==e&&d){this.getParent().select(e)}else{this.setState(e);if(f==0.5){while(d){NG.replaceClass(d.getNode().firstChild,/state[0-9]+/,"state1-ancestor");d.getCollection().state=0;d=d.getParent()}}else{while(d){d.getCollection().state=f;NG.replaceClass(d.getNode().firstChild,/state[0-9]+/,"state"+f);d=d.getParent()}}}};NG.tree.item.prototype.setState=function(c){this.getCollection().state=c;NG.replaceClass(this.getNode().firstChild,/state[0-9]+/,"state"+c);for(var d=0;d<this.children.length;d++){this.children[d].setState(c)}};NG.tree.item.prototype.getSiblingState=function(){var e=null;var d=this.getParent();for(var f=0;f<d.children.length;f++){if(e===null){e=d.children[f].getCollection().state}else{if(e!=d.children[f].getCollection().state){return 0.5}}}return e};NG.tree.item.prototype.getNextSibling=function(){if(this.parentOffset<this.getParent().children.length-1){return this.getParent().children[this.parentOffset+1]}return null};NG.tree.item.prototype.getPreviousSibling=function(){if(this.parentOffset>0){return this.getParent().children[this.parentOffset-1]}return null};NG.tree.item.prototype.startEdit=function(){if(this.editNode){return}var f=this;var g=this.getNode();var h=this.getCollection();while(g.firstChild&&g.firstChild.nodeType==1){g=g.firstChild}var c=document.createElement("span");c.innerHTML='<input type="text" class="edit" />';this.editNode=c.firstChild;this.editNode.value=h.label;NG.addEventListener(this.editNode,"blur",function(a){f.stopEdit();NG.stopPropagation(a)});NG.addEventListener(this.editNode,"keypress",function(a){if(!a){a=window.event}if(a.keyCode==13){f.stopEdit()}else{if(a.keyCode==27){f.cancelEdit()}}});this.getNode().appendChild(this.editNode);NG.addClass(this.getNode().firstChild,"editlabel");this.editNode.focus()};NG.tree.item.prototype.stopEdit=function(){if(this.editNode){this.getCollection().setLabel(this.editNode.value);this.cancelEdit()}};NG.tree.item.prototype.cancelEdit=function(){if(this.editNode){this.refresh();this.editNode=null}if(this.getTree().editingItem===this){this.getTree().editingItem=null}};NG.tree.layers={label:function(c){var i=this;var g=this.getTree();var j=this.getCollection();NG.addEventListener(c,"click",function(a){i.expand();NG.stopPropagation(a)});NG.addEventListener(c.parentNode,"mousedown",function(d){var b=null;if(g.canMultiFocus&&d.ctrlKey&&g.focusedItem){if(i.teamFocus()){b=g.focusedItem}}else{if(g.canMultiFocus&&g.focusedItem&&g.focusedItem!==i&&g.focusedItem.onFocusTeam(i)){b=g.focusedItem}else{g.focusItem(i);b=i}}if(b&&g.isDraggable&&g.editingItem!==b){var a=new NG.drag.item(g.dragName);a.item=b;a.ondragstart=function(){b.getCollection().startDrag();for(var e=0;e<b.focusTeam.length;e++){b.focusTeam[e].startDrag()}};a.ondragend=function(){b.getCollection().stopDrag();for(var e=0;e<b.focusTeam.length;e++){b.focusTeam[e].stopDrag()}};NG.drag(a)}NG.preventDefault(d);NG.stopPropagation(d)});c.appendChild(document.createTextNode(j.label));if(g.isEditable){NG.addEventListener(c.parentNode,"dblclick",function(a){g.editItem(i);NG.stopPropagation(a)});var h=[];if(isDef(typeof g.hooks.edit)){h.push({label:"Edit",func:function(){i.applyHooks("edit")}})}if(isDef(typeof g.hooks["delete"])){h.push({label:"Delete",func:function(){i.applyHooks("delete")}})}if(h.length>0){NG.ContextMenu.attach(c.parentNode,h)}}},icon:function(c){var d=this;NG.addEventListener(c,"click",function(a){d.expand();NG.stopPropagation(a)})},toggle:function(c){var d=this;NG.addEventListener(c,"click",function(a){d.toggle();NG.stopPropagation(a)})},select:function(c){var d=this.getCollection();NG.addEventListener(c,"click",function(a){d.select();NG.stopPropagation(a)})}};NG.tree.dropZone=function(){};NG.tree.dropZone.prototype=new NG.drag.zone();NG.tree.dropZone.prototype.direction="e";NG.tree.dropZone.prototype.isNativeDrop=function(){return(NG.drag.curItem.type==this.getItem().getTree().dragName&&NG.drag.curItem.item&&NG.drag.curItem.item.getTree&&NG.drag.curItem.item.getTree()==this.getItem().getTree())};NG.tree.dropZone.prototype.canDrop=function(c){if(this.isNativeDrop()){var d=this.getItem().getTree();if(NG.drag.curItem.item.focusTeam.length>1){return false}if(c.ctrlKey&&c.shiftKey&&!d.isLinkable){return false}else{if(c.ctrlKey&&!c.shiftKey&&!d.isCopyable&&(!d.linkOnNotCopyable||!d.isLinkable)){return false}else{if(!c.ctrlKey&&!c.shiftKey&&!d.isMoveable){return false}else{if(this.getItem().getCollection().hasAncestor(NG.drag.curItem.item.getCollection())){return false}}}}return true}else{return(this.getItem().getTree().canDropList.search(NG.drag.curItem.type)>-1)}};NG.tree.dropZone.prototype.over=function(n){this.out(n);var m=this.isNativeDrop();if(m){var k=this.getItem().getNode();var l=NG.getPagePos(k).y;var e=k.offsetHeight/4;if(n.clientY<l+e&&this.getItem().getPreviousSibling()!=NG.drag.curItem.item){this.direction="n"}else{if(n.clientY>l+(3*e)&&this.getItem().getNextSibling()!=NG.drag.curItem.item){this.direction="s"}else{this.direction="e";if(!this.getItem().getCollection().isComplete){this.getItem().reload()}if(this.getItem().children.length>0&&!this.getItem().isExpanded){var h=this.getItem();setTimeout(function(){if(/(^| )draghover\-e( |$)/.test(h.getNode().firstChild.className)){h.expand()}},1000)}}}}var i=this.getItem().getTree();if(n.ctrlKey&&n.shiftKey&&(!m||i.isLinkable)){NG.drag.setCursor("link-drop")}else{if(n.ctrlKey&&!n.shiftKey&&(!m||i.isCopyable||(i.linkOnNotCopyable&&i.isLinkable))){NG.drag.setCursor("copy-drop")}else{if(!n.ctrlKey&&!n.shiftKey&&(!m||i.isMoveable)){NG.drag.setCursor("move-drop")}else{NG.drag.setCursor("bad-drop")}}}NG.addClass(this.getItem().getNode().firstChild,"draghover-"+this.direction)};NG.tree.dropZone.prototype.out=function(b){NG.delClass(this.getItem().getNode().firstChild,/draghover\-[nse]/)};NG.tree.dropZone.prototype.drop=function(l){if(this.isNativeDrop()){switch(this.direction){case"n":var m=this.getItem().getParent();var k=this.getItem().parentOffset;break;case"s":var m=this.getItem().getParent();var k=this.getItem().parentOffset+1;break;case"e":var m=this.getItem();var k=this.getItem().children.length;break;default:return}var e=m.getTree();if(l.ctrlKey&&e.isLinkable&&(l.shiftKey||(e.linkOnNotCopyable&&!e.isCopyable))){var f=m.linkChild(NG.drag.curItem.item,k);e.qajax({pk:NG.drag.curItem.item.getCollection(),apk:m.getCollection(),pos:k})}else{if(l.ctrlKey&&!l.shiftKey&&e.isCopyable){var f=m.copyChild(NG.drag.curItem.item,k);var n=function(a){e.reload()};e.qajax({pk:NG.drag.curItem.item.getCollection(),cpk:m.getCollection(),pos:k,response:n})}else{if(!l.ctrlKey&&!l.shiftKey&&e.isMoveable){var j=NG.drag.curItem.item.getParent().getCollection();var f=m.moveChild(NG.drag.curItem.item,k);e.qajax({pk:NG.drag.curItem.item.getCollection(),rpk:j,apk:m.getCollection(),pos:k})}else{return}}}m.getCollection().refresh();if(f){f.getTree().focusItem(f)}}else{this.getItem().getCollection().applyHooks("external"+(l.ctrlKey?"copy":"move"),[this.getItem(),NG.drag.curItem])}};NG.tree.dropZone.prototype.attach=function(d){var c=this;NG.addEventListener(d,"mouseover",function(a){if(NG.drag.curZone==c){c.over(a)}});NG.drag.zone.prototype.attach.apply(this,[d])};NG.menu=function(){this.children=[];this.last=null;this.node=null;this.focusedItem=null;this.expandedItem=null;this.layers=[NG.menu.layers.select,NG.menu.layers.label];this.isRoot=false};NG.menu.prototype.add=function(d,e,f){return this.addItem(new NG.menu.item(d,e,f))};NG.menu.prototype.attach=function(b){this.isRoot=true;b.appendChild(this.getNode())};NG.menu.prototype.addItem=function(c){var d=this;c.getTree=function(){return d};c.parentOffset=this.children.length;this.children.push(c);this.last=this.children[this.children.length-1];return this.last};NG.menu.prototype.focusItem=function(b){if(this.focusedItem){this.focusedItem.blur()}b.focus();this.focusedItem=b};NG.menu.prototype.collapseItem=function(){if(this.expandedItem){this.expandedItem.collapse()}};NG.menu.prototype.collapseAll=function(){for(var b=0;b<this.children.length;b++){if(this.children[b].isExpanded){this.children[b].collapse()}}if(this.focusedItem){this.focusedItem.blur()}if(this._ca){NG.removeEventListener(document,"mouseover",this._ca);this._ca=false}};NG.menu.prototype.getNode=function(){if(!this.node){this.node=document.createElement("div");for(var b=0;b<this.children.length;b++){this.node.appendChild(this.children[b].getNode())}this.node.onselectstart=function(){return false};NG.addEventListener(this.node,"mouseover",NG.stopPropagation)}return this.node};NG.menu.prototype.refresh=function(){var b=this.getNode().parentNode;b.removeChild(this.node);this.node=null;this.attach(b)};NG.menu.prototype.getProp=function(b){return this[b]};NG.menu.layers={label:function(c){var d=this;NG.addEventListener(c,"mouseover",function(a){NG.ContextMenu.closeAll();if(d.getTree()){d.getTree().focusItem(d)}d.expand(a);NG.stopPropagation(a)});if(this.label){if(isStr(this.label)){c.appendChild(document.createTextNode(this.label))}else{c.appendChild(this.label)}}},select:function(c){var d=this;NG.addEventListener(c,"click",function(a){d.select();NG.stopPropagation(a)})}};NG.menu.item=function(d,e,f){this.pk=d;this.label=e;this.isCurrent=f;this.children=[];this.node=null;this.isExpanded=false;this.state=0;this.parentOffset=null};NG.menu.isCurrent=function(d){var c=new NGUrl(window.location);var d=new NGUrl(d);if(d.path==c.path){return true}else{return false}};NG.menu.item.prototype.getNode=function(){if(!this.node){this.node=document.createElement("div");var d,f=this.getProp("layers");d=this.node;for(var e=0;e<f.length;e++){d.appendChild(document.createElement("div"));d=d.lastChild;NG.addClass(d,"layer"+e);if(this.isCurrent==true){NG.addClass(d,"selected")}f[e].apply(this,[d])}if(this.children.length>0){if(this.getParent()){this.node.appendChild(ar=document.createElement("div"));NG.addClass(ar,"arrow");ar.appendChild(document.createTextNode("►"))}if(this.isExpanded){this.isExpanded=false;this.expand()}else{NG.addClass(this.node.firstChild,"collapsed")}}NG.addEventListener(this.node,"mouseover",NG.stopPropagation)}return this.node};NG.menu.item.prototype.getParent=function(){return null};NG.menu.item.prototype.getTree=function(){return null};NG.menu.item.prototype.getNextSibling=function(){var b=this.getParent();if(!b){b=this.getTree()}if(b&&this.parentOffset<b.children.length-1){return b.children[this.parentOffset+1]}return null};NG.menu.item.prototype.getPreviousSibling=function(){var b=this.getParent();if(!b){b=this.getTree()}if(b&&this.parentOffset>0){return b.children[this.parentOffset-1]}return null};NG.menu.item.prototype.refresh=function(){var c=this.getNode().parentNode;var d=this.getNode().nextSibling;c.removeChild(this.getNode());this.node=null;if(d){c.insertBefore(this.getNode(),d)}else{c.appendChild(this.getNode())}};NG.menu.item.prototype.expand=function(i){var k=this.getTree();if(!k._ca){k._ca=function(a){k.collapseAll(a)};NG.addEventListener(document,"mouseover",k._ca)}if(i&&k.expandedItem&&k.expandedItem!=this&&(!this.getParent()||(k.expandedItem&&this.getParent()==k.expandedItem.getParent()))){var j=k.expandedItem.getParent();k.collapseItem();if(j){k.expandedItem=j}}if(this.isExpanded||this.children.length==0){return}NG.hideZdisregard();var e=document.createElement("div");var h=this.getNode();NG.addClass(e,"children");h.appendChild(e);for(var l=0;l<this.children.length;l++){h.lastChild.appendChild(this.children[l].getNode())}NG.replaceClass(h.firstChild,"collapsed","expanded");this.isExpanded=true;if(k){k.expandedItem=this}};NG.menu.item.prototype.collapse=function(){if(!this.isExpanded||this.children.length==0){return}for(var e=0;e<this.children.length;e++){if(this.children[e].isExpanded){this.children[e].collapse()}}var f=this.getTree();var d=this.getNode();d.removeChild(d.lastChild);NG.replaceClass(d.firstChild,"expanded","collapsed");this.isExpanded=false;if(f){f.expandedItem=null}NG.showZdisregard()};NG.menu.item.prototype.toggle=function(){if(this.isExpanded){this.collapse()}else{this.expand()}};NG.menu.item.prototype.focus=function(d){NG.addClass(this.getNode().firstChild,(d?"focused-ancestor":"focused"));var c=this.getParent();if(c){c.focus(true);c.expand()}};NG.menu.item.prototype.blur=function(){NG.delClass(this.getNode().firstChild,/^focused(\-ancestor)?$/);if(this.getParent()){this.getParent().blur()}};NG.menu.item.prototype.select=function(){};NG.menu.item.prototype.addItem=function(c){var d=this;c.getParent=function(){return d};c.getTree=function(){return d.getTree()};c.parentOffset=this.children.length;this.children.push(c);this.last=this.children[this.children.length-1];if(c.isCurrent){this.setCurrent()}return this.last};NG.menu.item.prototype.setCurrent=function(){this.isCurrent=true;var b=this.getParent();if(b){b.setCurrent()}};NG.menu.item.prototype.getProp=function(b){if(isDef(typeof this[b])){return this[b]}if(this.getParent()){return this.getParent().getProp(b)}return this.getTree().getProp(b)};NG.menu.item.prototype.add=NG.menu.prototype.add;NG.ContextMenu=function(c){this.node=null;this.focusedItem=null;this.items=[];this.targetNode=null;var d=this;if(c){this.loadSpec(c)}this.attachFunc=function(a){if(!isObj(a)&&isObj(window.event)){var a=window.event}NG.ContextMenu.closeAll();d.show(a.clientX+document.documentElement.scrollLeft,a.clientY+document.documentElement.scrollTop);d.targetNode=this;NG.stopPropagation(a);NG.preventDefault(a);return false}};NG.ContextMenu.hasRunOnce=false;NG.ContextMenu.runOnce=function(){if(!NG.ContextMenu.hasRunOnce){NG.ContextMenu.hasRunOnce=true;NG.addStyleRule(".context-menu","position:absolute; background-color:#fefefe; border:1px outset; padding:2px; z-Index:100;");NG.addStyleRule(".context-menu-item","padding:1px; padding-left:19px; padding-right:19px; height:16px; line-height:16px; overflow:none; -moz-user-select:none; -khtml-user-select:none; cursor:default; background-repeat:no-repeat; position:relative; white-space:nowrap;");NG.addStyleRule(".context-menu-item-focused","background-color:#cccccc;");NG.addStyleRule(".context-menu-item-disabled","color:#c0c0c0;");NG.addStyleRule(".context-menu-item span","right:2px; font-size:7px; top:1px; position:absolute; line-height:16px;");NG.addStyleRule(".context-menu-item div","top:0px; left:0px; font-size:9px; position:absolute; line-height:16px; width:16px; text-align:center;");NG.addStyleRule(".context-menu-item-disabled img","display:none;");NG.addStyleRule(".context-menu-separator","border-top:1px solid #c0c0c0; line-height:0px; font-size:0px; height:0px; margin-top:3px; margin-bottom:3px;");NG.addEventListener(document,"mousedown",NG.ContextMenu.closeAll)}};NG.ContextMenu.curMenu=null;NG.ContextMenu.prototype.loadSpec=function(i){var k=false;if(this.node&&this.node.parentNode){var l=this.node.offsetLeft;var g=this.node.offsetTop;this.hide();k=true}this.node=null;this.items=[];var j=this;for(var h=0;h<i.length;h++){this.items[h]=new NG.ContextMenu.item(i[h]);this.items[h].offset=h;this.items[h].getMenu=function(){return j}}if(k){this.show(l,g)}};NG.ContextMenu.prototype.getRootMenu=function(){return this};NG.ContextMenu.prototype.getParentItem=function(){return null};NG.ContextMenu.prototype.getNode=function(){if(!this.node){this.node=document.createElement("div");if(NG.ua.isEng("MSIE","6.0")){this.node.style.width="0%"}this.node.className="context-menu";for(var b=0;b<this.items.length;b++){this.node.appendChild(this.items[b].getNode())}}return this.node};NG.ContextMenu.prototype.focusItem=function(c,d){if(this.focusedItem){this.focusedItem.blur(d)}if(c.isDisabled){this.focusedItem=null}else{this.focusedItem=c;this.focusedItem.focus(d)}};NG.ContextMenu.prototype.focusNextItem=function(d){var e=(this.focusedItem?this.focusedItem.offset+1:0);for(var f=e;f<this.items.length;f++){if(!this.items[f].isDisabled&&!this.items[f].isSeparator){return this.focusItem(this.items[f],d)}}};NG.ContextMenu.prototype.focusPrevItem=function(d){var e=(this.focusedItem?this.focusedItem.offset-1:this.items.length-1);for(var f=e;f>=0;f--){if(!this.items[f].isDisabled&&!this.items[f].isSeparator){return this.focusItem(this.items[f],d)}}};NG.ContextMenu.prototype.show=function(i,j,g,h){if(arguments.length<3){g=i}if(arguments.length<4){h=j}var f=this.getRootMenu();if(NG.ContextMenu.curMenu!=f){NG.ContextMenu.closeAll();NG.ContextMenu.curMenu=f}NG.ContextMenu.documentPosition(this.getNode(),i,j,g,h);if(NG.ua.isEng("MSIE")){this.getNode().style.width=this.getNode().offsetWidth+"px";document.body.appendChild(this.getNode())}NG.hideZdisregard()};NG.ContextMenu.documentPosition=function(q,i,l,m,n){if(arguments.length<4){m=i}if(arguments.length<5){n=l}var d=NG.getComputedStyle(q);var r=["offsetHeight","offsetWidth","clientHeight","clientWidth","scrollTop","scrollLeft"];var o={};for(var p=0;p<r.length;p++){o[r[p]]=parseInt(document.documentElement[r[p]])}q.style.left=i+"px";q.style.top=l+"px";document.body.appendChild(q);if(m-q.offsetWidth>o.scrollLeft&&i+q.offsetWidth>o.clientWidth+o.scrollLeft){q.style.left=(m-q.offsetWidth)+"px"}if(n-q.offsetHeight>o.scrollTop&&l+q.offsetHeight>o.clientHeight+o.scrollTop){q.style.top=(n-q.offsetHeight)+"px"}};NG.ContextMenu.prototype.hide=function(){if(this.focusedItem){this.focusedItem.blur();this.focusedItem=null}if(NG.ContextMenu.curMenu==this){NG.ContextMenu.curMenu=null}if(this.getNode().parentNode){this.getNode().parentNode.removeChild(this.getNode())}NG.showZdisregard()};NG.ContextMenu.addContextListener=function(c,d){if(NG.ua.isEng("OPERA")){NG.addEventListener(c,"click",d)}else{if(NG.ua.isApp("Konqueror")){NG.addEventListener(c,"click",d)}else{NG.addEventListener(c,"contextmenu",d)}}};NG.ContextMenu.removeContextListener=function(c,d){NG.removeEventListener(c,"click",d);NG.removeEventListener(c,"contextmenu",d)};NG.ContextMenu.prototype.attach=function(b){NG.ContextMenu.runOnce();NG.ContextMenu.addContextListener(b,this.attachFunc)};NG.ContextMenu.prototype.detach=function(b){NG.ContextMenu.removeContextListener(b,this.attachFunc)};NG.ContextMenu.attach=function(e,f){var c=new NG.ContextMenu(f);c.attach(e);return c};NG.ContextMenu.item=function(d){this.node=null;this.label=d.label;this.confirm=d.confirm;this.isCancel=(d.cancel?true:false);this.isDisabled=(d.disabled?true:false);this.isSeparator=(d.separator?true:false);this.isFlagged=(d.flag?true:false);this.func=d.func;if(d.url){this.url=d.url}this.iconSrc=d.iconsrc;if(d.children){this.childMenu=new NG.ContextMenu(d.children)}else{if(d.childmenu){this.childMenu=d.childmenu}else{this.childMenu=null}}if(this.childMenu){var c=this;this.childMenu.getParentItem=function(){return c};this.childMenu.getRootMenu=function(){return c.getMenu().getRootMenu()}}this.value=d.value;this.offset=null};NG.ContextMenu.item.prototype.getMenu=function(){return null};NG.ContextMenu.item.prototype.getNode=function(){if(!this.node){this.node=document.createElement("div");if(this.isSeparator){this.node.className="context-menu-separator"}else{this.node.className="context-menu-item";if(this.isDisabled){this.node.className+=" context-menu-item-disabled"}if(this.iconSrc){this.node.style.backgroundImage="url("+this.iconSrc+")"}this.node.appendChild(document.createTextNode(this.label));if(this.childMenu){this.node.appendChild(document.createElement("span"));this.node.lastChild.appendChild(document.createTextNode("►"))}if(this.isFlagged){this.isFlagged=false;this.flag(true)}var b=this;NG.addEventListener(this.node,"mousedown",function(a){NG.stopPropagation(a)});NG.addEventListener(this.node,"mouseup",function(a){b.select(a);return NG.preventDefault(a)});NG.addEventListener(this.node,"mouseover",function(a){b.getMenu().focusItem(b,a)});NG.ContextMenu.addContextListener(this.node,function(a){return NG.preventDefault(a)})}}return this.node};NG.ContextMenu.item.prototype.select=function(b){if(this.isDisabled||this.isSeparator||this.childMenu){return}if(this.confirm&&!confirm(this.confirm)){}else{if(this.isCancel){}else{if(this.url){window.location=this.url}else{if(this.func&&isArr(this.func)){this.func[0][this.func[1]]()}else{if(this.func&&isFunc(this.func)){this.func(this,b)}}}}}if(NG.ua.isEng("MSIE")){setTimeout("NG.ContextMenu.closeAll();",0)}else{NG.ContextMenu.closeAll()}};NG.ContextMenu.item.prototype.focus=function(e){this.getNode().className=this.getNode().className.replace(/(^| )context-menu-item-focused( |$)/,"")+" context-menu-item-focused";if(this.childMenu){var f=this.getNode().offsetLeft+this.getMenu().getNode().offsetLeft;var d=this.getNode().offsetTop+this.getMenu().getNode().offsetTop;this.childMenu.targetNode=this.getMenu().targetNode;this.childMenu.show(f+this.getNode().offsetWidth,d,f,d+this.getNode().offsetHeight)}};NG.ContextMenu.item.prototype.blur=function(b){this.getNode().className=this.getNode().className.replace(/(^| )context-menu-item-focused( |$)/,"");if(this.childMenu){this.childMenu.hide()}};NG.ContextMenu.item.prototype.flag=function(b){if(arguments.length==0){b=!this.isFlagged}if(b&&!this.isFlagged){this.getNode().appendChild(document.createElement("div"));this.getNode().lastChild.appendChild(document.createTextNode("✔"))}else{if(!b&&this.isFlagged){this.getNode().removeChild(this.getNode().lastChild)}}this.isFlagged=b};NG.ContextMenu.item.prototype.flagone=function(){var d=this.getMenu();for(var c=0;c<d.items.length;c++){d.items[c].flag(d.items[c]==this)}};NG.ContextMenu.closeAll=function(b){if(NG.ContextMenu.curMenu){NG.ContextMenu.curMenu.hide()}};NG.DOMShuffle=function(e){for(var f=0;f<e.rows[0].cells.length;f++){var c=e.rows[0].cells[f].firstChild;while(c){if(c.nodeType==1){NG.DOMShuffle.install(c)}c=c.nextSibling}}};NG.DOMShuffle.curNode=null;NG.DOMShuffle.markerNode=null;NG.DOMShuffle.width=NG.DOMShuffle.height=NG.DOMShuffle.x=NG.DOMShuffle.y=null;NG.DOMShuffle.install=function(d){var c=d;NG.addEventListener(c,"mousedown",function(a){NG.DOMShuffle.begin(c,a)})};NG.DOMShuffle.begin=function(d,c){if(NG.DOMShuffle.curNode){NG.DOMShuffle.end(c)}NG.DOMShuffle.curNode=d;NG.addEventListener(document,"mousemove",NG.DOMShuffle.move);NG.addEventListener(document,"mouseup",NG.DOMShuffle.end);if(document.selection){document.selection.empty()}NG.preventDefault(c)};NG.DOMShuffle.move=function(e){if(!NG.DOMShuffle.curNode){return NG.DOMShuffle.end(e)}if(!e){e=window.event}if(!NG.DOMShuffle.markerNode){var i=NG.getPagePos(NG.DOMShuffle.curNode);NG.DOMShuffle.x=i.x-e.clientX;NG.DOMShuffle.y=i.y-e.clientY;if(NG.DOMShuffle.curNode.nodeName.toLowerCase()=="tr"){NG.DOMShuffle.markerNode=document.createElement("tr");for(var l=0;l<NG.DOMShuffle.curNode.cells.length;l++){NG.DOMShuffle.markerNode.appendChild(document.createElement("td"));NG.DOMShuffle.markerNode.lastChild.style.height=(NG.DOMShuffle.curNode.cells[l].offsetHeight-2)+"px"}NG.DOMShuffle.curNode.parentNode.insertBefore(NG.DOMShuffle.markerNode,NG.DOMShuffle.curNode);var m=document.createElement("table");m.style.width=NG.DOMShuffle.curNode.offsetWidth+"px";m.style.position="absolute";m.appendChild(document.createElement("tbody"));m.lastChild.appendChild(NG.DOMShuffle.curNode);NG.DOMShuffle.curNode=m;document.body.appendChild(m)}else{NG.DOMShuffle.markerNode=document.createElement("div");NG.DOMShuffle.markerNode.style.height=(NG.DOMShuffle.curNode.offsetHeight-2)+"px";NG.DOMShuffle.markerNode.style.width=(NG.DOMShuffle.curNode.offsetWidth-2)+"px";var o=NG.getComputedStyle(NG.DOMShuffle.curNode);NG.DOMShuffle.curNode.style.width=(NG.DOMShuffle.curNode.offsetWidth-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth))+"px";NG.DOMShuffle.curNode.parentNode.insertBefore(NG.DOMShuffle.markerNode,NG.DOMShuffle.curNode);NG.DOMShuffle.curNode.style.position="absolute";document.body.appendChild(NG.DOMShuffle.curNode)}NG.DOMShuffle.markerNode.className="shuffle-marker";NG.DOMShuffle.curNode.className+=" shuffle-drag"}NG.DOMShuffle.curNode.style.left=(e.clientX+NG.DOMShuffle.x)+"px";NG.DOMShuffle.curNode.style.top=(e.clientY+NG.DOMShuffle.y)+"px";var n=NG.getPagePos(NG.DOMShuffle.markerNode);var p=NG.DOMShuffle.markerNode.offsetWidth/2;while(NG.DOMShuffle.curNode.offsetLeft+p<n.x&&NG.DOMShuffle.markerNode.parentNode.previousSibling){NG.DOMShuffle.markerNode.parentNode.previousSibling.appendChild(NG.DOMShuffle.markerNode);n=NG.getPagePos(NG.DOMShuffle.markerNode)}while(NG.DOMShuffle.curNode.offsetLeft+p>n.x+NG.DOMShuffle.markerNode.offsetWidth&&NG.DOMShuffle.markerNode.parentNode.nextSibling){NG.DOMShuffle.markerNode.parentNode.nextSibling.appendChild(NG.DOMShuffle.markerNode);n=NG.getPagePos(NG.DOMShuffle.markerNode)}var k=NG.DOMShuffle.markerNode.offsetHeight/2;while(NG.DOMShuffle.curNode.offsetTop+k<n.y&&NG.DOMShuffle.markerNode.previousSibling){NG.DOMShuffle.markerNode.parentNode.insertBefore(NG.DOMShuffle.markerNode,NG.DOMShuffle.markerNode.previousSibling);n=NG.getPagePos(NG.DOMShuffle.markerNode)}while(NG.DOMShuffle.curNode.offsetTop+k>n.y+NG.DOMShuffle.markerNode.offsetHeight&&NG.DOMShuffle.markerNode.nextSibling){if(NG.DOMShuffle.markerNode.nextSibling.nextSibling){NG.DOMShuffle.markerNode.parentNode.insertBefore(NG.DOMShuffle.markerNode,NG.DOMShuffle.markerNode.nextSibling.nextSibling)}else{NG.DOMShuffle.markerNode.parentNode.appendChild(NG.DOMShuffle.markerNode)}n=NG.getPagePos(NG.DOMShuffle.markerNode)}};NG.DOMShuffle.end=function(b){NG.removeEventListener(document,"mousemove",NG.DOMShuffle.move);NG.removeEventListener(document,"mouseup",NG.DOMShuffle.end);if(NG.DOMShuffle.curNode&&NG.DOMShuffle.markerNode){if((NG.DOMShuffle.markerNode.parentNode.nodeName.toLowerCase()=="tbody"||NG.DOMShuffle.markerNode.parentNode.nodeName.toLowerCase()=="table")&&(NG.DOMShuffle.curNode.nodeName.toLowerCase()=="tbody"||NG.DOMShuffle.curNode.nodeName.toLowerCase()=="table")){NG.DOMShuffle.curNode.parentNode.removeChild(NG.DOMShuffle.curNode);NG.DOMShuffle.markerNode.parentNode.insertBefore(NG.DOMShuffle.curNode.getElementsByTagName("tr")[0],NG.DOMShuffle.markerNode)}else{NG.DOMShuffle.curNode.style.left=NG.DOMShuffle.curNode.style.top=NG.DOMShuffle.curNode.style.width="auto";NG.DOMShuffle.markerNode.parentNode.insertBefore(NG.DOMShuffle.curNode,NG.DOMShuffle.markerNode);NG.DOMShuffle.curNode.style.position="relative"}NG.DOMShuffle.markerNode.parentNode.removeChild(NG.DOMShuffle.markerNode);NG.DOMShuffle.curNode.className=NG.DOMShuffle.curNode.className.replace(/(^| )shuffle-drag( |$)/,"")}NG.DOMShuffle.markerNode=NG.DOMShuffle.curNode=null};NG.TextLookup=function(d,e,f){this.init(d,e,f)};NG.TextLookup.prototype.init=function(g,h,f){this.uSecDelay=1000;this.minLength=3;this.minWidth=100;this.displayHeight=100;NG.TextLookup.runOnce();this.url=new NGUrl(h);this.queryArg=(f?f:"q");this.textNode=g;this.eH=this.listNode=this.searchAJAX=this.lastLookup=this.focusedItem=null;this.ignoreNextBlur=this.inProgress=this.isValid=false;this.originalLabel=this.textNode.value;this.originalId=this.textNode.getAttribute("ngid");var e=this;this.textNode._ngTextLookup=function(){return e};NG.addClass(this.textNode,"ng-textlookup");if(this.originalLabel.length>0&&isId(this.originalId)){NG.addClass(this.textNode,"ng-textlookup-valid");this.isValid=true}NG.addEventListener(this.textNode,"focus",function(a){if(e.lastLookup==e.textNode.value){e.show()}});NG.addEventListener(this.textNode,"blur",function(a){e.blur(a)});NG.addEventListener(this.textNode,"keyup",function(a){e.keydown(a)});NG.addEventListener(this.textNode,"paste",function(){e.startSearch()});NG.addEventListener(document,"mousedown",function(a){if(a.target==e.textNode||a.srcElement==e.textNode){return}if(e.listNode&&(a.target==e.listNode||a.srcElement==e.listNode)){e.ignoreNextBlur=true;return}e.hide()})};NG.TextLookup.hasRunOnce=false;NG.TextLookup.runOnce=function(){if(!NG.TextLookup.hasRunOnce){NG.addStyleRule(".ng-textlookup-list","position:absolute; height:100px; border:1px solid #c0c0c0; background-color:white; overflow-y:scroll;");NG.addStyleRule(".ng-textlookup-list div","width:100%; overflow:hidden;");NG.addStyleRule(".ng-textlookup-list div div","padding:3px; padding-left:5px; line-height:110%; white-space:nowrap; cursor:pointer;");NG.addStyleRule(".ng-textlookup-valid","color:black;");NG.addStyleRule(".ng-textlookup","background-repeat:no-repeat; background-position:right center; color:red;");NG.addStyleRule(".ng-textlookup-empty","font-style:italic; color:#c0c0c0; text-align:center; height:200%;");NG.addStyleRule(".ng-textlookup-focus","background-color:#45a6e3; color:white;");NG.TextLookup.hasRunOnce=true}};NG.TextLookup.install=function(d,e,f){if(d._ngTextLookup){return d._ngTextLookup()}return new NG.TextLookup(d,e,f)};NG.TextLookup.prototype.keydown=function(b){switch(b.keyCode){case 40:if(this.focusedItem&&this.focusedItem.nextSibling){this.focusItem(this.focusedItem.nextSibling);this.scrollTofocused()}else{if(!this.focusedItem&&this.listNode&&this.listNode.firstChild&&this.listNode.firstChild.firstChild&&this.listNode.firstChild.firstChild.nodeType==1){this.focusItem(this.listNode.firstChild.firstChild);this.scrollTofocused()}}break;case 38:if(this.focusedItem&&this.focusedItem.previousSibling){this.focusItem(this.focusedItem.previousSibling);this.scrollTofocused()}else{if(!this.focusedItem&&this.listNode&&this.listNode.firstChild&&this.listNode.firstChild.lastChild&&this.listNode.firstChild.lastChild.nodeType==1){this.focusItem(this.listNode.firstChild.lastChild);this.scrollTofocused()}}break;case 13:if(this.focusedItem){this.selectItem(this.focusedItem)}else{if(this.isValid){this.hide()}}this.onfinish();break;case 27:this.cancel();this.onfinish();break;default:this.startSearch()}};NG.TextLookup.prototype.blur=function(b){if(this.ignoreNextBlur){this.ignoreNextBlur=false;this.textNode.focus()}else{this.hide();this.cancel();this.onfinish()}};NG.TextLookup.prototype.startSearch=function(){var e=false;if(this.textNode.value==this.originalLabel){this.select(this.originalId,this.originalLabel);this.hide();return}else{if(this.listNode&&this.listNode.firstChild&&this.listNode.firstChild.nodeType==1){var d=this.listNode.firstChild;for(var f=0;!e&&f<d.childNodes.length;f++){if(d.childNodes[f].nodeType==1&&d.childNodes[f].getAttribute("nglabel")==this.textNode.value){this.selectItem(d.childNodes[f]);e=true}}}}if(!e){this.unselectItem()}if(this.inProgress||this.eH){return}if(this.textNode.value.length<this.minLength){this.hide()}else{if(this.searchAJAX||this.textNode.value.length>=this.minLength){this.search()}}};NG.TextLookup.prototype.search=function(){if(this.lastLookup==this.textNode.value){if(this.eH){clearTimeout(this.eH)}this.eH=null;this.show();return}var b=this;if(!this.searchAJAX){this.searchAJAX=new NG.AJAX();this.searchAJAX.setResponseHandler(function(a){b.results(a)},200);this.searchAJAX.setResponseHandler(function(a){b.logout(a)},401);this.searchAJAX.setResponseHandler(function(a){b.cancel()},"")}else{this.searchAJAX.cancel()}NG.addClass(this.textNode,"ng-textlookup-process");this.lastLookup=this.textNode.value;this.inProgress=true;this.url.addArgument(this.queryArg,this.lastLookup,true);this.searchAJAX.url=this.url.toString();this.searchAJAX.send()};NG.TextLookup.prototype.scrollTofocused=function(){var b=this;if(!b.focusedItem||!b.listNode){return}if(b.focusedItem.offsetTop+b.focusedItem.offsetHeight>b.listNode.scrollTop+b.listNode.offsetHeight||b.focusedItem.offsetTop<b.listNode.scrollTop){b.focusedItem.scrollIntoView()}};NG.TextLookup.prototype.focusItem=function(b){this.blurItem();this.focusedItem=b;NG.addClass(this.focusedItem,"ng-textlookup-focus")};NG.TextLookup.prototype.blurItem=function(){if(this.focusedItem){NG.delClass(this.focusedItem,"ng-textlookup-focus")}this.focusedItem=null};NG.TextLookup.prototype.selectItem=function(b){this.select(b.getAttribute("ngid"),b.firstChild.nodeValue,b.getAttribute("nglabel"))};NG.TextLookup.prototype.select=function(d,e,f){this.textNode.value=e;NG.addClass(this.textNode,"ng-textlookup-valid");this.textNode.setAttribute("ngid",d);this.textNode.setAttribute("nglabel",f);this.isValid=true;this.cancel()};NG.TextLookup.prototype.unselectItem=function(){this.isValid=false;NG.delClass(this.textNode,"ng-textlookup-valid");this.textNode.removeAttribute("ngid");this.textNode.removeAttribute("nglabel")};NG.TextLookup.prototype.logout=function(b){};NG.TextLookup.prototype.cancel=function(b){if(this.searchAJAX){this.searchAJAX.cancel()}if(this.eH){clearTimeout(this.eH)}this.eH=null;this.inProgress=false;NG.delClass(this.textNode,"ng-textlookup-process");this.hide()};NG.TextLookup.prototype.results=function(i){this.inProgress=false;NG.delClass(this.textNode,"ng-textlookup-process");var l=this;if(i&&i.responseXML){var c=document.createElement("div");var j=i.responseXML.getElementsByTagName("item");this.blurItem();var f=null;for(var k=0;k<j.length;k++){c.appendChild(document.createElement("div"));c.lastChild.appendChild(document.createTextNode(j[k].getAttribute("label")));c.lastChild.setAttribute("title",j[k].getAttribute("label"));c.lastChild.setAttribute("alt",j[k].getAttribute("label"));c.lastChild.setAttribute("ngid",j[k].getAttribute("id"));c.lastChild.setAttribute("nglabel",ifnull(j[k].getAttribute("nglabel"),j[k].getAttribute("label")));NG.addEventListener(c.lastChild,"mouseover",function(){l.focusItem(this)});NG.addEventListener(c.lastChild,"mousedown",function(){l.selectItem(this);l.onfinish()});if(j[k].getAttribute("label")==this.textNode.value){this.selectItem(c.lastChild)}}if(j.length==0){c.className="ng-textlookup-empty";c.appendChild(document.createTextNode("Empty"))}else{if(j.length==1){this.focusItem(c.lastChild)}}this.show(c)}this.eH=setTimeout(function(){l.search()},this.uSecDelay)};NG.TextLookup.prototype.show=function(f){if(!this.textNode.parentNode){return this.hide()}var e=NG.getComputedStyle(this.textNode);if(!this.listNode){this.listNode=document.createElement("div");this.listNode.className="ng-textlookup-list";this.listNode.style.height=this.displayHeight+"px";this.listNode.style.fontFamily=e.fontFamily;this.listNode.style.fontSize=e.fontSize}if(f){while(this.listNode.firstChild){this.listNode.removeChild(this.listNode.firstChild)}this.listNode.appendChild(f)}var d=NG.getPagePos(this.textNode);this.listNode.style.width=Math.max(this.minWidth,this.textNode.offsetWidth-NG.getComputedStylePx(this.listNode,"borderLeftWidth")-NG.getComputedStylePx(this.listNode,"borderRightWidth"))+"px";d.y+=window.document.documentElement.scrollTop;d.x+=window.document.documentElement.scrollLeft;NG.ContextMenu.documentPosition(this.listNode,d.x,d.y+this.textNode.offsetHeight,d.x,d.y)};NG.TextLookup.prototype.hide=function(){if(this.listNode&&this.listNode.parentNode){this.listNode.parentNode.removeChild(this.listNode)}};NG.TextLookup.prototype.onfinish=function(){};
