function display_tweet(tweet_arr, call_again) {
	var JSON = JSON || {};
	 var tweet_arr_size = tweet_arr.length;
	
	JSON.stringify = JSON.stringify || function (obj) {
		var t = typeof (obj);
		if (t != "object" || obj === null) {
			// simple data type
			if (t == "string") obj = '"'+obj+'"';
			return String(obj);
		}
		else {

			// recurse array or object
			var n, v, json = [], arr = (obj && obj.constructor == Array);

			for (n in obj) {
				v = obj[n]; t = typeof(v);

				if (t == "string") v = '"'+v+'"';
				else if (t == "object" && v !== null) v = JSON.stringify(v);

				json.push((arr ? "" : '"' + n + '":') + String(v));
			}

			return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
		}
	};
	
	JSON.parse = JSON.parse || function (str) {
		if (str === "") str = '""';
		eval("var p=" + str + ";");
		return p;
	};
	
	var tweet = tweet_arr.pop();
	if(null != tweet){ 
		showTweet(tweet_arr, tweet.history_record);
	}
	if (stopped == false && call_again == true) {
		setTimeout(function(){$.post('/grab', {}, null, "script")}, 1000);
	}

}

function showTweet(tweet_arr, tweet)
{
	var reply_link = "http://twitter.com/?status=@" + tweet.from_user + "&in_reply_to_status_id=" + tweet.tweet_id + "&in_reply_to=" + tweet.from_user
 	var content = $("<div id=\"tweet_" + tweet.tweet_id + "\" class=\"tweet\" style=\"display: none;\"><div class=\"tweet-bg\"><div class=\"tweet-ribbon tweet-ribbon-" + tweet.dominant_category.split('_')[0][0] + tweet.dominant_category.split('_')[1][0] + "\"><div><table cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\" class=\"twitter-image\"><a href=\"http://twitter.com/" + tweet.from_user + "\" target=\"_blank\"><img height=\"48\" width=\"48\" src=\"" + tweet.profile_image_url + "\" /></td><td  style=\"max-width: 170px;\" width=\"170\" class=\"twitter-text\"></a>" + tweet.tweet + " <a href=\"" + reply_link + "\" target=\"_new\">reply</a></td></tr></table></div></div></div></div>");

  $(content).appendTo("#tweets").fadeIn(600, function(){ 
        tweet = tweet_arr.pop();
        if(null != tweet){ 
           showTweet(tweet_arr, tweet.history_record);
        }
   });
}

