function report_content_in_context(url) {
  // they must be logged in to be here
  if (!logged_in()) {
    request_login(function(){ report_content_in_context(url); });
    return false;
  }
  
  new Ajax.Request(url,
    {
        asynchronous : true
      , onSuccess    : report_content_onSuccess
      , onFailure    : report_content_onFailure
    });
  return false;
}
function report_content(related_id, reported_type) {
  // they must be logged in to be here
  if (!logged_in()) {
    request_login(function(){ report_content(related_id, reported_type); });
    return false;
  }
  
  new Ajax.Request('/report/report_content.json',
    {
      asynchronous:true, 
      parameters:'reported_type='+reported_type+'&related_id='+related_id,
      onSuccess:report_content_onSuccess,
      onFailure:report_content_onFailure
    });
  return false;
}
function report_content_onSuccess(t) {
  var result = t.responseJSON;
  
  //We have failed display message
  if(!result.success)
  {
    switch(result.error_code)
    {
      case 'no_rights':
        display_notification('You must be logged in to report content.');
        break;
      case 'already_reported':
        display_notification('You have already reported this piece of content, you will be able to report it again once it has been moderated by an admin.');
        break;
      default:
        display_notification('You must be logged in to report content.');
        break;
    }
  }
  else
  {
    display_notification('This content has been reported to the moderators.');    
  }

}
function report_content_onFailure(t) {
  display_notification('There was a problem reporting the content');
}
