// Verve Straplines

// ADD MULTIPLE PAGE LOADS HERE
addLoadEvent(prepareStraplines);


function addLoadEvent(vFunction) {
  var vOldOnLoad = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = vFunction;
  } else {
    window.onload = function() {
    vOldOnLoad();
    vFunction();
    }
  }
}

window.onunload = function() {
  window.clearTimeout(gStrapTimer);
}

// ======================================================= GLOBALS
var gStrapList;
var gStrapTimer;
var gStrapChangeInt = 7000;
var gStrapCounter = -1;

function prepareStraplines() {
  var vBrowVer= parseInt(navigator.appVersion);
  var vBrowType = navigator.appName;
  gBrowserType = "old";
  
  if ((vBrowType == "Netscape" && !(vBrowVer < 3)) || (vBrowType == "Microsoft Internet Explorer" && !(vBrowVer < 4))){
    gBrowserType = "new";
  }
  
  if (gBrowserType == "new") {
    gStrapCounter = Math.round(Math.random()*10);
    gStrapTimer = setTimeout('changeStrapline()', 4000);
  }
}

function changeStrapline() {
  if (gBrowserType == "new" && document.getElementById("topStrapline")) {
    gStrapCounter ++;
    if (gStrapCounter >= gStrapList.length) gStrapCounter = 0;
    document.getElementById("topStrapline").firstChild.nodeValue = gStrapList[gStrapCounter];
    gStrapTimer = setTimeout('changeStrapline()', gStrapChangeInt);
  }
}
