// Global Killswitch
if (isJsEnabled()) {
  addLoadEvent(tickerStart);
}
// Constant built at startup to ratio the costs.
var costConst = 0;
// Store the start of the year so we don't have to rebuild it.
var yearStart = 0;

function TOfunc() {
  window.setTimeout( "TOfunc()", 1000 );

  actionspan = document.getElementById("action_money");
  var today = new Date();

  money = (today.getTime() - ((today.getFullYear() - 1970) * (1000 * 60 * 60 * 24 * 365))) * costConst;
  moneystring = money.toFixed(2);
  moneystring = moneystring.split('');
  // alert(moneystring.length);

  moneyTemp = moneycomma = '';
  // Add in commas.
  for (i = (moneystring.length - 4); i >= 0 ; i--) {
    if (moneystring.length == 14) { 
     if (i != (moneystring.length - 4) && (i-1)%3 == 0) {
      moneyTemp += ',';
     }
    }
    if (moneystring.length < 14) {
     if (i != (moneystring.length - 4) && i%3 == 0) {
      moneyTemp += ',';
     }
    }
    moneyTemp += moneystring[i];
  }

  // Reverse moneyTemp back into the right order.
  for (i = (moneyTemp.length - 1); i >= 0 ; i--) {
    moneycomma += moneyTemp.charAt(i);
  }

  // Add decimal back on.
  for (i = (moneystring.length - 3); i < moneystring.length ; i++) {
    moneycomma += moneystring[i];
  }
  if (actionspan){
    actionspan.innerHTML = '$' + moneycomma;
  }
}

function tickerStart() {
  var tempYear = new Date();
  year = tempYear.getFullYear();

  tempYear.setFullYear(year, 1, 1);
  tempYear.setHours(0, 0, 0, 0);
  yearStart = tempYear.getTime();

  tempYear.setFullYear(year, 12, 31);
  yearEnd = tempYear.getTime();

  costConst = 19500000000 / (yearEnd - yearStart);

  TOfunc();
}
