	jQuery.event.add(window, "scroll", scrollLeftNavMenu);
	jQuery.event.add(window, "resize", resizeFrame);
	var menuHeight = $('#core-leftmenunav').height();
	var menuTopInitial = $('#core-leftmenunav').offset().top;
	var menuLeftInitial = $('#core-leftmenunav').offset().left;
	var menuBottomInitial = menuTopInitial + menuHeight;
	
	function resizeFrame() {
		scrollLeftNavMenu();
	}

	function scrollLeftNavMenu() {
		windowTop = $(window).scrollTop();
		windowHeight = $(window).height();
		windowBottom = windowTop + windowHeight;
		menuTop = $('#core-leftmenunav').offset().top;
		menuBottom = menuTop + menuHeight;

		// fits on screen
		if (menuHeight < windowHeight) {
			// stick to top
			if (windowTop >= menuTopInitial) {
				$('#core-leftmenunav').css('position', 'fixed');
				$('#core-leftmenunav').css('top', '0');
				$('#core-leftmenunav').css('left', menuLeftInitial);
			}
			// or return to normal
			else if (windowTop < menuTopInitial) {
				$('#core-leftmenunav').css('position', 'static');
				$('#core-leftmenunav').css('top', menuTopInitial);
			}
		}
		
		// doesn't fit on screen
		if (menuHeight >= windowHeight) {
			//stick menu to the screen bottom by changing menu.top
			if (windowBottom >= menuBottomInitial) {
				$('#core-leftmenunav').css('position', 'fixed');
				$('#core-leftmenunav').css('top', -(menuHeight - windowHeight) );
				$('#core-leftmenunav').css('left', menuLeftInitial);
			}
			// return to normal
			else {
				$('#core-leftmenunav').css('position', 'static');
				$('#core-leftmenunav').css('top', menuTopInitial);
			}
		}
	}

