Drag.Move=new Class({Extends:Drag,options:{droppables:[],container:false,precalculate:false,includeMargins:true,checkDroppables:true},initialize:function(element,options){this.parent(element,options);element=this.element;this.droppables=$$(this.options.droppables);this.container=document.id(this.options.container);if(this.container&&typeOf(this.container)!="element"){this.container=document.id(this.container.getDocument().body)}if(this.options.style){if(this.options.modifiers.x=="left"&&this.options.modifiers.y=="top"){var parent=element.getOffsetParent(),styles=element.getStyles("left","top");if(parent&&(styles.left=="auto"||styles.top=="auto")){element.setPosition(element.getPosition(parent))}}if(element.getStyle("position")=="static"){element.setStyle("position","absolute")}}this.addEvent("start",this.checkDroppables,true);this.overed=null},start:function(event){if(this.container){this.options.limit=this.calculateLimit()}if(this.options.precalculate){this.positions=this.droppables.map(function(el){return el.getCoordinates()})}this.parent(event)},calculateLimit:function(){var element=this.element,container=this.container,offsetParent=document.id(element.getOffsetParent())||document.body,containerCoordinates=container.getCoordinates(offsetParent),elementMargin={},elementBorder={},containerMargin={},containerBorder={},offsetParentPadding={};["top","right","bottom","left"].each(function(pad){elementMargin[pad]=element.getStyle("margin-"+pad).toInt();elementBorder[pad]=element.getStyle("border-"+pad).toInt();containerMargin[pad]=container.getStyle("margin-"+pad).toInt();containerBorder[pad]=container.getStyle("border-"+pad).toInt();offsetParentPadding[pad]=offsetParent.getStyle("padding-"+pad).toInt()},this);var width=element.offsetWidth+elementMargin.left+elementMargin.right,height=element.offsetHeight+elementMargin.top+elementMargin.bottom,left=0,top=0,right=containerCoordinates.right-containerBorder.right-width,bottom=containerCoordinates.bottom-containerBorder.bottom-height;if(this.options.includeMargins){left+=elementMargin.left;top+=elementMargin.top}else{right+=elementMargin.right;bottom+=elementMargin.bottom}if(element.getStyle("position")=="relative"){var coords=element.getCoordinates(offsetParent);coords.left-=element.getStyle("left").toInt();coords.top-=element.getStyle("top").toInt();left-=coords.left;top-=coords.top;if(container.getStyle("position")!="relative"){left+=containerBorder.left;top+=containerBorder.top}right+=elementMargin.left-coords.left;bottom+=elementMargin.top-coords.top;if(container!=offsetParent){left+=containerMargin.left+offsetParentPadding.left;top+=((Browser.ie6||Browser.ie7)?0:containerMargin.top)+offsetParentPadding.top}}else{left-=elementMargin.left;top-=elementMargin.top;if(container!=offsetParent){left+=containerCoordinates.left+containerBorder.left;top+=containerCoordinates.top+containerBorder.top}}return{x:[left,right],y:[top,bottom]}},getDroppableCoordinates:function(element){var position=element.getCoordinates();if(element.getStyle("position")=="fixed"){var scroll=window.getScroll();position.left+=scroll.x;position.right+=scroll.x;position.top+=scroll.y;position.bottom+=scroll.y}return position},checkDroppables:function(){var overed=this.droppables.filter(function(el,i){el=this.positions?this.positions[i]:this.getDroppableCoordinates(el);var now=this.mouse.now;return(now.x>el.left&&now.x<el.right&&now.y<el.bottom&&now.y>el.top)},this).getLast();if(this.overed!=overed){if(this.overed){this.fireEvent("leave",[this.element,this.overed])}if(overed){this.fireEvent("enter",[this.element,overed])}this.overed=overed}},drag:function(event){this.parent(event);if(this.options.checkDroppables&&this.droppables.length){this.checkDroppables()}},stop:function(event){this.checkDroppables();this.fireEvent("drop",[this.element,this.overed,event]);this.overed=null;return this.parent(event)}});Element.implement({makeDraggable:function(options){var drag=new Drag.Move(this,options);this.store("dragger",drag);return drag}});