/* Google Reference - MUST BE SET! */
FGoogleRef = 'UA-26366284-1';
if (FGoogleRef == '') alert('You must configure the Google Reference Number in the analytics.js file otherwise the tracking will not work');

/* Standard Google Code */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', FGoogleRef]);
_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';
	//ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com//u/ga_debug.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

// Now add our little twiddly bits!
window.addEvent('domready', function()
{
	// Add external links tracking
	$$('a[href^="http://"]').each(function(aLink)
		{
			aLink.addEvent('click', function(){_gaq.push(['_trackEvent', 'Outbound Links', this.href]);});
		});
		
	// Add mailto links tracking
	$$('a[href^="mailto:"]').each(function(aLink)
		{
			aLink.addEvent('click', function(){_gaq.push(['_trackEvent', 'Email Links', this.href]);});
		});


	// Add document tracking based on the title or document name!
	$$('a[href$=".pdf"], a[href$=".doc"], a[href$=".docx"], a[href$=".xls"], a[href$=".xlsx"]').each(function(aLink)
		{
			aLink.addEvent('click', function(){_gaq.push(['_trackEvent', 'Document Links', this.href]);});
		});

	// Contact forms
	if ($('contactform')) $('contactform').addEvent('submit', function(){_gaq.push(['_trackEvent', 'Contact Review Form', 'Submission', window.location]);});
});

// Code for integrating AddThis with Analytics
// http://www.addthis.com/help/google-analytics-integration#.TqGJGvrP-9V
var addthis_config = {
  data_ga_property: FGoogleRef,
  data_ga_social: true
};
