
Reader = new Class({
    initialize: function(name, url){	
        this.div = $(name);     
        this.quotes = null;    
        this.count = 0;       
        this.show = 0;
        this.fx = new Fx.Style(this.div, 'opacity', { duration: 1000 });
        
	    new Json.Remote(url, {
            onComplete: function(obj){
                this.quotes = obj.testimonials;
                this.start();
            }.bind(this)
        }).send();
    },
	
	start:function()
	{
	    this.count = this.quotes.length;
	    this.display();
	    if(this.count > 1) this.next.periodical(12000, this);
	},
	
	display:function()
	{
        this.fx.start(1, 0).chain
        (
            this.settext.pass(this.show, this)
        );
	},
	
	settext:function(num)
	{
	    this.div.setHTML('<p class="quote">"' + this.quotes[num].quote + '"<span>' + this.quotes[num].person + '</span></p>');
	    this.fx.start(0, 1);
	},
	
	next:function(num)
	{
	    if((this.show +1) < this.count) this.show++;
	    else this.show = 0;
	    this.display();
	}
	
	
});	