var mouseLastX=0, mouseLastY=0; var posX=0, posY=0; var viewWidth = 540; var viewHeight = Element.getHeight('main'); var start=0; function scrollMouse(e){ var sbox = $('main'); var thisX = e.pageX; var thisY = e.pageY; if (mouseLastX>0) { dx = thisX - mouseLastX; posX = posX-dx; if (posX <0) posX =0; if (posX > (sbox.scrollWidth - viewWidth)) posX = sbox.scrollWidth - viewWidth; sbox.scrollLeft = posX; } if (mouseLastY>0) { dy = thisY - mouseLastY; posY = posY-dy; if (posY <0) posY =0; if (posY > (sbox.scrollHeight - viewHeight)) posY = sbox.scrollHeight - viewHeight; sbox.scrollTop = posY; }; mouseLastX = thisX; mouseLastY = thisY; return false; }; function startScrollMouse (){ start = 1; document.onmousemove= scrollMouse; return false; }; function stopScrollMouse(){ start = 0; document.onmousemove = null; mouseLastX=0; mouseLastY=0 return false; };