$(document).ready(function() {
	// process links for google analytics
	$('a').each(function(){
		var href = $(this).attr('href');
		//download file types
		var fileTypes = /\.(zip|exe|pdf|doc*|xls*|ppt*|mp3)$/i;
		
		// external links - any link with target="_blank"
		if($(this).attr('target') == '_blank') {
			$(this).click(function(){
				try{
              		_gaq.push(['_trackEvent', 'External', 'Click', href]);
        		} catch(err) {}
			});
		} else if (href && href.match(/^mailto\:/i)) {
			$(this).click(function(){
				try {								
					// strip down to just the email address
					var mailLink = href.replace(/^mailto\:/i, '');
                    _gaq.push(['_trackEvent', 'Email', 'Click', mailLink]);
                } catch(err) {}
			});							
		} else if(href && href.match(fileTypes)) {
			$(this).click(function() {
				try {
					_gaq.push(['_trackPageview', href]);
					setTimeout('location.href = "'+href+'";', 300);
				} catch(err) {}
				return false;
			});
		}
	});
});


var _gaq = _gaq || [];
_gaq.push(['_setAccount', gaCode]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
