// JavaScript Document

$(function(){
	var $el, leftPos, newWidth,
		$nav = $("#nav");

	$nav.prepend("<li id='hoverbg'></li>");

	var $hoverbg = $("#hoverbg");

	$hoverbg
		.width($(".active").width()-10)
		.height($nav.height()-10)
		.css("left", $(".active a").position().left+5)
		.data("origLeft", $(".active a").position().left+5)
		.data("origWidth", $hoverbg.width());
//		.data("origColor", $(".active a").attr("rel"));

	$("#nav li").find("a").hover(function() {
		$el = $(this);
		leftPos = $el.position().left;
		newWidth = $el.parent().width();
		$hoverbg.stop().animate({
			left: leftPos+5
			,width: newWidth-10
//			,backgroundColor: $el.attr("rel")
		},"slow")
	}, function() {
		$hoverbg.stop().animate({
			left: $hoverbg.data("origLeft")
			,width: $hoverbg.data("origWidth")
//			,backgroundColor: $hoverbg.data("origColor")
		},"slow");    
	});
});

