﻿(function ($) {
    var _quoteType = null,
    _fadeOutDuration = 2000,
    _fadeInDuration = 2000,
    _nextQuoteDelay = 10000,
    _quoteContainer = null;

    function run() {
        _quoteContainer = $("#quotes");
        _quoteType = $("input[type=hidden]", _quoteContainer).val();
        setTimeout(showQuote, _nextQuoteDelay)
    }

    function showQuote() {
        // Grab the next quote from the server.
        $.get("/testimonials/random/" + _quoteType, function (response) {
            _quoteContainer.fadeOut(_fadeOutDuration, function () {
                _quoteContainer
                .html(response)
                .fadeIn(_fadeInDuration, function () {
                    setTimeout(showQuote, _nextQuoteDelay)
                });
            });
        });
    }

    $(run);
})(jQuery); 

