var GoogleAnalytics = new Class({
	Implements: [Options],
	
	options: {
		cookieName: 'gid',
		host: 'google-analytics.com/ga.js',
		secure: 'https://ssl.',
		unsecure: 'http://www.'
	},
	
	initialize: function(options) {
		this.setOptions(options);
		this.start(this.getGID());
	},
	
	getGID: function() {
		return Cookie.read(this.options.cookieName);
	},
	
	start: function(gid) {
		if (!gid) return;
		var src = ("https:" == document.location.protocol) ? this.options.secure : this.options.unsecure;
		src = src + this.options.host;
		var myScript = Asset.javascript(src, {onload: this.onLoad.bind(this, gid)});
	},
	
	onLoad: function(gid) {
		try {
			this.pageTracker = _gat._getTracker(gid);
			this.pageTracker._trackPageview();
		} catch(err) {};		
	}
});

