$(document).ready(function(){
	//initialize slideshow if any
	//Uncomment this when there is more than one partner
	if ($('#partners-slideshow').length != 0) {
		$("#partners-slideshow a").css({opacity: 0.0, display: "block"});

		var $length = $("#partners-slideshow a").length;
		var $random = Math.floor(Math.random()*$length) + 1;
		$("#partners-slideshow a:nth-child(" + $random + ")").addClass("active");
	
		$("#partners-slideshow a:nth-child(" + $random + ")").css({opacity: 1.0});
		
		setInterval( function() { slideSwitch("partners-slideshow"); }, 4000 );

	}
});

function slideSwitch(id) {
    var $active = $('#' + id + ' a.active');

    if ( $active.length == 0 ) $active = $('#' + id + 'a:last');

    var $next =  $active.next().length ? $active.next()
        : $('#' + id + ' a:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

