﻿var Testimonials = new Class({
    initialize: function() {
        this.items = new Array();
        this.interval = 25000;
        this.position = 0;
    },
    
    addItem: function(item) {
        this.items[this.items.length] = item;
    },
    
    start: function() {
        this.timer = setTimeout((function() {
            this.rotate();
        }).bind(this), this.interval);
    },
    
    rotate: function() {
        if (this.items.length > 1) {
        
            this.items[this.position].setStyle("display", "none");
            
            this.position++;
            if (this.position >= this.items.length)
                this.position = 0;
            
            this.items[this.position].setStyle("display", "inline");

            this.timer = setTimeout((function() {
                this.rotate();
            }).bind(this), this.interval);
        }
    }
});
