Dragging image within constrained area

Here is an example of what I want to do:

http://wendtgallery.com/wendtgallery/artists/danmccaw/

I’m talking about when you’re looking at the zoomed in image… you can drag it around within the box, you can’t drag it past the box. Does anyone have any suggestions on where I can find out how to do this? The dragging part I can do… but when it comes to constraining the drag to within a certain area… ???