function togglePoints(interval)
{
	var current = $('points_' + interval);
	$('points_daily').className = 'tab-b';
	$('points_weekly').className = 'tab-b';
	$('points_monthly').className = 'tab-b';
	$('points_all').className = 'tab-b';

	current.className = 'tab-s';
	
	getLeaderboard('points', interval);
}

function toggleCash(interval)
{
	var current = $('cash_' + interval);
	$('cash_daily').className = 'tab-g';
	$('cash_weekly').className = 'tab-g';
	$('cash_monthly').className = 'tab-g';
	$('cash_all').className = 'tab-g';

	current.className = 'tab-s';

	getLeaderboard('cash', interval);
}

function getLeaderboard(type,interval)
{
	var postStr = 'type=' + type + '&interval=' + interval;
	
	var url = '/method/leaderboard';
	// notice the use of a proxy to circumvent the Same Origin Policy.
	
	new Ajax.Request(url, {
		method: 'post',
		parameters: postStr,
		onSuccess: function(transport) {
			var json = transport.responseText.evalJSON();
			if (json.result.error)
			{
				$('winners_' + type).innerHTML = '<tr><td colspan="4">An error occurred while loading the leaderboard</td></tr>';
			}
			else if (json.result.success)
			{
				$('winners_' + type).innerHTML = json.result.resultsHTML;
			}
		}
	});
}
