document.onmousedown=DragSelectMouse;
document.onmouseup = new Function("bDragMouseMove=false");

function DragInit(sId, bNoMouseDown)
{
    if (!document.getElementById(sId)) return;
    document.getElementById(sId).setAttribute("Drag", true)
    if (!bNoMouseDown && !document.getElementById(sId).onmousedown) document.getElementById(sId).onmousedown = new Function("bDrag=true");
    if (!document.getElementById(sId).onmouseup) document.getElementById(sId).onmouseup = new Function("bDrag=false");
} // DragInit

var bDragMouseMove=false, bDrag=false;
var lDragX ,lDragY, lDragLeft, lDragTop;
var oDrag;

function DragMouseMove(e)
{
  if (bDragMouseMove)
  {
    oDrag.style.left = !document.all ? lDragLeft + e.clientX - lDragX  +'px': lDragLeft + event.clientX - lDragX;
    oDrag.style.top  = !document.all ? lDragTop + e.clientY - lDragY  +'px': lDragTop + event.clientY - lDragY;
    return false;
  }
} // DragMouseMove

function DragSelectMouse(e) 
{
  var oFind = !document.all ? e.target : event.srcElement;
  while (!oFind.getAttribute("Drag"))
  {
    oFind = !document.all ? oFind.parentNode : oFind.parentElement;
    if (oFind == null) return;
  }
  if (oFind.getAttribute("Drag") && bDrag)
  {
    bDragMouseMove = true;
    oDrag = oFind;
    lDragLeft = parseInt(oDrag.style.left + 0);
    lDragTop = parseInt(oDrag.style.top + 0);
    lDragX = !document.all ? e.clientX : event.clientX;
    lDragY = !document.all ? e.clientY : event.clientY;
    document.onmousemove=DragMouseMove;
    return false;
  }
} // DragSelectMouse