///////////////////////////////////////////////////////////////////////////////
//
// Functions to simulate a Dictionary type
//
// Dictionary functions from Marjin Haverbeke's Eloquent JavaScript
// http://eloquentjavascript.net/ (C) Marjin Haverbeke
//
// Creative Commons License: http://creativecommons.org/licenses/by/3.0/
//
///////////////////////////////////////////////////////////////////////////////

function Dictionary(startValues)
{
	this.values = startValues || {};
	//this.values = startValues;
}

Dictionary.prototype.store = function(name, value)
{
	this.values[name] = value;
};

Dictionary.prototype.lookup = function(name)
{
	return this.values[name];
};

Dictionary.prototype.contains = function(name)
{
	return Object.prototype.hasOwnProperty.call(this.values, name) && Object.prototype.propertyIsEnumerable.call(this.values, name);
};

Dictionary.prototype.each = function(action)
{
	forEachIn(this.values, action);
};


// This is the list of sites and codes
var GAlookup = new Dictionary(
{
	"www.mygreatsite.com": "ABC123",
	"www.someothersite.com": "XYZ789",
	"www.iamduffy.com": "UA-3895152-2",
	"www.girlsaloud.com": "UA-3864943-1"
}
);


function getGACode(text)
{
	if (GAlookup.contains(text))
	{
		//alert('You passed: ' + text);

		return (GAlookup.lookup(text));
	} else
	{
		return (text + " not found");
	}
}


//var dummy = getGACode (window.location.hostname);

document.write("\n<script type=\"text/javascript\">" +
"\n var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");" +
"\n document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));" +
"\n</script>\n");


document.write("\n<script>" +

"\n var pageTracker = _gat._getTracker(\"" + getGACode(window.location.hostname) + "\");" +
"\n pageTracker._initData();" +
"\n pageTracker._trackPageview();" +

"\n var pageTracker2 = _gat._getTracker('UA-3895152-1');" +
"\n pageTracker2._initData();" +
"\n pageTracker2._trackPageview();" +
"\n</script>\n");

