$(document).ready(function(){
	
	$('#email').attr("href", "mailto:steve.odom@gmail.com")
	
	$.ajax({ dataType:'script',
	 	  type: "GET",
		  data: "screen_name=twntyapp&count=5",
			dataType: "jsonp",
		  url: "http://api.twitter.com/1/statuses/user_timeline.json",
		error: function(req, status, e) {
		  $('#tweets').html('<li>Oops, we had trouble communicating with Twitter.</li>')
		},
		success: function(data) {
			twnty.twitter_callback(data);
		}
	});
	
	$('#invite_date').html(twnty.date_formatter(21));
			
});

var twnty = {
	twitter_callback : function(data) {
		var target = $('#tweets');
		$.each(data, function(i, tweet){
			target.append("<li>" + tweet.text + "</li>");
		});
		twttr.anywhere(function (T) {
		    T.linkifyUsers();
		 });
	},
	date_formatter : function(daysInTheFuture) {
		
		   var months = new Array(13);
		   months[0]  = "Jan";
		   months[1]  = "Feb";
		   months[2]  = "March";
		   months[3]  = "April";
		   months[4]  = "May";
		   months[5]  = "June";
		   months[6]  = "July";
		   months[7]  = "August";
		   months[8]  = "Sept";
		   months[9]  = "Oct";
		   months[10] = "Nov";
		   months[11] = "Dec";
		   var now         = new Date();
			 now.setDate(now.getDate()+daysInTheFuture);
		   var monthnumber = now.getMonth();
		   var monthname   = months[monthnumber];
		   var monthday    = now.getDate();
		   var dateString = monthname + ' ' + monthday;
		   return dateString;
	}
}


