I have a pure CSS flyout navigation menu. If this menu is viewed on certain lower resolutions, then the submenu will be clipped by the viewport and disappear of screen. If the user has a scroll wheel they can scroll down the page but this is far from ideal.

I would like to use some JavaScript to do something like calculate the height of the submenu, determine the height of the viewport and then, if the drop down will go off screen, pop it up the way instead of down the way. DOes that make sense?

Any suggestions or recommended readnig appreciated!