	
$(document).ready(function() {
	function gallery_section() {
		$('#gallery_section').html('PHOTOS ' + ((selected_gallery * 8) + 1) + '-' + ((selected_gallery * 8) + 8) + ' OF ' + $('#gallery_thumbs li').length);
	}
		
	var selected_image = null;
	var selected_gallery = 0;
	var gallery_image_sets = $('#gallery_thumbs ul').length - 1;
	gallery_section();
	
	$('#next').click(function(){
		$('#prev').show();		
		// hide the current gallery and show the new set
		$('#gallery_thumbs ul:eq(' + selected_gallery + ')').hide();
		selected_gallery++;
		$('#gallery_thumbs ul:eq(' + selected_gallery + ')').show();
		gallery_section();
		if(selected_gallery >= gallery_image_sets) {
			$(this).hide();
		}
		return false;
	});

	$('#prev').click(function(){
		$('#next').show();	
		
		$('#gallery_thumbs ul:eq(' + selected_gallery + ')').hide();
		selected_gallery--;
		$('#gallery_thumbs ul:eq(' + selected_gallery + ')').show();
		gallery_section();
		if(selected_gallery == 0) {
			$(this).hide();
		}
		return false;
	});
		
	$('#gallery_thumbs li a img').mouseover(function() {
		if(selected_image != null) {
			$(selected_image).animate({opacity: .5}, 300);
		}
		
		var source = $(this).attr('src').replace('sm_', 'lg_');
		$('#large_image').css({
			'opacity' : '0',
			'filter'  : 'alpha(opacity=0)'
		});
		$('#large_image').attr("src", source);
		$('#large_image').animate({opacity: 1}, 300);
		
		selected_image = $(this);

		$(this).animate({opacity: 1}, 300);
		
		$('#contact_link').attr('src', 'images/contact_off.png');
		$('#gallery_link').attr('src', 'images/gallery_on.png');
		
	});
});

