Code to make sub-menu open right if at edge of window

Added code that makes the sub-menus open to the right if the sub-menus goes
past the left edge of the window.