﻿//OUTBOUND Links tracking
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

if (typeof jQuery == 'function') { /* use jQuery if it exists because it is a more elegant solution */
    jQuery(function () {
        jQuery('a:not([href*="' + document.domain + '"])').click(function () {

            var pageTracker = _gat._getTracker('UA-354922-3');
            pageTracker._trackPageview('/outgoing/' + jQuery(this).attr('href'));
        });
    });
}
else { /* use regular Javascript if jQuery does not exist */
    window.onload = function () {
        var links = document.getElementsByTagName('a');
        for (var x = 0; x < links.length; x++) {
            links[x].onclick = function () {
                var mydomain = new RegExp(document.domain, 'i');
                if (!mydomain.test(this.getAttribute('href'))) {

                    var pageTracker = _gat._getTracker('UA-354922-3');
                    pageTracker._trackPageview('/outgoing/' + this.getAttribute('href'));
                }
            };
        }
    };
}
