var currentItem = 0;
var itemArray = new Array();
var documentId = new String();

function loadItems(items) {
  itemArray = items;
}

function initItemCycler(items, itemid) {
  // load all the items of the array
  loadItems(items);

  documentItemId = itemid;
}

function getNextItem() {
  // if we have no items there is no point in cycling
  if (itemArray.length == 0)
    return;

  // we reached the last item so turn around
  if (currentItem >= itemArray.length)
    currentItem = 0;

  // return the item and increase the counter
  return itemArray[currentItem++];
}

function cycleItems() {
  var item = getNextItem();
 
  document.getElementById(documentItemId).href = item[1]; 
  document.getElementById(documentItemId).target = "_parent"; 
  document.getElementById(documentItemId).innerHTML = item[0];

  // set the time each item stays on the screen (in this case  4 secs)
  setTimeout("cycleItems();", 4000);
}

function startItemCycler() {
  cycleItems();
}

