/* Google Reference - MUST BE SET! */
FGoogleRef = 'UA-1178479-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 blog rss
	$$('a[href$="blogrss.php"]').each(function(aLink)
		{
			aLink.addEvent('click', function(){_gaq.push(['_trackEvent', 'Blog RSS', window.location]);});
		});


	// 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]);});
		});
		
	// Add team tab tracking
	if ($('teamtab')) $('teamtab').addEvent('click', function(){_gaq.push(['_trackEvent', 'Team Tab', this.href]);});

	// Sign up form
	if ($('signupform')) $('signupform').addEvent('submit', function(){_gaq.push(['_trackEvent', 'Newsletter Signup', 'Right Column Submission', window.location]);});
	if ($('signupformlarge')) $('signupformlarge').addEvent('submit', function(){_gaq.push(['_trackEvent', 'Newsletter Signup', 'Signup Page Submission', window.location]);});

	// Contact forms
	if (FGoogleForceConversionPage != '') _gaq.push(['_trackPageview', FGoogleForceConversionPage]);
});
