// JSPack key: 0ebcf532cef5bdac2f1aba0bb5a881ff

//// JSPack file: /dxtk/dxtk.js
if(!window.DXTK)window.DXTK={};if(window.Prototype&&Prototype.isIE!=null)DXTK.isIE=Prototype.isIE;else DXTK.isIE=navigator.userAgent.toLowerCase().indexOf('msie')>=0 ? true:false;
//// JSPack file: /dxtk/color.js
DXTK.Color=Class.create({initialize:function(r,g,b){if(arguments.length==1&&typeof(r)=='string')this._rgb=DXTK.Color.parseRGB(r);else if(arguments.length==2){var el=arguments[0],st=arguments[1],bg;do{b=r.getStyle(g);if(b!='transparent')break;r=r.parentNode}while(el);this._rgb=DXTK.Color.parseRGB(b)}else if(arguments.length==3)this._rgb={r:r,g:g,b:b};if(!this._rgb)this._rgb={r:0,g:0,b:0}},duplicate:function(){var clone=new DXTK.Color();if(this._rgb)clone.rgb(this._rgb);else if(this._hsb)clone.hsb(this._hsb);return clone},compliments:function(){this.hsb();return[this.duplicate().shift(1/3),this.duplicate().shift(2/3)]},nextCompliment:function(){this.hsb();return this.duplicate().shift(1/3)},prevCompliment:function(){this.hsb();return this.duplicate().shift(-1/3)},contrast:function(percent){if(typeof(percent)=='undefined'||percent==null)percent=1.0;this.hsb();var c=this.duplicate();if(c.isMid())c._hsb.b=c._hsb.b>0.5 ?(1.0 - percent):percent;else if(c.isDark())c.brighten(percent);else c.darken(percent);return c},setRed:function(r){this.rgb().r=r;return this},setGreen:function(g){this.rgb().g=g;return this},setBlue:function(b){this.rgb().b=b;return this},setHue:function(h){this.hsb().h=h;return this},setSaturation:function(s){this.hsb().s=s;return this},setBrightness:function(b){this.hsb().b=b;return this},darken:function(percent){this.hsb();this._hsb.b=Math.max(this._hsb.b - percent,0);return this},brighten:function(percent){this.hsb();this._hsb.b=Math.min(this._hsb.b+percent,1);return this},desaturate:function(percent){this.hsb();this._hsb.s=Math.max(this._hsb.s - percent,0);return this},saturate:function(percent){this.hsb();this._hsb.s=Math.min(this._hsb.s+percent,1);return this},shift:function(percent){this.hsb();var h=this._hsb.h+percent;if(h>1)h -=1.0;else if(h<1)h+=1.0;this._hsb.h=h;return this},blend:function(color,balance){if(typeof(color)=='string')color=new DXTK.Color(color);if(typeof(balance)=='undefined'||balance==null)balance=0.5;var mb=1.0 - balance;color.rgb();this.rgb();this._rgb.r=Math.floor(mb*this._rgb.r+balance*color._rgb.r);this._rgb.g=Math.floor(mb*this._rgb.g+balance*color._rgb.g);this._rgb.b=Math.floor(mb*this._rgb.b+balance*color._rgb.b);return this},isBright:function(){return this.hsb().b>=2/3 ? true:false},isDark:function(){return this.hsb().b<=1/3 ? true:false},isMid:function(){this.hsb();return(this._hsb.b>=1/3&&this._hsb.b<=2/3)? true:false},asRGB:function(){var rgb=this._rgb||DXTK.Color.HSBtoRGB(this._hsb);return "rgb("+rgb.r+","+rgb.g+","+rgb.b+")"},asHex:function(){var rgb=this._rgb||DXTK.Color.HSBtoRGB(this._hsb);return "#"+rgb.r.toColorPart()+rgb.g.toColorPart()+rgb.b.toColorPart()},rgb:function(rgb){if(rgb)this._rgb={r:rgb.r,g:rgb.g,b:rgb.b};else if(this._hsb)this._rgb=DXTK.Color.HSBtoRGB(this._hsb);delete this._hsb;return this._rgb},hsb:function(hsb){if(hsb)this._hsb={h:hsb.h,s:hsb.s,b:hsb.b};else if(this._rgb)this._hsb=DXTK.Color.RGBtoHSB(this._rgb);delete this._rgb;return this._hsb}});DXTK.Color.prototype.toString=DXTK.Color.prototype.asHex;Object.extend(DXTK.Color,{parseRGB:function(s){if(typeof(s)!='string')return null;var cap=/^rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)$/.exec(s);if(cap!=null)return{r:parseInt(cap[1]),g:parseInt(cap[2]),b:parseInt(cap[3])};cap=/^#([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])/.exec(s);if(cap!=null)return{r:parseInt(cap[1],16),g:parseInt(cap[2],16),b:parseInt(cap[3],16)};cap=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(s);if(cap!=null)return{r:parseInt(cap[1]+cap[1],16),g:parseInt(cap[2]+cap[2],16),b:parseInt(cap[3]+cap[3],16)};return null},HSBtoRGB:function(hsb){if(hsb.s==0){var grey=Math.floor(hsb.b*255.0+0.5);return{r:grey,g:grey,b:grey}}else{var rgb;var h=(hsb.h - Math.floor(hsb.h))*6.0;var f=h - Math.floor(h);var p=hsb.b*(1.0 - hsb.s);var q=hsb.b*(1.0 - hsb.s*f);var t=hsb.b*(1.0 -(hsb.s*(1.0 - f)));switch(Math.floor(h)){case 0:rgb={r:hsb.b,g:t,b:p};break;case 1:rgb={g:hsb.b,r:q,b:p};break;case 2:rgb={g:hsb.b,r:p,b:t};break;case 3:rgb={b:hsb.b,r:p,g:q};break;case 4:rgb={b:hsb.b,r:t,g:p};break;case 5:rgb={r:hsb.b,g:p,b:q};break}return{r:Math.floor(rgb.r*255.0+0.5),g:Math.floor(rgb.g*255.0+0.5),b:Math.floor(rgb.b*255.0+0.5)}}},RGBtoHSB:function(rgb){var hsb={};var cmax=Math.max(rgb.r,Math.max(rgb.g,rgb.b));var cmin=Math.min(rgb.r,Math.min(rgb.g,rgb.b));hsb.b=cmax/255.0;hsb.s=cmax!=0 ?(cmax - cmin)/cmax:0;if(hsb.s==0)hsb.h=0;else{var rc=(cmax - rgb.r)/(cmax - cmin);var gc=(cmax - rgb.g)/(cmax - cmin);var bc=(cmax - rgb.b)/(cmax - cmin);if(rgb.r==cmax)hsb.h=bc - gc;else if(rgb.g==cmax)hsb.h=2.0+rc - bc;else hsb.h=4.0+gc - rc;hsb.h=hsb.h/6.0;if(hsb.h<0)hsb.h=hsb.h+1.0}return{h:hsb.h,s:hsb.s,b:hsb.b}}});
//// JSPack file: /dxtk/effect.js
DXTK.Effect={};DXTK.Effect.MouseOver=Class.create({delay:50,initialize:function(element,options){this.element=$(element);this.__onmouseover=this._onmouseover.bindAsEventListener(this);this.__onmouseout=this._onmouseout.bindAsEventListener(this);Event.observe(this.element,'mouseover',this.__onmouseover);Event.observe(this.element,'mouseout',this.__onmouseout);this.mouseover=false;this.options=options||{}},destroy:function(){Event.stopObserving(this.element,'mouseover',this.__onmouseover);Event.stopObserving(this.element,'mouseout',this.__onmouseout);delete this.__onmouseover;delete this.__onmouseout},_onmouseover:function(e){if(this._mouseouttimeout){clearTimeout(this._mouseouttimeout);delete this._mouseouttimeout}if(!this.mouseover){var position=Position.translatedPosition(this.element,Event.pointerX(e),Event.pointerY(e));this._mouseovertimeout=setTimeout(function(){delete this._mouseovertimeout;this.mouseover=true;this.onmouseover(position)}.bind(this),this.delay)}},_onmouseout:function(e){if(this._mouseovertimeout){clearTimeout(this._mouseovertimeout);delete this._mouseovertimeout}if(this.mouseover){var position=Position.translatedPosition(this.element,Event.pointerX(e),Event.pointerY(e));this._mouseouttimeout=setTimeout(function(){delete this._mouseouttimeout;this.mouseover=false;this.onmouseout(position)}.bind(this),this.delay)}},onmouseover:function(position){if(this.options.className)this.element.addClassName(this.options.className);if(this.options.onmouseover)this.options.onmouseover(position)},onmouseout:function(position){if(this.options.className)this.element.removeClassName(this.options.className);if(this.options.onmouseout)this.options.onmouseout(position)}});DXTK.Effect.HoverColor=DXTK.Effect.MouseOver.extend({initialize:function(element,options){DXTK.Effect.MouseOver.prototype.initialize.apply(this,[element,Object.extend({delay:true,duration:200},options||{})]);this.fx=new DXTK.Effect.Color(this.element,this.options)},onmouseover:function(position){if(this.element.disabled||this.disabled)return;if(this.fx.started)this.fx.reverse();else this.fx.start()},onmouseout:function(position){if(this.element.disabled||this.disabled)return;if(this.fx.started)this.fx.reverse();else this.fx.start()}});DXTK.Effect.ShowOnHover=DXTK.Effect.MouseOver.extend({initialize:function(e1,e2,options){this.element2=$(e2);DXTK.Effect.MouseOver.prototype.initialize.apply(this,[e1,options]);this.e2height=this.element2.offsetHeight;this.element2.hide();if(this.options.slide){this.element2.style.height='0px';this.element2.style.overflow='hidden'}if(!this.element2.descendantOf(this.element)){this.element2.onmouseover=this._onmouseover.bind(this);this.element2.onmouseout=this._onmouseout.bind(this)}},onmouseover:function(position){DXTK.Effect.MouseOver.prototype.onmouseover.apply(this,[position]);this.element2.show();if(this.options.slide){var opt={};if(this.effect&&!this.effect.finished){opt.steps=this.effect.curstep;this.effect.cancel()}else opt.duration=200;this.effect=new DXTK.Effect.Size(this.element2,[null,this.e2height],opt)}},onmouseout:function(position){DXTK.Effect.MouseOver.prototype.onmouseout.apply(this,[position]);if(this.options.slide){var opt={onFinish:function(e){e.element.hide()}};if(this.effect&&!this.effect.finished){opt.steps=this.effect.curstep;this.effect.cancel()}else opt.duration=200;this.effect=new DXTK.Effect.Size(this.element2,[null,0],opt)}else{this.element2.hide()}}});DXTK.Effect.Transition=Class.create({resolution:25,initialize:function(options){this.options=options||{};if((!this.options.duration&&!this.options.steps)||(this.options.duration&&this.options.steps))throw(new Error('Must specify one of steps or duration'));this.onStart=[];this.onFinish=[];if(this.options.onStart){this.onStart.push(this.options.onStart);delete this.options.onStart}if(this.options.onFinish){this.onFinish.push(this.options.onFinish);delete this.options.onFinish}if(this.options.resolution){this.resolution=this.options.resolution;delete this.options.resolution}this.interval=1000/this.resolution;if(this.options.duration){this.duration=this.options.duration;this.steps=Math.round(this.duration/this.interval);delete this.options.duration;if(this.steps<=0)this.steps=1}else if(this.options.steps){this.steps=this.options.steps;this.duration=this.steps*this.interval;delete this.options.steps}this.started=false;this.finished=false;this.curstep=1;if(!this.options.delay)this.start()},cancel:function(revert){if(this.started&&!this.finished){if(typeof(revert)=='undefined')revert=null;if(this.timeout){clearTimeout(this.timeout);delete this.timeout}if(this.ticking){this.__cancel=function(){this.finished=true;this._cancel(revert)}.bind(this);return}else{this.finished=true;this._cancel(revert)}}},start:function(){if(this.started)return;for(var i=0;i<this.onStart.length;++i)this.onStart[i](this);this.started=true;this._start();this.tick()},finish:function(){if(this.finished)return;this.finished=true;this._finish();for(var i=0;i<this.onFinish.length;++i)this.onFinish[i](this)},tick:function(){if(!this.started)return;if(this.ticking){++this.lapse;return}this.ticking=true;if(this.lapse){this.curstep+=this.lapse;if(this.curstep>this.steps)this.curstep=this.steps}this.lapse=0;if(!this._tick)this._tick=this.tick.bind(this);this.timeout=setTimeout(this._tick,this.interval);if(this.curstep==this.steps){clearTimeout(this.timeout);delete this.timeout}if(this.curstep<this.steps){this.doStep();this.ticking=false}else if(!this.finished){this.ticking=false;this.finish()}if(this.__cancel){this.__cancel();delete this.__cancel()}},doStep:function(){this._doStep();this.curstep++;if(this.curstep>this.steps)this.curstep=this.steps},_doStep:Prototype.emptyFunction,_finish:Prototype.emptyFunction,_start:Prototype.emptyFunction,_cancel:Prototype.emptyFunction});DXTK.Effect.Position=DXTK.Effect.Transition.extend({initialize:function(element,pos,options){this.element=$(element);if(!this.element)throw(new Error('No element'));if(!pos)throw(new Error('No position'));this.endpos=pos;if(typeof(options)=='number')options={duration:options};if(options.speed){options.steps=1;this.speed=options.speed;delete options.speed}DXTK.Effect.Transition.prototype.initialize.apply(this,[options])},_start:function(){this.startpos=Position.cumulativeOffset(this.element);if(this.endpos[0]==null)this.endpos[0]=this.startpos[0];if(this.endpos[1]==null)this.endpos[1]=this.startpos[1];if(this.element.style.right){this.element.style.left=this.startpos[0]+'px';this.element.style.right=null}if(this.element.style.bottom){this.element.style.top=this.startpos[1]+'px';this.element.style.bottom=null}this.delta=[(this.endpos[0]- this.startpos[0]),(this.endpos[1]- this.startpos[1])];this.distance=Math.sqrt(this.delta[0]*this.delta[0]+this.delta[1]*this.delta[1]);if(this.speed){this.duration=this.distance/this.speed;this.steps=Math.floor(this.duration/this.interval)}else this.speed=this.distance/this.duration},_doStep:function(){var pct=this.curstep/this.steps;this.element.style.left=(this.startpos[0]+this.delta[0]*pct).toFixed(1)+'px';this.element.style.top=(this.startpos[1]+this.delta[1]*pct).toFixed(1)+'px'},_finish:function(){this.element.style.left=this.endpos[0]+'px';this.element.style.top=this.endpos[1]+'px'},_cancel:function(revert){if(revert!=null){var pos;if(revert=='start')pos=this.startpos;else if(revert=='end')pos=this.endpos;if(pos){this.element.style.width=pos[0]+'px';this.element.style.height=pos[1]+'px'}}}});DXTK.Effect.Size=DXTK.Effect.Transition.extend({initialize:function(element,size,options){this.element=$(element);if(!this.element)throw(new Error('No element'));if(!size)throw(new Error('No size'));this.endsize=size;if(typeof(options)=='number')options={duration:options};if(options.speed){options.steps=1;this.speed=options.speed;delete options.speed}DXTK.Effect.Transition.prototype.initialize.apply(this,[options])},_start:function(){this.startsize=[this.element.offsetWidth,this.element.offsetHeight];if(this.element.style.width)this.startsize[0]=parseInt(this.element.style.width);if(this.element.style.height)this.startsize[1]=parseInt(this.element.style.height);this.delta=[this.endsize[0]==null ? 0:(this.endsize[0]- this.startsize[0]),this.endsize[1]==null ? 0:(this.endsize[1]- this.startsize[1])];this.distance=Math.sqrt(this.delta[0]*this.delta[0]+this.delta[1]*this.delta[1]);if(this.speed){this.duration=this.distance/this.speed;this.steps=Math.floor(this.duration/this.interval)}else this.speed=this.distance/this.duration},_doStep:function(){var pct=this.curstep/this.steps;if(Math.abs(this.delta[0])>0)this.element.style.width=(this.startsize[0]+this.delta[0]*pct).toFixed(1)+'px';if(Math.abs(this.delta[1])>0)this.element.style.height=(this.startsize[1]+this.delta[1]*pct).toFixed(1)+'px'},_finish:function(){if(this.endsize[0]!=null)this.element.style.width=this.endsize[0]+'px';if(this.endsize[1]!=null)this.element.style.height=this.endsize[1]+'px'},_cancel:function(revert){if(revert!=null){var size;if(revert=='start')size=this.startsize;else if(revert=='end')size=this.endsize;if(size){if(this.endsize[0]!=null)this.element.style.width=size[0]+'px';if(this.endsize[1]!=null)this.element.style.height=size[1]+'px'}}}});DXTK.Effect.Color=DXTK.Effect.Transition.extend({initialize:function(element,options){this.element=$(element);if(!this.element)throw(new Error('No element'));this.style=options.style;this.mode=options.mode;this.endvalue=options.endvalue;delete options.style;delete options.mode;delete options.endvalue;DXTK.Effect.Transition.prototype.initialize.apply(this,[options])},_init:function(){if(!this.startcolor){this.startcolor=new DXTK.Color(this.element,this.style);switch(this.mode){case 'blend':if(typeof(this.endvalue)=='string')this.endvalue=new DXTK.Color(this.endvalue);else if(typeof(this.endvalue)=='object'&&this.endvalue.color&&this.endvalue.balance)this.endvalue=this.startcolor.duplicate().blend(this.endvalue.color,this.endvalue.balance);break;case 'brightness':this.mode=this.startcolor.hsb().b>0.5 ? 'darken':'brighten';break;case 'saturation':this.mode=this.startcolor.hsb().s>0.5 ? 'desaturate':'saturate';break}}},_start:function(){if(!this.startcolor)this._init()},_finish:function(){this._setColor(this.endcolor());if(this.options.loop)if(typeof(this.options.loop)=='number')--this.options.loop;this._reverse(this.options.loop ? false:true)},_doStep:function(){var pct=this.curstep/this.steps;var curcolor=this.startcolor.duplicate();switch(this.mode){case 'blend':curcolor.blend(this.endvalue,pct);break;case 'desaturate':case 'saturate':case 'darken':case 'shift':case 'brighten':curcolor[this.mode](this.endvalue*pct);break}this._setColor(curcolor)},_setColor:function(color){var set={};set[this.style]=color.asRGB();if(this.options.setStyle)this.options.setStyle(set,color);this.element.setStyle(set)},endcolor:function(){if(!this.startcolor)this._init();var color;switch(this.mode){case 'blend':color=this.endvalue.duplicate();break;case 'desaturate':case 'saturate':case 'darken':case 'brighten':case 'shift':color=this.startcolor.duplicate();color[this.mode](this.endvalue);break}return color},_cancel:function(revert){if(revert==null)return;if(revert=='start')this._setColor(this.startcolor);else if(revert=='end')this._finish();else if(revert=='reverse')this._reverse()},reverse:function(){if(this.started&&!this.finished)this.cancel('reverse');else this._reverse()},_reverse:function(delay){this.curstep=this.steps - this.curstep+1;if(this.mode=='blend'){var c=this.startcolor;this.startcolor=this.endvalue;this.endvalue=c}else{this.startcolor=this.endcolor();switch(this.mode){case 'desaturate':this.mode='saturate';break;case 'saturate':this.mode='desaturate';break;case 'darken':this.mode='brighten';break;case 'brighten':this.mode='darken';break;case 'shift':this.endvalue=this.endvalue*- 1;break}}this.started=false;this.finished=false;if(!delay)this.start()}});DXTK.Effect.moveTo=function(element,pos,dur){return new DXTK.Effect.Position(element,pos,{duration:dur})};
//// JSPack file: /dxtk/popupbox.js
DXTK.PopupBox=Class.create({initialize:function(){this.anchor=DXTK.PopupBox.ANCHOR_TOP_LEFT;this.curpos=[0,0];if(!this.element)this.element=document.body.appendChild(Element.create('div',{className:'popupBox',style:{position:'absolute',top:'0px',left:'0px',zIndex:10,display:'none'}}))},destroy:function(){if(this.element.parentNode)this.element.parentNode.removeChild(this.element);delete this.element},showAt:function(pos,anchor){if(typeof(anchor)=='number')this.anchor=anchor;this.curpos=pos;if(this.shown)this.updateSize();else this.show()},show:function(){if(this.shown)return;this.shown=true;this.element.show();this.updateSize()},hide:function(){if(!this.shown)return;this.shown=false;this.element.hide()},boxSize:function(){var off=this.element.boxSizeOffset();var box=[this.element.offsetWidth+off[1]+off[3],this.element.offsetHeight+off[0]+off[2]];return box},updateSize:function(){var box=this.boxSize();var pos=[this.curpos[0],this.curpos[1]];switch(this.anchor){case DXTK.PopupBox.ANCHOR_TOP_LEFT:break;case DXTK.PopupBox.ANCHOR_TOP_RIGHT:pos[0]-=box[0];break;case DXTK.PopupBox.ANCHOR_BOTTOM_RIGHT:pos[0]-=box[0];pos[1]-=box[1];break;case DXTK.PopupBox.ANCHOR_BOTTOM_LEFT:pos[1]-=box[1];break}var vp=Position.viewport();if((pos[0]+box[0])>vp[0])pos[0]=vp[0]- box[0];if((pos[1]+box[1])>vp[1])pos[1]=vp[1]- box[1];this.element.style.left=pos[0]+'px';this.element.style.top=pos[1]+'px'}});Object.extend(DXTK.PopupBox,{ANCHOR_TOP_LEFT:0,ANCHOR_TOP_RIGHT:1,ANCHOR_BOTTOM_RIGHT:2,ANCHOR_BOTTOM_LEFT:3});DXTK.PopupBox.prototype.moveTo=DXTK.PopupBox.prototype.showAt;
//// JSPack file: /dxtk/dnd.js
DXTK.DnD=Class.singleton({initialize:function(){this.dropZones=[];this.draggables=[];this.currentDragObjects=[];this.onselectionchanged=[];this.dragElement=null;this.lastSelectedDraggable=null;this.currentDragObjectVisible=false;this.observingDragEvents=false;this._mouseDown=this._mouseDownHandler.bindAsEventListener(this);this._mouseMove=this._mouseMoveHandler.bindAsEventListener(this);this._mouseUp=this._mouseUpHandler.bindAsEventListener(this);this._keyPress=this._keyPressHandler.bindAsEventListener(this)},observeDragEvents:function(){if(this.observingDragEvents)return;this.observingDragEvents=true;Event.observe(document,'mousemove',this._mouseMove);Event.observe(document,'mouseup',this._mouseUp);Event.observe(document,'keypress',this._keyPress)},stopObservingDragEvents:function(){if(!this.observingDragEvents)return;this.observingDragEvents=false;Event.stopObserving(document,'mousemove',this._mouseMove);Event.stopObserving(document,'mouseup',this._mouseUp);Event.stopObserving(document,'keypress',this._keyPress)},updateSelection:function(draggable,extend){if(!extend||draggable.options.singleSelect)this.clearSelection();if(draggable.selected){this.currentDragObjects=this.currentDragObjects.without(draggable);draggable.deselect();if(draggable==this.lastSelectedDraggable)this.lastSelectedDraggable=null}else{for(var i=0;i<this.currentDragObjects.length;++i){if(this.currentDragObjects[i].dropZone!=draggable.dropZone){this.clearSelection();break}}this.currentDragObjects.push(draggable);draggable.select();this.lastSelectedDraggable=draggable}this.notifySelectionChanged()},clearSelection:function(){for(var i=0;i<this.currentDragObjects.length;++i)this.currentDragObjects[i].deselect();this.currentDragObjects=[];this.lastSelectedDraggable=null;this.notifySelectionChanged()},notifySelectionChanged:function(){for(var i=0;i<this.onselectionchanged.length;i++)this.onselectionchanged[i](this.currentDragObjects,this.lastSelectedDraggable)},hasSelection:function(){return this.currentDragObjects.length>0 ? true:false},_mouseDownHandler:function(e){if(!Event.isLeftClick(e))return;var draggable,foundDropZone=false,el=Event.element(e);while(!draggable&&el.parentNode){if(el.dropZone)foundDropZone=true;draggable=el.draggable;el=el.parentNode}if(foundDropZone||draggable)Event.stop(e);if(!draggable)return;this.__preselected=draggable.selected;if(e.ctrlKey){if(!draggable.selected)this.updateSelection(draggable,true)}else this.updateSelection(draggable,false);if(draggable.canDrag&&!draggable.canDrag())return;if(draggable.dropZone&&draggable.dropZone.canDrag&&!draggable.dropZone.canDrag(draggable))return;if(this.hasSelection()){this.observeDragEvents();this.origPos=[Event.pointerX(e),Event.pointerY(e)]}},_mouseMoveHandler:function(e){if(!DXTK.DnD.dragging){if(!this.__dragInitTimeout)this.__dragInitTimeout=setTimeout(function(){DXTK.DnD.dragging=true;delete this.__dragInitTimeout}.bind(this),DXTK.DnD.dragTimeThreshold);if(this.__dragMoveCount==null)this.__dragMoveCount=0;else if(++this.__dragMoveCount>=DXTK.DnD.dragMoveThreshold){if(this.__dragInitTimeout)clearTimeout(this.__dragInitTimeout);DXTK.DnD.dragging=true;delete this.__dragMoveCount;delete this.__dragInitTimeout}return}if(!this.currentDragObjectVisible){for(var i=0;i<this.currentDragObjects.length;++i)this.currentDragObjects[i].startDrag();this._makeDraggableObjectVisible(e)}Event.stop(e);this._updateDraggableLocation(e);if(!this.activatedDropZones)this._activateRegisteredDropZones();var el=Event.element(e);var x=Event.pointerX(e),y=Event.pointerY(e);var newDropZone=null,depth=-1;for(var i=0;i<this.dropZones.length;++i){var dropZone=this.dropZones[i];if(dropZone.active&&Position.within(dropZone.html,x,y)){var d=0,n=dropZone.html;while(n=n.parentNode)++d;if(d>depth)newDropZone=dropZone}}if(this.currentDropZone&&this.currentDropZone==newDropZone){if(this.currentDropZone.dragInnerMove)this.currentDropZone.dragInnerMove(this.currentDragObjects,e)}else if(this.currentDropZone){this.currentDropZone.dragLeave();this.currentDropZone=null}else if(newDropZone&&newDropZone.active){this.currentDropZone=newDropZone;this.currentDropZone.dragEnter()}},_mouseUpHandler:function(e){if(this.__dragInitTimeout)clearTimeout(this.__dragInitTimeout);delete this.__dragInitTimeout;delete this.__dragMoveCount;Event.stop(e);this.stopObservingDragEvents();if(!DXTK.DnD.dragging){var draggable,el=Event.element(e);while(!draggable&&el.parentNode){draggable=el.draggable;el=el.parentNode}if(draggable){if(this.__preselected)this.updateSelection(draggable,true)}else this.clearSelection()}else{DXTK.DnD.dragging=false;if(!this.currentDropZone)this._cancelDrag(e);else{this.currentDropZone.dragLeave();this.currentDropZone.accept(this.currentDragObjects,true);delete this.currentDropZone;if(this.dragElement&&this.dragElement.parentNode)this.dragElement.parentNode.removeChild(this.dragElement);this._deactivateRegisteredDropZones();for(var i=0;i<this.currentDragObjects.length;i++)this.currentDragObjects[i].endDrag();this.clearSelection();this.dragElement=null;this.currentDragObjectVisible=false}}},_keyPressHandler:function(e){if(!this.dragElement)return;if(e.charCode==0){Event.stop(e);DXTK.DnD.dragging=false;this.stopObservingDragEvents();if(this.currentDropZone){this.currentDropZone.dragLeave();delete this.currentDropZone}this._cancelDrag(e)}},_cancelDrag:function(e){if(DXTK.Effect&&this.dragElement){new DXTK.Effect.Position(this.dragElement,this.origPos,{duration:250,onFinish:this._cancelDragFinish.bind(this)})}else{if(this.dragElement){this.dragElement.style.left=this.origPos[0]+'px';this.dragElement.style.top=this.origPos[1]+'px'}this._cancelDragFinish()}},_cancelDragFinish:function(){for(var i=0;i<this.currentDragObjects.length;i++)this.currentDragObjects[i].cancelDrag();if(this.dragElement&&this.dragElement.parentNode!=null)this.dragElement.parentNode.removeChild(this.dragElement);this._deactivateRegisteredDropZones();delete this.dragElement;this.currentDragObjectVisible=false},_makeDraggableObjectVisible:function(e){if(!this.hasSelection())return;var dragElement=this.currentDragObjects[0].createDragElement(this.currentDragObjects);if(dragElement.getStyle('position')!='absolute')dragElement.style.position='absolute';this.dragElement=document.body.appendChild(dragElement.parentNode ? dragElement.parentNode.removeChild(dragElement):dragElement);this._updateDraggableLocation(e);this.currentDragObjectVisible=true},_activateRegisteredDropZones:function(){for(var i=0;i<this.dropZones.length;i++){var dropZone=this.dropZones[i];if(dropZone.accepts(this.currentDragObjects,true))dropZone.activate()}this.activatedDropZones=true},_deactivateRegisteredDropZones:function(){for(var i=0;i<this.dropZones.length;i++)this.dropZones[i].deactivate();this.activatedDropZones=false;},_updateDraggableLocation:function(e){var point=[Event.pointerX(e),Event.pointerY(e)];this.dragElement.style.left=point[0]+2+"px";this.dragElement.style.top=point[1]+2+"px"}});Object.extend(DXTK.DnD,{dragging:false,dragMoveThreshold:6,dragTimeThreshold:250});DXTK.DnD.Draggable=Class.create({initialize:function(options){this.options=options||{};var dnd=DXTK.DnD.instance();if(!this.element){if(this.options.element){this.element=$(this.options.element);delete this.options.element}else if(this.options.onCreateElement)this.element=this.options.onCreateElement(this);if(!this.element)throw(new Error('Could not get draggable element'));this.element.addClassName('draggable')}this.element.draggable=this;dnd.draggables.push(this);this.dropZone=null;if(this.options.dropZone){if(!this.options.dropZone.accepts([this],false))throw(new Error('Initial dropZone does not accept that type of draggable.'));this.options.dropZone.accept([this],false);delete this.options.dropZone}Event.observe(this.element,'mousedown',dnd._mouseDown)},destroy:function(){if(this.options.onDestroy)this.options.onDestroy(this);if(this.element)this.removeFromDropZoneHTML();if(this.dropZone){this.dropZone.draggables=this.dropZone.draggables.without(this);delete this.dropZone}var i,l,dnd=DXTK.DnD.instance(),selchg=false;for(i=0,l=dnd.draggables;i<l.length;++i)if(l[i]==this){l.splice(i,1);selchg=true;break}for(i=0,l=dnd.currentDragObjects;i<l.length;++i)if(l[i]==this){l.splice(i,1);break}if(dnd.lastSelectedDraggable==this)dnd.lastSelectedDraggable=null;if(selchg)dnd.notifySelectionChanged();Event.stopObserving(this.element,'mousedown',dnd._mouseDown)},startDrag:function(){if(this.options.onDragStart)this.options.onDragStart(this);else{this.element.removeClassName('selected');this.element.addClassName('dragging')}},endDrag:function(){if(this.options.onDragEnd)this.options.onDragEnd(this);else{this.element.addClassName('selected');this.element.removeClassName('dragging')}},cancelDrag:function(){if(this.options.onDragCancel)this.options.onDragCancel(this);else this.element.removeClassName('dragging')},select:function(){if(this.selected)return;this.selected=true;if(this.options.onSelectChange)this.options.onSelectChange(this,true);else this.element.addClassName('selected')},deselect:function(){if(!this.selected)return;this.selected=false;if(this.options.onSelectChange)this.options.onSelectChange(this,false);else this.element.removeClassName('selected')},createDragElement:function(draggables){if(this.options.onDragBoxCreate)return this.options.onDragBoxCreate(this,draggables);else{var dragElement=Element.create('div',{className:'dragBox'});for(var i=0;i<draggables.length;++i){dragElement.appendChild(draggables[i].createDragElementItem())}return dragElement}},createDragElementItem:function(){if(this.options.onCreateDragBoxItem)return this.options.onCreateDragBoxItem(this);else{var div=Element.create('div',{className:'item'});div.appendChild(document.createTextNode(this.element.getTextContent(true)));return div}},updateInsertionIndicator:function(state){var a=false,b=false;if(state==-1)b=true;else if(state==1)a=true;if(a)this.element.addClassName('insertAfter');else this.element.removeClassName('insertAfter');if(b)this.element.addClassName('insertBefore');else this.element.removeClassName('insertBefore')},removeFromDropZoneHTML:function(){if(this.element.parentNode)this.element.parentNode.removeChild(this.element)},appendToDropZoneHTML:function(){this.dropZone.html.appendChild(this.element)},insertIntoDropZoneHTML:function(idx){this.dropZone.html.insertBefore(this.element,this.dropZone.draggables[idx].element)}});DXTK.DnD.DropZone=Class.create({initialize:function(options){this.options=options||{};this.active=false;this.active=false;this.draggables=[];if(!this.html)if(this.options.element){this.html=$(this.options.element);delete this.options.element}else this.html=Element.create('div',{className:'dropZone'});this.html.dropZone=this;DXTK.DnD.instance().dropZones.push(this)},destroy:function(){if(this.options.onDestroy)this.options.onDestroy(this);while(this.draggables.length)this.draggables[0].destroy();var dnd=DXTK.DnD.instance();dnd.dropZones=dnd.dropZones.without(this);if(this.html&&this.html.parentNode)this.html.parentNode.removeChild(this.html)},activate:function(){if(this.active)return;this.active=true;if(this.options.onActivate)this.options.onActivate(this);else this.html.addClassName('active')},deactivate:function(){if(!this.active)return;this.active=false;if(this.options.onDeactivate)this.options.onDeactivate(this);else this.html.removeClassName('active')},dragEnter:function(){if(this.options.onHoverChange)this.options.onHoverChange(this,true);else this.html.addClassName('hover')},dragLeave:function(){if(this.options.onHoverChange)this.options.onHoverChange(this,false);else this.html.removeClassName('hover')},accepts:function(draggables,isDrag){if(this.options.onAcceptCheck)return this.options.onAcceptCheck(this,draggables);else return(draggables[0].dropZone&&draggables[0].dropZone==this)? false:true},accept:function(draggables,isDrag){for(var i=0;i<draggables.length;++i){draggables[i].removeFromDropZoneHTML();if(draggables[i].dropZone)draggables[i].dropZone.draggables=draggables[i].dropZone.draggables.without(draggables[i]);draggables[i].dropZone=this;this.draggables.push(draggables[i]);draggables[i].appendToDropZoneHTML()}if(this.options.onAccept)this.options.onAccept(this,draggables)}});DXTK.DnD.OrderableDropZone=DXTK.DnD.DropZone.extend({interestedInMotionEvents:true,dragEnter:function(){delete this.dragSpliceIndex;DXTK.DnD.DropZone.prototype.dragEnter.apply(this,arguments)},dragLeave:function(){this._resetDragIndicator();DXTK.DnD.DropZone.prototype.dragLeave.apply(this,arguments)},_resetDragIndicator:function(i){if(!this.draggables.length)return;if(typeof(i)=='undefined'||i==null)i=this.dragSpliceIndex;if(i==null)return;((i==this.draggables.length)?(i==0 ? this.draggables[i]:this.draggables[i - 1]):this.draggables[i]).updateInsertionIndicator(0)},dragInnerMove:function(draggables,e){if(!this.draggables.length){this.dragSpliceIndex=0;return}var oldSpliceIndex=this.dragSpliceIndex;this.dragSpliceIndex=null;var position=Position.translatedPosition(this.html,Event.pointerX(e),Event.pointerY(e));for(var i=0;i<this.draggables.length;++i){var midpoint=Position.cumulativeOffset(this.draggables[i].element)[1]+Math.floor(this.draggables[i].element.offsetHeight/2);if(position[1]<=midpoint){this.dragSpliceIndex=i;break}}if(this.dragSpliceIndex==null)this.dragSpliceIndex=this.draggables.length;if(oldSpliceIndex!=null&&oldSpliceIndex!=this.dragSpliceIndex)this._resetDragIndicator(oldSpliceIndex);if(this.draggables.length)if(this.dragSpliceIndex==this.draggables.length)(this.dragSpliceIndex==0 ? this.draggables[this.dragSpliceIndex]:this.draggables[this.dragSpliceIndex - 1]).updateInsertionIndicator(1);else this.draggables[this.dragSpliceIndex].updateInsertionIndicator(-1)},accepts:function(draggables,isDrag){if(this.options.onAcceptCheck)return this.options.onAcceptCheck(this,draggables);else return true},accept:function(draggables,isDrag){if(this.dragSpliceIndex==null)this.dragSpliceIndex=this.draggables.length;for(var i=0;i<draggables.length;++i){if(draggables[i].dropZone){draggables[i].removeFromDropZoneHTML();if(draggables[i].dropZone==this&&this.draggables.indexOf(draggables[i])<this.dragSpliceIndex)this.dragSpliceIndex--;draggables[i].dropZone.draggables=draggables[i].dropZone.draggables.without(draggables[i])}}for(var i=draggables.length-1;i>=0;--i){draggables[i].dropZone=this;if(this.dragSpliceIndex==this.draggables.length){this.draggables.push(draggables[i]);draggables[i].appendToDropZoneHTML()}else{this.draggables.splice(this.dragSpliceIndex,0,draggables[i]);draggables[i].insertIntoDropZoneHTML(++this.dragSpliceIndex)}}if(this.options.onAccept)this.options.onAccept(this,draggables);delete this.dragSpliceIndex}});
//// JSPack file: /dxtk/menu.js
DXTK.Menu=Class.create({initialize:function(options){this.options=options||{};this.html=document.createElement('div');this.html.menu=this;this.html.className='menu';this.html.style.position='absolute';this.html.style.top='0px';this.html.style.left='0px';this.html.style.zIndex=100;this.html.hide();document.body.appendChild(this.html);this.__onmouseover=this._onmouseover.bindAsEventListener(this);this.__onmouseout=this._onmouseout.bindAsEventListener(this);this.__onclick=this._onclick.bindAsEventListener(this);this.html.onmouseover=this.__onmouseover;this.html.onmouseout=this.__onmouseout;this.html.onclick=this.__onclick},destroy:function(){var items=this.menuitems();for(var i=0;i<items.length;++i)items[i].destroy();this.html.parentNode.removeChild(this.html);delete this.html.onmouseover;delete this.html.onmouseout;delete this.html.onclick;delete this.__onmouseover;delete this.__onmouseout;delete this.__onclick;delete this.html},_onmouseover:function(e){var el=Event.element(e);var item;while(el.parentNode){if(el.menuitem){item=el.menuitem;break}el=el.parentNode}if(item)item.onmouseover(e)},_onmouseout:function(e){var el=Event.element(e);var item;while(el.parentNode){if(el.menuitem){item=el.menuitem;break}el=el.parentNode}if(item)item.onmouseout()},_onclick:function(e){var el=Event.element(e);var item;while(el.parentNode){if(el.menuitem){item=el.menuitem;break}el=el.parentNode}if(item){Event.stop(e);if(item.popup)return;if(item.onActivate)item.onActivate();if(this.onActivate)this.onActivate(item);else if(this.isPopup){var m=this;while(m&&m.parentItem)if(m.parentItem.menu.onActivate){m.parentItem.menu.onActivate(item);break}else m=m.parentItem.menu}item.html.removeClassName('selected');DXTK.Menu.hideAll()}},showAt:function(pos,avoid){this.html.show();var size=[this.html.offsetWidth,this.html.offsetHeight];if(pos[0]+size[0]>window.innerWidth)pos[0]=window.innerWidth - size[0];if(pos[1]+size[1]>window.innerHeight)pos[1]=window.innerHeight - size[1];if(avoid){var avoidx=(pos[0]>=avoid[0]&&pos[0]<=avoid[2])? true:false;var avoidy=(pos[1]>=avoid[1]&&pos[1]<=avoid[3])? true:false;if(avoidx&&avoidy){if(avoid[2]+size[0]+1<window.innerWidth)pos[0]=avoid[2]+1;else if(avoid[0]- size[0]- 1>=0)pos[0]=avoid[0]- size[0]- 1;else if(avoid[3]+size[1]+1<window.innerHeight)pos[1]=avoid[3]+1;else if(avoid[1]- size[1]- 1>=0)pos[1]=avoid[1]- size[1]- 1;else pos[0]=avoid[2]}}this.html.style.left=pos[0]+'px';this.html.style.top=pos[1]+'px';if(!DXTK.Menu.shownMenus.length)DXTK.Menu.observeCleanupEvents();DXTK.Menu.shownMenus.push(this)},showAtEvent:function(e){this.showAt([Event.pointerX(e),Event.pointerY(e)])},hide:function(){if(this._hideTimeout)delete this._hideTimeout;if(this.cursel)this.cursel.unselect();this.html.hide();for(var i=0;i<this.html.childNodes.length;++i)if(this.html.childNodes[i].menuitem)this.html.childNodes[i].menuitem.hide();for(var i=0;i<DXTK.Menu.shownMenus.length;++i)if(DXTK.Menu.shownMenus[i]==this){DXTK.Menu.shownMenus.splice(i,1);break}},menuitems:function(){var r;for(var i=0;i<this.html.childNodes.length;++i)if(this.html.childNodes[i].menuitem)r.push(this.html.childNodes[i].menuitem);return r}});Object.extend(DXTK.Menu,{shownMenus:[],hideAll:function(){while(DXTK.Menu.shownMenus.length)DXTK.Menu.shownMenus[0].hide();DXTK.Menu.stopObservingCleanupEvents()},windowClick:function(e){Event.stop(e);this.hideAll()},windowKeyPress:function(e){if(e.charCode==0){Event.stop(e);this.hideAll()}},stopObservingCleanupEvents:function(){Event.stopObserving(window,'click',DXTK.Menu._windowClick);Event.stopObserving(window,'keypress',DXTK.Menu._windowKeyPress)},observeCleanupEvents:function(){Event.observe(window,'click',DXTK.Menu._windowClick);Event.observe(window,'keypress',DXTK.Menu._windowKeyPress)},createMenuStructure:function(items){var menu=new DXTK.Menu();for(var i=0;i<items.length;++i){var ai=items[i];var item=new DXTK.MenuItem(menu,ai[0],ai[1],ai[2],ai[3]);if(ai[4])item.setPopup(DXTK.Menu.createMenuStructure(ai[4]))}return menu}});DXTK.Menu._windowClick=DXTK.Menu.windowClick.bindAsEventListener(DXTK.Menu);DXTK.Menu._windowKeyPress=DXTK.Menu.windowKeyPress.bindAsEventListener(DXTK.Menu);DXTK.MenuItem=Class.create({initialize:function(menu,name,title,img,callback){this.name=name;this.menu=menu;this.html=this.menu.html.appendChild(document.createElement('div'));this.html.menuitem=this;this.html.className='item';if(!this.menu.options.noGutter)this.html.style.paddingLeft='18px';this.s_title=this.html.appendChild(document.createElement('span'));this.s_title.appendChild(document.createTextNode(title));this.html.style.backgroundRepeat='no-repeat';this.html.style.backgroundPosition='1px center';if(img)this.html.style.backgroundImage='url('+img+')';if(callback)this.onActivate=callback},destroy:function(){this.html.parentNode.removeChild(this.html);this.popup.destroy();delete this.popup.parentItem;delete this.html.menuitem;delete this.html;delete this.s_title;delete this.menu;delete this.popup},select:function(){this.html.addClassName('selected');if(this.menu.cursel&&this.menu.cursel!=this){if(this.menu.cursel.popup){if(this.menu.cursel.popup._hideTimeout){clearTimeout(this.menu.cursel.popup._hideTimeout);delete this.menu.cursel.popup._hideTimeout}this.menu.cursel.popup.hide()}this.menu.cursel.unselect()}this.menu.cursel=this},unselect:function(){if(this.menu.cursel==this)this.menu.cursel=null;this.html.removeClassName('selected')},onmouseover:function(e){if(this.menu._hideTimeout){clearTimeout(this.menu._hideTimeout);delete this.menu._hideTimeout}this.select();if(this.popup){if(this.popup._hideTimeout){clearTimeout(this.popup._hideTimeout);delete this.popup._hideTimeout}else if(!this.popup._showTimeout)this.popup._showTimeout=setTimeout(function(){this.showPopup();delete this.popup._showTimeout}.bind(this),100)}},onmouseout:function(){if(this.popup){if(this.popup._showTimeout){clearTimeout(this.popup._showTimeout);delete this.popup._showTimeout}else if(!this.popup._hideTimeout)this.popup._hideTimeout=setTimeout(function(){this.unselect();this.popup.hide()}.bind(this),100)}else this.unselect()},hide:function(){this.html.removeClassName('selected')},setPopup:function(menu){this.popup=menu;this.popup.isPopup=true;this.popup.parentItem=this},showPopup:function(){var pos=Position.cumulativeOffset(this.html);pos[0]+=this.html.offsetWidth - 2;var avoid=Position.cumulativeOffset(this.menu.html);avoid[0]+=2;avoid[1]+=2;avoid[2]=avoid[0]+this.menu.html.offsetWidth - 4;avoid[3]=avoid[1]+this.menu.html.offsetHeight - 4;this.popup.showAt(pos,avoid)}});
//// JSPack file: /dxtk/stacked.js
DXTK.Stacked=Class.create({initialize:function(element,options){this.element=$(element);this.element.stacked=this;this.options=options||{};this.areas=[];this.curarea=null;this.areaBodyHeight=100;if(!this.options.noAreaInit)for(var i=0;i<this.element.childNodes.length;++i){var node=this.element.childNodes[i];if(node.nodeType==Node.ELEMENT_NODE&&node.hasClassName('area'))this.createArea(node)}},updateSize:function(){var h=this.element.clientHeight;for(var i=0;i<this.areas.length;++i)h -=this.areas[i].header.offsetHeight;this.areaBodyHeight=h;for(var i=0;i<this.areas.length;++i)this.areas[i].updateSize(-1)},createArea:function(element){this.addArea(new DXTK.Stacked.Area(this,element))},addArea:function(area){this.areas.push(area);this.updateSize();if(this.areas.length==1){this.curarea=area;area.show(true)}},slideFXOpt:{duration:200}});DXTK.Stacked.Area=Class.create({initialize:function(stacked,element){this.stacked=stacked;if(element)this.element=$(element);if(this.element){for(var i=0;i<this.element.childNodes.length;++i){var node=this.element.childNodes[i];if(node.nodeType==Node.ELEMENT_NODE)if(node.hasClassName('header'))this.header=node;else if(node.hasClassName('body'))this.body=node}}else{this.element=this.stacked.element.appendChild(Element.create('div',{className:'area'}))}this.element.area=this;if(!this.header){this.header=this.element.appendChild(document.createElement('div'));this.header.className='header'}if(!this.body){this.body=this.element.appendChild(document.createElement('div'));this.body.className='body'}this.shown=false;this.body.style.height='0px';this.body.style.overflow='auto';this.body.hide();this.header.onclick=this.onHeaderClick.bind(this);if(this.stacked.options.areaInit)this.stacked.options.areaInit(this)},destroy:function(){if(this.element.parentNode)this.element.parentNode.removeChild(this.element);for(var i=0;i<this.stacked.areas.length;++i)if(this.stacked.areas[i]==this){this.stacked.areas.splice(i,1);break}if(this.stacked.curarea==this)this.stacked.curarea=null;this.stacked.updateSize();if(this.shown&&this.stacked.areas.length)this.stacked.areas[this.stacked.areas.length - 1].show();this.header.onclick=null;delete this.stacked;delete this.header;delete this.body;delete this.element.area;delete this.element},onHeaderClick:function(){if(this.shown){if(this.tristate&&!this.shownMin)this.showMin();else{var j=0;for(var i=0;i<this.stacked.areas.length;++i)if(this.stacked.areas[i]!=this&&this.stacked.areas[i].shownMin){j++;this.stacked.areas[i].hide()}if(!j&&!this.stacked.options.noExplicitHide)this.hide()}}else if(this.tristate){if(this.shownMin)this.show();else this.showMin()}else this.show()},updateSize:function(s){if(!this.element)return;if(s==null||typeof(s)!='number')s=this.curHeight;if(s==-1){if(this.shown){s=this.stacked.areaBodyHeight;for(var i=0;i<this.stacked.areas.length;++i)if(this.stacked.areas[i].shownMin!=this&&this.stacked.areas[i].shownMin)s -=this.stacked.areas[i].curHeight}else if(this.shownMin){s=this.minHeight();if(s==0){this.show(true);return}}else{s=0}}this.curHeight=s;this._updateSize()},_updateSize:function(){this.body.style.height=this.curHeight+'px'},slideSize:function(onFinish,size){if(size!=null)this.curHeight=size;return new DXTK.Effect.Size(this.body,[null,this.curHeight],Object.extend({onFinish:onFinish},this.stacked.slideFXOpt))},show:function(instant){if(this.shown)return;if(this.stacked.curarea)this.stacked.curarea.hide(instant);this.stacked.curarea=this;this.body.show();var height=this.stacked.areaBodyHeight;for(var i=0;i<this.stacked.areas.length;++i)if(this.stacked.areas[i]!=this&&this.stacked.areas[i].shownMin)height -=this.stacked.areas[i].curHeight;if(this.shownMin)this.shownMin=false;this.shown=true;this.curHeight=height;if(instant)this._show();else this.slideSize(this._show.bind(this))},showMin:function(instant){if(this.shownMin||!this.stacked.curarea||this.stacked.curarea==this)return;if(this.shown)this.shown=false;this.body.show();var minh=this.minHeight();if(minh<=0)return this.show();var other=this.stacked.curarea;var remh=this.stacked.areaBodyHeight - minh;this.curHeight=minh;other.curHeight=remh;this.shownMin=true;if(instant){other.updateSize();this._showMin()}else{other.slideSize(other.updateSize.bind(other));this.slideSize(this._showMin.bind(this))}},hide:function(instant){if(!this.shown&&!this.shownMin)return;if(this.stacked.curarea==this)this.stacked.curarea=null;var other=(this.shownMin&&this.stacked.curarea)? this.stacked.curarea:null;if(other)other.curHeight=this.stacked.areaBodyHeight;this.curHeight=0;this.shown=false;if(this.tristate)this.shownMin=false;if(instant){if(other)other.updateSize();this._hide()}else{if(other)other.slideSize(other.updateSize.bind(other));this.slideSize(this._hide.bind(this))}},_show:function(){if(!this.element)return;this.updateSize();if(this.stacked.options.onAreaShown)this.stacked.options.onAreaShown(this)},_showMin:function(){this.updateSize();if(this.stacked.options.onAreaShown)this.stacked.options.onAreaShown(this)},_hide:function(){if(!this.element)return;this.body.hide();this.updateSize();if(this.stacked.options.onAreaHidden)this.stacked.options.onAreaHidden(this)}});
//// JSPack file: /dxtk/tree.js
DXTK.Tree=DXTK.DnD.OrderableDropZone.extend({initialize:function(options){if(!options)options={};if(options.element){this.html=$(options.element);if(!this.html)throw(new Error('DXTK.Tree - Invalid html element option'));delete options.element}else this.html=document.createElement('div');this.html.addClassName('treeList');this.html.addClassName('dropZone');this.html.tree=this;this.children=[];DXTK.DnD.OrderableDropZone.prototype.initialize.apply(this,[Object.extend(options,{element:this.html})])},accepts:function(draggables,isDrag){if(isDrag&&!this.options.mutable)return false;for(var i=0;i<draggables.length;++i)if(!Class.kind_of(draggables[i],DXTK.TreeItem))return false;else if(isDrag&&!draggables[i].tree.options.mutable)return false;return true},accept:function(draggables,isDrag){DXTK.DnD.OrderableDropZone.prototype.accept.apply(this,[draggables]);for(var i=0;i<this.draggables.length;++i){var item=this.draggables[i];if(item.parent!=this){item.parent.children=item.parent.children.without(item);this.children.splice(i,0,item);item.parent=this;if(item.onparentchange&&isDrag)item.onparentchange(i)}else{if(item.onmove&&isDrag)item.onmove(i)}}},destroy:function(){if(this.options.onDestroy)this.options.onDestroy(this);if(this.html&&this.html.parentNode)this.html.parentNode.removeChild(this.html);while(this.children.length)this.children[0].destroy();if(this.dropZone)this.dropZone.destroy();delete this.dropZone;delete this.options;delete this.html;delete this.children}});Object.extend(DXTK.Tree,{expanderImageSize:[12,12],collapsedImage:'/dxtk/images/tree_collapsed.gif',expandedImage:'/dxtk/images/tree_expanded.gif'});DXTK.TreeItem=DXTK.DnD.Draggable.extend({initialize:function(parent,options){if(typeof(parent)!='object')throw(new Error('DXTK.TreeItem: Missing parent argument'));options=options||{};if(Class.kind_of(parent,DXTK.Tree)){this.tree=parent;options.dropZone=parent}else if(Class.kind_of(parent,DXTK.TreeItem)){this.tree=parent.tree;options.dropZone=parent.subDropZone}else throw(new Error('DXTK.TreeItem: Invalid parent argument, expecting a DXTK.Tree or DXTK.TreeItem'));this.parent=parent;this.children=[];parent.children.push(this);if(Class.kind_of(this.parent,DXTK.TreeItem))this.parent.__leafCheck();this.createHTML();DXTK.DnD.Draggable.prototype.initialize.apply(this,[options]);this.subDropZone=new DXTK.Tree.DropZone({treeitem:this,element:this.html.list});this.expanded=false;this.__isleaf=true},destroy:function(){while(this.children.length)this.children[0].destroy();if(this.parent){this.parent.children=this.parent.children.without(this);if(Class.kind_of(this.parent,DXTK.TreeItem))this.parent.__leafCheck();delete this.parent}this.subDropZone.destroy();delete this.children;delete this.subDropZone;delete this.tree;DXTK.DnD.Draggable.prototype.destroy.apply(this,[])},canDrag:function(){return this.tree.options.draggable ? true:false},createHTML:function(){this.html=Element.create('div',{className:'item'});this.html.content=this.html.appendChild(Element.create('div',{className:'content',onclick:function(e){if(this._expanderShown&&Position.within(this.html,Event.pointerX(e),Event.pointerY(e)))this.expandToggle()}.bindAsEventListener(this)}));this.html.list=this.html.appendChild(Element.create('div',{className:'children dropZone'}));this._expanderShown=false;this.element=this.html.content},_showExpander:function(){if(!this._expanderShown){this._expanderShown=true;this.html.content.style.backgroundImage='url('+(this.expanded ? DXTK.Tree.expandedImage:DXTK.Tree.collapsedImage)+')';this.html.content.style.backgroundRepeat='no-repeat';this.html.content.style.backgroundPosition='1px center';this.html.content.style.paddingLeft=(DXTK.Tree.expanderImageSize[0]+2)+'px'}},_hideExpander:function(){if(this._expanderShown){this._expanderShown=false;this.html.content.style.backgroundImage='none';this.html.content.style.paddingLeft='0px'}},collapse:function(){if(!this.expanded)return;if(!this._expanderShown)this._showExpander();this.expanded=false;this.html.list.hide();this.html.content.style.backgroundImage='url('+DXTK.Tree.collapsedImage+')'},expand:function(){if(this.expanded)return;if(!this._expanderShown)this._showExpander();this.expanded=true;this.html.list.show();this.html.content.style.backgroundImage='url('+DXTK.Tree.expandedImage+')'},expandToggle:function(){if(this.expanded)this.collapse();else this.expand()},removeFromDropZoneHTML:function(){if(this.html&&this.html.parentNode)this.html.parentNode.removeChild(this.html)},appendToDropZoneHTML:function(){this.dropZone.html.appendChild(this.html)},insertIntoDropZoneHTML:function(idx){this.dropZone.html.insertBefore(this.html,this.dropZone.draggables[idx].html)},childOf:function(item){var p=this.parent;while(p){if(p==item)return true;p=p.parent}return false},isLeaf:function(){return this.children.length ? false:true},__leafCheck:function(){var il=this.isLeaf();if(il==this.__isleaf)return;this.__isleaf=il;if(il){this._hideExpander();this.html.list.show()}else{this._showExpander();this.html.list.hide();this.collapse()}}});DXTK.Tree.DropZone=DXTK.DnD.OrderableDropZone.extend({accepts:function(draggables,isDrag){if(isDrag&&!this.options.treeitem.tree.options.mutable)return false;for(var i=0;i<draggables.length;++i)if(!Class.kind_of(draggables[i],DXTK.TreeItem))return false;else if(this.options.treeitem==draggables[i]||this.options.treeitem.childOf(draggables[i]))return false;return true},accept:function(draggables,isDrag){DXTK.DnD.OrderableDropZone.prototype.accept.apply(this,[draggables]);var treeitem=this.options.treeitem;for(var i=0;i<treeitem.subDropZone.draggables.length;++i){var item=treeitem.subDropZone.draggables[i];if(item.parent!=treeitem){item.parent.children=item.parent.children.without(item);if(Class.kind_of(item.parent,DXTK.TreeItem))item.parent.__leafCheck();treeitem.children.splice(i,0,item);item.parent=treeitem;if(Class.kind_of(item.parent,DXTK.TreeItem)){item.parent.__leafCheck();item.parent.expand()}if(item.onparentchange)item.onparentchange(i)}else{if(item.onmove&&isDrag)item.onmove(i)}}},dragEnter:function(){if(!this.draggables.length)this.html.addClassName('insertInto');DXTK.DnD.OrderableDropZone.prototype.dragEnter.apply(this,arguments)},dragLeave:function(){if(!this.draggables.length)this.html.removeClassName('insertInto');DXTK.DnD.OrderableDropZone.prototype.dragLeave.apply(this,arguments)}});
