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