
function WBEDragDropManager()
{this.object;this.w_helper=new WBEJsHelper();this.mouseXY;this.isMoving=false;this.startValues=new Object();this.movingValues=new Object();this.endValues=new Object();this.zIndex=0;this.type=0;this.MinOffSet=10;this.yRefCoord=0;this.xRefCoord=0;this.doAutoScroll=false;this.setZoneMoving=function(){this.type=0;};this.setXYMoving=function(){this.type=1;};this.setResizing=function(){this.type=2;};this.continueWithEvents=function(event){if(window.event){window.event.cancelBubble=true;window.event.returnValue=false;}else if(event){event.preventDefault();};};this.checkMinOffSet=function(event,mouseXY){this.continueWithEvents(event);return((this.startValues.cursorX-this.MinOffSet)<mouseXY.x&&mouseXY.x<(this.startValues.cursorX+this.MinOffSet)&&(this.startValues.cursorY-this.MinOffSet)<mouseXY.y&&mouseXY.y<(this.startValues.cursorY+this.MinOffSet));};this.start=function(event,id)
{if(id){this.object=document.getElementById(id);}else{if(window.event)
this.object=window.event.srcElement;else if(event.target)
this.object=event.target;if(this.object.nodeType==3)
this.object=this.object.parentNode;}
this.movingValues.movingObj=new WBEDivManager(this.object.id);this.continueWithEvents(event);this.mouseXY=this.w_helper.getMouseXY(event);this.resetValues();if(this.zIndex==0)this.zIndex=this.w_helper.getMaxZindex();this.object.style.zIndex=this.zIndex++;this.isMoving=false;};this.resetValues=function(){this.movingValues.movingObj=new WBEDivManager(this.object.id);if(this.mouseXY){this.startValues.cursorX=this.mouseXY.x;this.startValues.cursorY=this.mouseXY.y;this.endValues.left=this.mouseXY.x;this.endValues.top=this.mouseXY.y;}
this.startValues.x=(parseInt(this.movingValues.movingObj.x0,10)||0);this.startValues.y=(parseInt(this.movingValues.movingObj.y0,10)||0);this.startValues.z=this.movingValues.movingObj.div.style.zIndex;this.startValues.top=(parseInt(this.object.offsetTop,10)||0);this.startValues.left=(parseInt(this.object.offsetLeft,10)||0);this.startValues.h=this.movingValues.movingObj.h;this.startValues.w=this.movingValues.movingObj.w;}
this.move=function(event)
{this.mouseXY=this.w_helper.getMouseXY(event);if(this.doAutoScroll)
this.w_helper.doPageScroll(this.mouseXY);this.continueWithEvents(event);switch(this.type)
{case 0:if(this.mouseXY.x<0||this.mouseXY.y<0)return;this.movingValues.movingObj.moveToXY(this.mouseXY.x+3,this.mouseXY.y+3);break;case 1:if(this.mouseXY.x<0||this.mouseXY.y<0)return;this.movingValues.movingObj.moveToXY(this.startValues.left+(this.mouseXY.x-this.startValues.cursorX),this.startValues.top+(this.mouseXY.y-this.startValues.cursorY));break;case 2:this.movingValues.movingObj.w=100+(this.mouseXY.x-this.startValues.cursorX);this.movingValues.movingObj.h=100+(this.mouseXY.y-this.startValues.cursorY);if(this.movingValues.movingObj.w<100)this.movingValues.movingObj.w=null;if(this.movingValues.movingObj.h<100)this.movingValues.movingObj.h=null;this.movingValues.movingObj.resize(this.movingValues.movingObj.w,this.movingValues.movingObj.h);break;}}
this.stop=function(event){this.mouseXY=this.w_helper.getMouseXY(event);this.isMoving=false;}
this.reset=function(){this.object=null;}
this.manageMouseMoveHandler=function(handler,remove){this.w_helper.handleEvent(document,"mousemove",handler,remove);};this.manageMouseUpHandler=function(handler,remove){this.w_helper.handleEvent(document,"mouseup",handler,remove);};};