// Copyright 2009 Google Inc. All Rights Reserved.

/**
 * @fileoverview Adds analytics tracking on all a tags that have href's that
 * start with http.
 * @author Michael Rigoli
 */

/**
 * Grabs all a elements by tagname and checks the href to see if the link will
 * take the user off the site, if so, it attaches an onclick event to the
 * element which will track the behavior in Google Analytics.
  */
function trackOutgoingLinks() {
  var allPageLinks = document.getElementsByTagName('a');
  for (var i = 0; i < allPageLinks.length; i++) {
    allPageLinks[i].onclick = function() {
      pageTracker._trackPageview('/analytics/outgoing/' + this.href);
    }
  }
}

