// applied to all external links
$(document).ready(function() {
  $("a[@href^=http]").click(function(){
    if (this.href.indexOf(location.hostname) == -1) {
      // if the cookie is set, just open the selected page in a new window
      if ($.cookie('disclaimer_accepted') == 'true') $(this).attr('target', '_blank');
      else {
        // if the cookie is not set, show the disclaimer with a link to the chosen page
        current_href = escape($(this).attr('href'));
        new_href = 'disclaimer.html?destination='+current_href+'&KeepThis=true&TB_iframe=true';
        $(this).attr('href', new_href);
        $(this).addClass('modified');
        // call thickbox manually
        tb_show('', new_href, false);
        // set the href back what it was originally to prevent changes accumulating
        $(this).attr('href', unescape(current_href));
        return false;
      }
    }
  });
});