$(document).ready(function() {
  // Initialise overlay
  Overlay.initialise();
  
  var rpc = new Jamiedia.RPC({ url: baseUrl+'api' });
  
  // Bind all news links to show the full article linked to it
  $('a.news-link').click(function() {
    var id = this.id.substring(9);
    
    // Show the overlay
    Overlay.show('Latest news');
    
    // Invoke RPC call
    rpc.invoke('getNewsItem', {
      id: id
    }, function(data) {
      Overlay.setContent('<h2>'+data.title+'<\/h2>'+data.body);
    });
    
    return false; 
  });
});