function addCommas(nStr, french)
{
	var commaChar = ',';
	var dotChar = '.';

	if (french == true)
	{
		commaChar = " ";
		dotChar = ',';
	}

	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? dotChar + x[1] : '';

	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1))
	{
		x1 = x1.replace(rgx, '$1' + commaChar + '$2');
	}

	if (french == true)
		x2 = x2 + "&nbsp;$";
	else
		x1 = "$&nbsp;" + x1;

	return x1 + x2;
}


function updateDebtClock()
{
	var debtContainer = document.getElementById("public_debt");

	if (debtContainer)
	{
		var start = new Date("9/1/2009");
		var now = new Date();
		var seconds = (now.getTime() - start.getTime()) / 1000;
		var baseDebt = 212155000000;
		var newDebt = seconds * 286.92;
		var result = baseDebt + newDebt;

		var isClockFrench = document.getElementById('frenchClock');
	
		if (isClockFrench)
			isClockFrench = true;
		else
			isClockFrench = false;

		debtContainer.innerHTML = addCommas(result.toFixed(2), isClockFrench);

	}
	setTimeout("updateDebtClock()",1000);
}

updateDebtClock();

