jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

$(window).bind('load', function() {
	$('#gallery img').each(function(elm) { 
		$.preloadImages($(this).attr("src").replace("_up.jpg", "_active.jpg"));
	});
});

$(document).ready(function(){
	
	$("#gallery a img").hover(
		function(){
			if($(this).attr("src").indexOf("_active") == -1) {
				var newSrc = $(this).attr("src").replace("_up.jpg", "_active.jpg");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("_active.jpg") != -1) {
				var oldSrc = $(this).attr("src").replace("_active.jpg", "_up.jpg");
				$(this).attr("src",oldSrc);
			}
		}
	);
});
