
function Tool_Widget(htmlId,serverId){this.toolManager=null;this.targetWidget=null;this.superclass=Widget_Base;this.superclass(htmlId,serverId);var me=this;this.htmlObj=this.containerObj;this.init=function(){if(this.htmlObj){addEvent(this.htmlObj,'click',this.select,false);return true;}else{return false;}}
this.addTargetWidget=function(widget){this.targetWidget=widget;}
this.init();}
function Box_Tool_Widget(htmlId,serverId){this.superclass=Tool_Widget;this.superclass(htmlId,serverId);var me=this;this.addTargetWidget=function(widget){this.targetWidget=widget;this.box=new Box(this.targetWidget.containerObj);}}
function Drag(targetObj){this.firstX=null;this.firstY=null;this.lastX=null;this.lastY=null;this.currentTargetLeftPos=null;this.currentTargetTopPos=null;this.ll=null;this.rr=null;this.bb=null;this.tt=null;this.targetObj=targetObj;this.mouseDown=function(e){xyArray=findXYPos(e);this.currentTargetLeftPos=DL_GetElementLeft(this.targetObj);this.currentTargetTopPos=DL_GetElementTop(this.targetObj);this.firstX=xyArray[0]-this.currentTargetLeftPos;this.firstY=xyArray[1]-this.currentTargetTopPos;}
this.mouseMove=function(e){xyArray=findXYPos(e);this.currentTargetLeftPos=DL_GetElementLeft(this.targetObj);this.currentTargetTopPos=DL_GetElementTop(this.targetObj);this.lastX=xyArray[0]-this.currentTargetLeftPos;this.lastY=xyArray[1]-this.currentTargetTopPos;}
this.mouseUp=function(e){if(this.lastX==null||this.lastY==null){this.lastX=this.firstX;this.lastY=this.firstY;}
this.ll=min(this.lastX,this.firstX);this.tt=min(this.lastY,this.firstY);this.rr=max(this.lastX,this.firstX);this.bb=max(this.lastY,this.firstY);}
this.getLastCoords=function(){coords=Array(this.ll,this.tt,this.rr,this.bb);this.reset();return coords;}
this.reset=function(){this.firstX=null;this.firstY=null;this.lastX=null;this.lastY=null;this.currentTargetLeftPos=null;this.currentTargetTopPos=null;this.ll=null;this.rr=null;this.bb=null;this.tt=null;}}
function Box(targetObj){var me=this;this.boxDiv=document.createElement('div');this.boxDiv.oncontextmenu=function(){return false;};this.boxDiv.style.position='absolute';this.boxDiv.style.display='none';this.boxDiv.style.border='1px dashed #000000';this.boxDiv.style.margin='0px';this.boxDiv.style.padding='0px';this.boxDiv.style.lineHeight='0';this.boxDiv.style.background='#D63022';this.boxDiv.style.opacity='0.50';this.boxDiv.style.filter='alpha(opacity=50)';targetObj.appendChild(this.boxDiv);this.targetObj=targetObj;this.drag=new Drag(this.targetObj);this.startBox=function(e){this.drag.mouseDown(e);}
this.moveBox=function(e){this.drag.mouseMove(e);this.boxDiv.style.left=min(this.drag.firstX,this.drag.lastX)+'px';this.boxDiv.style.top=min(this.drag.firstY,this.drag.lastY)+'px';this.boxDiv.style.width=max(this.drag.lastX,this.drag.firstX)-min(this.drag.lastX,this.drag.firstX)+'px';this.boxDiv.style.height=max(this.drag.lastY,this.drag.firstY)-min(this.drag.lastY,this.drag.firstY)+'px';this.boxDiv.style.display='';}
this.stopBox=function(e){this.boxDiv.style.display='none';this.drag.mouseUp(e);}
this.getLastCoords=function(){return this.drag.getLastCoords();}
this.reset=function(){this.drag.reset();}}