// JavaScript Document

function slideSwitch() {
    var $active = $('#slideshow img.active');

    if ( $active.length == 0 ) $active = $('#slideshow img:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
		
	$('#s-caption p').animate({opacity: 0.0}, 300, function() {
		$('#s-caption p').html($next.attr('alt'))
		.animate({opacity: 1.0}, 700, function() {});
	});
}

$(document).ready(function() {
    var playSlideshow = setInterval( "slideSwitch()", 7000 );
	
	//Pause the slideshow on mouse over  
    $('#slideshow').hover(function() {
    	clearInterval(playSlideshow);
	},
	function() {
    	playSlideshow =  setInterval( "slideSwitch()", 7000 );
	});
});
