$(document).ready(function() {
	$("#nav a, a.rollover, #subnav_company a, #subnav_comm a, #footer_nav a, #subnav_lake_martin 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
					);
				}
			);
	
	$("#thumbs_comm 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.") );
					}
					
					var id = $(this).children(":first-child").attr('id');
					map_flash.showRollover(id);
					
				},
				
				// 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
					);
					
					var id = $(this).children(":first-child").attr('id');
					map_flash.hideRollover(id);
				}
				
			
			);

			
	$(".trackEmail").click(function(){
		var email = $(this).attr('href').substring(7);
		pageTracker._trackPageview('/actions/send_email/' + email);
	});
			
	
});

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

