﻿$(document).ready(function() {
	//loop though each anchor element
	$('a').each(function() {
		var href = $(this).attr('href');
		var text = $(this).text();
		var filetypes = /\.(zip|rar|exe|pdf|txt|doc*|xls*|ppt*|vsd|vxd|mp3|wma|mov|avi|wmv)$/i;
		
		//check for links with file extension that match the filetypes regular expression:
		if (href.match(filetypes)) {
			$(this).click(function() {
				var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;
				var filePath = href.replace(/^https?\:\/\/(www.)amphia\.nl\//i, '');
				pageTracker._trackEvent('Downloads', text);
			});
		}
	});
});
