$(document).ready(function() {
	preload_imgs(".button img");
	handle_mouseovers(".button");
});

function preload_imgs($selector) {
	$($selector).each(function() {
		// Set the original src
		rollsrc = $(this).attr("src");
		rollON = rollsrc.replace('_off', '_on');
		newImg = new Image(); 				// create new image obj
		$(newImg).attr("src", rollON);	// set new obj's src
	});
}

function handle_mouseovers($selector) {
	$($selector).mouseover(function(){
		imgsrc = $(this).children("img").attr("src");
		if (typeof(imgsrc) != 'undefined') {
			imgsrcON = imgsrc.replace('_off', '_on');
			$(this).children("img").attr("src", imgsrcON);
			//alert('over');
		}
	});

	$($selector).mouseout(function(){
		if (typeof(imgsrc) != 'undefined') {
			$(this).children("img").attr("src", imgsrc);
		}
	});

}

