oDiv.onmousedown = function (ev) {
var ev = ev || window.event;
disX = ev.clientX - oDiv.offsetLeft;
disY = ev.clientY - oDiv.offsetTop;
document.onmousemove = function (ev) {
var ev = ev || window.event;
var iL = ev.clientX - disX;
var iT = ev.clientY - disY;
var maxL = document.documentElement.clientWidth - oDiv.offsetWidth;
var maxT = document.documentElement.clientHeight - oDiv.offsetHeight;
iL <= 0 && (iL = 0);
iL >= maxL && (iL = maxL);
iT <= 0 && (iT = 0);
iT >= maxT && (iT = maxT);
oDiv.style.left = iL + "px";
oDiv.style.top = iT + "px";
return false;
};
document.onmouseup = function () {
document.onmousemove = null;
document.onmouseup = null;
this.releaseCapture && this.releaseCapture();
};
this.setCapture && this.setCapture();
return false;
};
var ev = ev || window.event;
disX = ev.clientX - oDiv.offsetLeft;
disY = ev.clientY - oDiv.offsetTop;
document.onmousemove = function (ev) {
var ev = ev || window.event;
var iL = ev.clientX - disX;
var iT = ev.clientY - disY;
var maxL = document.documentElement.clientWidth - oDiv.offsetWidth;
var maxT = document.documentElement.clientHeight - oDiv.offsetHeight;
iL <= 0 && (iL = 0);
iL >= maxL && (iL = maxL);
iT <= 0 && (iT = 0);
iT >= maxT && (iT = maxT);
oDiv.style.left = iL + "px";
oDiv.style.top = iT + "px";
return false;
};
document.onmouseup = function () {
document.onmousemove = null;
document.onmouseup = null;
this.releaseCapture && this.releaseCapture();
};
this.setCapture && this.setCapture();
return false;
};