﻿
// homeads.js

// Home page rotating ads.

var homeAdsTimer;
var homeAdsCounter = -1;     // First increment will be 0, to start at the first image.

// Init. Start display.
//  Kept this wrapper consistent with class ads.
function HomeAdsInit()
{
  // Start it.
  HomeAdDisplay();
}

// Display next ad, set timer to call again.
function HomeAdDisplay()
{
  // Set timer for next one.
  homeAdsTimer = setTimeout("HomeAdDisplay()", 3000);

  // Increment, wrap, display.
  homeAdsCounter++;
  homeAdsCounter %= homeAds.length;
  
  var el = document.getElementById("imgHomeAd");
  if (el)
  {
    el.src = "/assets/marketing/promos/home/images/" + homeAds[homeAdsCounter];
  }
}

// Go to ad destination.
function HomeAdGo()
{
  var counter = homeAdsCounter;      // Seems to snap a copy, in case it changes during the click.
  location = homeAdLinks[counter];
}

