// Tweets for my tweet...	
//	<h3>Tweets (<a href="http://www.twitter.com/coldert">twitter.com</a>)</h3>
//	<ul class="info" id="tweets"></ul>

function getTweets(){
	var tweeturl = "http://twitter.com/status/user_timeline/coldert.json?count=5&callback=?";
	$.getJSON(tweeturl, function(data){
		$.each(data, function(i, item){
			var txt = item.text
			/*
			.replace(/(https?:\/\/[-a-z0-9._~:\/?#@!$&\'()*+,;=%]+)/ig,'<a href="$1">$1</a>')
			.replace(/@+([_A-Za-z0-9-]+)/ig, '<a href="http://twitter.com/$1">@$1</a>')
			.replace(/#+([_A-Za-z0-9-]+)/ig, '<a href="http://search.twitter.com/search?q=$1">#$1</a>');
			/* */
			$('<li></li>').addClass('tweet').html(txt).appendTo('#tweets');
		});
		$("#tweets").append("<li><a href='http://www.twitter.com/coldert'>... more</a></li>");
	});
}

// last.fm
//	<h3>Recently played (<a href="http://www.lastfm.se/user/coldert">last.fm</a>)</h3>
//	<ul class="info" id="last_fm"></ul>

function getLastFM() {
	$.get("include/proxy.php?url=http://ws.audioscrobbler.com/2.0/user/coldert/recenttracks.rss", function(feed) {
		$(feed).find("item").each(function(i) {
			if(i<5){ // Maximum number of items
				var title = $(this).find("title").text();
				var link = $(this).find("link").text();
				var html = "<li><a href='"+link+"'>"+title+"</a></li>";
				$("#last_fm").append(html);
			}
		});
		$("#last_fm").append("<li><a href='http://www.lastfm.se/user/coldert'>... more</a></li>");
	});
}

$(function() {
	// Open external links outside of joker.com's frame
	$("a[href^='http://']").attr('target', '_top');
	
//	getTweets();
//	getLastFM();
});
