UI / Utility / Position

UI / Utility / Position

Hello, everybody!

I'm a n00b with jQuery, finding my way through things slowly. Just as I started to think I understood things, I started wading into the jQuery UI territory and well, I'm confused again. But let me begin with my problem:

I need to be able to position a flyout menu to the right of the main menu. I'm sure there's a plugin for that but for a variety of reasons, I'm stuck with what I've got here. What I'm actually doing is taking a couple unordered lists which are display:none and .clone()-ing them into a new div where they will be displayed. We want that new flyout menu to be able to intelligently handle its position in the window so that the menu slides up if it's normal flow would put part of it below the visible part of the window.

Everything is working fine except for this bit. I was trying to use a bit of math to dynamically determine where to set the absolute-positioned div on the page. I know I can use $('#top-menu').offset() to get the position of the parent menu item relative to the document, but the difficulty is that I have not found a specific method to deal with the position of the window relative to the document. I was looking into $(window).scrollTop(), but that does not seem to handle what I thought it would (keeps returning "undefined" when I test).

So I started looking into UI / Utility / Position. There's a bit of navigational confusion between JQuery.com and jQueryui.com and the Google Code repositories, I think, but am I right in thinking this is available only for the .8 version? I found this example when searching for position and have been down the rabbit hole ever since:
http://docs.jquery.com/UI/Position

I'm spinning my wheels, so any advice would be appreciated. I don't even think I'm really doing anything all that fancy, position-wise. I just need to place an element on the document and then bump it up if it wants to go "below the fold."

Thanks!!!