$(document).ready(function() {
/*		
$('#mainSidebar a.thumb img').each(function(i) {
	var imgFile = $(this).attr('src');
	var preloadImage = new Image();
	preloadImage.src = imgFile.replace('.','_h.');
		
	$(this).hover(
		function() {
			$(this).attr('src', preloadImage.src);
		},
		function () {
		var currentSource=$(this).attr('src');
			$(this).attr('src', imgFile);
	}); // end hover
}); // end each
*/	
//insert script 7.2 below this line
/*
$('#mainSidebar a.thumb').click(function(evt) {
	evt.preventDefault();
	var imgPath = $(this).attr('href');
	var oldImage = $('#mainContent img');
	var newImage = $('<img src="' + imgPath +'">');
	newImage.hide();
	$('#gallery').prepend(newImage);
	newImage.fadeIn(1000);
	oldImage.fadeOut(1000, function() {
		$(this).remove();						
	});
});

$('#mainSidebar a:first').click();
	*/
	$('#mainSidebar a.thumb').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 = $('#gallery img');
		 //check to see if they're the same image
		 if (imgPath == oldImage.attr('src')) { 
		 	//if they are then you're done
		 	return;
		 } else {
			 //remove highglight from previously clicked thumbnail
       $('.selected').removeClass('selected');		
			 //add highlight to this thumbnail
			 $(this).addClass('selected');
			 //create HTML for new image
			 var newImage = $('<img src="' + imgPath +'">');
			 //make new image invisible
			 newImage.hide();
			 //add to the #photo div
			 $('#gallery').prepend(newImage);
			 //fade out old image and remove from DOM
			 oldImage.fadeOut(1000,function(){
		     $(this).remove();
				});
			 //fade in new image
			 newImage.fadeIn(1000);
		 }
	});
	
		
		$('#mainSidebar a:eq(0)').click();
		
		$('#mainSidebarLandscape a.thumb').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 = $('#gallery img');
		 //check to see if they're the same image
		 if (imgPath == oldImage.attr('src')) { 
		 	//if they are then you're done
		 	return;
		 } else {
			 //remove highglight from previously clicked thumbnail
       $('.selected').removeClass('selected');		
			 //add highlight to this thumbnail
			 $(this).addClass('selected');
			 //create HTML for new image
			 var newImage = $('<img src="' + imgPath +'">');
			 //make new image invisible
			 newImage.hide();
			 //add to the #photo div
			 $('#gallery').prepend(newImage);
			 //fade out old image and remove from DOM
			 oldImage.fadeOut(1000,function(){
		     $(this).remove();
				});
			 //fade in new image
			 newImage.fadeIn(1000);
		 }
	});
	
		
		$('#mainSidebarLandscape a:eq(0)').click();
		
		$('#mainSidebarArchive a.thumb').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 = $('#gallery img');
		 //check to see if they're the same image
		 if (imgPath == oldImage.attr('src')) { 
		 	//if they are then you're done
		 	return;
		 } else {
			 //remove highglight from previously clicked thumbnail
       $('.selected').removeClass('selected');		
			 //add highlight to this thumbnail
			 $(this).addClass('selected');
			 //create HTML for new image
			 var newImage = $('<img src="' + imgPath +'">');
			 //make new image invisible
			 newImage.hide();
			 //add to the #photo div
			 $('#gallery').prepend(newImage);
			 //fade out old image and remove from DOM
			 oldImage.fadeOut(1000,function(){
		     $(this).remove();
				});
			 //fade in new image
			 newImage.fadeIn(1000);
		 }
	});
		
		$('#mainSidebarArchive a:eq(0)').click();
}); // end ready


