// TRACK EXTERNAL LINKAGE
// HTMLgraphic Plugin - Google Asynchronous Tracking Code 
// v2.0
function recordOutboundLink(link, category, action) {
  try {
    var myTracker=_gat._getTrackerByName();
    _gaq.push(['myTracker._trackEvent', ' + category + ', ' + action + ']);
    //setTimeout('document.location = "' + link.href + '"', 100) // Remove 'attr('target','_blank')' and uncomment this to track without opening a new window.
  }catch(err){}
}

jQuery(document).ready(function($) {
        $('a:not(.popupwindow), a img').filter(function() {
          var theHref = this; 
          if (theHref.hostname && theHref.hostname !== location.hostname) {
                  $(theHref).not(".noAutoIcon").addClass("offSite");
                  $(theHref).not(".noAutoLink").attr('target','_blank').bind('click keypress', function(event) {
					var code=event.charCode || event.keyCode;
					if (!code || (code && code == 13)) {
						var fixedLink = this.href;
						fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
						fixedLink = '/outgoing/' + fixedLink;
						recordOutboundLink(this, 'Outbound Links', 'Click');
					};
                  });
          };                              
  });

});

