var useDragAndDrop=true;

drag = 0; // starts drag operation
move = 0; // set to 1 if moving
overText=0; // allows for text selection on dragged object

// ************** Drag and Drop ***************
function initDrag()
{
	window.document.onmousemove = mouseMoveForDrag
	window.document.onmousedown = mouseDown
	window.document.onmouseup = mouseUp
	window.document.ondragstart = mouseStop
}

function mouseDown()
{
	if (drag==1 && overText==0)
	{
		clickleft = window.event.x - parseInt(dragObj.style.left)
		clicktop = window.event.y - parseInt(dragObj.style.top)
		//dragObj.style.zIndex += 1
		move = 1
	}
}

function mouseStop()
{
	window.event.returnValue = false
}

function mouseMoveForDrag()
{
	if (move)
	{
		if (window.event.x - clickleft > 0) dragObj.style.left = window.event.x - clickleft;
			else move=0;
		if (window.event.y - clicktop > 0) dragObj.style.top = window.event.y - clicktop;
			else move=0;
	}
}

function mouseUp()
{
	//	if (typeof(dragObj) != "undefined" && dragObj.id=="dragDiv" && typeof(endDragAction)!="undefined") endDragAction();
	//if (typeof(endDragAction)!="undefined") endDragAction();
	move = 0;
}

initDrag()
