//<script src="/js/Analytics/gaAutoLinkTag.js" type="text/javascript"></script>

//Coexist with mootools on aller.dk
jQuery.noConflict();

jQuery(document).ready(function() {
    jQuery('a').each(function() {
        var href = jQuery(this).attr('href');
        var filetypes = /\.(zip|exe|pdf|doc|xls|ppt|mp3|eps|docx|rar|csv|gz|dmg|xml)$/i;
        if (href) {
            //Website
            if ((href.match(/^https?\:/i)) && (!href.match(document.domain)) && (!href.match(filetypes))) {
                jQuery(this).click(function() {
                    var extLink = href.replace(/^https?\:\/\//i, '');
                    _gaq.push(['_trackEvent', 'External Link Click', 'Web', extLink]);
                });
            };
            //E-mail
            if (href.match(/^mailto\:/i))            {	        	    jQuery(this).click(function()	        	    {	            	    var mailLink = href.replace(/^mailto\:/i, '');	            	    _gaq.push(['_trackEvent', 'External Link Click', 'Email', mailLink]);	        	    });            }            //File            if (href.match(filetypes))            {	        	    jQuery(this).click(function()	        	    {	            	    var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;	            	    _gaq.push(['_trackEvent', 'External Link Click', 'Download - ' + extension, href]);                    });	        }        }    });});
