function Moveable(obj){

    obj.setLeft = function(value){
        var width = obj.offsetWidth;
        var parent = obj.parentNode;
        var parentLeft = parent.offsetLeft;
        var parentWidth = parent.offsetWidth;
        var parentRight = parentLeft + parentWidth;
        if(value < parentLeft){
            obj.left = parentLeft;
            obj.style.left = obj.left + "px";
            return false;
        }
        if((value + width) > parentRight){
            obj.left = parentRight - width;
            obj.style.left = obj.left + "px";
            return false;
        }
        obj.left = value;
        obj.style.left = value + "px";
        return true;
    };

    obj.setTop = function(value){
        var height = obj.offsetHeight;
        var parent = obj.parentNode;
        var parentTop = parent.offsetTop;
        var parentHeight = parent.offsetHeight;
        var parentBottom = parentTop + parentHeight;
        if(value < parentTop){
            obj.top = parentTop;
            obj.style.top = obj.top + "px";
            return false;
        }
        if((value + height) > parentBottom){
            obj.top = parentBottom - height;
            obj.style.top = obj.top + "px";
            return false;
        }
        obj.top = value;
        obj.style.top = value + "px";
        return true;
    };

    var move = function(obj){
        if(obj.isMaximizeable() && obj.isMaximized()){
            return;
        }
        var mouseDiffs = System.display.getMouseChange();
        var objLeft = obj.offsetLeft;
        var objTop = obj.offsetTop;
        obj.setLeft(objLeft + mouseDiffs[0]);
        obj.setTop(objTop + mouseDiffs[1]);
        obj.validate();
    };

    var addMove = function(){
        var mFunc = function(){ move(obj);};
        document.addSubscriber("onmousemove",mFunc);
        var removeFunc = function(){
            document.removeSubscriber(mFunc,"onmousemove",false);
            document.removeSubscriber(removeFunc,"onmouseup",false);
        };
        document.addSubscriber("onmouseup",removeFunc);
    };

    obj.addOnMove = function(action){ obj.addSubscriber("move", action); };
    obj.addOnMove(addMove);

    return obj;

}

