/**
 * Google Analytics
 */
$(document).ready(function(){
  
  /*
   * Track PDF clicks by adding analytics code
   * Get the last 4 characters of the href attribute and execute if '.pdf'
   * <a href="/en/downloads/PDF/commissioner_bio_eng.pdf" "title="PDF document, opens in a new window" target="new">
   *
   * Event Tracking Guide
   * http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
   * onClick="pageTracker._trackEvent(category, action, optional_label, optional_value)"
   * 
   * How do I track files (such as PDF, AVI, or WMV) that are downloaded from my site?
   * http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55529
   *
   * http://docs.jquery.com/Selectors
   *   = is exactly equal
   *   != is not equal
   *   ^= is starts with
   *   $= is ends with
   *   *= is contains
   *
   * $('a[href$=".pdf"]').attr('title', 'jfeiwojifew');
   */
  $('a[href$=".pdf"]').attr('onClick', function () {
    // ideally the title attribute of the links would include the title of the pdf
    // but instead they all say 'PDF document, opens in a new window'
    // so grab the href instead and pass that as the title
    var title =$(this).attr('href');
    return 'pageTracker._trackEvent(\'Downloads\', \'PDF\', \'' + title + '\')';
    });

});