/*
 * Global scripts file for TT
 * Dependency on jQuery
 */
// Functions and inline scripts
// Global declarations ============================================================================
var isHome = isHome || false;
var is404 = is404 || false;
// Login user info ================================================================================
var allcookies = document.cookie;
var indexLogin = allcookies.indexOf("Datav2");
var indexProps = indexLogin; // allcookies.indexOf("Datav2");
var indexProps2 = allcookies.indexOf("uidLoggedIn");
var SiteList = unescape(allcookies.substring(allcookies.indexOf("Site", indexProps) + 4));
var thisSite = SiteList.indexOf("," + SITE_v5sid + ",");
var loggedIn = (indexProps != -1 && thisSite != -1) ? 1 : -1;
var uidLoggedIn = (indexProps2 != -1 && thisSite != -1) ? 1 : -1;
var indexIPC = getCookieValue("IPC");
var ipcLoggedIn = (indexIPC != "") ? 1 : -1;
var DisplayName = (function () {
	var beginName = unescape(allcookies.substring(allcookies.indexOf("DispName", indexProps) + 8));
	var endName = beginName.substring(0, beginName.indexOf(";"));
	var regexp = /(\+)/g;
	return endName.replace(regexp, " ");
})();
var ttUser = (indexLogin != -1 && indexProps != -1) ? 1 : -1;
// Magazine-based access ==========================================================================
var userContentAccess = (function () {
	var accessMONYY = getChipValue("magAccess", "sid" + SITE_v5sid);
	var vc = (typeof SITE_magQualValidCookies == "undefined") ? "" : SITE_magQualValidCookies;
	return (accessMONYY != "" && vc.indexOf(accessMONYY) != -1);
})();
// Offer cookie ===================================================================================
var underscoreOffer = (function () {
	var offer = getURLParamValue("Offer");
	if (offer != "") {
		setSessionCookie("Offer", offer);
		return "-" + offer;
	}
	return "";
})();
// Member update ==================================================================================
var memberUpdate = (function () {
	if (memberUpdate && memberUpdate != "on") return;
	var memUpd = -1;
	var flag = (typeof SITE_memberUpdateFlag == "undefined" && "on" || SITE_memberUpdateFlag);
	if (flag == "on" && loggedIn == 1) {
		var mu1 = getCookieValue("mu1");
		if (mu1 == "") memUpd = 1;
		if (mu1 != 1 && mu1 != "") {
			var oneDay = (24*(60*(60*1000)));
			var cDate = (new Date(mu1)).getTime();
			var tDate = cDate + oneDay;
			var nowDate = (new Date()).getTime();
			if (nowDate > tDate) memUpd = 1;
		}
		if (memUpd != -1) {
			var url = (typeof SITE_memberUpdateURL == "undefined") ? "" : SITE_memberUpdateURL;
			if (url != "") {
				$(document).ready(function ($) {
					if (memberUpdate == "on") {
						$("body").append('<iframe id="memberUpdate"' +
						' width="1" height="0"' +
						' border="0" frameborder="0"' +
						' marginheight="0" marginwidth="0"' +
						' scrolling="no" />');
						$("iframe#memberUpdate").attr("src", url);
					}
				});
			}
		}
	}
	return flag;
})();
// Ads ============================================================================================
var adDebug = (function () {
	if (getURLParamValue("adIframe") == "on") return "iframe";
	if (getURLParamValue("adString") == "on") return "string";
	return "off";
})();
// Interstitial override
var dcopt = (function () {
	var on = (typeof interstitialSwitch == "undefined" || interstitialSwitch);
	var dc = (typeof dcopt == "undefined" && "ist" || dcopt);
	var urlOverride = getURLParamValue("int");
	if (!on || dc != "ist" || urlOverride == "off") {
		return "";
	}
	return "ist";
})();
// Dart Utility Class
function DartUtil() {
	this.log = [],
	// Cache these properties when the object is instantiated, so that
	// each call to getDartString does not have to recalculate them
	this.acct  = window.accountAbbr || "null",
	this.zone  = getURLParamValue("parentZone") || window.zone || "null",
	this.pth   = getURLParamValue("parentPth") || window.location.pathname.substring(1).replace(/\//g, "."),
	this.kw    = getURLParamValue("parentKw") || window.kw || (function () {
		var query = getURLParamValue("query") || getURLParamValue("q");
		if (query != "") {
			query = unescape(query).toLowerCase().
			replace(/[\s\+]+&[\s\+]+/g, "+"). // replace standalone ampersands
			replace(/[\s\+]+/g, "+"). // replace multipe spaces with a single space
			// replace spaces with +and+
			// protect +or+ from becoming +and+or+and+
			replace(/\+(?!(or\+))/g, function () {
				// no backreferences in js so must use this method
				return (RegExp.leftContext.substr(-3) == "+or") ? "+" : "+and+";
			});
			return escape(query);
		}
	})() || "", // keyword
	this.gci   = getURLParamValue("parentGci") || window.gci || "", // ad_id of a CI
	this.taxHelper = {
		taxLevel: function () {
			var pathArray = window.location.pathname.substring(1).split("/");
			var lvl = pathArray.length; 
			if (lvl > 0) {
				if (ENV_isStage && pathArray[0] == SITE_name) {
					return lvl - 1;
				}
			}
			return lvl;
		}
	},
	this.tax   = (function (o) { // ad_id of a CI primary topic or a channel
		if (document.referrer.indexOf("informationCenter") != -1) {
			// test for topicTax override cookie
			var topicTax = getCookieValue("topicTax");
			if (topicTax != "") {
				topicTax = topicTax.split(":");
				// set clu
				o.clu = (topicTax.length > 0) ? topicTax[1] : "NONE";
				return topicTax[0];
			}
		}
		return "";
	})(this) || (function (o) {
		var gci = window.gci || "";
		var zn = window.zone || "";
		if (gci != "" || (zn == "TOPICS" && o.taxHelper.taxLevel() > 1)) {
			// page is a CI page or Topics page that isn't topicsMain
			return window.tax;
		}
		return "";
	})(this) || getURLParamValue("parentTax") || (function (o) {
		var zn = window.zone || "";
		if ((zn == "AIOG" || zn == "ATE" || zn == "TIPS") && o.taxHelper.taxLevel() > 1) {
			// handles targeting we used to do by oid _tax
			return window.defaultTax;
		}
		return "";
	})(this) || "",
	this.clu   = this.clu || window.clu || getURLParamValue("parentClu") || "", // ad_id of a cluster
	this.adg   = getURLParamValue("adg") || window.adg || "", // channel override ad group
	this.ptile = 0,
	this.iid   = window.iid || getURLParamValue("parentIid") || "", // infocenter id
	this.iin   = getURLParamValue("parentIin") || (function () {
		if (typeof hbxMLC != "undefined" && hbxMLC.indexOf("infoCenter") != -1) {
			return hbxMLC.substring(1, hbxMLC.indexOf(";"));
		}
		return "";
	})(), // infocenter name
	this.rci   = window.rci || getURLParamValue("parentRci"), // resourcecenter id
	this.nl    = getURLParamValue("ad"), // newsletter ad id
	this.ses   = getURLParamValue("ses"), // persistent ad id
	this.track = getURLParamValue("track"), // track ad id
	this.ptag  = getURLParamValue("ptag"), // itkeptag
	this.tag   = getURLParamValue("tag"), // itketag
	this.blog  = getURLParamValue("blog") // itkeblog
	this.categoryExclusion = (function () {
		// welcome ad exclusionary clause, this suppresses certain ads when the welcome ad is shown
		if (typeof prestitialTimeOut != "undefined" || getURLParamValue("parentPre")) {
			return "!category=prestitial";
		}
		return "";
	})(),
	this.ord   = Math.round(Math.random() * 100000000),
	this.getDartString = function (adi, sz, ptile, zone, env, host, ses) {
		var zone = zone || this.zone;
		var env = env || this.env;
		return "http://ad.doubleclick.net/" + adi +
		"/" + this.acct +
		"/" + zone +
		";pos=0"  +
		";pth="   + this.pth +
		";kw="    + this.kw +
		";gci="   + this.gci +
		";tax="   + this.tax +
		";clu="   + this.clu +
		";adg="   + this.adg +
		";sz="    + sz +
		";dcopt=" + dcopt +
		";ptile=" + ptile +
		";iid="   + this.iid +
		";iin="   + this.iin +
		";rci="   + this.rci +
		";nl="    + this.nl +
		";ses="   + (ses || this.ses) +
		";track=" + this.track +
		";ptag="  + this.ptag +
		";tag="   + this.tag +
		";blog="  + this.blog +
		(env && typeof env == "string" ? ";env=" + env.toLowerCase() : "") +
		(host && typeof host == "string" ? ";host=" + host : "") +
		(this.categoryExclusion != "" ? ";" + this.categoryExclusion : "") +
		";ord="   + this.ord + "?";
	},
	this.getLeaderboard = function () {
		var ptile = ++this.ptile;
		var name = "leaderboard_" + ptile;
		var sz = "728x90";
		// var src = this.getDartString("adi", sz, ptile);
		// comment this in once we upload leaderboard.html
		// note: we also need to convert the adi parameter to adj in the dart string
		var src = this.getDartString("adj", sz, ptile);
		src = "/vgn-ext-templating/html/leaderboard.html?" + escape(src);
		var leaderboardIframe = '<iframe src="' + src + '" name="frame_' + name + '" width="728" height="90" border="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"></iframe>';
		if (adDebug == "iframe") this.log.push("Ad: " + name + "\n" + leaderboardIframe);
		if (adDebug == "string") this.log.push("Ad: " + name + "\n" + unescape(src));
		dcopt = "";
		return leaderboardIframe;
	},
	this.getVendorOffer = function () {
		var ptile = ++this.ptile;
		var name = "vendorOffer_" + ptile;
		var sz = "550x33,550x45";
		var src = this.getDartString("adi", sz, ptile);
		var vendorOfferIframe = '<iframe src="' + src + '" name="frame_' + name + '" width="550" height="45" border="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"></iframe>';
		if (adDebug == "iframe") this.log.push("Ad: " + name + "\n" + vendorOfferIframe);
		if (adDebug == "string") this.log.push("Ad: " + name + "\n" + src);
		dcopt = "";
		return vendorOfferIframe;
	},
	this.getSkyscraper = function () {
		var ptile = ++this.ptile;
		var name = "skyscraper_" + ptile;
		var sz = "160x600";
		var src = this.getDartString("adi", sz, ptile);
		var skyscraperIframe = '<iframe src="' + src + '" name="frame_' + name + '" width="160" height="600" border="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"></iframe>';
		if (adDebug == "iframe") this.log.push("Ad: " + name + "\n" + skyscraperIframe);
		if (adDebug == "string") this.log.push("Ad: " + name + "\n" + src);
		dcopt = "";
		return skyscraperIframe;
	},
	this.getPrestitialAd = function () {
		var ptile = ++this.ptile;
		var name = "welcome_" + ptile;
		var sz = "640x480";
		dcopt = ""; // do not also call an interstitial
		var prestialAdSrc = this.getDartString("adi", sz, ptile, "welcome");
		if (adDebug == "string") this.log.push("Ad: " + name + "\n" + prestialAdSrc);
		this.categoryExclusion = "!category=prestitial";
		return prestialAdSrc;
	},
	this.getBigAd = function () {
		var ptile = ++this.ptile;
		var name = "bigAd_" + ptile;
		var sz = "300x250";
		var src = this.getDartString("adi", sz, ptile);
		var bigAdIframe = '<iframe src="' + src + '" name="frame_' + name + '" width="300" height="250" border="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"></iframe>';
		if (adDebug == "iframe") this.log.push("Ad: " + name + "\n" + bigAdIframe);
		if (adDebug == "string") this.log.push("Ad: " + name + "\n" + src);
		dcopt = "";
		return bigAdIframe;
	},
	this.getCltAd = function () {
		deleteCookie("ugcCltHeight", "/", SITE_domain); // clear previous resize
		var ptile = ++this.ptile;
		var name = "cltAd_" + ptile;
		var sz = "310x950";
		var host;
		if (ENV_isStage) {
			// site name rewrites are turned off on preview stage
			host = "preview" + (ENV_name == "PROD" ? "" : "." + ENV_name.toLowerCase()) +
				".techtarget.com/" + SITE_name;
		}
		var src = this.getDartString("adi", sz, ptile, null, window.ENV_name, host);
		var cltAdIframe = '<iframe src="' + src + '" name="frame_' + name + '" width="310" height="950" border="0" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" onload="resizeCLT(this)"></iframe>';
		if (adDebug == "iframe") this.log.push("Ad: " + name + "\n" + cltAdIframe);
		if (adDebug == "string") this.log.push("Ad: " + name + "\n" + src);
		dcopt = "";
		return cltAdIframe;
	}
}
// This is called in the onload handler of the CLT ad iframe
function resizeCLT(adHandle) {
	var ugcCltHeight = readCookie("ugcCltHeight");
	var dbg = getURLParamValue("cltDbg");
	if (dbg == 1) {
		var doc = adHandle.contentWindow.document;
		alert("DEBUG:\nugcCltHeight cookie: " + ugcCltHeight +
		"\ndocument.body.scrollHeight: " + doc.body.scrollHeight +
		"\ndocument.height: " + doc.height);
	}
	// check for 0 length ugcCltHeight: occurs when cookie is set to empty value
	if (adHandle != null && (ugcCltHeight != null && ugcCltHeight.length > 0)) adHandle.height = ugcCltHeight;
}
// This function controls functional leaderboard
// Do not rename! Called from inside Dart placement
function setLeaderBoard(clickCommand) {
	var positioned = ($("#leaderboard").css("position") == "absolute");
	$("#leaderboard").addClass("functional");
	$("#leaderboard div").append('<p id="leaderboardToggle" />');
	$("p#leaderboardToggle").toggle(function () {
		$(this).toggleClass("collapse").append("<img />").
		// in order to trigger the click command we append an image
		// and remove it each time the lb is opened
		find("img").load(function () {
			$(this).remove();
		}).css("display", "none").attr("src", clickCommand);
		if (positioned) {
			$("#loginBand").each(function () {
				if (!$(this).data("css")) {
					$(this).data("css", {
						mb: parseInt($(this).css("margin-bottom"))
					});
				}
				$(this).animate({
					marginBottom: ($(this).data("css").mb + 210) + "px"
				}, 1500);
			});
		}
		$("#leaderboard div, #leaderboard iframe").animate({height:"300px"}, 1500);
	}, function () {
		$(this).toggleClass("collapse");
		$("#leaderboard iframe, #leaderboard div").animate({height:"90px"}, 1500);
		if (positioned) {
			$("#loginBand").animate({
				marginBottom: $("#loginBand").data("css").mb + "px"
			}, 1500);
		}
	});
	// Leaderboard will auto expand once per user session based on cookie
	if (cookieExists("adv") == -1) {
		setSessionCookie("adv", 1);
		$("p#leaderboardToggle").click(); // trigger auto expand
	}
}
$(document).ready(function ($) {
	var dartUtil = new DartUtil();
	// Call all ad placements in this order for correct ptile
	// Prestitial
	(function () {
		var on = (typeof prestitialSwitch != "undefined" && prestitialSwitch);
		var debug = (getURLParamValue("debug_prestitial") == "on");
		// show the prestitial? Not for members only or ike members only and 404
		if (debug) window.alert("Members only = " + forMembersOnly +
			", 404 page = " + is404 +
			", prestitialSwitch = " + on + ", document.referrer = " + document.referrer);
		if (on && !(forMembersOnly || is404)) {
			// check for prestitial cookie
			var adPre = getCookieValue("adPre");
			if (debug) window.alert("adPre Cookie = " + ((adPre) ? "set, no ad will show" : "not set, ad will show"));
			if (!adPre) {
				// time in milliseconds
				var adPreNow = new Date().getTime();
				var adPreOneDay = (24 * (60 * (60 * 1000)));
				var ttl = parseInt(typeof prestitialTTL != "undefined" && prestitialTTL) || 12;
				var adPreTimeout = (ttl * 1000);
				// retreive current page for redirect
				var adPreNextURL = window.top.location.href;
				// set prestitial cookie with an expiration of "tomorrow"
				var adPreTomorrow = new Date(adPreNow + adPreOneDay);
				setCookie("adPre", adPreNextURL, adPreTomorrow.toGMTString(), "/", SITE_domain);
				if (debug) window.alert("Cookie = " + document.cookie);
				// check to make sure prestitial cookie exists (excludes bots)
				if (getCookieValue("adPre") != "") {
	 				// this conditional checks for the existence of the cookie we just wrote
					// if it doesn't exist then we don't create the ad string, the hbx array,
					// nor do we show the prestitial
					// create ad string
					var adDartString = dartUtil.getPrestitialAd();
					// initialize HBX variables in the global namespace
					// Note: if wrData is not on then the hbx.js file is not loaded and _hbSet is not defined
					prestitialHBX = (wrData == "on" && (typeof prestitialHBX != "undefined" ? prestitialHBX : true));
					if (prestitialHBX) {
					 	prestitialHBXArrayOpen = new Array();
					 	prestitialHBXArraySkip = new Array();
						prestitialHBXArrayAuto = new Array();
					 	prestitialHBXArrayOpen[0] = '_hbSet("hb", "DM56031759VS83EN3;' + SITE_hbxAcct + '");';
						prestitialHBXArrayOpen[1] = '_hbSet("cv.c4", "CT|PRESTITIAL_OPEN");';
						prestitialHBXArrayOpen[2] = '_hbSet("cd", 1);';
						prestitialHBXArrayOpen[3] = '_hbSet("n", "/prestitial");';
						prestitialHBXArrayOpen[4] = '_hbSet("vcon", "/' + SITE_name + '/prestitialOpen");';
						prestitialHBXArrayOpen[5] = '_hbSet("hec", 1);';
						prestitialHBXArrayOpen[6] = '_hbSet("vjs", "HBX0200u");';
						prestitialHBXArraySkip[0] = '_hbSet("hb", "DM56031759VS83EN3;' + SITE_hbxAcct + '");';
						prestitialHBXArraySkip[1] = '_hbSet("cv.c4", "CT|PRESTITIAL_SKIP");';
						prestitialHBXArraySkip[2] = '_hbSet("cd", 1);';
						prestitialHBXArraySkip[3] = '_hbSet("n", "/prestitial");';
						prestitialHBXArraySkip[4] = '_hbSet("vcon", "/' + SITE_name + '/prestitialSkip");';
						prestitialHBXArraySkip[5] = '_hbSet("hec", 1);';
						prestitialHBXArraySkip[6] = '_hbSet("vjs", "HBX0200u");';
						prestitialHBXArrayAuto[0] = '_hbSet("hb", "DM56031759VS83EN3;' + SITE_hbxAcct + '");';
						prestitialHBXArrayAuto[1] = '_hbSet("cv.c4", "CT|PRESTITIAL_AUTO");';
						prestitialHBXArrayAuto[2] = '_hbSet("cd", 1);';
						prestitialHBXArrayAuto[3] = '_hbSet("n", "/prestitial");';
						prestitialHBXArrayAuto[4] = '_hbSet("vcon", "/' + SITE_name + '/prestitialAuto");';
						prestitialHBXArrayAuto[5] = '_hbSet("hec", 1);';
						prestitialHBXArrayAuto[6] = '_hbSet("vjs", "HBX0200u");';
					}
					prestitialTimeOut = window.setTimeout('tb_remove_tt("auto")', adPreTimeout);
					tb_show(
						'<img src="' + ENV_mediaHost + '/images/' + SITE_name.toLowerCase() + '/logo_greybg.gif" border="0" />',
						adDartString + "?KeepThis=true&TB_iframe=true&width=640&height=480&modal=false",
						false
					);
				}
			}
		}
	})();
	$("#leaderboard > div").each(function () {
		if (typeof leaderboardSwitch == "undefined" || leaderboardSwitch) {
			$(this).parent().add("#loginBand").addClass("on");
			$(this).html(dartUtil.getLeaderboard());
		}
	});
	$("#vendorOffer").each(function () {
		if (typeof vendorofferSwitch == "undefined" || vendorofferSwitch) {
			$(this).addClass("on").html(dartUtil.getVendorOffer());
		}
	});
	$("#cltAd").each(function () {
		if (typeof cltadSwitch == "undefined" || cltadSwitch) {
			$(this).addClass("on").html(dartUtil.getCltAd());
		}
	});
	$("#bigAd").each(function () {
		if (typeof bigadSwitch == "undefined" || bigadSwitch) {
			$(this).addClass("on").html(dartUtil.getBigAd());
		}
	});
	$("#skyscraper").each(function () {
		if (typeof skyscraperSwitch == "undefined" || skyscraperSwitch) {
			$(this).addClass("on").html(dartUtil.getSkyscraper());
		}
	});
	// This function executes inside of the CLT and VAU ad pages:
	// 1. Set the height cookie read by resizeCLT
	// 2. Set links to break out of the iframe when clicked
	$("#cltAdContainer").each(function () {
		var adH = $(this).outerHeight() || 950; // set min
		adH = Math.min(adH, 1150); // set max
		setSessionCookie("ugcCltHeight", adH);
		// set links to open in parent document
		$("a", this).click(function () {
			top.location.href = this.href;
			return false;
		});
	});
	// Call debug
	if (adDebug != "off") {
		for (var i = 0; i < dartUtil.log.length; i++) {
			alert(dartUtil.log[i]);
		}
	}
});
// Watermark
var watermark = (function () {
	var on = (typeof watermarkSwitch != "undefined" && watermarkSwitch);
	if (on) {
		var onlyHome = (typeof watermarkHomeOnly != "undefined" && watermarkHomeOnly);
		if (onlyHome && !isHome) {
			return false; // not the home page so exit
		}
		var url = (typeof watermarkURL == "undefined") ? "" : watermarkURL;
		var track = (typeof watermarkTrackingImageURL == "undefined") ? "" : watermarkTrackingImageURL;
		if (url != "" && track != "") {
			$(document).ready(function ($) {
				if (watermark) {
					$(document.body).
					css("background-image", "url(" + url + ")").
					append('<img src="' + track + '" class="track" />');
				}
			});
		}
	}
	return on;
})();
// Web Reporting ==================================================================================
// Debug also used by clicktrack
var wrDebug = (function () {
	var param = getURLParamValue("wrData");
    if (param == "on" || param == "off") {
		setCookie("wrData", param, null, "/");
		return param;
	} else {
		param = getCookieValue("wrData");
		if (param == "on" || param == "off") {
			return param;
		}
	}
	return ""; // debug not specified
})();
// Switch used to enable/disable web reporting
var wrData = (function () {
	return wrData || wrDebug || ((ENV_name == "PROD" && !ENV_isStage) ? "on" : "off");
})();
// Hitbox Utility class
function HbxUtil() {
	this.getPageName = function () {
	 	var gci = window.gci || "";
		var pn = window.location.pathname.replace(/^\/|\/$/g, "");
		pn = (pn == "") ? "home" : pn.replace(/\//g, "--");
		for (var a = ["offer","track","s"], p, param;
			p = a.shift();) {
			param = getURLParam(p);
			if (param != "") {
				pn += "--" + param;
			}
		}
		if (gci != "") {pn += "--" + gci;}
		return pn.replace(eval("/\%/g"), ".");
	},
	this.getAsrc = function () {
		var asrcParam = getURLParamValue("asrc");
		var asrc_und_1_pos = asrcParam.indexOf("_");
		var asrcLast2 = asrcParam.substring(asrc_und_1_pos + 1, asrcParam.length);
		var asrc_und_2_pos = asrcLast2.indexOf("_");
		var asrc_src = asrcParam.substr(0, asrc_und_1_pos);
		var asrc_vehicle = asrcLast2.substr(0, asrc_und_2_pos);
		var asrc_vid = asrcLast2.substr(asrc_und_2_pos + 1, asrcLast2.length);
		if (asrc_src != "") {
			if (typeof gci == "undefined") var gci = "";
			return asrc_src + "|" + SITE_name + "-" + asrc_vehicle + "-" + asrc_vid + "-" + gci;
		} else {
			return "";
		}
	},
	this.getPsrc = function () {
		var psrcParam = getURLParamValue("psrc");
		if (psrcParam.indexOf("_") != -1) {
			psrcParam = psrcParam.substring(0,psrcParam.indexOf("_")) +
			"|" + psrcParam.substring(psrcParam.indexOf("_") + 1, psrcParam.length);
		}
		return psrcParam;
	},
	this.getVisitorSegment = function (extraAcct) {
		var uStatus = [];
		if (thisSite != -1) {
			uStatus[uStatus.length] = SITE_hbxVsSiteMember;
		}
		if (indexLogin != -1) {
			uStatus[uStatus.length] = SITE_hbxVsLoggedIn;
		}
		if (ipcLoggedIn == "1") {
			uStatus[uStatus.length] = SITE_hbxVsIKEMember;
		}
		/*
		for future use once email cookies/logic are determined
		if(??????????){
			uStatus[uStatus.length] = SITE_hbxVsEmailSubscriber;
		}
		*/
		var uStatusRollup;
		if (ttUser == "1") uStatusRollup = "6";
		uStatusRollup = uStatusRollup || "*";
		uStatus = (uStatus.length == 0) ? "*" : uStatus.join(",");
		uStatus += ";" + uStatusRollup; // combine value with Global Rollup
		if (extraAcct) uStatus += ";*";
		return uStatus;
	};
};
// Clicktrack =====================================================================================
var clicktrackIMG = ENV_clicktrackHost.replace("clicktrack", "go") + "/activity.jpg";
// set the user id into a tt_ut cookie if the cookie is missing
// clicktrackUID == "" means user had tt_ut cookie already
var clicktrackUID = (function () {
	var uidParamValue = getURLParamValue("uid");
	var clicktrackUID = "";
	if (getCookieValue("tt_ut") == "" && (uidParamValue != "" || loggedIn != -1)) {
		var clicktrackNow = new Date().getTime();
		var clicktrackFiveYear = (5*(365*(24*(60*(60*1000))))); // 5 years
		if (uidParamValue != "") {
			clicktrackUID = uidParamValue;
		} else {
			var clicktrackUIDCookie = getCookieValue("Datav2");
			clicktrackUID = clicktrackUIDCookie.substring(clicktrackUIDCookie.indexOf("dgUserID") + 8);
			if (clicktrackUID.indexOf("%0A") != -1) {
				clicktrackUID = unescape(clicktrackUID.substring(0, clicktrackUID.indexOf("%0A")));
			} else {
				clicktrackUID = unescape(clicktrackUID);
			}
			if (clicktrackUID.indexOf(";") != -1) clicktrackUID = clicktrackUID.substring(0, clicktrackUID.indexOf(";"));
		}
		var clicktrackExpire = new Date(clicktrackNow + clicktrackFiveYear);
		setCookie("tt_ut", clicktrackUID, clicktrackExpire.toGMTString(), "/", SITE_domain);
	}
	return clicktrackUID;
})();
(function (tax,gci) {
	// if page is 404 page or explicitly set not to track then do not track
	if (is404 || wrData != "on") {
		if (wrDebug == "on") {
			alert("is404: " + is404 + " | wrData: " + wrData);
		}
		return;
	}
	// tax, gci are set as part of the ad variables
	// passed as parameter to script to avoid scope issues
	tax = tax || "";
	gci = gci || "";
	var ttUtCookieValue = getCookieValue("tt_ut");
	var preRegDebug = (wrDebug == "on" || getURLParamValue("preRegData") == "on") ? "on" : "off";
	if (getCookieValue("moActivity") == "on") {
		// If this cookie is set user has been tracked as part of registration
		// prevents double tracking when user returns from registering
		setSessionCookie("moActivity", "off");
		if (wrDebug == "on") {
			alert("moActivity Cookie shut off");
		}
	} else if (ttUtCookieValue != "" && tax != "") {
		var trackIMG = clicktrackIMG +
			"?activityTypeId=1&u=" + ttUtCookieValue +
			"&t=" + tax +
			"&c=normal" +
			"&r=" + Math.round(Math.random() * 1000000);
		if (gci != "") {
			trackIMG += "&g=" + gci;
		}
		$(document).ready(function ($) {
			$(document.body).append('<img src="' + trackIMG + '" class="track" />');
		});
		if (wrDebug == "on") {
			alert("Activity.jpg tracked: " + trackIMG);
		}
	} else if (tax != "" && ttUtCookieValue == "") {
		function LZ(x) {return (x < 0 || x > 9 ? "" : "0") + x;}
		var maxTax = 5;
		var thisDate = new Date();
		var preRegCurTime = thisDate.getTime();
		var timeZoneOffset = thisDate.getTimezoneOffset() * 60000;
		var preRegCurTimeUTC = preRegCurTime + timeZoneOffset;
		var preRegServerTime = preRegCurTimeUTC + (3600000 * -5);
		var estTime = new Date(preRegServerTime);
		var preRegCookieTime = estTime.getFullYear() + "-" +
			LZ(estTime.getMonth() + 1) + "-" +
			LZ(estTime.getDate()) + " " +
			LZ(estTime.getHours()) + ":" +
			LZ(estTime.getMinutes())+ ":" +
			LZ(estTime.getSeconds());
		var fiveYears = (5*(365*(24*(60*(60*1000))))); // 5 years
		var preRegExpire = new Date();
		preRegExpire.setTime(preRegExpire.getTime() + fiveYears);
		if (tax != "") {
			if (getCookieValue("tt_prereg") != "") {
				// update prereg cookie with this page taxonomy values
				var storedPreRegValues =  unescape(getCookieValue("tt_prereg"));
				var storedArray = storedPreRegValues.split(",");
				var preRegCookieString = "t1@"+tax+"$"+"_"+preRegCookieTime;
				if (gci != "") {preRegCookieString += "&g="+gci;}
				storedArray.push(preRegCookieString);
				//alert("initial length"+ storedArray.length);
				if(storedArray.length > maxTax) { 
					var overLimitCount = storedArray.length - maxTax; 
					for(i=0;i < overLimitCount;i++) {storedArray.shift()};}
				//alert("new length"+ storedArray.length);
				preRegCookieString = storedArray.join();
				setCookie("tt_prereg", preRegCookieString, preRegCookieTime, "/", SITE_domain);
				if (preRegDebug == "on") {
					alert("Pre Reg Tracking Cookie Updated: \n\n" + unescape(getCookieValue("tt_prereg")));
				}
			} else {
				// create prereg cookie and store this page taxonomy values
				// t1 = Primary Taxonomy
				var preRegCookieString = "t1@"+tax+"$"+"_"+preRegCookieTime;			
				if (gci != "") {preRegCookieString += "&g="+gci;}
				setCookie("tt_prereg", preRegCookieString, preRegExpire.toGMTString(), "/", SITE_domain);
				if (preRegDebug == "on") {
					alert("Pre Reg Tracking Cookie Created: \n\n" + unescape(getCookieValue("tt_prereg")));
				}
			}
		}
	} else if (preRegDebug == "on") {
		alert("No Activity: tax=" + tax + ": tt_ut=" + ttUtCookieValue);
	}
	// If tt_ut is set means user has registered. If user still has a pre-reg cookie
	// report all pre-reg tax values to clicktrack and delete the pre-reg cookie
	if (ttUtCookieValue != "") {
		var preRegCookieValues = getCookieValue("tt_prereg");
		if (preRegCookieValues != "") {
			if (preRegDebug == "on") var log = ["Pre Reg Activity.jpg tracked:"];
			var storedPreRegValues = unescape(preRegCookieValues);
		 	var trackArray = storedPreRegValues.split(",");
			var thisCookieResult, taxString, taxIDArray, taxID, j, jlen, thisTaxString, activityType, datetime, preRegTrackIMG;
			for (var i = 0, len = trackArray.length; i < len; i++) {
				thisCookieResult = trackArray[i];
				if(typeof thisCookieResult != "undefined") {
					taxString = "";
					taxIDArray = thisCookieResult.split("$");
					for (j = 0, jlen = taxIDArray.length; j < jlen - 1; j++) {
						thisTaxString = taxIDArray[j];
						//alert("thisTaxString: "+thisTaxString);
						activityType = thisTaxString.substring(0, 2);
						if (activityType == "t1") {activityType = "t";}
						taxID = thisTaxString.substring(thisTaxString.indexOf("@") + 1);
						taxString = taxString+"&"+activityType+"="+taxID;
						//alert("taxString: "+taxString);
					}
					datetime = thisCookieResult.substring(thisCookieResult.indexOf("_") + 1);
					datetime = datetime.replace(" ", "%20");
					preRegTrackIMG = clicktrackIMG +
						"?activityTypeId=1&u=" + ttUtCookieValue + taxString +
						"&a=" + datetime +
						"&c=pre" +
						"&r=" + Math.round(Math.random() * 1000000);
					$(document).ready(function ($) {
						$(document.body).append('<img src="' + preRegTrackIMG + '" class="track" />');
					});
					if (preRegDebug == "on") log.push(preRegTrackIMG);
				}
			}
			deleteCookie("tt_prereg", "/", SITE_domain);
			if (preRegDebug == "on") alert(log.join("\n\n"));
		}
	}
})(window.tax, window.gci);
// Members Only ===================================================================================
var forMembersOnly = (function () {
	var mo = (typeof forMembersOnly != "undefined" && forMembersOnly);
	var moOverride = getURLParamValue("mo");
	return (mo || moOverride == 1);
})();
// Bizo ===========================================================================================
var bizoDebug = (getURLParamValue("bizo") == "on");
var bizo = (function () {
	var flag = ((wrData != "on" || typeof SITE_bizoFlag == "undefined") && "off" || SITE_bizoFlag);
	if (bizoDebug) alert("wrData: " + wrData + " | Bizo: " + flag);
	if (flag == "on" && ((ENV_name == "PROD" && !ENV_isStage) || bizoDebug)) {
		if (cookieExists("tt_ut") != -1 && cookieExists("bizo2") == -1) {
			// user is logged in but does not have the bizo2 cookie
			var url = (typeof SITE_bizoIframeURL == "undefined") ? "" : SITE_bizoIframeURL;
			if (bizoDebug) alert("Bizo Iframe URL: " + url);
			if (url != "") {
			/*
				$(document).ready(function ($) {
					$("body").append('<iframe id="bizo"' +
					' width="0" height="1"' +
					' border="0" frameborder="0"' +
					' marginheight="0" marginwidth="0"' +
					' scrolling="no" />');
					$("iframe#bizo").attr("src", url);
				});
				[EP] V5 used an iframe call to set the bizo2 cookie and then call Bizo
			 	 But iframes are asynchronous, so the cookie is not set in time
			 	 to create _bizo_data_partner_data. By switching to a synchronous javascript
			 	 call the Bizo cookie can be set and read in time to create _bizo_data_partner_data
			*/
				document.write('<script type="text/javascript" src="' + url + '"></script>');
			}
		}
		// Bizo Data Partner Javascript
		_bizo_data_partner_id = 32
		document.write('<script type="text/javascript">' +
		'if (getCookieValue("bizo2") != "") {' +
			'_bizo_data_partner_data = getBizoDataObject(getCookieValue("bizo2"));' +
		'}' +
		'document.write(\'<script type="text/javascript" src="' +
			'http://js.bizographics.com/convert_data.js?partner_id=' + _bizo_data_partner_id +
			'"></scr\'+\'ipt>\');' +
		'if (bizoDebug) alert("Bizo Tracked!\\nbizo2=" + getCookieValue("bizo2"));' + '<\/script>');
	}
	return flag;
})();
function getBizoDataObject(_bizo_cookie_string) {
	var _bizo_data_object = {};
	var _bizo_cookie_entries = _bizo_cookie_string.split("#");
	for (var i = 0; i < _bizo_cookie_entries.length; i++) {
		var _bizo_cookie_entry_parts = _bizo_cookie_entries[i].split("*");
		if (_bizo_cookie_entry_parts.length > 1) {
			switch (_bizo_cookie_entry_parts[0]) {
				case "I1":
					_bizo_data_object.I1 = _bizo_cookie_entry_parts[1]; break;
				case "I2":
					_bizo_data_object.I2 = _bizo_cookie_entry_parts[1]; break;
				case "I3":
					_bizo_data_object.I3 = _bizo_cookie_entry_parts[1]; break;
				case "I4":
					_bizo_data_object.I4 = _bizo_cookie_entry_parts[1]; break;
				default:;
			}
		}
	}
	return _bizo_data_object;
}
// Utility Functions ==============================================================================
function cookieExists(name) {return document.cookie.indexOf(name + "=")}
function getCookieValue(name) {
	var cookie = document.cookie;
	var pos = cookie.indexOf(name + "=");
	if (pos != -1) {
		var start = pos + name.length + 1;
		var end = cookie.indexOf(";", start);
		if (end == -1) end = cookie.length;
		var value = cookie.substring(start, end);
		return value;
	} else {
		return "";
	}
}
function getChipValue(cookiename, chipname) {
	var cookievalue = getCookieValue(cookiename);
	if (cookievalue != "") {
		if (cookievalue.indexOf(chipname) != -1) {
			var start = unescape(cookievalue.substring(cookievalue.indexOf(chipname) + chipname.length));
			var end = start.substring(0, start.indexOf(";"));
			if (!end) end = start.substring(0, start.length);
			var regexp = /(\W)/g;
			var value = end.replace(regexp, " ");
			return value;
		} else {
			return "";
		}
	} else {
		return "";
	}
}
function setChipString(value) {
	// prepares a string of name/value pairs to get written to a cookie correctly to be compatible with
	// our existing 'chip' logic.
	// string must be in format: "name1value1;name2value2;name3value3"
	// note: no semi-colon should exist after last entry
	// we append linefeed at the end of the string to signify end of cookie value
	value = value + "\n";
	value = escape(value);
	return value;
}
function setSessionCookie(name, value) {
	document.cookie = name + "=" + value + ";path=/" + ";domain=" + SITE_domain;
}
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    return true;
}
function deleteCookie(name, path, domain){
	// sets the date of a cookie to the past which effectively deletes it the next time the browser loads
	if(cookieExists(name)){
   		setCookie(name, "", -30, path, domain);
	}
}
// readCookie is used by resizeCLT
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}
function getURLParam(param) {
    var paramValue = param + "=";
    var searchValue = window.location.search.toLowerCase();
    var searchValueParam = "";
    if (searchValue.indexOf(paramValue) != -1) {
        searchValueParam = window.location.search.substring(searchValue.indexOf(paramValue), searchValue.length);
        if (searchValueParam.indexOf("&") != -1) {
            searchValueParam = searchValueParam.substring(0, searchValueParam.indexOf("&"));
        }
    }
    return searchValueParam;
}
function getURLParamValue(param) {
    var paramValue = param.toLowerCase() + "=";
    var searchValue = window.location.search.toLowerCase();
    var searchValueParam = "";
    if (searchValue.indexOf(paramValue) != -1) {
        searchValueParam = window.location.search.substring(searchValue.indexOf(paramValue), searchValue.length);
        if (searchValueParam.indexOf("&") != -1) {
            searchValueParam = searchValueParam.substring(0, searchValueParam.indexOf("&"));
        }
    }
    searchValueParam = searchValueParam.substring(param.length + 1, searchValueParam.length);
    return searchValueParam;
}
function checkEmail(emailStr) {
    var num_error = 0;
    var NewemailStr = "";
    var emailPat = /^(.+)@(.+)$/;
    var specialChars = "\\(\\)\\{\\}\/%?\\$\\*\\^\\|\\.=&`~#!<>@,;:\\\\\\\"\\.\\[\\]";
    var invalidchars = "\\(\\)\\{\\}\/%?\\$\\s\\^~#!&`\\*\\|=@<>,;:\\\\\\\"\\[\\]'";
    var validChars = "[^\\s" + specialChars + "]";
    var validChars1 = "[^\\s" + invalidchars + "]";
    var quotedUser = /(\"[^\"]*\"\')/;
    var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom = validChars + "+";
    var atom1 = validChars1 + "+";
    var word = "(" + atom + "|" + quotedUser + ")";
    var word1 = "(" + atom1 + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + word1 + "(" + word1 + ")*$");
    if (emailStr == "") {
        return "An email address is required";
    } else {
        var NewemailStr = emailStr;
    }
    var matchArray = NewemailStr.match(emailPat);
    if (matchArray == null) {
        return "E-mail address is not a valid format (check @ and .'s)";
    }
    var user = matchArray[1];
    var domain = matchArray[2];
    if (user.match(userPat) == null) {
        return "The username in the email address doesn't seem to be valid.";
    }
    var IPArray = domain.match(ipDomainPat);
    if (IPArray != null) {
        for (var i = 1; i <= 4; i++) {
            if (IPArray[i] > 255) {
                return "Destination IP address in the email address is invalid!";
            }
        }
        return true;
    }
    var domainArray = domain.match(domainPat);
    if (domainArray == null) {
        return "The domain name in the email address doesn't seem to be valid.";
    }
    if (domain.length > 0) {
        if (domain.charAt(0) == ".") {
            return "The domain name in the email address doesn't seem to be valid.";
        } else if (domain.charAt(domain.length - 1) == ".") {
            return "The domain name in the email address doesn't seem to be valid.";
        } else {
            var errors = 0;
            for (var k = 1; k < domain.length; k++) {
                if (domain.charAt(k) == ".") {
                    errors++;
                }
                if (domain.charAt(k) == "." && domain.charAt(k + 1) == ".") {
                    errors = errors + 5;
                    k = domain.length;
                }
            }
            if (errors > 4) {
                return "The domain name in the email address doesn't seem to be valid.";
            }
        }
    }
    var atomPat = new RegExp(atom, "g");
    var domArr = domain.match(atomPat);
    var len = domArr.length;
    if (domArr[domArr.length - 1].length < 2) {
        return "The email address must end in a valid domain.";
    }
    if (len < 2) {
        return "This email address is missing a hostname!";
    }
    return "good";
}
function validateEmail(emailAddr) {
    var emailAlert = checkEmail(emailAddr);
    if (emailAlert == "good") {
        return true;
    } else {
        alert(emailAlert);
        return false;
    }
}
// Embed a podcast player
// Proxy object to handle v5 migrated components
function SWFObject() {
	this.addVariable = function (a, b) {
		switch (a) {
			case "file": this.file = unescape(b);
		}
	};
	this.useExpressInstall = function () {};
	this.write = function (a) {
		$("#" + a).remove();
		PPF.newPlayer(this.file || "");
	};
	return this;
}
SWFObject.proxy = true;
var PPF = new PodcastPlayerFactory(); // instantiate factory
function PodcastPlayerFactory() {
	this.counter = 10;
	this.loadLibrary = function (fn) {
		if (typeof SWFObject == "undefined" || SWFObject.proxy) {
			delete SWFObject;
			$.getScript("http://media.techtarget.com/bitpipe/player/swfobject.js", fn);
		} else if (fn) {
			fn();
		}
	};
	var self = this;
	this.writePlayer = function (id, url) {
		var i = id.substring(12); // strip off the "flashcontent" text to get the incr used
		var so = new SWFObject("http://media.techtarget.com/bitpipe/player/mp3player.swf", "mp3player" + i, "225", "175", "7", "#CCCCCC");
		so.addVariable("file", escape(url));
		so.addVariable("displayheight", "155");
		so.addVariable("displaywidth", "225");
		so.addVariable("height", "175");
		so.addVariable("width", "225");
		so.addVariable("shownavigation", "true");
		so.addVariable("overstretch", "none");
		so.useExpressInstall('http://media.techtarget.com/bitpipe/player/expressinstall.swf');
		so.write(id);
	};
	this.newPlayer = function (url) {
		var id = "flashcontent" + (++this.counter);
		document.write('<div id="' + id + '"><strong>You must have Adobe Flash Player 7 or above to view this content.</strong> ' +
		'See <a href="http://www.adobe.com/products/flashplayer/">http://www.adobe.com/products/flashplayer</a> to download now.</div>');
		if (typeof SWFObject == "undefined" || SWFObject.proxy) {
			this.loadLibrary(function () {self.writePlayer(id, url);});
			return false;
		} else {
			this.writePlayer(id, url);
			return true;
		}
	};
}
/*
   Embed a brightcove video player:
   First call to function by this name loads the required video resources on demand
   The brightcove experience_util.js file replaces this function with its own
   Next call to function by this name will call the brightcove function
   
   [EP] Note: commented out as temp fix for ie, which isn't blocking scripts from other domains 
*/
// function createExperience() {
	document.write('<link rel="stylesheet" href="' + ENV_mediaHost + '/css/tt_thickbox_reg.css" type="text/css" media="screen" />');
	document.write('<script src="http://admin.brightcove.com/js/experience_util.js" type="text/javascript"></scr'+'ipt>');
	document.write('<script src="' + ENV_mediaHost + '/javascript/tt_video.js" type="text/javascript"></scr'+'ipt>');
	// document.write('<script type="text/javascript">createExperience(config, 8);</scr'+'ipt>');
