// JavaScript Document
var delay = 3000;

function slideSwitch() {
    var $active = $('#clients img.active');
	
    if ( $active.size() == 0 ) { $active = $('#clients img:last'); }

    var $next =  $active.next().length ? $active.next() : $('#clients img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
	});
}

$().ready(function() {
	var imageCount = $('#clients img').size() + 1;
	var randomNumber = Math.floor(Math.random()*imageCount);
	$('#clients img').eq(randomNumber).addClass('active');
		
	setInterval('slideSwitch()', delay);
});
