[jQuery] Keeping a hover popup in viewable region

[jQuery] Keeping a hover popup in viewable region


I have a gallery where when you hover over a thumbnail, the large
version displays parallel to it, aligned to the top. This works great
at the top of the page, but when you reach the bottom of the page,
there is a div that has position:relative, which makes it render above
the popup. Also, if you "restore down" the browser window and scroll
so that the image it as the bottom of the browser, when you hover over
it, almost all of it is being cut off.
I'm sure I can work out how to do this with javascript, but I am
curious if there is anything built-in to jQuery to help me with this.
Thanks.