var Analytics = new Class({

	// extensions & implementations
	Implements: [],

	// instance properties
	instance: null,
	profileId: null,
	path: [],
	vars: {},
	debug: false,
	ignore: false,
	
	// constructor
	initialize: function ($profileId, $path, $vars, $debug, $ignore) {
		
		// record the parameters
		this.profileId = $profileId;
		if ($defined($path)) this.path = $path;
		if ($defined($vars)) this.vars = $vars;
		if ($defined($debug)) this.debug = $debug;
		if ($defined($ignore)) this.ignore = $ignore;
		
		// abort if no profileID was set
		if (!this.profileId) return;
		
		// load the instance
		this.load();
		
		// track the event
		this.track();
		
	},
	
	load: function () {
		if (!this.instance) {
			this.instance = _gat._getTracker(this.profileId);
			this.instance._initData();
		}
		return this.instance;
	},
	
	track: function () {
		var path = '';
		var vars = [];
		// track the user-defined variables, in the format:
		//  `varName-varValue`
		for (var p in this.vars) {
			var v = [p, this.vars[p]].join('-');
			vars.push(v)
			this.instance._setVar(v);
		}
		// track the pageview
		if (this.path.length) {
			path = this.path.join('/');
			this.instance._trackPageview(path);
		} else {
			this.instance._trackPageview();
		}
		// trace the event
		this.trace(path, vars);
	},
	
	trace: function ($path, $vars) {
		if (!this.debug) return;
		Log.logger('ga:', $path, $vars);
	}
	
});