$(document).ready(function() {
	
	function rollOver(s) {
		// Preload all rollovers
		$(s + " img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace('Off', 'On');
			newImg = new Image(); // create new image obj
			$(newImg).attr("src", rollON); // set new obj's src
		});

		// Navigation rollovers
		$(s + " a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			
			if (typeof(imgsrc) != 'undefined') {
			imgsrcON = imgsrc.replace('Off', 'On');
			$(this).children("img").attr("src", imgsrcON);
			}
		});
		
		// Handle mouseout
		$(s + " a").mouseout(function(){
			if (typeof(imgsrc) != 'undefined') {
			$(this).children("img").attr("src", imgsrc);
			}
		});
	}
	
	// Init rollovers
	rollOver("#navigation");
	rollOver("#homeButton");	
	rollOver("#contact");
});