window.addEvent('domready', function() {

	//Twitter JSONP request
	var myTwitterRequest = new Request.JSONP({
		url: 'http://twitter.com/statuses/user_timeline/theblockmag.json',
		data: {
			count: '3'
		},
		noCache: true,
		onComplete: function(myTweets) {
			var el = document.id('twitter-post');
			el.empty();
			myTweets.each(function(tweet) {
				var myElement = new Element('li',{
					html:  '<p class="tweet">' + convert(tweet.text) + '</p>'
				}).injectInside('twitter-post');

			});
		}
	}).send();
	delete myTwitterRequest;
 function convert(text) {
 text = text.replace(/@([^ ]\w*)/g,"<a href=\"http://twitter.com/$1\">@$1</a>");
 text = text.replace(/\#([^ ]\w*)/g,"<a href=\"http://search.twitter.com/search?q=%23$1\">#$1</a>");
 text = text.replace(/ http:\/\/([^ ]*)/g," <a href=\"http://$1\">http://$1</a>");

 return text;
 } 

	
	});
