var objectToMove; var drag = false; window.document.onmousemove = moveObject; function ObjectToMove(htmlObject, mouseX, mouseY) { this.htmlObject = htmlObject; this.mouseX = mouseX; this.mouseY = mouseY; var position = getPosition(htmlObject); this.mouseX = mouseX - position.x; this.mouseY = mouseY - position.y; } function dragObject(event) { if (objectToMove == null) { event = event ? event : window.event; var target = event.target ? event.target : event.srcElement; while ( (!target.id || target.id == "virtualWindowHeader" || target.id == "virtualWindowLabel" || target.id == "virtualWindowContent" || target.id == "virtualMessageLabel" ) && target != null) { target = target.parentNode; } objectToMove = new ObjectToMove(target, event.clientX, event.clientY); var dragDropDiv = document.createElement("div"); var dragDropDivWidth = 0; var dragDropDivHeight = 0; if(!document.all) { dragDropDivWidth = document.body.offsetWidth; dragDropDivHeight = document.body.offsetHeight; } else { dragDropDivWidth = document.body.scrollWidth; dragDropDivHeight = document.body.scrollHeight; } dragDropDiv.setAttribute("style","cursor: move; width: " + dragDropDivWidth + "px; height: " + dragDropDivHeight + "px; position: absolute; top: 0px; left: 0px; z-index: 16;"); dragDropDiv.setAttribute("id", "dragDropDiv"); document.body.appendChild(dragDropDiv); if (document.all) { dragDropDiv.style.position = "absolute"; dragDropDiv.style.left = "0px"; dragDropDiv.style.top = "0px"; dragDropDiv.style.width = dragDropDivWidth + "px"; dragDropDiv.style.height = dragDropDivHeight + "px"; dragDropDiv.style.zIndex = 16; dragDropDiv.style.cursor = "move"; } dragDropDiv.onmouseup = dropObject; stopEventBubbling(event); } return false; } function moveObject(event) { if (objectToMove != null) { event = event ? event : window.event; var positionX = event.clientX; var positionY = event.clientY; positionX = positionX - (objectToMove.mouseX); positionY = positionY - (objectToMove.mouseY); objectToMove.htmlObject.style.left = Math.max(0, positionX) + "px"; objectToMove.htmlObject.style.top = Math.max(0, positionY) + "px"; } } function dropObject(event) { if (objectToMove != null) { event = event ? event : window.event; objectToMove = null; delete objectToMove; var dragDropDiv = document.getElementById("dragDropDiv"); if (dragDropDiv) { dragDropDiv.parentNode.removeChild(dragDropDiv); } } return false; }