
// relies on jquery libraries
 $(document).ready(function(){
	$.getJSON("http://search.twitter.com/search.json?q=from%3AIresigncom&callback=?",
        function(data){
		  $.each(data.results, function(i,result){
		    var theDate = new Date(result.created_at);
			var today = new Date();
			var outDate;
			if (today.toDateString() == theDate.toDateString())	{
				var hrs = today.getHours() - theDate.getHours();
				if (hrs < 1) {
					outDate = "Today, less than an hour ago";
				}
				else if (hrs == 1) {
					outDate = "Today, about an hour ago";
				}
				else {
					outDate = "Today, about " + hrs + " hours ago";
				}
			}
			else {
				outDate = theDate.toDateString();
			}

			var thetext = result.text;

			thetext = thetext.replace(/(http:\S+)/gi, "<a href=\"$1\" class=\"tweetlink\">Link<\/a>");

			$("<div class=\"tweet\">" + thetext + "</div><div class=\"meta\">" + outDate + "</div>").appendTo("#tweetcontainer");
            if ( i == 2 ) return false;
          });
		  $("#tweetloading").remove();
		  $("#tweetcontainer").slideDown("normal");
        });
  });

