﻿(function($) {
    $(function() {
    var spots = $("#frontPagePic");
        var count = spots.length;
        var next = 0;
        var slidetime = 1000;
        var waittime = 10000;
        var fade = "normal";

        var turnspot = function() {
            if (next >= count) {
                next = 0;
            }
            var spot = spots.eq(next);

            spots.eq(next).children(".frontPageBlock:visible").fadeOut(fade, function() {
                $(this).next().fadeIn(fade, function() {
                    $(this).removeClass("hide");

                    next++;
                    setTimeout(turnspot, (next >= count ? waittime : slidetime));

                }).end().insertAfter(spot.children(".frontPageBlock:last"));

            });

        };
        setTimeout(turnspot, waittime);

    });

})(jQuery);



