$(document).ready(function() {
		
$('#overviewgallery img').each(function(i) {
	var imgFile = $(this).attr('src');
	var preloadImage = new Image();
  var imgExt = /(\.\w{3,4}$)/;
  preloadImage.src = imgFile.replace(imgExt,'_h$1');
		
	//$(this).hover(
	//	function() {
	//		$(this).attr('src', preloadImage.src);
	//	},
	//	function () {
	//	var currentSource=$(this).attr('src');
	//		$(this).attr('src', imgFile);
	//}); // end hover
}); // end each
	
	$('#overviewgallery a').click(function(evt) {
		//don't follow link
		 evt.preventDefault();
		 //get path to new image
	   var imgPath = $(this).attr('href');
		 //get reference to old image
		 var oldImage = $('#overviewphoto img');
		 //check to see if they're the same image
	
			
			 //create HTML for new image
			 var newImage = $('<img src="' + imgPath +'">');
			 //make new image invisible
			 newImage.hide();
			 //add to the #overviewphoto div
			 $('#overviewphoto').prepend(newImage);
			 //fade in new image
			 newImage.fadeIn(1000);
			 
			 //fade out old image and remove from DOM
			 oldImage.fadeOut(1000,function(){
		     $(this).remove();
				});
			 
		 
	}); // end click
		
		$('#overviewgallery a:first').click();
}); // end ready

