/**
 * Behaviors for main navigation links
 */
$( function() {

	$("#nav").removeClass("noscript");

	$("#nav a")
		
		// In order for jquery.backgroundPosition.js to work properly, the
		// elements being animated must have their initial
		// background-position specified inline
		.css( { backgroundPosition: "0 0" } )
		
		// Store the color of each link, so we can animate back to it later
		.each( function() {
			var $this = $(this);
			$this.data( "defaultColor", $this.css("color") );
		} )
		
		// On mouseover, lift the background image up and fade the text to
		// white
		.mouseover( function() {
			var $this = $(this);
			$this.stop();
			$this.animate(
				{
					backgroundPosition: "0 -49px",
					color: "#ffffff"
				},
				250
			);
		} )
		
		// On mouseout, lower the background image up and fade the text back
		// to its original color
		.mouseout( function() {
			var $this = $(this);
			$this.stop();
			$this.animate(
				{
					backgroundPosition: "0 0",
					color: $this.data("defaultColor")
				},
				250
			);
		} );

} );
