$(document).ready(function(){


	// Twitter Rulez!!!
	var twitterUser = "ikhuerta";
	var tweets = 5;
	$.getJSON("http://twitter.com/status/user_timeline/"+twitterUser+".json?count=" + (tweets*2) +"&callback=?",function(json){
		html = "<ul class='myTweets'>";
		var urlregex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
		var userregex = /(\@([-A-Z0-9+&\/%?=~_|!:,.;]*))/gi;
		var hashtagregex = /(\#([-A-Z0-9+&\/%?=~_|!:,.;]*))/gi;
		var count = 0;
		for (i=0;i<json.length;i++)
		{
			if (json[i].in_reply_to_screen_name==null)
			{
				html += "<li><p class='text'>" + json[i].text.replace(urlregex,"<a class='url' href='$1' rel='nofollow'>$1</a>").replace(userregex,"<a class='user' href='http://twitter.com/$2' rel='nofollow'>$1</a>").replace(hashtagregex,"<a class='hashtag' href='http://twitter.com/#search?q=$1' rel='nofollow'>$1</a>") + "</p>";
				html += "<p><a href='http://twitter.com/home?status=RT @"+twitterUser+" "+json[i].text+"' rel='nofollow'>[ReTweet]</a> ";
				html += "<a href='http://twitter.com/home?status=@"+twitterUser+" &amp;in_reply_to_status_id=" + json[i].id + "&amp;in_reply_to="+twitterUser+"' rel='nofollow'>[Responder]</a></p></li>";
				count++;
			}
			if (count >= tweets) break;
		}
		html += "</ul>";
		$("#sidebar .twitter").append(html);
	})




});// End OnReady

