$(function(){

	time = new Date();
	clockStart = time.getTime();

	if($.cookie('starttime')) {
		clockStart = $.cookie('starttime');
	} else {
		// Expire after 1 day
		// $.cookie('starttime', clockStart, { expires: 1} );
		// Cookie lasts as long as the session
		$.cookie('starttime', clockStart);
	}

	window.setTimeout("getSecs()", 1);
});

startday = new Date();

function initStopwatch() {
	var myTime = new Date();
	var timeNow = myTime.getTime();
	var timeDiff = timeNow - clockStart;
	this.diffSecs = timeDiff/1000;
	return(this.diffSecs);
}

function getSecs() {
	var mySecs = initStopwatch();
	var mySecs = "" + mySecs;
	var worldStart	= parseFloat($('#worldpop2').html().replace(/,/g,''));
	
	var worldCount = "" + parseFloat(worldStart + 2.37);
	$('#worldpop').html(worldCount);
	$('#worldpop2').html(worldCount);
	mySecs = parseFloat(mySecs.substring(0,mySecs.indexOf(".")) * 2.37);
	$('#popgrowth').html(mySecs);
	$('#popgrowth').format({format:"#,###,###,###", locale:"us"});
	$('#worldpop').format({format:"#,###,###,###", locale:"us"});
	window.setTimeout('getSecs()',1000);
}


