﻿//Load the sponsors to the target element from the sourceArray.
function LoadSponsors(target, sourceUrl) {

    sourceUrl += "?jsoncallback=?";

    $.getJSON(sourceUrl, function(data) { LoadSponsors_Complete(data, target); }); 

}

//Load sponsors response event.
function LoadSponsors_Complete(data, target) {

    //Sort the array randomly.
    var sourceArray = data.items;
    sourceArray.sort(function() { return 0.5 - Math.random() })     

    var sponsorsHtml = new Array();
    $.each(sourceArray, function(index, value) {
        sponsorsHtml.push("<a href=\"" + value.href + "\">");
        sponsorsHtml.push(" <img src=\"" + value.src + "\" />");
        sponsorsHtml.push("</a>");
    });
    $(target).html(sponsorsHtml.join(""));

    //Initiate the coin slider.
    $(target).coinslider({ width: 220, height: 150, navigation: false, delay: 5000, spw: 1, sph: 1, hoverPause: true, opacity: 1, titleSpeed: 0 });

} 