$(document).ready(function() {
  var retractionURL;
  
  /* Add retraction notice at top of retracted article */
  if ($('div#col-2 li.notice.correction-links a span.retraction').length > 0) {
    retractionURL = $('div#col-2 li.notice.correction-links a').has('span.retraction').attr('href');
    
  /* Also check RM-based relationships (for candisc) */
  } else {
    $('div#col-2 li.notice.correction-links li.relmgr-relation.errata a').has('span.cit-section').each(function() {
      var retraction_check = $(this).children('span.cit-section').is(function() {
        return (($(this).text() == "Retractions") || ($(this).text() == "Retraction"))
      });
      if (retraction_check) {
        $(this).html('<span class="cit-section">A retraction has been published</span>');
        retractionURL = $(this).attr('href');
        /* Add "retraction" class to span (for CSS) */
        $(this).children('span.cit-section').addClass('retraction');
      }
    });
  }

  if (retractionURL) {
    $("div#content-block").prepend('<div class="retraction-notice"><a href="' + retractionURL + '">This article has been RETRACTED</a></div>');
  }
});
