var subsubpage;

$(document).ready(function(){
	// nav, subnav and liststingsSubsubnav hover
	$("#nav a, #subnav a, #listingsSubsubnav a").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
					);
				}
			);

	
			
	// hilight section, page and subpage
	if ($("#nav_" + section).length) {
		$("#nav_" + section).attr(
			"src", $("#nav_" + section).attr("src").replace(/\./, "-over.")
		);
	}
	
	if ($("#subnav_" + page).length) {
		$("#subnav_" + page).attr(
			"src", $("#subnav_" + page).attr("src").replace(/\./, "-over.")
		);
	}

	if ($("#subsubnav_" + subsubpage).length) {
		$("#subsubnav_" + subsubpage).attr(
			"src", $("#subsubnav_" + subsubpage).attr("src").replace(/\./, "-over.")
		);
	}
	
	
				
});

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


}