$j(function() {   
    $j(".footer-logo").hide();
    showLogos(5000, hideAll);

    // hack to link to global partners section. Far from ideal, I know.
    $j("#logos").css("cursor", "pointer").click(function(){
        window.location = "/our-members-and-strategic-partners/global-partners";
    });
});
var hideAll = function() {

    var $count = 0;
      $j(".footer-logo:visible").fadeOut("slow", function() {
          if(++$count==5){
            setTimeout(function(){showLogos(5000,hideAll)}, 1000);
          }

      });
};

function getRandom(set) {
    var index = (Math.floor(Math.random() * set.length));
    return($j($j(set)[index]))
}

var showLogos = function(delay, cb) {

    var $length = $j(".footer-logo:visible").length;

    if($length < 5) {

        var hidden = $j(".footer-logo:hidden"),
            $item = getRandom(hidden);
    
        $item.remove().appendTo("#logos").fadeIn(1000, function() {
            showLogos(delay, cb);
        });
    } else {

           setTimeout(cb, delay);
    }
};




