////////////////////// Config options //////////////////////////

var googleAccountId = 'UA-28157471-1';

////////////////////// end options //////////////////////////

////////////////////// init routines ///////////////////////////


////////// Google Analytics provided Tracking Script Module
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', googleAccountId]);
  _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);
  })();


// ennovative init routines
$(document).ready(function() {
	
	initGoogleTrackers();	
});

////////////////////// Functions below here ///////////////////////////

function initGoogleTrackers() {
	// hide the divs we want to appear after clicking
	$('.googleTrackClickAction .clickedView').hide();
	
	// add the click event to the default view
	$('.googleTrackClickAction').bind('click', googleActionTrackClick);
	
}

function googleActionTrackClick(event) {
	// get the tracker and page Ids	
	var pageId = $(this).attr("pageId");
	var mode = $(this).attr("mode")
	
	// error checking
	if (pageId == null || pageId == "") {
		alert("Google track page view error: no page ID supplied");	
		return false;
	}	


	$('.defaultView', this).hide();
	$('.clickedView', this).show();
	
	// unbind click event
	$(this).unbind('click');
	
	// do the google tracking stuff
	if (mode == "debug") {
		alert("track event triggered for tracker: " + googleAccountId + ", page id: " + pageId);
	}
	else {
		var pageTracker = _gat._getTracker(googleAccountId);
		pageTracker._initData();
		pageTracker._trackPageview(pageId); 
	}
	
}


