var imageCount = 0;
var logged = false;
function slideSwitch() {
    
    if(imageCount > 1) {
        var $active = $('#imageRotator img.active');


        if ( $active.length == 0 ) { $active = $('#imageRotator img:last'); }

        var $next = $active.next().length ? $active.next() : $('#imageRotator img:first');

        $active.addClass('last-active');

        $next.css({opacity: 0.0})
            .addClass('active')
            .animate({opacity: 1.0}, 1000, function() {
                $active.removeClass('active last-active').animate({ opacity: 0.0 }, 100);
            });
    }
}

$(document).ready(function() {
    imageCount = $('#imageRotator').children().length;
    $('#imageRotator img').css( { opacity: 0.0 } );
    $('#imageRotator img.active').css( {opacity: 1.0} );
    $(document).everyTime('5s', 'imageSwicth', function() { slideSwitch(); } );
});

