//////////////////////////////////////////////////////
//
//	The purpose of this file is to
//	apply a hover class on mouseover
//	on the <li> elements in the nav.
//	This is because IE doesn't put
//	the pseudo class :hover on <li> elements
//
//	This is code that uses the
//	jquery javascript library (http://jquery.com/)
//
//////////////////////////////////////////////////////
$(document).ready(function() {

	var navItems = $(".navtop > li");
	var totalWidth = 0;
	
	navItems.each(function(i){
		navItem = $(this);
		var bgPos = -1 * totalWidth + 'px -39px';
		var isSelected = false;
		if(navItem.hasClass('selected'))
			navItem.css({backgroundPosition: bgPos});
		totalWidth = totalWidth + navItem.width();
		navItem.hover(function() {
			$(this).css({backgroundPosition: bgPos});
		},
		function () {
			if(!$(this).hasClass('selected'))
				$(this).css({backgroundPosition: '50px 50px'});
		});
		
	});
	navTopWidth = $(".navtop").width();
	if(totalWidth > navTopWidth){
		pl = $(".navtop > li:last > a");
		pl.css({
			paddingLeft: function(index, value) {
				return parseFloat(value) -  (totalWidth - navTopWidth);
			}});
	}
	
	


	if ($.browser.msie && $.browser.version <= 6) {
		// this is needed for the IE 6 pseudo hover class bug
		$(".navtop > li").hover(function() {
			$(this).addClass("hover");
		},
		function () {
			$(this).removeClass("hover");
		});
		
	}
});

