$(document).ready(function(){
	
	if($('#countersboard').length > 0)
	{
		$('#countersboard').flightboard({
			lettersImage: '/images/flightboard/flightBoardLarge-Impact_16X34.png',
			lettersSize: [16,34],
			messages: ['COUNTERS ARE HOT', 'EYE CATCHING', 'CUSTOMIZABLE', 'EASY TO UPDATE'],
			maxLength: 16,
			selection: 'forward'
		});
	}

	if($('#worldpopulation').length>0)
	{
		time	= new Date();
		clockStart	= time.getTime();

		if($.cookie('starttime'))
		{
			clockStart	= $.cookie('starttime');
		} else {
			date = new Date();
			$.cookie('starttime', clockStart, { expires: (date.getTime() + 5) });
		}

		window.setTimeout('getSecs()', 0.5);
		
		startday = new Date();

	}
	
});

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

function getSecs() {
	var mySecs = initStopwatch();
	var mySecs = "" + mySecs;
	var worldStart	= parseInt($('#worldpopulation').html().replace(/,/g,''));
//	var worldCount = "" + parseInt(worldStart + 2.37);
	var worldCount = "" + parseInt(worldStart + 1);
	$('#worldpopulation').html(worldCount);
//	mySecs = parseInt(mySecs.substring(0,mySecs.indexOf(".")) * 2.37);
	mySecs = parseInt(mySecs.substring(0,mySecs.indexOf(".")) * 1);
	$('#netgrowth').html(mySecs);
	$('#netgrowth').format({format:"#,###,###,###", locale:"us"});
	$('#worldpopulation').format({format:"#,###,###,###", locale:"us"});
	window.setTimeout('getSecs()',500);
}
