function Drag(obj) { obj.onmousedown=function(ev) { var ev=ev||event; var disX=ev.clientX-obj.offsetLeft; var disY=ev.clientY-obj.offsetTop; if(obj.setCapture) { obj.setCapture(); } document.onmousemove=function(ev) { var ev=ev||event; obj.style.left=ev.clientX-disX+'px'; obj.style.top=ev.clientY-disY+'px'; } document.onmouseup=function () { document.onmousemove=null; document.onmouseup=null; if(obj.releaseCapture) { obj.releaseCapture(); } } return false; } }