var timerID = 0;
var baseTimeConst = "January 1, 2004";
var baseCount = 6001000000;
var increasePerMillisecond = 0.0025;
var refreshRate = 100;  //  in ms, of course

function startTimer(){
  timerID  = setTimeout("updateCounter()", refreshRate);
}

function updateCounter(){
  if(timerID) {
    clearTimeout(timerID);
    clockID  = 0;
  }
  var now = new Date();
  var baseTime = new Date(baseTimeConst);
  var totalMilliseconds = now.getTime() - baseTime.getTime();
  var newCount = Math.round(totalMilliseconds * increasePerMillisecond + baseCount);
  newCount = ThouS(newCount);

  document.getElementById('metriccounter').innerHTML = newCount;
  timerID  = setTimeout("updateCounter()", refreshRate);
}


// this code from http://www.merlyn.demon.co.uk/js-maths.htm
function ThouS(SS) {
  var X = "", S = String(SS),  L 	// SS >= 0
  while (S != "") { 
    L = S.length-3
    X = S.substr(L, 3) + (X>"" ? ','+X : '')
    S = S.substr(0, L) 
  }
  return X 
}

