﻿var test = Ext.get('testimonial');
var updater = test.getUpdater();
var currentTestimonial = 0;
var testCount = 10;

Ext.onReady(function(){    
    setTimeout('fetchTestimonial()',5000);       
});

function fetchTestimonial()
{ 
        Ext.Ajax.request({
            url: 'gettestimonial.ashx',
            success: 
                function(conn,resp,options)
                {                    
                    test.fadeOut({duration: 1,callback:function()
                    {
                        currentTestimonial = currentTestimonial + 1 >= testCount ? 0 : currentTestimonial+1;
                        setTimeout('fetchTestimonial()',8000);
                        test.update(conn.responseText);
                        test.fadeIn({duration:1.5,endOpacity:1,useDisplay:true});
                    }});                                        
                }
            ,                
           params: { type: 'get',id:currentTestimonial }
        });
        
}