$(function() {
    var numImages = $('#image-slideshow img').length;
    var flag = 1;
    setInterval(function() {
        $('#image-slideshow img').each(function() {
            $(this).animate({top: '+=224px'}, 1000, 'easeOutCirc');
        });
        setTimeout(function() {
            $('#image'+flag).css('top', '-672px');
            
            flag = flag > numImages-1 ? 1 : flag + 1;
        }, 2000);
    }, 5000);
});
