$(document).ready(function () {
    $('a').click(function () {
        var url = $(this).attr('href');
        if (url) {
            url = url.toLowerCase();
            var isWithinDomain = url.search('aprisorx\.com');
            var isWithinDomain2 = url.search('apriso\.com');
            var siteList = new Array('salix\.com', 'aprisorx\.com', 'metozolvodt\.com', 'tabletprep\.com', 'trialcard\.com');
            var siteListPassed = true;
            for (var i = 0; i < 5; i++) {
                if (url.search(siteList[i]) != -1)
                    siteListPassed = false;
            }
            var hasHTTP = url.search('http');
            if ((isWithinDomain == -1) && (isWithinDomain2 == -1) && (hasHTTP != -1) && siteListPassed) {
                $(this).attr('href', 'javascript:void(0);');
                $(this).attr('target', '_self');
                if (!goodbye(url)) {
                    $(this).attr('href', url);
                    $(this).attr('target', '_blank');
                    return false;
                }
            }
        }

    });

});

function goodbye(URL) {
    speech = "\nThank you for visiting www.aprisorx.com.  \nBy clicking OK you will be taken to a Web site or sites to which our Privacy Policy and other rules do not apply. Salix Pharmaceuticals does not possess editorial control over the content of the information provided in such Web site(s) and therefore does not warrant their accuracy and completeness. You are solely responsible for interactions with such Web site(s).";
    if (confirm(speech)) {
        window.open(URL, '_blank', 'toolbar=1,scrollbars=yes,location=1,status=1,menubar=1,resizable=1');
        return false;
    } else
        return false;
}
