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