
var DnD={CODE_ACCEPT:"accept",CODE_DEFAULT:"default",CODE_REJECT:"reject",startDrag:function(drag){if(!window.drag){this.init();window.drag=drag;Event.observe(document,'mousemove',this.mousemove);Event.observe(document,'mouseup',this.mouseup);}else{alert('drag in progress');}},endDrag:function(event){Event.stopObserving(document,'mousemove',this.mousemove);Event.stopObserving(document,'mouseup',this.mouseup);var drag=window.drag;if(drag){window.drag=null;var dropzone=drag.dropzone;drag.source.endDrag(event,drag);if(dropzone){dropzone.onbeforedrag(event,drag);if(dropzone.accept(drag)){dropzone.drop(event,drag);}
dropzone.onafterdrag(event);}}},updateDrag:function(event){var drag=window.drag;if(!drag.source.onupdatedrag||(drag.source.onupdatedrag(event)!=false)){var x=Event.pointerX(event);var y=Event.pointerY(event);drag.indicator.position(x+5,y+14);Event.stop(event);}},initialized:false,init:function(){if(!this.initialized){this.mousemove=this.updateDrag.bindAsEventListener(this);this.mouseup=this.endDrag.bindAsEventListener(this);this.initialized=true;}}};DnD.Drag=Class.create();DnD.Drag.prototype={initialize:function(source,indicator,type){this.source=source;this.indicator=indicator;this.type=type;},params:{},dragged:false,dropzone:null,getParameters:function(){var params={};Object.extend(params,this.params);return params;}};DnD.Draggable=function(){};DnD.Draggable.prototype={getContentType:function(){return"ZZZZZ";},getIndicator:function(){return null;},startDrag:function(event){var type=this.getContentType();var indicator=this.getIndicator();var drag=new DnD.Drag(this,indicator,type);DnD.startDrag(drag);DnD.updateDrag(event);this.ondragstart(event,drag);if(indicator){indicator.show();}},endDrag:function(event,drag){var indicator=drag.indicator;if(indicator){indicator.hide();}
this.ondragend(event,drag);},ondragstart:function(event,drag){},ondragend:function(event,drag){}};DnD.Dropzone=function(){};DnD.Dropzone.DROP_TARGET_ID="dropTargetId";DnD.Dropzone.prototype={accept:function(drag){return this.getAcceptedTypes().indexOf(drag.type)>-1;},getAcceptedTypes:function(){return[];},getTypeMapping:function(){return{};},drop:function(event,drag){},getIconCodeForType:function(type){var types=this.getTypeMapping();if(type&&types){return types[type];}
return null;},dragEnter:function(event){var drag=window.drag;drag.dropzone=this;var icon;var indicator=drag.indicator;if(this.accept(drag)){icon=this.getIconCodeForType(drag.type);if(!indicator.hasTemplate(icon)){icon=DnD.CODE_ACCEPT;}
indicator.accept();}else{icon=DnD.CODE_REJECT;indicator.reject();}
indicator.setLeftCell(icon);},dragLeave:function(event){var drag=window.drag;drag.dropzone=null;var indicator=drag.indicator;indicator.setLeftCell(DnD.CODE_DEFAULT);indicator.leave();},onafterdrag:function(event){},onbeforedrag:function(event,drag){},ondragenter:function(event){},ondragexit:function(event){}};
