﻿ $(document).ready(function(){
// Check whether links are external:
// (Only works with elements that have href):
$.extend($.expr[':'], {
    external: function(a, i, m) {
        if (!a.href) { return false; }
        if (a.hostname && a.hostname!= window.location.hostname) {
            var fixedHostname = a.hostname.replace(/^\s+|\s+$/g, '').toLowerCase().replace('qa.', '').replace('stage.','').replace('www.', '');
            //fixedHostname = fixedHostname.left(fixedHostname.indexOf(':'), fixedHostname.length - fixedHostname.indexOf(':'));
            if (jQuery.inArray(fixedHostname, safeList) >= 0) {
                return false;
            }
            if (fixedHostname.indexOf('javascript') > 0 || fixedHostname.indexOf('(') > 0 )
            {
                return false;
            }
            
            if (a.hostname.substr(0, a.hostname.indexOf(':')) == window.location.hostname)
            {
                //alert(a.hostname.substr(0, a.hostname.indexOf(':')));
                return false;
            }
            else 
            {
                return true;
            }
        }
        else return false;
    }
});

 var msg = "\nLinks which take you out of Abbott Laboratories worldwide \n"+
 "web site are not under the control of Abbott Laboratories, \n"+
 "and Abbott Laboratories is not responsible for the contents \n"+
 "of any such site or any further links from such site. Abbott \n"+
 "Laboratories is providing these links to you only as a \n"+
 "convenience, and the inclusion of any link does not imply \n"+
 "endorsement of the linked site by Abbott Laboratories.\n\n"+
 "Do you wish to leave this site?"; 

    $(document).ready(function() { 
        $('a:external').attr('target', '_blank').click(function(e) 
         { 
            if (confirm(msg) !=true ) 
            {
                e.preventDefault();    
            }
          }
        )
    });
    });