﻿if (typeof Dea === "undefined" || null === Dea) {
    var Dea = {};
}

Dea.TestimonialRotator = {
    timeoutHandle: null,
    onIndex: 1,
    rotate: function() {
        if (typeof testimonialsToRotate !== "undefined") {
            var last = testimonialsToRotate.length;
            if (Dea.TestimonialRotator.onIndex === last - 1) {
                Dea.TestimonialRotator.onIndex = 0;
            }
            else {
                Dea.TestimonialRotator.onIndex = Dea.TestimonialRotator.onIndex + 1;
            }

            var tAndC = testimonialsToRotate[Dea.TestimonialRotator.onIndex].split("|");

            $(quoteId).innerHTML = tAndC[0];
            $(citationId).innerHTML = "-" + tAndC[1];

            Dea.TestimonialRotator.startRotation();
        }
    },
    startRotation: function() {
        Dea.TestimonialRotator.timeoutHandle = setTimeout(Dea.TestimonialRotator.rotate, 8000);
    }
};

browser.addEvent(window, "load", Dea.TestimonialRotator.startRotation);
