	/////////////////////////////////////////////////// preload array of images
	$(window).bind('load', function(){
	var preload = [
	'/wp-content/themes/boulderscape/images/blank.png'
	];
	$(document.createElement('img')).bind('load', function(){
	if(preload[0]) this.src = preload.shift();
	}).trigger('load');
	});

		
	////////////////////////////////////////////////////////////////////////////////
  $(document).ready(function() {

	///////////////////////////////////////////////////////////////////////////// jquery tools 
	$('div.scrollable').scrollable({
		vertical: true,
		loop: true,
		clickable: true,
		size: 5
	});
		
	//////////////////////////////////////////////////////////////////////////////// extend jquery reverse array
	jQuery.fn.reverse = function() {
		return this.pushStack(this.get().reverse(), arguments);
	};
	
	///////////////////////////////////////////////// hide large images initially
	//$('#gallery_panel_medium img').each().hide();
	
	////////////////////// show the first
	//$('#gallery_panel_medium img:first').fadeIn(500);
	
	//////////////////////////////////////////////////////////////////////////////// set vars
	var current_img = 'null';
	
	// grabbing all thumbnails
	// --reversing the array
	$('.thumb').reverse().each(function(intIndex) {
					
		$(this).bind("click", function() {
	   		hash = intIndex + 1; // each position in reverse + 1
		    window.location.hash = hash;
			
			$(this).parent().siblings('li').children('img').removeClass('selected');
		    $(this).addClass('selected');
										
				if (current_img != hash) {					
					// Hide
					$('#gallery_panel_medium').children('img').hide();
					$('#caption').children('span.download').hide();
					$('#caption').children('div.description').hide();
					
					// Show
					$('img#panel'+hash).fadeIn(700);
					$('div#description'+hash).show();
					$('span#span'+hash).show();
					
					// Set current image to hash
					current_img = hash;							
				} // end if							
		}); // end bind
	}); // end each	
	
	/////////////////////////////////////////////////////////////////////////// move forward ( next )		
	$('.next_img').click(function() {
		$('img.selected').parent().next('li').children('.thumb').click();
	});
	
	/////////////////////////////////////////////////////////////////////////// move backwards ( back )		
	$('.prev_img').click(function() {
		$('img.selected').parent().prev('li').children('.thumb').click();
	});	
	
	/////////////////////////////////////////////////////////////////////////// load requested hash or load default
	
	function getHash() {
	var hash = window.location.hash.substr(1);		
	return hash; // remove #
	}

	var hash = getHash();
	// alert(hash);	
	
	if (hash == 'default') {
		$('ul.thumbs li').children().eq(0).click();
				if ($.browser.msie) { // little hack for crappy IE
					window.location.reload(true);
				}
	} else {
		$('ul.thumbs li').children().reverse().eq(hash-1).click();
	}
								
	/////////////////////////////////////////////////////////////////////////// end doc ready
  });

