function DesktopManager()
{
	this.currentDraggableWidget = null;
	this.dragCallback = null;
	this.endDragCallback = null;
};

DesktopManager.prototype = new WebObject;

DesktopManager.prototype.beginDrag = function(widget, dragCallback, endDragCallback)
{
	this.currentDraggableWidget = widget;
	
	if(Toolkit.getBrowser() == Toolkit.INTERNET_EXPLORER)
	{
		document.onmousemove = function()
		{
			dragCallback(event.x, event.y);
		}
	} else
	{
		document.onmousemove = function(e)
		{
			dragCallback(e.clientX, e.clientY);
		}
	}
	
	document.onmouseup = function()
	{
		if(endDragCallback)
		{
			endDragCallback();
		}
		
		document.onmousemove = null;
		document.onmouseup = null;
	};
};

DesktopManager.prototype.drag = function(widget, widgetOriginX, widgetOriginY, eventOriginX, eventOriginY, newX, newY)
{
	widget.setLocation(widgetOriginX + (eventX - eventOriginX), widgetOriginY + (eventY - eventOriginY));
}; 

DesktopManager.prototype.getResizeDirection = function(widget, location, dragInsets)
{
    var direction = 0;
    
    // alert("(" + location.x + ", " + location.y + ") -> [" + dragInsets.left + ", " + dragInsets.top + ", " + dragInsets.right + ", " + dragInsets.bottom + "]");
    
    if(location.x > 0 && location.x < dragInsets.left)
    {
        direction = DesktopManager.WEST;
    } else if(location.x > widget.getWidth() - dragInsets.right && location.x < widget.getWidth())
    {
        direction = DesktopManager.EAST;
    }
    
    if(location.y > 0 && location.y < dragInsets.top)
    {
        direction |= DesktopManager.NORTH;
    } else if(location.y > widget.getHeight() - dragInsets.bottom && location.y < widget.getHeight())
    {
        direction |= DesktopManager.SOUTH;
    }
    
    return direction;
};

DesktopManager.NORTH    = 0x01;
DesktopManager.EAST     = 0x02;
DesktopManager.SOUTH    = 0x04;
DesktopManager.WEST     = 0x08;
