/* 
----------
Someones:Collected 
splash page javascript
----------
*/



function get_stats()
{
  var interval = 1000
	$.ajax({
		url: '/items.json',
		type: 'GET',
		contentType: 'application/json',
		success: function (data, textStatus, jqXHR) {
			var pcount = format_number(data.items);
			$('#content .post-count').text(pcount);
			
			setTimeout(function(){
				get_stats();
			}, interval)
		},
		error: function(data){
			setTimeout(function(){
				get_stats()
			}, interval)
		}
	});
};

function format_number(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;
};

// DOM ready events
$(function(){
	get_stats();
});

