$(document).ready(function(){
 
	$(".tab-nav-menu li.tab a img").each(function() {
		$(this).data("image-off", $(this).attr("src"));
		
		var hoverSrc = $(this).attr("src");
		hoverSrc = hoverSrc.replace("-norm.png", "-over.png");
		$(this).data("image-on", hoverSrc);
	});

	$(".tab-nav-menu li.tab").hover(
		function() { // On
			var baseOffset = $(".tab-nav-menu"); baseOffset = baseOffset[0];
			baseOffset = $(baseOffset).offset();
			baseOffset = baseOffset.left - 45;
			
			$(".tab-nav-menu li.tab ul").stop().css("opacity", "1").hide();

			var tabOffset = $(this).offset(); tabOffset = tabOffset.left - baseOffset;
			var tabWidth = $(this).width();
			
			$(this).find("img").each(function(i) {
				$(this).attr("src", $(this).data("image-on"));
			});

			$(this).find("ul").each(function(i) {
				var pos = tabOffset - ($(this).width() / 2);
				$(this).css("left", pos + "px");
				$(this).fadeIn("fast");
			});
		},
		function() { // Off
			$(this).find("img").each(function(i) {
				$(this).attr("src", $(this).data("image-off"));
			});
		}
	);

 });
