function relative_time(C){var B=C.split(" ");C=B[1]+" "+B[2]+", "+B[5]+" "+B[3];var A=Date.parse(C);var D=(arguments.length>1)?arguments[1]:new Date();var E=parseInt((D.getTime()-A)/1000);E=E+(D.getTimezoneOffset()*60);if(E<60){return"less than a minute ago"}else{if(E<120){return"about a minute ago"}else{if(E<(60*60)){return(parseInt(E/60)).toString()+" minutes ago"}else{if(E<(120*60)){return"about an hour ago"}else{if(E<(24*60*60)){return"about "+(parseInt(E/3600)).toString()+" hours ago"}else{if(E<(48*60*60)){return"1 day ago"}else{return(parseInt(E/86400)).toString()+" days ago"}}}}}}};

function displayTweets(tweets) {
	$("#twitterloading").hide();
	for (i=0;i<tweets.length;i++) {
		itemtext = tweets[i].text;
		itemdate = relative_time(tweets[i].created_at);
		itemid = tweets[i].id;
		$("#twitteritems").append("<div id=\"twitteritem\">" + itemtext + "<br/>Added "
								  + "<a href=\"http://twitter.com/keanei/statuses/" + itemid + "\">"
								  + itemdate + "</a></div>");
	}
}

$(document).ready(function() {
	$("div.menuitem").corner("9px");
	$("div.menuitem").hover( function(){$(this).css("background-color","#AAAAFF"); }, 
							 function(){$(this).css("background-color","#F4F5FC"); } 
	); 
	
	$("div.menuitem").mouseup(function(event) {
							event.preventDefault();
							if (event.which == 2 | event.ctrlKey | event.shiftKey) {
								window.open( $(this).attr("url") );
							} else if (event.which == 1) {
								window.location = $(this).attr("url");
							}
					 })
					 .hover(
						function(){
							$(this).addClass("cursor_pointer");
						},
						function(){
							$(this).removeClass("cursor_pointer");
						} 
	);

	$("#twitterheading").corner("9px");
	
	//$.getScript("http://twitter.com/statuses/user_timeline/keanei.json?count=5&callback=displayTweets", function() {});	
	//$.getScript("http://www.keanei.com/twitter/twitter.php", function() {});	
	$.getScript("twitter/tweets.js", function() {});	
});