$(document).ready(function(){

	$("#nav a").hover(
		// over
		function(){

			// store the original image src
			$(this).children(":first-child").data( "originalsrc" , $(this).children(":first-child").attr("src") );
			
			// add -over to the image unless it is already -over
			if (!$(this).children(":first-child").attr("src").match(/-over/) ) {
				$(this).children(":first-child").attr( "src", $(this).children(":first-child").attr("src").replace(/\./, "-over.") );
			}
			
		},
		
		// out
		function(){
			// replace the original src
			$(this).children(":first-child").attr(
				"src", $(this).children(":first-child").data("originalsrc")
			);
			
			$(this).children(":first-child").data(
				"originalsrc", null
			);
		}
	);

});