var gallery_current_page = 1;

var gallery_labels = new Array();
gallery_labels.push(["img1.jpg", "Marina view of Bermuda"]);
gallery_labels.push(["img2.jpg", "Exterior view of Grape Bay Beach Hotel"]);
gallery_labels.push(["img3.jpg", "The Beach at Grape Bay Beach Hotel"]);
gallery_labels.push(["img4.jpg", "Aerial view of Grape Bay Beach Hotel"]);
gallery_labels.push(["img5.jpg", "Botanical Gardens in Bermuda"]);
gallery_labels.push(["img6.jpg", "Caves in Bermuda"]);
gallery_labels.push(["img7.jpg", "Traffic director in Bermuda"]);
gallery_labels.push(["img8.jpg", "Bermuda sunset"]);
gallery_labels.push(["img9.jpg", "Traditional Gombey dancer"]);
gallery_labels.push(["img10.jpg", "Bermuda shoreline"]);
gallery_labels.push(["img11.jpg", "Bermuda shoreline"]);
gallery_labels.push(["img12.jpg", "Aerial view of Grape Bay Beach Hotel"]);

function gallery_page(page) {
	if (page != gallery_current_page) {
		var id = "#gallery_thumbs_page" + gallery_current_page;
		var id2 = "#gallery_thumbs_page" + page;
		gallery_current_page = page;
		
		$(id).animate({opacity: 0}, 250, function() { $(id).hide(); $(id2).show(); $(id2).css('opacity','0'); $(id2).animate({opacity: 1}, 250); });
	}
}

function update_caption(src) {
	var label = "";
	for(var i=0; i<gallery_labels.length; i++) {
		if (src.indexOf(gallery_labels[i][0]) > -1) {
			label = gallery_labels[i][1];
			break;
		}
	}
	if (label.length > 0) {
		$("#gallery_main_caption").show();	
		$("#gallery_main_caption").html(label);
	} else {
		$("#gallery_main_caption").hide();	
	}
}

$(function() {
 	$("#gallery_main img").load(function() { $(this).animate({opacity: 1}, 250); });

	$("#gallery_thumbs img").click(function() {
		var img = $(this);
		var src = img.attr('src');		
		src = src.replace('thumbnail','large');
		
		$("#gallery_main img").animate({opacity: 0}, 250, function() {
			update_caption(src);
			$(this).attr('src',src);
		});
	});
	$("#gallery_main").css('position','relative');
	$("#gallery_main").append("<div id=\"gallery_main_caption\" style=\"position: absolute; z-index: 20; bottom: 0; left: 0; background-color: Black; color: White; text-align: center; padding: 8px; width: 504px;\">Test</div>");
	
	update_caption("img1.jpg");
});