// preload nav images
(function($) {
	// garbage collection hack - use a public variable outside private function
	var cache = [];
	// just use image paths relative to the current page.
	$.preloadIMG = function() {
		// how many images
		var args_len = arguments.length;
		// loop
		for (var i = args_len; i--;) {
			// use DOM element
		  	var cacheImage = document.createElement('img');
			cacheImage.src = arguments[i];
			cache.push(cacheImage);
   		}
  	}
})(jQuery)

// specify the images
$.preloadIMG("images/who_red.jpg", "images/contact_red.jpg", "images/links_red.jpg", "images/blog_red.jpg", "images/home_red.jpg");

// *********************************************************************************************************

// create a slideshow
function slideShow() {
    	var $active = $('#slideshow IMG.active');
	// continue forward from end
    	if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
    	// continue back from start
    	var $next =  $active.next().length ? $active.next()
        	: $('#slideshow IMG:first');
	// blend images
    	$active.addClass('last-active');
    	$next.css({opacity: 0.0})
        	.addClass('active')
        	.animate({opacity: 1.0}, 2000, function() {
            		$active.removeClass('active last-active');
       	 	});
}

$(function() {
	// set a time for IMG's to be displayed
    	setInterval( "slideShow()", 3500 );
});

