var twitter_url = 'http://twitter.com/statuses/user_timeline/mludd.json?count=5&callback=?';

function ISODateString(d){
	function pad(n){
		return n<10 ? '0'+n : n;
	}
	
	return d.getUTCFullYear()+'-'
    + pad(d.getUTCMonth()+1)+'-'
    + pad(d.getUTCDate())+' '
    + pad(d.getUTCHours()+2)+':'
    + pad(d.getUTCMinutes())+':'
    + pad(d.getUTCSeconds());
}

function checkForUrls(text) {
	return text;
}

function updateTwitList() {
	$.getJSON(
		twitter_url,
		function(data) {
			$('#twitterBox ul').html('');
			for(var i = 0; i < data.length; i++) {
				var saneTime = new Date(data[i].created_at);
				var strTime = ISODateString(saneTime);
				
				var post = checkForUrls(data[i].text);
				
				$('#twitterBox ul').append('<li>'+post+'<br /><a href="http://twitter.com/#!/mludd/status/'+data[i].id_str+'">['+strTime+']</a></li>');
			}
    });
}
$(document).ready(function() {
	updateTwitList();
	setInterval("updateTwitList()", 60000);
});
