
	function init()
	{
		// make sure sidebar columns are same height
		stretchCols();
	}
	
	function stretchCols()
	{
		var height_a = document.getElementById('col-a').offsetHeight;
		var height_b = document.getElementById('col-c').offsetHeight;

		if (height_a > height_b)
		{
			document.getElementById('col-c').style.height = height_a-110+'px';	
		}
		else
		{
			document.getElementById('col-a').style.height = height_b-110+'px';
		}
	}
	
	if(typeof window.addEventListener != 'undefined') {
		window.addEventListener('load', init, false);
	} else if(typeof document.addEventListener != 'undefined') {
		document.addEventListener('load', init, false);
	} else if(typeof window.attachEvent != 'undefined') {
		window.attachEvent('onload', init);
	}

jQuery(function($) {
	$('#nav-main li, #nav-loggedin li').hover(
		function() {
			$(this).children("ul:first").css({display :"block",zIndex: 10000, position: "absolute"});
			$(this).css({zIndex: 10000 });
			 windowHeight = $(window).height();
			 myHeight = $(this).height();
			 childHeight = $(this).children("ul:first").height();
			 childOffset = $(this).children("ul:first").offset();
			 windowscrollTop = $(window).scrollTop();
		//	 document.title = windowHeight+":"+myHeight+":"+childOffset.top+":"+windowscrollTop;
			 
			 if((childOffset.top-windowscrollTop)+ childHeight > windowHeight) {			 	
			 	$(this).children("ul:first").css("top", 0 - (childHeight- (myHeight+1)));	
			 }
		},
		function(){
			$(this).css({zIndex: 100});
			$(this).children("ul:first").css("display", "none");
			$(this).children("ul:first").css("top", "");
		}
	);
});
