// Seconds to wait before rotating content
var spotlightDuration = 9;
var spotlightImpressions = 8;

// Define array length constants
var spotlightItems = 21 ;

// Define spotlight array ordinal constants
var spotlightEnterprise = 0;
var spotlightAgency = 1;
var spotlightLocation = 2;
var spotlightLogo = 3;
var spotlightCreative = 4;

/* ============================= Data ============================= */

// Initialize spotlight arrays
var arrSpotlight = new Array(spotlightItems);
for (var idx = 0; idx < spotlightItems; idx++)
{
    arrSpotlight[idx] = new Array(5);
}

// Load the Agency Spotlight data
arrSpotlight[0][0] = "514514"
arrSpotlight[0][1] = "Access To Media"
arrSpotlight[0][2] = "Chicopee, MA"
arrSpotlight[0][3] = "a2m.logo.gif"
arrSpotlight[0][4] = "0"

arrSpotlight[1][0] = "168436"
arrSpotlight[1][1] = "Brunner"
arrSpotlight[1][2] = "Pittsburgh, PA"
arrSpotlight[1][3] = "blattnerbrunner0103.logo.jpg"
arrSpotlight[1][4] = "0"

arrSpotlight[2][0] = "3258"
arrSpotlight[2][1] = "Campbell-Ewald"
arrSpotlight[2][2] = "Warren, MI"
arrSpotlight[2][3] = "campbellewald3.logo.gif"
arrSpotlight[2][4] = "1"

arrSpotlight[3][0] = "525530"
arrSpotlight[3][1] = "Campus Party, Inc"
arrSpotlight[3][2] = "Philadelphia, PA"
arrSpotlight[3][3] = "campusparty.logo.gif"
arrSpotlight[3][4] = "0"

arrSpotlight[4][0] = "279887"
arrSpotlight[4][1] = "Cashman & Katz Integrated Communications"
arrSpotlight[4][2] = "Glastonbury, CT"
arrSpotlight[4][3] = "cashmankatz.logo.gif"
arrSpotlight[4][4] = "0"

arrSpotlight[5][0] = "472390"
arrSpotlight[5][1] = "Clayton Design Group LLC"
arrSpotlight[5][2] = "Falls Church, VA"
arrSpotlight[5][3] = "claytondesigngroup.logo.jpg"
arrSpotlight[5][4] = "0"

arrSpotlight[6][0] = "147759"
arrSpotlight[6][1] = "Doremus"
arrSpotlight[6][2] = "New York, NY"
arrSpotlight[6][3] = "doremus2.logo.gif"
arrSpotlight[6][4] = "1"

arrSpotlight[7][0] = "423104"
arrSpotlight[7][1] = "EJW Associates, Inc."
arrSpotlight[7][2] = "Alpharetta, GA"
arrSpotlight[7][3] = "ejw.logo.gif"
arrSpotlight[7][4] = "0"

arrSpotlight[8][0] = "583233"
arrSpotlight[8][1] = "eTargetMedia.com, Inc."
arrSpotlight[8][2] = "Coconut Creek, FL"
arrSpotlight[8][3] = "etargetmedia.logo.jpg"
arrSpotlight[8][4] = "0"

arrSpotlight[9][0] = "86407"
arrSpotlight[9][1] = "Fletcher Martin"
arrSpotlight[9][2] = "Atlanta, GA"
arrSpotlight[9][3] = "fletcher2.logo.gif"
arrSpotlight[9][4] = "1"

arrSpotlight[10][0] = "272591"
arrSpotlight[10][1] = "ISM"
arrSpotlight[10][2] = "Boston, MA"
arrSpotlight[10][3] = "ism.logo.gif"
arrSpotlight[10][4] = "0"

arrSpotlight[11][0] = "4592"
arrSpotlight[11][1] = "Posner Advertising"
arrSpotlight[11][2] = "New York, NY"
arrSpotlight[11][3] = "posner.logo.gif"
arrSpotlight[11][4] = "0"

arrSpotlight[12][0] = "180819"
arrSpotlight[12][1] = "Purohit Navigation"
arrSpotlight[12][2] = "Chicago, IL"
arrSpotlight[12][3] = "dpm.logo.gif"
arrSpotlight[12][4] = "0"

