$(document).ready(function(){
	initRollOvers();
});

function initRollOvers(){
	// Preload all rollovers
	$(".RollOver").each(function() {
		rollsrc = $(this).attr("src");
		var ext = rollsrc.match(/(.{3}$)/)[1];
		rollON = rollsrc.replace('.' + ext, "_over." + ext);
		$("<img>").attr("src", rollON);
	});

	// Setup javascript for rollovers
	$('.RollOver').hover(function(){
		imgsrc = $(this).attr("src");
		var ext = rollsrc.match(/(.{3}$)/)[1];
		matches = imgsrc.match(/_over/);
		if(!matches){
			imgsrcON = imgsrc.replace('.' + ext, "_over." + ext);
			$(this).attr("src", imgsrcON);
		}
	}, function(){
		$(this).attr("src", imgsrc);
	})
}
