<img src="http://javascript.ru/forum/images/ca_serenity/misc/logo.gif" id="id" alt="" />
<script type="text/javascript">
!function(id, x, y, drag) {
var scroll = {
left: function(event) {
return event.clientX + document.body.scrollLeft;
},
top: function(event) {
return event.clientY + document.body.scrollTop;
}
};
id.style.cssText = "cursor: move; position: absolute; left: 0px; top: 0px";
id.onmousedown = function(event){
event = event || window.event;
x = scroll.left(event) - parseInt(id.style.left);
y = scroll.top(event) - parseInt(id.style.top);
drag = 1;
};
document.onmouseup = function() {
drag = 0;
};
document.onmousemove = function(event) {
event = event || window.event;
if(drag) {
id.style.left = scroll.left(event) - x;
id.style.top = scroll.top(event) - y;
}
};
}(document.getElementById('id'), 0, 0, 0);
</script>