$(document).ready(function() {
	
	// Preload all rollovers
	$("#main-nav ul li img").each(function() {
		// Set the original src
		rollsrc = $(this).attr("src");
		rollON = rollsrc.replace(/.png$/ig,"2.png");
		$("<img>").attr("src", rollON);
	});
	
	// Navigation rollovers
	$("#main-nav ul li a").mouseover(function(){
		imgsrc = $(this).children("img").attr("src");
		matches = imgsrc.match(/2/);
		
		// don't do the rollover if state is already ON
		if (!matches) {
		imgsrcON = imgsrc.replace(/.png$/ig,"2.png"); // strip off extension
		$(this).children("img").attr("src", imgsrcON);
		}
		
	});
	$("#main-nav ul li a").mouseout(function(){
		$(this).children("img").attr("src", imgsrc);
	});

});