$(document).ready(function() {
	var ticker = new Task(new AmountsTicker());
    ticker.interval = 3000;
    ticker.start();
});

function AmountsTicker() {
	var self = this;
	
	this._url = "/ajax/json/amounts";
	this._trees = $("#amount_trees");
	this._co2 = $("#amount_co2");
	
	this.run = function() {
		$.getJSON(self._url, function(data) {
			if (data) {
				var amountTrees = Utils.formatNumber(data.amount.trees, 0);
				var amountCo2 = Utils.formatNumber(data.amount.co2, 5);
				self._trees.text(amountTrees);
				self._co2.text(amountCo2);
			}
		});
	};
}