$(document).ready(function() {		
	
	 slideShow();

});

function slideShow() {

	 $('#gallery a').css({opacity: 0.0});
	
	 $('#gallery a:first').css({opacity: 1.0});
	
	 $('#gallery .caption').css({opacity: 1});
 
	
	 $('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))   
	.animate({opacity: 1}, 600);
	
	$('#gallery .caption').fadeIn(1000).fadeTo(4000, 1).fadeOut(1000);

	
	 setInterval('gallery()',7000);
	
}

function gallery() {
	
	 var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	 var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	 var caption = next.find('img').attr('rel');    
	
	 next.css({opacity: 0.0})
	 .addClass('show')
	.animate({opacity: 1.0}, 1000);

	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//$('#gallery .caption').animate({opacity: 0.0}, { queue:true, duration:500 });
	$('#gallery .caption').fadeIn(1500).fadeTo(4000, 1).fadeOut(1500);	

	//$('#gallery .caption').animate({opacity:1},500);
	
	 
	$('#gallery .content').html(caption);
	
	
}