/**
* Outbound link tracking
*
* This code largely based on examples from
* [Google Analytics Help](http://www.google.com/support/googleanalytics/bin/answer.py?answer=55527).
*/
jQuery(function($){
$('a:not([href*="' + document.domain + '"])').click(function(event){
// Just in case, be safe and don't do anything
if (typeof _gat == 'undefined') {
return;
}
// Stop our browser-based redirect, we'll do that in a minute
event.preventDefault();
var link = $(this);
var href = link.attr('href');
var noProtocol = href.replace(/http[s]?:\/\//, '');
// Track the event
_gat._getTrackerByName()._trackEvent('Outbound Links', noProtocol);
// Opening in a new window?
if (link.attr('target') == '_blank') {
/* If we are opening a new window, go ahead and open it now
instead of in a setTimeout callback, so that popup blockers
don't block it. */
window.open(href);
}
else {
/* If we're opening in the same window, we need to delay
for a brief moment to ensure the _trackEvent has had time
to fire */
setTimeout('document.location = "' + href + '";', 100);
}
});
});