/*
Title: Masthead Gallery.
Description: jQuery vertical slide navigation on an unordered list.
Author: Anthony Booth
Date: 05-10-2009
Version: 1.0

Free to use and manipulate but reference me.

Copyright 2009 by Anthony Booth

web: http://www.misterbooth.co.uk
email: anthony@misterbooth.co.uk
*/

$(document).ready(function() {
						   
	var imageStart = $('#gallery ul.button li a.button-link:first').attr('rel');
	
	$('#slideshow').html('<img src="' + imageStart + '"/>');
	
	$('#gallery ul.button li a.button-link').bind("mouseenter",function(){
		
		var image = $(this).attr("rel");
		
		if(!$(this).hasClass('over')) {
			
			$(this).parent().parent().find('a.button-link').removeClass('over');
			
			$(this).addClass('over');
		
			$('#slideshow').fadeOut('slow').hide('slow', function() {
   				$('#slideshow').html('<img src="' + image + '"/>').fadeIn(500);
  			});
		}
    })
});

/*
The following comes from:
http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript
*/

(function($) {
		  
	var cache = [];
	// Arguments are image paths relative to the current page.
	
	$.preLoadImages = function() {
		
		var args_len = arguments.length;
		
		for (var i = args_len; i--;) {
			var cacheImage = document.createElement('img');
			cacheImage.src = arguments[i];
			cache.push(cacheImage);
		}
		
	}
	
})(jQuery)
