
var GoogleAnalytics = Class.create({
	initialize: function(params)	// rootpath is default param... if a string is sent for var params, it will be used for rootpath
	{
		// Extract params
		if (typeof(params) == 'string')
		{
			_params = [];
			_params.rootpath = params;
			
			params = _params;
		}else{
			params = params;
		}
		this.params = params;
		this.params.sitemode = (this.params.sitemode != undefined ? this.params.sitemode : 'dev');
	},
	
	trackPageview: function(url)
	{
		// Only run on production server
		if (this.params.sitemode != 'production') return false;

		try {
			// Data protection
			regexp = /^[^:]*:\/\//;
			regexp = regexp + this.params.rootpath.replace('.', '\.').replace('/', '\/');	
			url = url.replace(regexp, '');

			// Trigger google analytics
			_gaq.push(['_trackPageview', url]);
		}catch(err) {}
	}
});
