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

function slideShow(speed) {
    //Set the opacity of all images but the first to 0
    $('ul.slideshow li').not('li:first').css({opacity: 0.0});

    //Call the gallery function to run the slideshow
    var timer = setInterval('gallery()',speed);
};
function gallery() {
    //if no images have the slideshow-current class, grab the first image
    var current = ($('ul.slideshow li.slideshow-current') ? $('ul.slideshow li.slideshow-current') : $('#ul.slideshow li:first'));

    //Get next image, if we've reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? current.next() : $('ul.slideshow li:first'));

    //Set the fade in effect for the next image, slideshow-current class has higher z-index
    next.css({opacity: 0.0}).addClass('slideshow-current').animate({opacity: 1.0}, 5000);

    //Hide the current image
    current.animate({opacity: 0.0}, 5000).removeClass('slideshow-current');
};

