var loading_html = ''
	+'<div class="loading">'
	+'<img src="/images/ajax-loader.gif" alt="loading" />'
	+' LOADING'
	+'</div>';

Event.observe(window, 'load', function () {

	var current = app_values.current_piece_href;

	$$('#thumbs a').each(function (elem) {
		elem.observe('mouseover', function () {
			if (current !== elem.readAttribute('href')) {
				new Ajax.Updater('right_column', elem.readAttribute('href')+'/ajax', {
					onCreate: function () {
						$('right_column').update(loading_html);
					},
					onSuccess: function () {
						current = elem.readAttribute('href');
					}
				});
			}
		});
	});

	// Preload
//	var i = 0;
//	$$('#thumbs a').each(function (elem) {
//		$('container').insert({
//			after: '<div id="preload_'+i+'" class="hide_from_view"></div>'
//		});
//		if (current !== elem.readAttribute('href')) {
//			new Ajax.Updater('preload_'+i, elem.readAttribute('href')+'/ajax');
//		}
//		i++;
//	});
});