arrSpotlight[13][0] = "507912"
arrSpotlight[13][1] = "Quigley-Simpson"
arrSpotlight[13][2] = "Los Angeles, CA"
arrSpotlight[13][3] = "quigley.logo.gif"
arrSpotlight[13][4] = "0"

arrSpotlight[14][0] = "288129"
arrSpotlight[14][1] = "Rosen & Brichta"
arrSpotlight[14][2] = "Chicago, IL"
arrSpotlight[14][3] = "rosen702.logo.gif"
arrSpotlight[14][4] = "0"

arrSpotlight[15][0] = "5102"
arrSpotlight[15][1] = "Sanders/Wingo Advertising, Inc."
arrSpotlight[15][2] = "El Paso, TX"
arrSpotlight[15][3] = "sanders.logo.jpg"
arrSpotlight[15][4] = "0"

arrSpotlight[16][0] = "576656"
arrSpotlight[16][1] = "Scuderia O2"
arrSpotlight[16][2] = "New York, NY"
arrSpotlight[16][3] = "so2.logo.jpg"
arrSpotlight[16][4] = "0"

arrSpotlight[17][0] = "209340"
arrSpotlight[17][1] = "Seiter & Miller Advertising, Inc."
arrSpotlight[17][2] = "New York, NY"
arrSpotlight[17][3] = "seiter.logo.gif"
arrSpotlight[17][4] = "0"

arrSpotlight[18][0] = "2024"
arrSpotlight[18][1] = "SiboneyUSA"
arrSpotlight[18][2] = "Coral Gables, FL"
arrSpotlight[18][3] = "siboney.logo.jpg"
arrSpotlight[18][4] = "1"

arrSpotlight[19][0] = "580405"
arrSpotlight[19][1] = "Take 5 Solutions"
arrSpotlight[19][2] = "Boca Raton, FL"
arrSpotlight[19][3] = "take5.logo.gif"
arrSpotlight[19][4] = "0"

arrSpotlight[20][0] = "1365423"
arrSpotlight[20][1] = "Woodlands Media Solutions"
arrSpotlight[20][2] = "Spring, TX"
arrSpotlight[20][3] = "woodlands.logo.jpg"
arrSpotlight[20][4] = "0"


/* ============================= Functions ============================= */

function rotateSpotlight() {
    var idxSequence, idxRandom, displayList = ",";
    var name, loc, src, folio, hoverfile, ent, hoverUrl, profileUrl, includePortfolio;
    for (idxSequence = 1; idxSequence <= spotlightImpressions; idxSequence++) {
        // get next unique participant
        while (true) {
        idxRandom = Math.floor(Math.random() * spotlightItems);
        if (displayList.indexOf(idxRandom) == -1) {
            break;
        }
    }
    displayList += String(idxRandom) + ",";

    // get participant data
    ent = arrSpotlight[idxRandom][spotlightEnterprise];
    name = arrSpotlight[idxRandom][spotlightAgency];
    loc = arrSpotlight[idxRandom][spotlightLocation];
    src = arrSpotlight[idxRandom][spotlightLogo];
    hoverUrl = "./Content/Spotlight/" + ent + ".htm";
    profileUrl = "./Subscriber/Profile.aspx?ent=" + ent;
    includePortfolio = (arrSpotlight[idxRandom][spotlightCreative] == 1);
    advisePortfolio = includePortfolio ? "creative and " : "";

    // place data on page
    var thisImage = document.getElementById("imgSpotlight" + idxSequence);
    thisImage.src = "./Image/Agencies/Spotlight/" + src;
    thisImage.alt = "View " + advisePortfolio + "complete profile for " + name + " (" + loc + ")";
    thisImage.title = "View " + advisePortfolio + "complete profile for " + name + " (" + loc + ")";
    thisImage.setAttribute('agentUrl', hoverUrl);

    var thisAnchor = document.getElementById("aSpotlight" + idxSequence);
    thisAnchor.href = profileUrl;
    }
    setTimeout("rotateSpotlight()", spotlightDuration * 1000);
}

