/*--------------------------------------GOOGLE ANALYTICS--------------------------------------*/

// GOOGLE ANALYTICS code
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20136576-1']);
_gaq.push(['_setDomainName', '.argylesocial.com']);
_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);
})();

// pushes a link to another site to GA
function ga_click(link,category,action) {
  	try {
		var myTracker = _gat._getTrackerByName();
		myTracker._trackEvent(category,action);
	//	_gaq.push(['myTracker._trackEvent',category,action]);
	//	setTimeout('document.location = "' + link + '"', 100);
	}
	catch(err){}
}

$('a').live({
	'click' : function() {
		var this_href = $(this).attr('href');
		var is_external = ( this_href.indexOf('#') != 0 && this_href.indexOf('/') != 0 && this_href.indexOf('argylesocial.com') == -1 ) ? true : false;
		if ( is_external && $(this).attr('target') != '_blank' ) {
			$(this).attr('target','_blank');
		}
		if ( is_external ) {
			ga_click(this_href,'Outbound Links',this_href);
		} else {
			ga_click(this_href,'Internal Links',this_href);
		}
	}	
});
