/**
 * @author jens-petergrundmann
 * Gefunden auf http://iso-100.com/blog/post/updated-script-for-tracking-outbound-links-in-google-analytics-with-jquery/
 */
jQuery(document).ready(function() {
	jQuery('a').filter(function() {
		var theHref = this;
		//console.log("Attach "+theHref.hostname+"/"+theHref.pathname);
		jQuery(theHref).bind('click keypress', function(event) {
			var code=event.charCode || event.keyCode;
			if (!code || (code && code == 13) && pageTracker) {
				var fixedLink = this.href;
				fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
				if (theHref.hostname && theHref.hostname != location.hostname) {
					pageTracker._trackEvent('ExternalLink', 'Click', fixedLink);
				} else if(theHref.pathname && (theHref.pathname.search(/\.(xls|pdf|doc)$/i) != -1 ) ) {
					pageTracker._trackEvent('DownloadLink', 'Click', fixedLink);
				} else if(theHref.search && (theHref.search.search(/\.(xls|pdf|doc)$/i) != -1 ) ) {
					pageTracker._trackEvent('DownloadLink', 'Click', fixedLink);
				}
			}
		});
	});
});


