if(typeof Effect=="undefined"){
throw ("dragdrop.js requires including script.aculo.us' effects.js library");
}
var Droppables={drops:[],remove:function(_1){
this.drops=this.drops.reject(function(d){
return d.element==$(_1);
});
},add:function(_3){
_3=$(_3);
var _4=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});
if(_4.containment){
_4._containers=[];
var _5=_4.containment;
if((typeof _5=="object")&&(_5.constructor==Array)){
_5.each(function(c){
_4._containers.push($(c));
});
}else{
_4._containers.push($(_5));
}
}
if(_4.accept){
_4.accept=[_4.accept].flatten();
}
Element.makePositioned(_3);
_4.element=_3;
this.drops.push(_4);
},findDeepestChild:function(_7){
deepest=_7[0];
for(i=1;i<_7.length;++i){
if(Element.isParent(_7[i].element,deepest.element)){
deepest=_7[i];
}
}
return deepest;
},isContained:function(_8,_9){
var _a;
if(_9.tree){
_a=_8.treeNode;
}else{
_a=_8.parentNode;
}
return _9._containers.detect(function(c){
return _a==c;
});
},isAffected:function(_c,_d,_e){
return ((_e.element!=_d)&&((!_e._containers)||this.isContained(_d,_e))&&((!_e.accept)||(Element.classNames(_d).detect(function(v){
return _e.accept.include(v);
})))&&Position.within(_e.element,_c[0],_c[1]));
},deactivate:function(_10){
if(_10.hoverclass){
Element.removeClassName(_10.element,_10.hoverclass);
}
this.last_active=null;
},activate:function(_11){
if(_11.hoverclass){
Element.addClassName(_11.element,_11.hoverclass);
}
this.last_active=_11;
},show:function(_12,_13){
if(!this.drops.length){
return;
}
var _14=[];
if(this.last_active){
this.deactivate(this.last_active);
}
this.drops.each(function(_15){
if(Droppables.isAffected(_12,_13,_15)){
_14.push(_15);
}
});
if(_14.length>0){
drop=Droppables.findDeepestChild(_14);
Position.within(drop.element,_12[0],_12[1]);
if(drop.onHover){
drop.onHover(_13,drop.element,Position.overlap(drop.overlap,drop.element));
}
Droppables.activate(drop);
}
},fire:function(_16,_17){
if(!this.last_active){
return;
}
Position.prepare();
if(this.isAffected([Event.pointerX(_16),Event.pointerY(_16)],_17,this.last_active)){
if(this.last_active.onDrop){
this.last_active.onDrop(_17,this.last_active.element,_16);
}
}
},reset:function(){
if(this.last_active){
this.deactivate(this.last_active);
}
}};
var Draggables={drags:[],observers:[],register:function(_18){
if(this.drags.length==0){
this.eventMouseUp=this.endDrag.bindAsEventListener(this);
this.eventMouseMove=this.updateDrag.bindAsEventListener(this);
this.eventKeypress=this.keyPress.bindAsEventListener(this);
Event.observe(document,"mouseup",this.eventMouseUp);
Event.observe(document,"mousemove",this.eventMouseMove);
Event.observe(document,"keypress",this.eventKeypress);
}
this.drags.push(_18);
},unregister:function(_19){
this.drags=this.drags.reject(function(d){
return d==_19;
});
if(this.drags.length==0){
Event.stopObserving(document,"mouseup",this.eventMouseUp);
Event.stopObserving(document,"mousemove",this.eventMouseMove);
Event.stopObserving(document,"keypress",this.eventKeypress);
}
},activate:function(_1b){
if(_1b.options.delay){
this._timeout=setTimeout(function(){
Draggables._timeout=null;
window.focus();
Draggables.activeDraggable=_1b;
}.bind(this),_1b.options.delay);
}else{
window.focus();
this.activeDraggable=_1b;
}
},deactivate:function(){
this.activeDraggable=null;
},updateDrag:function(_1c){
if(!this.activeDraggable){
return;
}
var _1d=[Event.pointerX(_1c),Event.pointerY(_1c)];
if(this._lastPointer&&(this._lastPointer.inspect()==_1d.inspect())){
return;
}
this._lastPointer=_1d;
this.activeDraggable.updateDrag(_1c,_1d);
},endDrag:function(_1e){
if(this._timeout){
clearTimeout(this._timeout);
this._timeout=null;
}
if(!this.activeDraggable){
return;
}
this._lastPointer=null;
this.activeDraggable.endDrag(_1e);
this.activeDraggable=null;
},keyPress:function(_1f){
if(this.activeDraggable){
this.activeDraggable.keyPress(_1f);
}
},addObserver:function(_20){
this.observers.push(_20);
this._cacheObserverCallbacks();
},removeObserver:function(_21){
this.observers=this.observers.reject(function(o){
return o.element==_21;
});
this._cacheObserverCallbacks();
},notify:function(_23,_24,_25){
if(this[_23+"Count"]>0){
this.observers.each(function(o){
if(o[_23]){
o[_23](_23,_24,_25);
}
});
}
if(_24.options[_23]){
_24.options[_23](_24,_25);
}
},_cacheObserverCallbacks:function(){
["onStart","onEnd","onDrag"].each(function(_27){
Draggables[_27+"Count"]=Draggables.observers.select(function(o){
return o[_27];
}).length;
});
}};
var Draggable=Class.create();
Draggable._dragging={};
Draggable.prototype={initialize:function(_29){
var zdd=zk.ie&&arguments[1]&&arguments[1].z_dragdrop;
var _2b={handle:false,reverteffect:function(_2c,_2d,_2e){
var _2f=_2c.style.position;
var dur=Math.sqrt(Math.abs(_2d^2)+Math.abs(_2e^2))*0.02;
new Effect.Move(_2c,{x:-_2e,y:-_2d,duration:dur,queue:{scope:"_draggable",position:"end"}});
if(zdd&&_2f!="absolute"&&_2f!="relative"){
setTimeout(function(){
var p=_2c.parentNode;
var n=_2c.nextSibling;
Element.remove(_2c);
_2c.style.position=_2f;
if(n){
p.insertBefore(_2c,n);
}else{
p.appendChild(_2c);
}
},dur*1000+10);
}
},endeffect:function(_33){
var _34=typeof _33._opacity=="number"?_33._opacity:1;
new Effect.Opacity(_33,{duration:0.2,from:0.7,to:_34,queue:{scope:"_draggable",position:"end"},afterFinish:function(){
Draggable._dragging[_33]=false;
}});
},zindex:1000,revert:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};
if(arguments[1]&&typeof arguments[1].endeffect=="undefined"){
Object.extend(_2b,{starteffect:function(_35){
_35._opacity=Element.getOpacity(_35);
Draggable._dragging[_35]=true;
new Effect.Opacity(_35,{duration:0.2,from:_35._opacity,to:0.7});
}});
}
var _36=Object.extend(_2b,arguments[1]||{});
this.element=$(_29);
if(_36.handle&&(typeof _36.handle=="string")){
var h=Element.childrenWithClassName(this.element,_36.handle,true);
if(h.length>0){
this.handle=h[0];
}
}
if(!this.handle){
this.handle=$(_36.handle);
}
if(!this.handle){
this.handle=this.element;
}
if(_36.scroll&&!_36.scroll.scrollTo&&!_36.scroll.outerHTML){
_36.scroll=$(_36.scroll);
this._isScrollChild=Element.childOf(this.element,_36.scroll);
}
if(!_36.z_dragdrop){
Element.makePositioned(this.element);
}
this.delta=this.currentDelta();
this.options=_36;
this.dragging=false;
this.eventMouseDown=this.initDrag.bindAsEventListener(this);
Event.observe(this.handle,"mousedown",this.eventMouseDown);
Draggables.register(this);
},destroy:function(){
Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);
Draggables.unregister(this);
},currentDelta:function(){
return ([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")]);
},initDrag:function(_38){
if(typeof Draggable._dragging[this.element]!="undefined"&&Draggable._dragging[this.element]){
return;
}
if(Event.isLeftClick(_38)){
var src=Event.element(_38);
if(src.tagName&&(src.tagName=="INPUT"||src.tagName=="SELECT"||src.tagName=="OPTION"||src.tagName=="BUTTON"||src.tagName=="TEXTAREA")){
return;
}
var _3a=[Event.pointerX(_38),Event.pointerY(_38)];
var pos=Position.cumulativeOffset(this.element);
this.offset=[0,1].map(function(i){
return (_3a[i]-pos[i]);
});
Draggables.activate(this);
Event.stop(_38);
zkau.autoZIndex(src,false,true);
}
},startDrag:function(_3d){
this.dragging=true;
if(this.options.ghosting){
var _3e=true;
if(typeof this.options.ghosting=="function"){
_3e=this.options.ghosting(this,true);
}
if(_3e){
this._clone=this.element.cloneNode(true);
this.z_orgpos=this.element.style.position;
if(this.z_orgpos!="absolute"){
Position.absolutize(this.element);
}
this.element.parentNode.insertBefore(this._clone,this.element);
}
}
if(this.options.zindex){
this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);
this.element.style.zIndex=this.options.zindex;
}
if(this.options.scroll){
if(this.options.scroll==window){
var _3f=this._getWindowScroll(this.options.scroll);
this.originalScrollLeft=_3f.left;
this.originalScrollTop=_3f.top;
}else{
this.originalScrollLeft=this.options.scroll.scrollLeft;
this.originalScrollTop=this.options.scroll.scrollTop;
}
}
Draggables.notify("onStart",this,_3d);
if(this.options.starteffect){
this.options.starteffect(this.element);
}
},updateDrag:function(_40,_41){
if(!this.dragging){
this.startDrag(_40);
}
Position.prepare();
Droppables.show(_41,this.element);
Draggables.notify("onDrag",this,_40);
this.draw(_41);
if(this.options.change){
this.options.change(this,_41);
}
if(this.options.scroll){
this.stopScrolling();
var p;
if(this.options.scroll==window){
with(this._getWindowScroll(this.options.scroll)){
p=[left,top,left+width,top+height];
}
}else{
p=Position.page(this.options.scroll);
p[0]+=this.options.scroll.scrollLeft;
p[1]+=this.options.scroll.scrollTop;
p[0]+=(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0);
p[1]+=(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0);
p.push(p[0]+this.options.scroll.offsetWidth);
p.push(p[1]+this.options.scroll.offsetHeight);
}
var _43=[0,0];
if(_41[0]<(p[0]+this.options.scrollSensitivity)){
_43[0]=_41[0]-(p[0]+this.options.scrollSensitivity);
}
if(_41[1]<(p[1]+this.options.scrollSensitivity)){
_43[1]=_41[1]-(p[1]+this.options.scrollSensitivity);
}
if(_41[0]>(p[2]-this.options.scrollSensitivity)){
_43[0]=_41[0]-(p[2]-this.options.scrollSensitivity);
}
if(_41[1]>(p[3]-this.options.scrollSensitivity)){
_43[1]=_41[1]-(p[3]-this.options.scrollSensitivity);
}
this.startScrolling(_43);
}
if(navigator.appVersion.indexOf("AppleWebKit")>0){
window.scrollBy(0,0);
}
Event.stop(_40);
},finishDrag:function(_44,_45){
this.dragging=false;
if(this.options.ghosting){
var _46=true;
if(typeof this.options.ghosting=="function"){
_46=this.options.ghosting(this,false);
}
if(_46){
if(this.z_orgpos!="absolute"){
Position.relativize(this.element);
this.element.style.position=this.z_orgpos;
}
Element.remove(this._clone);
this._clone=null;
}
}
if(_45){
Droppables.fire(_44,this.element);
}
Draggables.notify("onEnd",this,_44);
var _47=[Event.pointerX(_44),Event.pointerY(_44)];
var _48=this.options.revert;
if(_48&&typeof _48=="function"){
_48=_48(this.element,_47);
}
var d=this.currentDelta();
if(_48&&this.options.reverteffect){
this.options.reverteffect(this.element,d[1]-this.delta[1],d[0]-this.delta[0]);
}else{
this.delta=d;
}
if(this.options.zindex){
this.element.style.zIndex=this.originalZ;
}
if(this.options.endeffect){
this.options.endeffect(this.element,_47);
}
Draggables.deactivate(this);
Droppables.reset();
},keyPress:function(_4a){
if(_4a.keyCode!=Event.KEY_ESC){
return;
}
this.finishDrag(_4a,false);
Event.stop(_4a);
},endDrag:function(_4b){
if(!this.dragging){
return;
}
this.stopScrolling();
this.finishDrag(_4b,true);
Event.stop(_4b);
},draw:function(_4c){
var pos=Position.cumulativeOffset(this.element);
if(this.options.ghosting){
var r=Position.realOffset(this.element);
window.status=r.inspect();
pos[0]+=r[0]-Position.deltaX;
pos[1]+=r[1]-Position.deltaY;
}
var d=this.currentDelta();
pos[0]-=d[0];
pos[1]-=d[1];
if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){
pos[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;
pos[1]-=this.options.scroll.scrollTop-this.originalScrollTop;
}
var p=[0,1].map(function(i){
return (_4c[i]-pos[i]-this.offset[i]);
}.bind(this));
if(this.options.snap){
if(typeof this.options.snap=="function"){
p=this.options.snap(p[0],p[1],this);
}else{
if(this.options.snap instanceof Array){
p=p.map(function(v,i){
return Math.round(v/this.options.snap[i])*this.options.snap[i];
}.bind(this));
}else{
p=p.map(function(v){
return Math.round(v/this.options.snap)*this.options.snap;
}.bind(this));
}
}
}
if(this.z_scrl){
p[0]-=this.z_scrl[0];
p[1]-=this.z_scrl[1];
}
var _55=this.element.style;
if((!this.options.constraint)||(this.options.constraint=="horizontal")){
_55.left=p[0]+"px";
}
if((!this.options.constraint)||(this.options.constraint=="vertical")){
_55.top=p[1]+"px";
}
if(_55.visibility=="hidden"){
_55.visibility="";
}
},stopScrolling:function(){
if(this.scrollInterval){
clearInterval(this.scrollInterval);
this.scrollInterval=null;
Draggables._lastScrollPointer=null;
}
},startScrolling:function(_56){
if(!(_56[0]||_56[1])){
return;
}
this.scrollSpeed=[_56[0]*this.options.scrollSpeed,_56[1]*this.options.scrollSpeed];
this.lastScrolled=new Date();
this.scrollInterval=setInterval(this.scroll.bind(this),10);
},scroll:function(){
var _57=new Date();
var _58=_57-this.lastScrolled;
this.lastScrolled=_57;
if(this.options.scroll==window){
with(this._getWindowScroll(this.options.scroll)){
if(this.scrollSpeed[0]||this.scrollSpeed[1]){
var d=_58/1000;
this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1]);
}
}
}else{
this.options.scroll.scrollLeft+=this.scrollSpeed[0]*_58/1000;
this.options.scroll.scrollTop+=this.scrollSpeed[1]*_58/1000;
}
Position.prepare();
Droppables.show(Draggables._lastPointer,this.element);
Draggables.notify("onDrag",this);
if(this._isScrollChild){
Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);
Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*_58/1000;
Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*_58/1000;
if(Draggables._lastScrollPointer[0]<0){
Draggables._lastScrollPointer[0]=0;
}
if(Draggables._lastScrollPointer[1]<0){
Draggables._lastScrollPointer[1]=0;
}
this.draw(Draggables._lastScrollPointer);
}
if(this.options.change){
this.options.change(this);
}
},_getWindowScroll:function(w){
var T,L,W,H;
with(w.document){
if(w.document.documentElement&&documentElement.scrollTop){
T=documentElement.scrollTop;
L=documentElement.scrollLeft;
}else{
if(w.document.body){
T=body.scrollTop;
L=body.scrollLeft;
}
}
if(w.innerWidth){
W=w.innerWidth;
H=w.innerHeight;
}else{
if(w.document.documentElement&&documentElement.clientWidth){
W=documentElement.clientWidth;
H=documentElement.clientHeight;
}else{
W=body.offsetWidth;
H=body.offsetHeight;
}
}
}
return {top:T,left:L,width:W,height:H};
}};
Element.isParent=function(_5c,_5d){
if(!_5c.parentNode||_5c==_5d){
return false;
}
if(_5c.parentNode==_5d){
return true;
}
return Element.isParent(_5c.parentNode,_5d);
};
Element.findChildren=function(_5e,_5f,_60,_61){
if(!_5e.hasChildNodes()){
return null;
}
_61=_61.toUpperCase();
if(_5f){
_5f=[_5f].flatten();
}
var _62=[];
$A(_5e.childNodes).each(function(e){
if(e.tagName&&e.tagName.toUpperCase()==_61&&(!_5f||(Element.classNames(e).detect(function(v){
return _5f.include(v);
})))){
_62.push(e);
}
if(_60){
var _65=Element.findChildren(e,_5f,_60,_61);
if(_65){
_62.push(_65);
}
}
});
return (_62.length>0?_62.flatten():[]);
};
Element.offsetSize=function(_66,_67){
if(_67=="vertical"||_67=="height"){
return zk.offsetHeight(_66);
}else{
return zk.offsetWidth(_66);
}
};


