$(document).ready(function() {

    // Creating custom :external selector
    $.expr[':'].external = function(obj) {
        return !obj.href.match(/^http\:\/\/\?|.covidien\.com\//)

                && !obj.href.match(/^mailto\:/)
				&& (obj.hostname != location.hostname)
                && (!obj.href.match(/^http\:\/\/\?|.bariatrics4diabetes\.com\//))
                && (!obj.href.match(/^http\:\/\/\?|.tamans-ww01d\//))
                && (!obj.href.match(/^http\:\/\/\?|.valleylab\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.cool-tiprf\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.valleylabeducation\.org\//))
				&& (!obj.href.match(/^http\:\/\/\?|.bariatricspro\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.autosuture\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.sils\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.yourhernia\.com\//))
				&& (!obj.href.match(/^javascript\:/))
				&& (!obj.href.match(/^http\:\/\/publish\.vx\.roo\.com\/covidien\//))
				&& (!obj.href.match(/^http\:\/\/podcast\.websurg\.com\/covidien\//))
				&& (!obj.href.match(/^http\:\/\/\?|.durasealinfo\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.durasealspine\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.surgipeer\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.duettrs\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.ligasure\.com\//))
                && (!obj.href.match(/^http\:\/\/\?|.nellcor\.com\//))
                && (!obj.href.match(/^http\:\/\/\?|.newligasure5mm\.com\//))
                && (!obj.href.match(/^http\:\/\/\?|.puritanbennett\.com\//))
                && (!obj.href.match(/^http\:\/\/\?|.livingwithavent\.com\//))
				&& (!obj.href.match(/^http\:\/\/\?|.forcetriad\.com\//))
     ;
    };


    // Add 'external' CSS class to all external links

    $('a:external').addClass('external').attr('target', '_blank').after('<a href="http://www.covidien.com/covidien/pageBuilder.aspx?topicID=189796&page=ExternalLinks:Introduction"><img src="../graphics/externalLink.gif" title="Click to read the full dislaimer text." class="disclaimerIcon"/></a>')


    // Create the tooltip
    $(".external").qtip(
	    			{
	    			    content: {
	    			        text: $(".disclaimerText").html()
	    			    },
	    			    position: {
	    			        corner: {
	    			            tooltip: 'bottomRight' // Use the corner...
	    			        },
	    			        target: 'mouse',
	    			        adjust: { mouse: false, screen: true }
	    			    },
	    			    hide: { effect: { type: 'fade', length: 500} },
	    			    style: {
	    			        border: {
	    			            width: 5,
	    			            radius: 0
	    			        },

	    			        padding: 10,
	    			        textAlign: 'left',
	    			        tip: true, // Give it a speech bubble tip with automatic corner detection
	    			        name: 'blue' // Style it according to the preset 'cream' style
	    			    }
	    			});

    $(".external").click(function() {
        pageTracker._trackPageview('/external_link_clicked');
    });
});