var numNavHeight = 0;	// height of the current element
var numNavParentHeight = 0;	// height of the menu
var numNavNewPos = 0;	// new position for the menu

// all jquery functions go here

/*
$(document).ready(function(){ 
	// Make all menus in the middle position of the parent node
	$("#LeftNav li").hover(
		function(){
			numNavHeight = $(this).height();
			numNavParentHeight = $(this).find("ul").height();
			numNavNewPos = Math.ceil( ( numNavParentHeight - numNavHeight ) / 2 );
			numNavNewPos = numNavNewPos - ( numNavNewPos * 2 );	// make value negative
			
			$(this).find("ul").css("margin-top",numNavNewPos);
		},
		function(){
		}					 
	);
}); */

function sfHover() {
	var sfEls = document.getElementById("LeftNav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
//			alert($(this).children('ul').clone().prependTo(document).css('display', 'block').height());

//			b.css('display', 'block');
//			alert(b.height());
//			$(this).children('ul').css('display', 'block');
//			$(this).children('ul').css('z-index', '100');

			numNavHeight = $(this).children('ul').height();
			numNavParentHeight = $(this).parent("ul").height();
			currentPos = $(this).position().top;
//			numNavNewPos = ((numNavParentHeight - numNavHeight) / 2) - currentPos;
//			numNavNewPos = ((numNavParentHeight - numNavHeight) / 2) - ((numNavParentHeight - currentPos) / 2);
//			numNavNewPos = ((numNavParentHeight - numNavHeight) / 2) - ((numNavHeight - currentPos) / 2);
			numNavNewPos = ((numNavParentHeight - numNavHeight) / 2) - ((numNavParentHeight - $(this).height()) / 2);

//			$(this).children("ul").css("margin-top", numNavNewPos);
//			alert(numNavNewPos);
			$(this).children("ul").css("top", numNavNewPos);
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
//			$(this).children('ul').css('display', 'none');
		}
	}
}
// if (window.attachEvent) window.attachEvent("onload", sfHover);
$(document).ready(sfHover);



/*
	Desc: 	This will make the three columns have the same height. It is called on an onload function in the body HTML tag
			because there seems to be an error with FF and Safari when invoking this during the ready state. Any dynamic
			content flowed in breaks the equal height call.
	Param:	N/A
	Return:	N/A
*/
function SetEqualHeights()
{
	$("#LeftNav,#MainContent,#LatestNews").equalHeights(); 
}	// SetEqualHeights