// JavaScript Document
function initDragDrop() {
__dragX = 0; // cursor X 
__dragY = 0; // cursor Y 
__dragId = ''; // ID do el. a ser movido 
__dragging = false; // true se há um el. sendo movido 
document.body.onmousedown = __dragDown;
document.body.onmousemove = __dragMove;
document.body.onmouseup = function() { __dragging = false; };
}

function __dragMove(e) {
if(typeof __dragging == "undefined" || !__dragging) return;
e = e ? e : window.event;
__dragEl.style.left = (e.clientX - __dragX)+"px";
__dragEl.style.top = (e.clientY - __dragY)+"px";
};

function __dragDown(e) {
e = e ? e : window.event;
__dragEl = document.getElementById(__dragId) || null;
var _target = document.all ? e.srcElement : e.target;
if(!__dragEl || !(/drag/.test(_target.className))) return;
__dragX = e.clientX - __dragEl.offsetLeft;
__dragY = e.clientY - __dragEl.offsetTop;
__dragging = true;
};
