$(document).ready(function() {
	// Preload dei rollover
	$("img").each(function() {
		// Prende l'url originale
		rollsrc = $(this).attr("src");
		rollON = rollsrc.replace(/.png$/ig,"_over.png");
		$("<img>").attr("src", rollON);
	});
	
	//over del mouse
	$("a.rollover").mouseover(function(){
		imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			// non compie il rollover se il mouse è già over
			if (!matches) {
				imgsrcON = imgsrc.replace(/.png$/ig,"_over.png"); // esclude l'estensione del file
				$(this).children("img").attr("src", imgsrcON);
			}
	});
	
	//out del mouse
	$("a.rollover").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
	});
});
