var WhatsHappening = {
  loadBlock : function(selector) {
    var listElem = $(selector);
	var max = 5;
	WhatsHappening.readData(function(entries) {
	  if (entries.length > 0) {
	      listElem.find("li").remove();
		  $.each(entries, function(i, entry) {
			if (i < max) {
				listElem.append('<li><a href="' + entry.url + '" target="_blank">' + entry.title + '</a></li>');
			} else {
			  return false;
			}
		  });
	  }
	});
  },
  
  readData : function(callback) {
	  var t = new Date().getTime();
	  $.getJSON('/json/whats-happening.json?t=' + t, callback);
  }
};
