
var galleries = [];

function refreshThumbnailGallery(offset, galleryId)
{
	var display = '#display_'+galleryId;
	var thumbs = '#thumbs_'+galleryId;
	var descr = '#descr_'+galleryId;
	var thumbRows = galleries[galleryId][0];
	var thumbCols = galleries[galleryId][1];
	var align = galleries[galleryId][2];
	
	// Build the AJAX request	
	$.ajax({
		   type: 'GET',
		   url: 'getthumbs.php',
		   dataType:'html',
		   data:{'align':align, 'rows':thumbRows, 'cols':thumbCols, 'offset':offset, 'gallery_id':galleryId},
		   cache:false,
		   success:function(html){
			   $(thumbs).html(html);
			   $(thumbs+' .gallery_image').bind("click",function(e){
				   var id = $(this).attr('id').substr(6);
				   $(descr).html($('#image_desc_'+id).html());
				   $(display).attr('src',$(this).attr('rel'));
				});
		   }
	});
}	


/*
// Refresh thumbnail gallery
function refreshThumbnailGallery(offset, galleryId)
{
	var display = 'display_'+galleryId;
	var thumbs = 'thumbs_'+galleryId;
	var descr = 'descr_'+galleryId;
	var thumbRows = galleries[galleryId][0];
	var thumbCols = galleries[galleryId][1];
	var align = galleries[galleryId][2];
	
	// Build the AJAX request
	var qstr = Object.toQueryString({'align':align, 'rows':thumbRows, 'cols':thumbCols, 'offset':offset, 'gallery_id':galleryId});
	var url = "getthumbs.php?"+qstr;
	var ajax = new Ajax(url, {'method':'get', 'update':thumbs});
	
	// Clear any existing thumbnails.
	$(thumbs).innerHTML = "";
	
	// Add an event handler to each image in the gallery DIV to display the thumbnail's corresponding large image
	ajax.addEvent('onComplete', function(){
		$$('div#' + thumbs + ' .gallery_image').each(function(e){
			e.addEvent('click', function(){
				var id = e.getProperty('id').substr(6);
				$(descr).innerHTML = $('image_desc_'+id).innerHTML;
				$(display).src = e.getProperty('rel');
			});
		});
	});
	ajax.request();
}
*/
