$(document).ready(function() {
	$("#nav a:not('.noHover')").hover(
				// over
				function(){
					// store the original image src
					$(this).children(":first-child").attr( "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").attr("originalsrc")
					);
					
					$(this).children(":first-child").attr(
						"originalsrc", null
					);
				}
			);
	
	
	$('.searchListings').click(function (e) {
		e.preventDefault();
		$.get("/find_home/rehava_search.html", function(data){
			$.modal(data, {opacity : '75'});
		});
	});
	
});

window.onload = function() {
		// preload
		$("#nav a:not('.noHover') img").each(
			function() {
				if (!$(this).attr("src").match(/-over/) ) {
					$("<img>").attr( "src", $(this).attr("src").replace(/\./, "-over.") );
				}
			}
		);
}

