/**
 * @author eric
 */

var random = false;
var count = $('#clients').children('img').size();

if (random) {var current = numRand();}
else {var current = 0}

// initial hide of extra images
$('#clients img').hide();

// set first images and current image
$('#clients img:eq(' + current + ')').show();

// start timers
startTimer();

function startTimer(){$(document).everyTime(8000, 'slideshow', function(i) {fade(getID());})}

function getID(){
	if (random) {
		var next = numRand();
		while (next == current) {next = numRand();}
		current = next;
		return next;
	}
	else{
		while(current < count - 1){current++;return current;}
		current = 0;
		return current;
	}
}

function fade(fadeID){
	$('#clients img:visible').fadeOut(1000);
	$('#clients img:eq(' + fadeID + ')').fadeIn(1000);
}

function numRand(){return Math.floor(Math.random() * (count))}