var worker = {
		
	tweets:function(tweetData){
		
		var numberOfTweets = tweetData.results.length;
		
							
			function initialTweets(){
						
				for(i=0; i<numberOfTweets; i++){
			
					var tweetText = tweetData.results[i].text.replace(/(http:\/\/\S+)/g, "<a href='$1' target='_blank'>$1</a>"); 
					var tweetFreshness = new Date(tweetData.results[i].created_at);
		
					$('#twits').append('<div class="tweet"><div class="tweet-contain">' + tweetText + '</div><div class="tweet-arrow"></div><a href="http://twitter.com/joeydehnert" target="_blank">@joeydehnert</a></div>');
					
				}		
			}
			initialTweets();	
			
	}
}

// ajax call using twitter search api
$(document).ready(function(){	
	
	var twitUser = 'joeydehnert';
	
	function getTweets(){
		
		$.getJSON('http://search.twitter.com/search.json?callback=?&rpp=4&q=from:' + twitUser, function(data) {
		
			worker.tweets(data);
	
		});
	}
	getTweets();
	
});
