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

// Script variables
var total_logos;
var current_logo = 1;
var timer_logos;

// Goes to next slide (this uses timer for recursion)
function next_logo()
{
	// Determines which slide comes next depending on how many total (set by total_slides)
   var next_logo;
   if (current_logo >= total_logos)
      next_logo = 1;
   else next_logo = current_logo + 1;
   
   // Fades out current slide,fades in next one, updates button backgrounds
   $("div#client_logo_slide li:nth-child("+current_logo+")").fadeTo(500, 0.0,
		   function(){
	   			$("div#client_logo_slide li:nth-child("+next_logo+")").fadeTo(500,1.0);
   			});
   
   // Sets current state
   current_logo = next_logo;
   
   // Resets timer for recursion
   timer_logos = setTimeout("next_logo()", 2500);
}

$(document).ready(function(){
		   total_logos = $("div#client_logo_slide li").size();
	      $("div#client_logo_slide li:nth-child("+current_logo+")").fadeTo(500,1.0);
	      timer_logos = setTimeout("next_logo()", 2500);
});

