// Analytics.js
// original code from http://permanentinkdesign.com/articles/google-analytics-jquery-and-file-downloads/
// modified to add tracking support for all .doc, .xls, .zip, .pdf, .mp3 and .psd file
// this code assumes you have already done your initial call to google analytics 
// and that a pageTracker variable has been set

jQuery(document).ready(function(){
  filetypes = /\.doc$|\.xls$|\.zip$|\.pdf$|\.mp3$|\.psd$/i;
  jQuery("a").each(function(){
 		if (jQuery(this).attr("href") && jQuery(this).attr("href").match(filetypes)) {
      // The URL needs to be changed for each site this is applied to.
      var url = jQuery(this).attr("href").replace(/^http\:\/\/[^\/]*\.[a-z]{2,5}/i, "");
      jQuery(this).click(function() {pageTracker._trackPageview("/downloads" + url);})
		}
	});
});