// }
// Ready (onload) events ==========================================================================
$(document).ready(function ($) {
	
	// Update login band and site index splash registration links
	if (loggedIn == 1) {
		// var SITE_logoutURL = SITE_logoutURL || "";
		$("#loginBand > .membershipLinks").
		prepend("<em>You're logged in as:</em> <strong>" + DisplayName + " </strong>").
		children("a").each(function (i) {
			if (i == 0) {
				$(this).text("Edit your Profile");
			} else {
				$(this).attr("href", SITE_logoutURL).text("Log-out");
			}
		});
		$("#siteIndexMembers > ul > li").children("a").each(function (i) {
			if (i == 0) {
				$(this).attr("href", SITE_logoutURL).text("Logout");
			} else {
				$(this).text("Edit Profile").parents("ul").eq(0).prepend($(this).parent());
			}
		});
	}
	
	// Topical navbar
	$("#ddNav").each(function () {
		var ddNavW = $(this).width();
		var tnb = $("#topicalNavbar");
		var nbW = tnb.width();
		var nbR = tnb.position().left + nbW;
		var navits = $("> li", this);
		var nbLast = navits.length - 1;
		navits.each(function (i) {
			// adjust the items to fill the navbar
			var newW = Math.floor($(this).width()*nbW/ddNavW);
			$(this).width(newW);
			var menu = $("ul", this);
			if (menu.length > 0) {
				// make sure we have a menu
				var menuL = $(this).position().left;
				var menuOW = menu.outerWidth();
				if (menuL + menuOW > nbR) {
					// menu goes beyond the navbar right edge
					if (i == nbLast) {
						// use the navbar right edge in case of extra space
						menu.css("left", nbR - (menuOW - 1));
					} else {
						menu.css("left", (menuL + newW) - (menuOW - 1));
					}
				}
				if ($.browser.msie && $.browser.version < 7) {
					// fix the horizontal lines by making links same width
					var menuIW = menu.innerWidth();
					var menuPL = 0;
					var menuPR = 0;
					$("a", menu).each(function () {
						menuPL = parseInt($(this).css("padding-left"));
						menuPR = parseInt($(this).css("padding-right"));
						return false;
					}).css("width", menuIW - (menuPL + menuPR));
					// embed hidden iframe to clear windowed elements like ads
					var menuOH = menu.outerHeight();
					menu.prepend('<iframe src="javascript:false;" frameborder="0" tabindex="-1" />');
					$("iframe", menu).css({
						position:"absolute",
						left:"-1px",
						zIndex:"-1",
						filter:"Alpha(Opacity=0)",
						width:menuOW,
						height:menuOH
					});
				}
			}
		}).mouseover(function () {
			if (!$(this).hasClass("over")) {
				 $(this).addClass("over");
			}
		}).mouseout(function () {
			$(this).removeClass("over");
		});
	});
	
	// Set all Cnet-related links to open in a new window
	$("a").filter(function() {
		return (/\b(builder|cnet|zdnet|cnetchannel|techrepublic|itpapers|news\.com)\.\w{2,4}\b/i).test(this.href);
	}).addClass("openInNewWindow");
	
	// Open in new window: replaces target="_blank" on links
	// Note: used for more that just Cnet links
	$("a.openInNewWindow").click(function() {
		window.open(this.href);
		return false;
	});
	
	// Open a popup window (used by the media popop and others)
	$("a[rel='pop-up']").click(function () {
		var features = "height=350,width=350,scrollTo,resizable=1,scrollbars=1,location=0,left=300,top=150";
		newwindow=window.open(this.href, 'Popup', features);
		return false;
	});
	
	// Hide tracking images
	$("img.track").css("display", "none");
	
	// Copy the contents from header navbar div into footer navbar div
	$("#footerBar").html($("#headerBar").text());
	$("#footerNavbar").html($("#headerNavbar").html());
	
	// Adjust the page as per the requirement - 3 column should collapse to 2 if empty
	$(".threecol .col2:not(:has(div,p))").parents(".colmask").removeClass("threecol").addClass("twocol");
	
	// Align the Popular Terms splash by 1, 2, or 3 columns, depending on what is there
	$("#popularTerms").each(function () {
		var cols = $(".popularTermsContainer", this);
		cols.css("width", (93 / cols.length) + "%");
	});
	
	// Dc3 Quadrants rounded corners
	var w = ($("#quadrantsContent").width() / 2) - 2.5;
	$("#quadrantsContent > div").wrapInner(
		'<div class="tl">' +
			'<div class="tr">' +
				'<div class="bl">' +
					'<div class="br">' +
					'</div>' +
				'</div>' +
			'</div>' +
		'</div>'
	).css({"padding": 0, "width": w + "px"});
	
	// Dc3 Quadrants even height
	$("#quadrantsContent > .odd").each(function () {
		var sib = $(this).next();
		var sibH = sib.height();
		var thisH = $(this).height();
		var h = Math.max(sibH, thisH);
		$(".br", sib ).height(h);
		$(".br", this).height(h);
	});
	
	// Dc3 Featured Video rounded corners and equal height
	// Note: selection from .col1 is needed so the script doesn't execute for dc0
	var el = $(".col1 > #featuredVideoSplash > #featuredVideoSplashContent > p");
	if (el.length > 0) {
		el.eq(0).wrapInner(
			'<div class="tl">' +
				'<div class="tr">' +
					'<div class="bl">' +
						'<div class="br">' +
						'</div>' +
					'</div>' +
				'</div>' +
			'</div>'
		).css({"padding": 0, "width": el.outerWidth() + "px"});
		var pel = el.parent();
		var p = Math.max(parseInt(pel.css("paddingTop")) + parseInt(pel.css("paddingBottom")), 0);
		$(".br", el).css({"height": (pel.height() - p) + "px"});
	}
	
	// Fixes for v5 cotnent components:
	// Parse for components and rewrite to the v7 versions
	$(".ciCLT .ciText").each(function () {
		var reTrim = /^\s+|\s+$/g;
		$("table[width='200']").each(function () {
			// could be a v5 sidebar component
			var heading = $("tr.colorback td.body b", this);
			if (heading.length > 0) {
				heading = heading.text().replace(reTrim, "");
				var body = $("tr.colorSuperLite td.body, tr.colorsuperlite td.body", this).eq(0);
				$(this).parents("table").eq(0).each(function () {
					var align = $(this).attr("align");
					align = align || "left";
					align = "align" + align.charAt(0).toUpperCase() + align.substring(1);
					$(this).replaceWith(
						'<div class="sidebar ' + align + '">' +
							'<h5>' + heading + '</h5>' +
							'<div>' + body.html().replace(reTrim, "") + '</div>' +
						'</div>'
					);
				});
			}
		});
		$("table[width='147']").each(function () {
			// could be a v5 pullquote component
			if (String($(this).html()).indexOf("callout_begin_quote.gif") != -1) {
				// rewrite to v7 pullquote
				var quote = $(".big > b", this).text().replace(reTrim, "");
				var byline = $(".small", this).text().replace(reTrim, "");
				var align = $(this).attr("align");
				align = align || "left";
				align = "align" + align.charAt(0).toUpperCase() + align.substring(1);
				$(this).replaceWith(
					'<blockquote class="pullquote ' + align + '">' +
						'<div>' +
							'<div>' +
								'<div>' +
									'<span class="pullquoteContent">' + quote + '</span>' +
									'<p>' + byline + '</p>' +
								'</div>' +
							'</div>' +
						'</div>' +
					'</blockquote>'
				);
			}
		});
	});
	
});

// fix for ie6 flickering background images
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}

// eof