// Movable div

//<![CDATA[



function DivMover()
{
	this.dragObj = new Object();
	this.dragObj.zIndex = 0;



	poller.register(this,EVENT_HOVER|EVENT_LEFTUP|EVENT_LEFTDOWN);


}

var divmover = new DivMover;

DivMover.prototype.handler = function(event,type)
{
	switch(type)
	{
		case EVENT_LEFTDOWN:


		break;
		case EVENT_HOVER:
			this.dragGo(event);
		break;
		case EVENT_LEFTUP:
			this.dragStop(event);
		break;

	}


}
DivMover.prototype.dragStart = function(event, id) {

	var el;
	var x, y;

	poller.nodefault(event);
	this.drag = 1;

	// If an element id was given, find it. Otherwise use the element being
	// clicked on.

	if (id)
	this.dragObj.elNode = getObj(id);
	else {


		this.dragObj.elNode = event.target;

		// If this is a text node, use its parent element.

		if (this.dragObj.elNode.nodeType == 3)
		this.dragObj.elNode = dragObj.elNode.parentNode;
	}

	// Get cursor position with respect to the page.

	x=poller.x;
	y=poller.y;

	// Save starting positions of cursor and element.

	this.dragObj.cursorStartX = x;
	this.dragObj.cursorStartY = y;
	this.dragObj.zIndex = 1000;
	this.dragObj.elStartLeft  = parseInt(this.dragObj.elNode.style.left, 10);
	this.dragObj.elStartTop   = parseInt(this.dragObj.elNode.style.top,  10);

	if (isNaN(this.dragObj.elStartLeft)) this.dragObj.elStartLeft = 0;
	if (isNaN(this.dragObj.elStartTop))  this.dragObj.elStartTop  = 0;

	// Update elements z-index.

	this.dragObj.elNode.style.zIndex = ++this.dragObj.zIndex;

	// Capture mousemove and mouseup events on the page.


}

DivMover.prototype.dragGo = function(event) {

	if(!this.drag) return;
	var x, y;

	// Get cursor position with respect to the page.

	x=poller.x;
	y=poller.y;

	// Move drag element by the same amount the cursor has moved.

	this.dragObj.elNode.style.left = (this.dragObj.elStartLeft + x - this.dragObj.cursorStartX) + "px";
	this.dragObj.elNode.style.top  = (this.dragObj.elStartTop  + y - this.dragObj.cursorStartY) + "px";


}

DivMover.prototype.dragStop = function(event) {

	// Stop capturing mousemove and mouseup events.
	this.drag = 0;
}


//]]>
