$(document).ready(function() {		
	
	slideShow();

});

function slideShow() {

	$('#gallery a').css({opacity: 0.7});
	
	$('#gallery a:first').css({opacity: 1.0});
	
	$('#gallery .caption').css({opacity: 0.7});

	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 1.0}, 500);
	
	setInterval('gallery()',24000);
	
}

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.5})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	current.animate({opacity: 1.0}, 1000)
	.removeClass('show');
	
	$('#gallery .caption').animate({opacity: 0.7}, { queue:false, duration:0 }).animate({width: '1px'}, { queue:true, duration:200 });	
	
	$('#gallery .caption').animate({opacity: 1.0},50 ).animate({width: '943px'},200 );
	
	$('#gallery .content').html(caption);
	
	
}