$(function() {
	// This is a list of internal domain names.  By default, the current domain is included.	
	$domains   = [window.location.hostname];
	// This is a listing of possible download types.
	$filetypes = ['doc','docx','pdf','zip'];
	// Alternatively, you can do an exclude of common web page extensions
	// $filetypes = ['htm','html','php','asp','aspx','cf'];
	// You would then comment line 32 and uncomment line 31.
	$('a').click(function() {
		var $href = $(this).attr('href');
		// var $linktype = 'Internal';
		var $linktype = 'Untracked';
		var $action   = 'Click';
		
		if ($href.indexOf('?') > -1) {
			$href = $href.substr(0,$href.indexOf('?'));
		}
		if ($href.indexOf('mailto:') == 0) {
			$linktype = 'Email';
		} else {
			if (($href.substr(0,7) == 'http://' || $href.substr(0,8) == 'https://') && $.inArray($href.replace(/http(s)?:\/\//i,'').split('/')[0],$domains) < 0) {
				$linktype = 'Outbound';
			} else {
				$hrefpieces = $href.split('.');
				// if ($.inArray($hrefpieces[$hrefpieces.length -1],$filetypes) < 0) {
				if ($.inArray($hrefpieces[$hrefpieces.length -1],$filetypes) > -1) {
					$action = $hrefpieces[$hrefpieces.length -1];
					$linktype = 'Download';
				}
			}
		}
		// For debugging, you can uncomment this code.
	 	// alert($linktype);
		// Adding check for 'Untracked' links. Only track if NOT 'Untracked'
		if ($linktype != 'Untracked') {
			_gaq.push(['_trackEvent', $linktype, $action, $(this).attr('href')]);
		}
		return $href;
	});
});