/* -----------------------------------------------
Title: Metrics Setup File
Author: Jarid Love
Modified: 2 Dec 2010 by Jarid Love
          "Added Header Link Checking"
----------------------------------------------- */

// begin google analytics code
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var gaNovellKey = "UA-3367212-1";
var gaNovellKey_video = "UA-9518721-1";
if((typeof isStage != "undefined" && isStage) || (typeof isTest != "undefined" && isTest) || (typeof isDev != "undefined" && isDev)) {
	gaNovellKey = "UA-3367212-4";
	gaNovellKey_video = "UA-9518721-3";
}
// end google analytics code

// header link tracking
var hasjQuery = jQuery || false;
if(hasjQuery) {
	function trackHeaderLink(val) {
		eventTracker._trackEvent('Header Links','clicks',val);
	}
	$(document).ready(function() {
		if(typeof isSupportedTouchDevice == "undefined" || (typeof isSupportedTouchDevice != "undefined" && !isSupportedTouchDevice())) {
			// filter touch devices, we want header menus to expand instead of firing click event for touch
			$("#hdr_lnks h3 a").click(function() {
				trackHeaderLink($(this).parent().parent().attr("id").replace("hdr_mnu_", "") + ": " + this.href.replace(ss,""));
				setTimeout('window.location = "' + this.href + '"', 100);
				return false;
			});
		}
		$(".hdr_mnu_container a").click(function() {
			if(typeof eventTracker != "undefined") {
				var tabId = "";
				var parentContainer = $(this).parent();
				while(parentContainer.parent().attr("id") != "hdr_lnks") {
					parentContainer = parentContainer.parent();
					if(parentContainer.hasClass("hdr_mnu_tab")) {
						tabId = parentContainer.parent().children(".hdr_mnu_tab").index(parentContainer);
					}
				}
				switch(tabId) {
					case 0 :
						tabId = "-bycategory";
						break;
					case 1 :
						tabId = "-atoz";
						break;	
				}
				trackHeaderLink(parentContainer.attr("id").replace("hdr_mnu_", "") + tabId + ": " + this.href.replace(ss,""));
				if(this.href.indexOf("sales_call") < 0) {
					setTimeout('window.location = "' + this.href + '"', 100);
				}
				return false;
			}
		});
		$("#hdr_home a").click(function() {
			if(typeof eventTracker != "undefined") {
				trackHeaderLink("home");
				setTimeout('window.location = "' + this.href + '"', 100);
				return false;
			}
		});
		$("#hdr_login a").click(function() {
			if(typeof eventTracker != "undefined") {
				trackHeaderLink("login");
				setTimeout('window.location = "' + this.href + '"', 100);
				return false;
			}
		});
		$("#hdr_lnks .hdr_mnu_tabs h5").click(function() {
			if(typeof eventTracker != "undefined") {
				trackHeaderLink($(this).find("strong").text());
			}
		});
	});
}
