$(document).ready(function() {
	
	// Preload any image ending in -on.png
	$("img").each(function() {
		rollsrc = $(this).attr("src");
		rollON = rollsrc.replace(/.png$/ig,"-on.png");
		$("<img>").attr("src", rollON);
	});
	
	$("a.o").mouseover(function(){
		imgsrc = $(this).children("img").attr("src");
		matches = imgsrc.match(/_over/);
		if (!matches) {
		imgsrcON = imgsrc.replace(/.png$/ig,"-on.png");
		$(this).children("img").attr("src", imgsrcON);
		}
	});	
	
	$("a.o").mouseout(function(){
		$(this).children("img").attr("src", imgsrc);
	});
	
	// Preload any image ending in _over_down.png
	$("img").each(function() {
		rollsrc1 = $(this).attr("src");
		rollON1 = rollsrc1.replace(/.png$/ig,"-on.png");
		$("<img>").attr("src", rollON1);
	});
	
	$("a.o").mousedown(function(){
		imgsrc1 = $(this).children("img").attr("src");
		matches1 = imgsrc.match(/-down/);
		if (!matches1) {
		imgsrcON1 = imgsrc1.replace(/.png$/ig,"-down.png");
		$(this).children("img").attr("src", imgsrcON1);
		}
	});	
	
	$("a.o").mouseup(function(){
		$(this).children("img").attr("src", imgsrc1);
	});
	
});

