function closePopup(lnk) {
  jQuery.unblockUI();
  //VAN-32
  /* Unica event tag, for external links */
  if(lnk != null){
    return ntptLinkTag(lnk);
  } 
}




$(function() {

  //VAN-32, unica tagging for pdf's
  jQuery("a[href$='.pdf']").click(function(){
    var href=window.location.href;
    if (href != null  && href.indexOf("kazaamweb") == -1 && href.indexOf(".local") == -1 && href.indexOf("www.endo.com") == -1) {
      if ($.browser.msie) {
        //IE7 shows popup warning if we call ntptLinkTag here so we will not do it for now.
      } else {
        return ntptLinkTag(this);
      }
    }
  });

  //VAN-32, unica tagging for img links
  jQuery('.thickbox').bind("click",function(){
    var href=window.location.href;
    if (href != null && href.indexOf("kazaamweb") == -1 && href.indexOf(".local") == -1 && href.indexOf("www.endo.com") == -1) {
      ntptEventTag( 'lc=' + this + '.img' );
    } 
  });


  //VAN-29
  jQuery('.visit-hcp-site').click(function() {

    return confirm('This site contains information for licensed healthcare professionals in the United States. By entering this Web site you acknowledge that you are a licensed healthcare professional practicing in the United States.');
  });

  //VAN-16
  $('a.external').attr('target', '_blank');
  
  //VAN-18
  $('#block-menu-primary-links a').each(function() {
    rExp  = $(this).html().replace('&reg;','<sup>&#174;</sup>');
    $(this).html(rExp);
  });
  $('#navigation .menu-407 a').each(function() {
    rExp  = $(this).html().replace('&reg;','<sup>&#174;</sup>');
    $(this).html(rExp);
  });

  //VAN-18 - open PDFs in new window
  $("a[href$=.pdf]").attr("target","_blank");
  $("a[href$=.PDF]").attr("target","_blank");

  var rExp = '';
  if ($('.section-admin').length == 0) {
    $('h1, h2, h3, h4, p').each(function() {
      rExp  = $(this).html().replace('&reg;','<sup>&#174;</sup>');
      $(this).html(rExp);
    });
  }

  // VAN-18 Exit Disclaimer
  // VAN-42 fixed disclaimer so it won't appear for absolute links to vantas'
  jQuery("a[href^=http]").click(function() {
    var href=jQuery(this).attr("href");
    if (href != null && href.indexOf("vantasimplant") == -1 && href.indexOf("www.endo.com") == -1 && href.indexOf("vantas") == -1) {
      jQuery.blockUI({
        message: "<div class=\"exitPopup\"><p>This link will direct you to a site maintained by a third party who is solely responsible for its content.</p><p>Endo Pharmaceuticals provides this link as a service to Web site visitors.</p><p>Endo Pharmaceuticals is not responsible for the Privacy Policy of any third party Web sites.</p><p>We encourage you to read the Privacy Policy of every Web site you visit. Click CANCEL to return or OK to continue.</p><p><a href=\"" + href + "\" target=\"_blank\" onclick=\"closePopup('"+this+"');\">OK</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"javascript:closePopup(null);\">CANCEL</a></p></div>",

        css: {
          width:          '590px',
          padding:        '10px',
          margin:         0,
          color:          '#333',
          textAlign:      'left',
          border:         '1px solid #999',
          backgroundColor:'#fff',
          cursor:         'wait'
        },

        // styles for the overlay
        overlayCSS:  {
          backgroundColor:'#000',
          opacity:        '0.3'
        }
      });
      return false;
    }
  });

});

// VAN-5 - Enlarge Text
// Fixed in VAN-18
// @see http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing
var origSize = 14, origLineHeight = 18;
function enlargeText(){
  var currFontSize = $('#content-area').css('font-size');
  var fontSizeUnit = currFontSize.slice(-2);
  var currLineHeight = $('#content-area').css('line-height');
  var lineHeightUnit = currLineHeight.slice(-2);
  var finalSize = parseFloat(currFontSize, 10); // parse into base 10 number
  finalSize = finalSize < origSize ? origSize : finalSize;
  var finalHeight = parseFloat(currFontSize, 10); // parse into base 10 number
  finalHeight = finalHeight < origLineHeight ? origLineHeight : finalHeight;
  if (finalSize < 22) {
    finalSize *= 1.2;
    finalHeight *= 1.2;
  } else {
    finalSize = origSize;
    finalHeight = origLineHeight;
  }
  $('#content-area, #pre_footer').each(function(){
    $(this).css('font-size', finalSize + fontSizeUnit);
    $(this).css('line-height', finalHeight + lineHeightUnit);
  });
}
