/*
	Twitter Slurp - JavaScript component (phptek edition)
	Author: John Bafford - http://bafford.com
	Copyright 2009 The Bivings Group
	http://www.bivings.com
*/

var ts = new TwitterSlurp(function(self){
	self.applicationURL = 'search.php';
	
	
	self.MakeNewLeaderboardEntry = function(leader)
	{
		var url = 'http://twitter.com/' + leader.fromUser;
				
		return '<li class="leader"><span class="avatar"><a href="' + url + '"><img src="' + leader.profileImage + '" height="48" width="48" /></a></span> <span class="tweetBody"><b><a href="' + url + '">' + leader.fromUser + '</a></b>: ' + leader.count + '</span></li>';
	}
	
	self.MakeNewLeaderboardTotalsEntry = function(total)
	{
		$('#leaderTotals').html('Total Tweets: ' + total.tweets + '<br />Total People: ' + total.users);
		
		return '';
	}
	
	self.startStats = function()
	{
		var newID = {
			'leaderboard': {},
			'stats': {}
		};
		
		$('.twitterLeaderboard').each(function(index) {
			newID.leaderboard[this.id] = {maxDisp: 20};
		});
		
		$('.twitterStats').each(function(index) {
			newID.stats[this.id] = 0;
		});
		
		this.refresh(newID);
	}
});



$(function() { ts.startStats(); } );

