/******************************************************************************************************
 * Testimonial Slideshow Script for Graymatter
 * Digital Ink Technologies
 * Coded by: Guilherme Moura
 * Last revised: June 8, 2011
 ******************************************************************************************************/

// Script variables
var total_testimonials;
var current_testimonial = 1;
var timer_testimonial;

// Goes to next slide (this uses timer for recursion)
function next_testimonial()
{
	// Determines which testimonial comes next depending on how many total (set by total_testimonials)
   var next_testimonial;
   if (current_testimonial >= total_testimonials)
      next_testimonial = 1;
   else next_testimonial = current_testimonial + 1;
   
   // Fades out current testimonial,fades in next one
   $("div#testimonials_slide div:nth-child("+current_testimonial+")").fadeTo(1500, 0.0,
		   function(){
	   			$("div#testimonials_slide div:nth-child("+next_testimonial+")").fadeTo(1500,1.0);
   			});
   
   // Sets current state
   current_testimonial = next_testimonial;
   
   // Resets timer for recursion
   timer_testimonial = setTimeout("next_testimonial()", 8000);
}

$(document).ready(function(){
		   total_testimonials = $("div#testimonials_slide div").size();
	      $("div#testimonials_slide div:nth-child("+current_testimonial+")").fadeTo(2500,1.0);
	      timer_testimonial = setTimeout("next_testimonial()", 7500);
});

