var timer;
$(document).ready(function() {
	getSearch();
	
});
function getSearch(){
	clearTimeout(timer);
	//var newTweet;
	var theQuery = "quitthecig";
	$.post("../getSearch.php", {query: theQuery},  function(xml){
		$('#Content #tweet_holder li').remove();
		$('entry',xml).each(function(i){
			var tweetContent = $(this).find("content").text();
			var tweetSource = $(this).find("twitter\\:source").text();
			var tweetAuthorLink = $(this).find("author uri").text();
			var tweetAuthor = $(this).find("author name").text();
			tweetAuthor = tweetAuthor.split(" ");
			var tweetAuthorPic = $(this).find("link[type='image/png']").attr("href");
			var newTweet = '<li class="tweet"><a href="'+tweetAuthorLink+'"><img src="'+tweetAuthorPic+'" width="48" height="48" alt="'+tweetAuthor[0]+'" /></a><div class="tweet_content"><p class="tweet_text"><a href="'+tweetAuthorLink+'">'+tweetAuthor[0]+'</a> '+tweetContent+'</p><p class="tweet_source">via '+tweetSource+'</p></div></li>';
			$('#Content #tweet_holder').append(newTweet);
		});
		$("a[@href^='http']").attr('target','_blank');
	});
	timer = setTimeout('getSearch()', 30000);
}
