function shortlist(related_id, shortlist_type_id, item_name) {
  // make sure they're logged in first
  if (!logged_in()) {
    // throw-up the login form
    request_login( function(){ shortlist(related_id, shortlist_type_id, item_name); } );
    // and bail out
    return;
  }
  
  new Ajax.Request('/shortlists/add.json',
    {
      asynchronous:true, 
      parameters:'shortlist_type_id='+shortlist_type_id+'&related_id='+related_id,
      onSuccess:function(t) { shortlist_onSuccess(t, item_name); },
      onFailure:function(t) { shortlist_onFailure(t, item_name); }
    });
  return false;
}
function shortlist_onSuccess(t, item_name) {
  var result = t.responseJSON;
  if (result.success)
    display_notification('This '+item_name+' has been added to <a href="/member/pitches/"> your shortlist </a>');
  else
    display_notification('This '+item_name+' is already on <a href="/member/pitches/"> your shortlist </a>');
}
function shortlist_onFailure(t, item_name) {
  display_notification('There was a problem shortlisting the '+item_name);
}
