/*
 * Copyright T.Lawton @ Activezero 2011
 * Licensed for use by Web Purity / Activezero only.
 */


(function($){jQuery.fn.extend({testimonials: function(options){
	
	var defaults = {  
			attack: 200,
			sustain: 1000,
			release: 200
			};  
	
	var options = $.extend(defaults, options);  
	
	
	var that = this;
	
	var customers = new Array();
	var testimonials = new Array();
	
	var counter = 0;
	
	function cycle()
	{
		counter ++;
		
		if(counter == customers.length)
		{
			counter = 0;
		}
		
		jQuery("#st_testimonialsTest",that).animate({opacity: 0.001}, options.release, function(){
			
			jQuery(this).html(testimonials[counter]);
			jQuery(this).animate({opacity: 0.999}, options.attack);
			
		});
		jQuery("#st_testimonialsCustomer",that).animate({opacity: 0.001}, options.release, function(){
			jQuery(this).html(customers[counter]);
			jQuery(this).animate({opacity: 0.999}, options.attack);
			
		});
	}
	

	
	jQuery("ul li h4",this).each(function(){
		
		testimonials.push(jQuery(this).html());
		
	});	jQuery("ul li p",this).each(function(){
		
		customers.push(jQuery(this).html());
		
	});
	
	jQuery("#st_testimonialsTest", that).html(testimonials[counter]);
	
	jQuery("#st_testimonialsCustomer", that).html(customers[counter]);
	
	setInterval(cycle, options.attack + options.sustain + options.release);


}});

return this;

})(jQuery);
