try {
String.prototype.endsWith = function(str)
{return (this.match(str+"$")==str)}
$(document).ready(function(){
  $('a').filter(function() {
    var theHref = this;
    var theHrefLC = theHref.toString().toLowerCase();
    if (theHref.hostname && theHref.hostname !== location.hostname) {
      $(theHref).not(".noAutoLink").attr('target','_blank').bind('click keypress', function(event) {
        var code=event.charCode || event.keyCode;
        if (!code || (code && code == 13)) {
          if(pageTracker){
            var fixedLink = this.href;
            fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
            fixedLink = fixedLink.replace(/\//,'_');
            // pageTracker._trackEvent('Offsite','Click',fixedLink);
            pageTracker._trackPageview('/TrackedEvents/Offsite/' + fixedLink);
            
          }
        }
      });
    } else {
      if (theHrefLC.endsWith('.pdf') || theHrefLC.endsWith('.doc') || theHrefLC.endsWith('.docx') || theHrefLC.endsWith('.xls') || theHrefLC.endsWith('.xlsx') || theHrefLC.endsWith('.ppt') || theHrefLC.endsWith('.pptx')) {
        $(theHref).not(".noAutoLink").attr('target','_blank').bind('click keypress', function(event) {
          var code=event.charCode || event.keyCode;
          if (!code || (code && code == 13)) {
            if(pageTracker){
              var fixedLink = this.href;
              fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
              fixedLink = fixedLink.replace(/\//,'_');
              // pageTracker._trackEvent('Onsite Download','Click',fixedLink);
              pageTracker._trackPageview('/TrackedEvents/Download/' + fixedLink);
            }
          }
        });
       }
    }
  });
});
} catch(err) {}
