function down(e) {
    this.strX = e.pageX;
    this.strY = e.pageY;
    this.strL = this.offsetLeft;
    this.strT = this.offsetTop;
    if (this.setCapture) {
        this.setCapture();
        xdyEvent.on(tool, "mousemove", move);
        xdyEvent.on(tool, "mouseup", up);
    } else {
        this.MOVE = xdyEvent.processThis(move, this);
        this.UP = xdyEvent.processThis(up, this);
        xdyEvent.on(document, "mousemove", this.MOVE);
        xdyEvent.on(document, "mouseup", this.UP);
    }

    xdyEvent.fire.call(this, "xdyDragStart", e);
}

function move(e) {


    var curL = e.pageX - this.strX + this.strL;


    var curT = e.pageY - this.strY + this.strT;

     var minL = 0, minT = 0, maxL = tabBox.offsetWidth-tool.offsetWidth, maxT = tabBox.offsetHeight-tool.offsetHeight;


    curL = curL <= minL ? minL : (curL >= maxL ? maxL : curL);
    curT = curT <= minT ? minT : (curT >= maxT ? maxT : curT);
    this.style.left = curL + "px";
    this.style.top = curT + "px";

    xdyEvent.fire.call(this, "xdyDragMove", e);
}

function up(e) {
    if (this.releaseCapture) {
        this.releaseCapture();
        $event.off(tool, "mousemove", move);
        $event.off(tool, "mouseup", up);
    } else {
        $event.off(document, "mousemove", this.MOVE);
        $event.off(document, "mouseup", this.UP);
    }

    xdyEvent.fire.call(this, "xdyDragEnd", e);
}