$(document).ready(function() {
  $('a.externLink').each(bindGoogleEventTracker);
  $('a.downloadLink').each(bindGoogleEventTracker);
});

/**
 * Bind a Google Event Tracker to the current object
 */
bindGoogleEventTracker = function(idx) {
  $(this).bind('click', function() {
    if($(this).hasClass('downloadLink')) {
      // download van bestand
      var extension = $(this).attr('class').replace('downloadLink ', '').toUpperCase();
      _gaq.push(['_trackEvent', 'Download', extension, $(this).attr('href')]);
    }
    else {
      // externe verwijzing
      _gaq.push(['_trackEvent', 'Externe link', $(this).attr('href')]);
    }
  });
};
