﻿$(document).ready(function () {
	// grab each link on the page
	$('a').each(function () {

		// extract the link address from the link
		var strLink = $(this).attr("href");

		// check if its a link to one of our list
		if (IsLocalTrackableLink(strLink)) {

			// add an onclick method to it
			$(this).click(function () {
				// run the google page view function
				pageTracker._trackPageview(strLink);
			});
		}
	});
});

function IsLocalTrackableLink(linkUrl) {
	// check that a link is not null, local, 
	// and contains our file extensions
	if (linkUrl != null &&
        linkUrl.indexOf("http://") < 0 &&
        linkUrl.match(/\.(?:doc|xls|pdf|zip|rar|exe|mp3)($|\&|\?)/)) {
		return true;
	}
	return false;
}
