jQuery(document).ready(function(){
		
	// Fade in thumbnails on hover
	var thumb = jQuery('ul#gallery-thumbnails li').fadeTo(0, .6);
	thumb.hover(
		function(){
			jQuery(this).fadeTo('fast', 1);
		},
		function(){
			jQuery(this).fadeTo('fast', .6);
		}
	);
	
	// The Thumbnail Scrollbar
	jQuery('#scrollbar').slider({
		handle: '.handle',
		animate: 'true',
		change:	handleSliderChange,
		slide:	handleSliderSlide
	});
	
	var scrollHeight = jQuery('#gallery-thumbnails').attr('scrollHeight');
	
	jQuery('.handle').height(scrollHeight * .1);
	
	function handleSliderChange(e, ui){
		var maxScroll = jQuery("#gallery-thumbnails").attr("scrollHeight") - jQuery("#gallery-thumbnails").height();
  	jQuery("#gallery-thumbnails").animate({scrollTop: ui.value * (maxScroll / 100) }, 1000);
	}
	
	function handleSliderSlide(e, ui){
		var maxScroll = jQuery("#gallery-thumbnails").attr("scrollHeight") - jQuery("#gallery-thumbnails").height();
  	jQuery("#gallery-thumbnails").attr({scrollTop: ui.value * (maxScroll / 100) });
	}
		
});