$(document).ready(function() {
						   
	
						   
	//////////////////////////////////////////////////////////////////////////////////////
	/// LOAD MORE REVIEWS FOR REVIEWS BLOCK //////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////
	
	$('.review_block').find('.hidden_review').wrapAll('<div id="hidden_reviews_holder"></div>')
	
	$('#load_more_reviews').click(function(){
		
		$(this).remove();
		$('#hidden_reviews_holder').children().css('display','block').parent().slideDown('slow').fadeIn('slow');
		return false;
		
	});

	//////////////////////////////////////////////////////////////////////////////////////
	/// SLIDER ANIMATIONS ////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////				
	
	headingHeight = 0;
	singleLineHeight = 20;
	
	$('.slider_inner').each(function(){ // Find tallest box
		
		var itemHeight = $(this).find(':header:first').height();
		if(itemHeight > headingHeight) headingHeight = itemHeight;
		
	});
	
	$('.slider_inner').each(function(){

		
		var itemHeadingHeight = $(this).find(':header:first').height();
		var currentOffset = $(this).css('bottom').replace('px','');
		
		// Only run the individual normalisation code for normal sliders
		if(! $(this).parent().hasClass('square_slider') ) {
			
			
			if(itemHeadingHeight > singleLineHeight) {
				$(this).children('h3').addClass('double_height_slide');
				//offsetAdjustment = (itemHeadingHeight / 2) // LR - No longer adjusting offset, just adding the class
				offsetAdjustment = 0;
			}else{
				offsetAdjustment = 0;	
			}
			

		}else{ // Square Sliders
		
			if( headingHeight > itemHeadingHeight ) { // Single line H3's
				$(this).find('h3').addClass('extra_padding');
			}
			
			if( headingHeight > singleLineHeight ) {
				$(this).addClass('double_height_slide');
				offsetAdjustment = (headingHeight / 2);				
			}else{
				offsetAdjustment = 0;	
			}
			
		}
		
		$(this).data('lowerOffset', Number(currentOffset) + Number(offsetAdjustment));
		$(this).css('bottom',$(this).data('lowerOffset'))
		
	});
	
	$('.slider_wrap').hover(
	
		function() { // Hover on
		
			$(this).find('.slider_inner').animate( { bottom:'0' }, { queue:false, duration:400 })
			
		},
		
		function() { // Hover off
		
			originalOffset = $(this).find('.slider_inner').data('lowerOffset');
			$(this).find('.slider_inner').animate({ bottom:originalOffset }, { queue:false, duration:400 })	
			
		}
	
	);
	
	//////////////////////////////////////////////////////////////////////////////////////
	/// WHITE NAVIGATION FADES ///////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////		
	
	$('.fader_links a').hover(
	
		function() { //Hover on function
			
			$(this).animate( { backgroundColor:'#FFFFFF' }, 100, function() {
			
				$(this).css('backgroundColor','#FFFFFF'); //Force it to be white on callback
			
			});

		},
		
		function() { // Hover off function
		
			// If anchor or its parent do not have the 'selected' selected
			
			if( (!$(this).parent().hasClass('selected')) && (!$(this).hasClass('selected')) ) {	
				
				// Revert background colour to default
				
				$(this).animate({ backgroundColor:'#F0F1EE' }, { queue:false, duration:200, complete:function(){
																											  
					$($(this)).removeAttr("style"); // Clean up the 'style' attribute on this link
				
				}
				});
					
			}
			
		}
	
	);
	
	//////////////////////////////////////////////////////////////////////////////////////
	/// IMAGE THUMBNAIL FADES ////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////
	
	$('.img_thumbnails a').live('click',function() {
		
		//Only continue if NOT selected
		if(!$(this).hasClass('selected')) {
			
			if ($('.temp_image').length > 0) {
				var currentMasterPath = $('.temp_image').attr('src');
			}else{
				var currentMasterPath = $('.master_image').attr('src');				
			}
			
			var selectedThumb = $(this).find('img');
			
			// Give current thumbnail a class of selected
			//$('.img_thumbnails a').removeClass('selected').not($(this).addClass('selected'));
			
			// String replace 'thumb' with 'main' to get the path of new image
			var currentPath = $(this).children('img').attr('src');
			//var imagePath = currentPath.replace("/thumbs/","/main/");
			var imagePath = currentPath; // dg 090523 - use same image - not thumb or main
			
			// Load new image into wrapper master with special class (remove any previous ones first.)
			$('.temp_image').remove();
			
			var currentTemp = $('.img_master_wrapper').append('<img src="' + imagePath + '" class="temp_image">');
			
			// Show the image loader overlay
			//$('.img_master_wrapper .loader').height($('.img_master_wrapper').height()); //IE6 fix
			//$('.img_master_wrapper .loader').fadeIn('slow');
			
			// Switch over the image thumbnails
			selectedThumb.attr('src',currentMasterPath);			
			
			// Add a load function to the temp image
			//$('img.temp_image').load(function(){
				
				// Fade out the image loader
				//$('.img_master_wrapper .loader').fadeOut('fast');
		
				// Fade in the new main image
				$('img.temp_image').fadeIn('medium', function(){
				
					// Switch the attributes (temp into master)
					$('.master_image').attr('src',$(this).attr('src'));

				});
				
			//});
	
		}
		
		return false;

	});

});	