/*
* Toyota - Google Analytics Tracking Library
* Version: 1.0.2 2010-09-06
* Created by Panalysis www.panalysis.com
*/
var _gaSettings = {
	_lid: 'UA-7276741-14',
	_sid: 'UA-7276741-15',
	AccountID:'',
	DomainName: '',
	Path: "/",
	init: function()
	{
		if(typeof(CONFIG.GA.ua_id) != "undefined")
			this.AccountID = CONFIG.GA.ua_id;
		else if (window.location && window.location.hostname.toLowerCase().indexOf('tmca') > -1)
			this.AccountID = this._sid;
		else
			this.AccountID = this._lid;
		

	}
};
_gaSettings.init();
var _gaq = _gaq || [];
_gaq.push(['_setAccount', _gaSettings.AccountID]);
_gaq.push(['_setAllowHash',false]);
_gaq.push(['_setAllowLinker',true]);
if(_gaSettings.DomainName != "")
	_gaq.push(['_setDomainName',_gaSettings.DomainName]);
else
	_gaq.push(['_setDomainName','none']);
_gaq.push(['_setCookiePath',_gaSettings.Path]);
_gaq.push(['_trackPageview']);
/*Tracks Page Load Times*/
_gaq.push(['_trackPageLoadTime']);
 

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);

function GoogleAnalyticsWrapper (gaq)
{
	this.Type="googleanalytics"; 
	this._gaq = gaq;
	this._events = [];
};

GoogleAnalyticsWrapper.prototype._init = function(d)
{
	var wd = [];
	for(var i in d)
	{
		if(typeof(d[i])=="object" && d[i].length)
		{
			wd = [];
			wd.push(i);
			for(var x =0; x<d[i].length; x++)
			{
				if(typeof(d[i][x])=="object" && d[i][x].length)
				{
					wd = [];
					wd.push(i);
					for(var q=0;q<d[i][x].length;q++)
					{
						wd.push(d[i][x][q]);
					}
					this._events.push(wd);
					wd = [];
				}
				else
				{
					wd.push(d[i][x]);
				}
			}
			if(wd.length>0)
				this._events.push(wd);
		}
		else
		{
			this._events.push([i,d[i]]);
		}
	}
};


GoogleAnalyticsWrapper.prototype._sendData = function()
{
	for(var i in this._events)
	{
		var q = this._events[i];
		try
		{
			window["_gaq"].push(q);
		}
		catch(err) 
		{
			this._log("Error: Unable to add to GA events. " + err);
		}
	} 
	this._events = [];
};


