$(document).ready(function(){
    if($('.slideshow').length){
        $('.slideshow').css({
            'position':'relative',
            'overflow': 'hidden'
        });
        
        $('.slideshow > li').css({
            'position':'absolute',
            'top':0,
            'left':0,
            'z-index':8,
            'opacity':0
        });
        
        $('.slideshow > li:first-child').css({
            'z-index':10,
            'opacity':1
        }).addClass('active');
       

        setInterval( "slideSwitch()", 5000 );
    }
});

function slideSwitch() {
    var $shows = $('.slideshow');
    $shows.each(function(i){
        var $active = $(this).children('.active');
        var $next =  $active.next().length ? $active.next() : $(this).children('li:first-child');
        $active.addClass('last-active');
        $next.css({
            'opacity':0,
            'z-index':10})
            .addClass('active')
            .animate({opacity: 1.0}, 1000, function() {
                $active.removeClass('active last-active');
                $active.css({'z-index':'8'});
        });
    });
    
}

