var downloadAllowedExt = ["rar", "zip", "tar", "exe", "pdf", "mp3", "avi", "wmv", "mpg", "flv"]; // extensions to track

Event.observe(window, 'load', function() {
	if(window.urchinTracker) { // check that Google Analytics is available
		$$('a').each(function(el) {
			/* Loop through all our links */
			var hrefParts = el.href.split(".");
			if(downloadAllowedExt.indexOf(hrefParts[hrefParts.length-1]) != -1) { // only apply click event to files with allowed extensions
				el.observe('click', function(e) {
					var href = "Download: /" + this.href.split("/").slice(3).join("/"); // remove host and create our title to track as
					urchinTracker(href);
				}.bind(el));
			}
		});
	}
});
