var counterId = 'js_counter';
var perYear = 650000000;
var updateFreq = 200;

var perSec = perYear / (365 * 24 * 60 * 60);
var updateInterval = perSec / (1000 / updateFreq);

var timerId;
var count;
var counter;

function addCommas (num) {
	var str = num.toString ();
	
	var numCommas;
	var offset;
	
	numCommas = (str.length / 3);
	if (str.length%3) {
		numCommas = Math.floor (numCommas);
		offset = str.length%3;
	}
	else {
		numCommas--;
		offset = 3;
	}
	
	var withCommas = str.substr (0, offset);
	for (var i = numCommas; i > 0; i--) {
		withCommas += ',' + str.substr (str.length - i * 3, 3);
	}
	
	return withCommas;
}

function updateCounter () {
	count += updateInterval;
	
	if (document.getElementById) {
		counter.innerHTML = '';
	}
	counter.innerHTML = addCommas (Math.round (count));
}

function initCounter () {
	if (document.getElementById) {
		counter = document.getElementById(counterId);
	}
	else if (document.all) {
		counter = document.all[counterId];
	}

	var date = new Date ();
	
	var passedSeconds = (((date.getMonth() * 30) + date.getDate()) * 24 * 60 * 60) + (date.getHours() * 60 * 60) + (date.getMinutes() * 60) + date.getSeconds();
	count = passedSeconds * perSec;
	
	if (document.getElementById) {
		counter.innerHTML = '';
	}
	counter.innerHTML = addCommas (Math.round (count));
	
	timerId = setInterval ('updateCounter()', updateFreq);
}

window.onload = initCounter;
