﻿// We use SitecoreStarter as a kind of namespace, we avoid global functions and variables

var berryAlloc = {

	/****************************************************************/
	/*	Google Analytics											*/
	/****************************************************************/

	// Register event
	registerEvent: function (category, action, label) {
		DelawareCommons.logToConsole("Event: '" + category + "' - '" + action + "' - '" + label + "'");
		_gaq.push(['_trackEvent', category, action, label]);
	},

	// Register Error
	registerError: function (category, action, label) {
		DelawareCommons.logToConsole("Error: '" + category + "' - '" + action + "' - '" + label + "'");
		_gaq.push(['_trackEvent', category, action, label]);
	},

	// Register virtual view
	registerVirtualView: function (viewname) {
		DelawareCommons.logToConsole("Virtual view: '" + viewname + "'");
		_gaq.push(['_trackPageview', viewname]);
	},

	// Set a custom variable
	// Index:	(Required) The slot for the custom variable. This is a number whose value can range from 1 - 5, inclusive. 
	//			A custom variable should be placed in one slot only and not be re-used across different slots.
	//			Slot 1: CountryLanguage selection
	// Name:	(Required) The name for the custom variable. This is a string that identifies the custom variable and appears in the top-level 
	//			Custom Variables report of the Analytics reports.
	// Value:	(Required) The value for the custom variable. This is a string that is paired with a name. You can pair a number of values with 
	//			a custom variable name. The value appears in the table list of the UI for a selected variable name.
	//			Typically, you will have two or more values for a given name. For example, you might define a custom variable name gender 
	//			and supply male and female as two possible values.
	// Scope:	(Optional) The scope for the custom variable. As described above, the scope defines the level of user engagement with your site. 
	//			It is a number whose possible values are 1 (visitor-level), 2 (session-level), or 3 (page-level). 
	//			When left undefined, the custom variable scope defaults to page-level interaction.
	// http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
	setAnalyticsCustomVar: function (index, name, value, scope) {
		DelawareCommons.logToConsole("Custom var set: '" + index + "' - '" + name + "' - '" + value + "' - '" + scope + "'");
		_gaq.push(['_setCustomVar', index, name, value, scope]);
	}
};

