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

(function($){

    $.fn.slideshow = function() {
        // start fading
        var options = $.extend($.fn.slideshow.defaults, $.fn.slideshow.options);
        if (options.slideshow == 1) {
            setInterval('slide()', options.slideinterval);
        }
        $().ready(function() {
            // opacity of all images to 0
            $('.slideshow .slide').css({opacity: 0.0});
            // get the first image and display it
            $('.slideshow .slide:first').css({opacity: 1.0});
        });
    };

    $.fn.slideshow.defaults = {
        slideshow: 1,
        slideinterval: 5000
    };

})(jQuery);

function slide() {
    // get the current image
    var current = ($('.slideshow .slide.show') ? $('.slideshow .slide.show') : $('.slideshow .slide:first'));
    // get the next image
    var next = ((current.next().length) ? current.next() : $('.slideshow .slide:first') );
    // fade in
    next.css({opacity: 0.0})
    .addClass('show')
    .animate({opacity: 1.0}, 1000);
    // fade out
    current.animate({opacity: 0.0}, 1000)
    .removeClass('show');
}
