// JavaScript Document
$(function(){
	
	// PHOTO GALLERY CODE
	
	$('#photo img').css('display', 'none');// get rid of all images
	$('#photo #gallery_1').css('display', 'block'); // display initial image
	$('#thumbnails ul li img').css('cursor', 'pointer');
	$('#gallery #photo').css('overflow', 'hidden'); // get rid of scrolls (used for non JS users)
	$('#thumbnails #thumb_1').css('opacity', 0.6); // selected thumb
	$('#main_content .gallery_descriptions').css('display', 'none');// get rid of all descriptions
	
	// thumbnail image rollover states
	$('#thumbnails img').hover(
			function() {
				$(this).css('opacity', 0.6);
        });

	// show correct gallery image	
	$('#thumbnails ul li img').hover(function(event){
		if(this == event.target)
			{
				// get rid of any photos now showing
				$('#show_first').css('display', 'none');
				$('#photo img').css('display', 'none');
				$('#main_content .gallery_descriptions').css('display', 'none');
				$('#thumbnails img').css('opacity', 1.0);
				
				$(this).css('opacity', 0.6);
				
				// display correct photo
				var id = $(this).attr('title');
				$('#photo #' + id).css('display', 'block');
				
				// display correct description
				var id2 = $(this).attr('class');
				$('#' + id2).css('display', 'block');
				
				
					
			}
		});
	
	// END GALLERY CODE
	
	// this fades in the main image on the sub pages
	$('#main_image img').hide();
	$('#main_image img').fadeIn(3000);
	
	// SCROLL BARS CODE
	$('#thumbnails').css('width', '144px');
	$('#thumbnails').jScrollPane();
	$('#gallery_page #main_content .padding').jScrollPane();
	
	// this adjusts the position of the thumbnails based
	// on whether the scrollbar will show or not
	$('#thumbnails').css('min-height', '297px');
	var $thumbnail_height = $('#thumbnails').height();
	if($thumbnail_height > 297) // if scrollbar shows do this
		{
			$('#thumbnails li').css('left', '-5px');	
		}
		
	// animation subpage code
	$('#slideshow').cycle({
		fx: 'fade',
		speed: 2500
	});

});
