function thefader() {
	jQuery('.fader div').css({opacity: 0.0});
	jQuery('.fader div:first').css({opacity: 1.0});
	setInterval('rotate()',13000);
}

function rotate() {	
	//Get the first image
	var current = (jQuery('.fader div.show')?  jQuery('.fader div.show') : jQuery('.fader div:first'));
    if ( current.length == 0 ) current = jQuery('.fader div:first');
	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? jQuery('.fader div:first') :current.next()) : jQuery('.fader div:first'));
	
	//Un-comment the 3 lines below to get the images in random order
	//var sibs = current.siblings();
    //var rndNum = Math.floor(Math.random() * sibs.length );
    //var next = jQuery( sibs[ rndNum ] );

	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
};

(function(jQuery){
jQuery(document).ready(function() {		
	thefader();
	jQuery('.fader').fadeIn(1000);
    jQuery('.fader div').fadeIn(1000); // tweek for IE
});
})(jQuery);

