﻿$(document).ready(function () {
    contentRotator($("ul#banner > li:first"));
});

var doAnimate = true;

function contentRotator(content) {
    if (doAnimate) {
        content.fadeOut(200, function (content) {
            return function () {
                /* HIDE ALL ITEMS */
                $("ul#banner > li").hide();

                content.fadeIn(200, function () {
                    /* GO BACK TO FIRST ITEM */
                    if ($(this).attr("id") == $("ul#banner > li:last").attr("id")) {
                        setTimeout(function () {
                            contentRotator($("ul#banner > li:first"));
                        }, 5000);
                    }
                    else { /* FADE IN NEXT ITEM  */
                        setTimeout(function () {
                            contentRotator($(content.next()));
                        }, 5000);
                    }
                });
            };
        } (content));
    }
}


