﻿(function($) {

    $.fn.rotate = function(timeout, items) {
        if (!items) items = 1;
        var idx = items - 1;
        var t = $(this);

        if (items < t.size()) {
            setInterval(function() {
                t.hide();
                for (lcv = 0; lcv < items; lcv++) {
                    idx++;
                    if (idx > t.length - 1)
                        idx = 0;
                    $(t[idx]).stop().show().fadeOut(1).fadeIn(425);
                }
            }, timeout);
        }
    }

    $.fn.rotate2 = function(timeout, items, id) {
        if (!items) items = 1;
        var idx = items - 1;
        var t = $("#" + id).children(".testimonial");
        if (items < t.size()) {
            setInterval(function() {
                var ts = $("#" + id).children(".testimonial");
                ts.hide();
                for (lcv = 0; lcv < items; lcv++) {
                    idx++;
                    if (idx > ts.length - 1)
                        idx = 0;
                    $(ts[idx]).stop().show().fadeOut(1).fadeIn(425);
                }
            }, timeout);
        }
    }
})(jQuery);