var timer_banner = 0;
$(document).ready(function() {
	//Execute the slideShow
        slideShowIndex();
 });

function slideShowIndex() {
	if($('#gallery').html()!=null)
	{
	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('updateTimer()',1000);
	}


}
function galleryNext() {
	 timer_banner=0	
	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'));	
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
}

function galleryPrev() {

      timer_banner=0
	var current = (jQuery('#gallery a.show')?  jQuery('#gallery a.show') : jQuery('#gallery a:last'));
	var prev = ((current.prev().length) ? ((current.prev().hasClass('caption'))? jQuery('#gallery a:first') :current.prev()) : jQuery('#gallery a:last'));
	prev.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
}

function updateTimer()
{    
    if(timer_banner>=6)
    {
        galleryNext();
        timmer_banner=0;
    }
    timer_banner+=1;

}

