$(document).ready(function(normalgallery) {
		
$('#galleryOtherImages img').each(function(i) {
	var imgFile = $(this).attr('src');
	var preloadImage = new Image();
  var imgExt = /(\.\w{3,4}$)/;
  preloadImage.src = imgFile;		
	$(this).hover(
		function() {
			$(this).attr('src', imgFile);
		},
		function () {
		var currentSource=$(this).attr('src');
			$(this).attr('src', imgFile);
	});
});
	
	$('#galleryOtherImages a').click(function(evt) {
		 evt.preventDefault();
	   var imgPath = $(this).attr('href');
		 var oldImage = $('#galleryRandomImage img');
		 if (imgPath == oldImage.attr('src')) { 
		 	return;
		 } else {
       $('.selected').removeClass('selected');		
			 $(this).addClass('selected');
			 var newImage = $('<img src="' + imgPath +'">');
			 newImage.hide();
			 $('#galleryRandomImage').prepend(newImage);
			 oldImage.fadeOut(1000,function(){
		     $(this).remove();
				});
			 newImage.fadeIn(1000);
		 }
	});
		
		$('#galleryOtherImages a:eq(0)').click();
});
