﻿if (typeof CBOL == "undefined") CBOL = new Object();
if (typeof CBOL.params == "undefined") CBOL.params = new Object();
if (typeof CBOL.ga == "undefined") CBOL.ga = new Object();

CBOL.init = function ()
{
	CBOL.id = $("body").attr("id").toLowerCase();
	
	console.log("CBOL.init()", CBOL.id);
	
	if (typeof CBOL["base"] == "object" && typeof CBOL["base"]["init"] == "function") {
		try {
			CBOL.base.init();
		} catch (e) {
		}
	}

	if (typeof CBOL[CBOL.id] == "object" && typeof CBOL[CBOL.id]["init"] == "function") {
		try {
			CBOL[CBOL.id].init();
		} catch (e) {
		}
	}
	
	CBOL.ga.init();
}

CBOL.ga.account = "UA-10010442-7";

CBOL.ga.init = function ()
{
//	$("a[href$='.pdf']").bind("click", CBOL.ga.trackDownload);
//	$("a[href$='.zip']").bind("click", CBOL.ga.trackDownload);
//	$("a[href$='.ppt']").bind("click", CBOL.ga.trackDownload);
												 
	try {
		CBOL.ga.pageTracker = _gat._getTracker(CBOL.ga.account);
		CBOL.ga.pageTracker._trackPageview();
		console.log("CBOL.ga.init()", CBOL.ga.account);
	} catch (e) {
	}
}

CBOL.ga.trackDownload = function ()
{
	var href = $(this).attr("href").replace("http://www.barcodeoflife.org", "");
	if (href.charAt(0) != "/") href = "/" + href;
	
	try {
		CBOL.ga.pageTracker._trackPageview(href);
	} catch (e) {
	}
	
	return true;
}
