/* this function uses variables produced on the fly
   by 'hotproducts.asp' --
     hpID = index of current Hot Product item
     hotProductsUrlList = list of all Hot Products   */

var tickerID = 0;

function startTicker() {
  tickerID = setInterval('changeTicker(true)', 5000);
}

function changeTicker(cDirection) {
  var hpElm, maxID = hotProductsUrlList.length - 1;
  hpID = (cDirection ? hpID - 1 : hpID + 1);
  hpID = (hpID < 0 ? maxID : (hpID > maxID ? 0 : hpID));
  hpElm = document.getElementById("tickerMainItem");
  hpElm.src = hotProductsUrlList[hpID][4];
  hpElm = document.getElementById("tickerNameInfo");
  hpElm.innerHTML = hotProductsUrlList[hpID][1];
  hpElm = document.getElementById("tickerNameColour");
  hpElm.innerHTML = hotProductsUrlList[hpID][2];
  hpElm = document.getElementById("tickerPriceInfo");
  hpElm.innerHTML = hotProductsUrlList[hpID][3];
  if (tickerID) clearInterval(tickerID);
  tickerID = setInterval('changeTicker(true)', 5000);
}

function showTickerPage() {
  window.location.href = "detail.asp?id=" + hotProductsUrlList[hpID][0];
}

window.onload = startTicker;