  // McGowan - prompts user if they wish to leave the page. For performance, limit what we're processing to specified reigions
  // @selectorText JQuery string for selecting elements i.e. "#page a, #content a"
  function rewriteExternalLinks(selectorText)
  {
    var links = $(selectorText);
    for (var i=0;i<links.length;i++)
    {
      var link=$(links[i]);
      var href=link.attr('href');
      if (href != null && href !=''
          && (href.match('^http') == 'http')
         )
      {
        var thisUrl = 'http://www.nhschicago.org/';
        thisUrl = thisUrl.replace('www.','');
        var matchUrl = href.replace('www.','');
        if (matchUrl.match('^'+thisUrl) != thisUrl)
        {
          link.attr('target','_blank');
          link.click(function() {
            return confirm("You are about to leave this website.  Do you wish to continue?");
          });
        }
      }
    }
  }

  $(document).ready(function() {
    rewriteExternalLinks('#interior_content a, .search_icons a');
  });
