
var isSF = 0, isNS = 0, isIE = 0, isOP = 0, isXX = 0, apV = 1;
var isMac = 0, isWin = 0, isX = 0;
var isDHTML = 0, isID = 0, isAll = 0, isLayers = 0;
if (navigator.userAgent.indexOf('Safari') != -1)
{isSF = 1;
var sf = navigator.userAgent.indexOf('Safari') + 7;
apV = parseFloat(navigator.userAgent.substring(sf));
if (navigator.appVersion.indexOf('Macintosh') != -1) isMac = 1;
else if (navigator.appVersion.indexOf('Windows') != -1) isWin = 1;}
else if (navigator.userAgent.indexOf('Opera') != -1)
{isOP = 1;
var op = navigator.userAgent.indexOf('Opera') + 6;
apV = parseFloat(navigator.userAgent.substring(op));
if (isNaN(apV)) apV = parseFloat(navigator.appVersion);}
else if (navigator.appName == "Netscape")
{isNS = 1;
var ns = navigator.userAgent.lastIndexOf('/') + 1;
apV = parseFloat(navigator.userAgent.substring(ns));
if ((isNaN(apV)) || (apV > 10))
apV = parseFloat(navigator.appVersion);}
else if (navigator.appName == "Microsoft Internet Explorer")
{isIE = 1;
var ie = navigator.appVersion.indexOf('MSIE') + 5;
apV = parseFloat(navigator.appVersion.substring(ie));}
else
{isXX = 1;
apV = parseFloat(navigator.appVersion);}
if (navigator.appVersion.indexOf('Macintosh') != -1) isMac = 1;
else if (navigator.appVersion.indexOf('Windows') != -1) isWin = 1;
else isX = 1;
if ((isMac) && (document.all)) isAll = 1, isDHTML = 1;
else if (document.getElementById) isID = 1, isDHTML = 1;
else if (document.all) isAll = 1, isDHTML = 1;
else if (document.layers) isLayers = 1, isDHTML = 1;
function getObj(objID) {
if (typeof objID == "string") {
if (isID) return (document.getElementById(objID));
if (isAll) return (document.all[objID]);
if (isLayers) return (document.layers[objID]);
}}
function getStyle(obj,cssProp) {
var cssValue = obj.style[cssProp];
if (!cssValue)
if (document.defaultView)
cssValue = document.defaultView.
getComputedStyle(obj,null).getPropertyValue(cssProp);
else if (obj.currentStyle)
cssValue = obj.currentStyle[cssProp];
return (cssValue);
}
function findLeft(obj) {
if ((isAll) && (obj.clientLeft)) return (obj.clientLeft);
if ((isLayers) && (obj.pageX)) return (obj.pageX);
var pos;
if (getStyle(obj,'position') == "absolute") {
pos = parseFloat(getStyle(obj,'left'));
if (!isNaN(pos)) return (pos);
pos = parseFloat(getStyle(obj,'pixelLeft'));
if (!isNaN(pos)) return (pos);
}
pos = 0;
if (obj.offsetParent)
while (obj.offsetParent) {
pos += obj.offsetLeft;
obj = obj.offsetParent;
}
else if (obj.x) pos += obj.x;
return (pos)
}
function findTop(obj) {
if ((isAll) && (obj.clientTop)) return (obj.clientTop);
if ((isLayers) && (obj.pageY)) return (obj.pageY);
var pos;
if (getStyle(obj,'position') == "absolute") {
pos = parseFloat(getStyle(obj,'top'));
if (!isNaN(pos)) return (pos);
pos = parseFloat(getStyle(obj,'pixelTop'));
if (!isNaN(pos)) return (pos);
}
pos = 0;
if (obj.offsetParent)
while (obj.offsetParent) {
pos += obj.offsetTop;
obj = obj.offsetParent;
}
else if (obj.y) pos += obj.y;
return (pos);
}
function findHeight(obj) {
if ((isAll) && (obj.clientHeight)) return (obj.clientHeight);
if ((isLayers) && (obj.height)) return (obj.height);
var pos;
pos = parseFloat(getStyle(obj,'height'));
if (!isNaN(pos)) return (pos);
pos = parseFloat(getStyle(obj,'pixelHeight'));
if (!isNaN(pos)) return (pos);
if (obj.offsetHeight) return (obj.offsetHeight);
}
function findBottom(obj) {
return (findTop(obj) + findHeight(obj));
}
function moveObjectTo(obj,x,y) {
if (obj.moveTo)
obj.moveTo(x,y);
else {
obj.style.left = x + "px";
obj.style.top = y + "px";
}}
function moveObjectBy(obj,deltaX,deltaY) {
if (obj.moveBy)
obj.moveBy(deltaX,deltaY);
else {
obj.style.left = (findLeft(obj) + deltaX) + "px";
obj.style.top = (findTop(obj) + deltaY) + "px";
}}
function setVisibility(obj) {
var state = getStyle(obj,'visibility');
if ((state == "hidden") || (state == "hide"))
obj.style.visibility = "visible";
else if ((state == "visible") || (state == "show"))
obj.style.visibility = "hidden";
else obj.style.visibility = "visible";
}
function setClip(obj,clipTop,clipRight,clipBottom,clipLeft) {
if ((isLayers) && (obj.layers)) obj.clip.top = clipTop, obj.clip.right = clipRight,
obj.clip.bottom = clipBottom, obj.clip.left = clipLeft;
else obj.style.clip = "rect(" + clipTop + "px " + clipRight + "px " + clipBottom + "px " + clipLeft + "px)";
}
function setMargin(obj,marginTop,marginRight,marginBottom,marginLeft) {
obj.style.margin = marginTop + "px " + marginRight + "px " + marginBottom + "px " + marginLeft + "px";
} /* Cookie Functions */

	var allcookies = document.cookie;

	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=..";
	}
	
	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);
    	}
	} 

	function getDisplayName() {return getChipValue("Datav2", "DispName")}
	function getHandle() {return getChipValue("Datav2", "Handle")} /* Ad Functions Section */

	// Leftover variables from Cobranded.
	var dgADW, dgCTW, locationPathname;
	var coBrandPath = new Object();
	var adDcopt = ""; //disable interstitial other than via adj call
	
	function getOIDValue(oidParam) {
		var oidValue = "";
		var wlp = window.location.pathname;
		if (wlp.indexOf("/0,") != -1) wlp = wlp.substring(wlp.indexOf("/0," + 3,wlp.length));
		if (wlp.indexOf("/1,") != -1) wlp = wlp.substring(wlp.indexOf("/1," + 3,wlp.length));
		if (wlp.indexOf(",00.html") != -1) wlp = wlp.substring(0,wlp.indexOf(",00.html"));
		if (wlp.indexOf(oidParam) != -1) {
			oidValue = wlp.substring(wlp.indexOf(oidParam) + oidParam.length,wlp.length);
			if (oidValue.indexOf("_") != -1) oidValue = oidValue.substring(0,oidValue.indexOf("_"));
			if (oidValue.indexOf(",") != -1) oidValue = oidValue.substring(0,oidValue.indexOf(","));
		}
		return oidValue;
	}


	function getReferOIDValue(oidParam) {
		var oidValue = "";
		var dr = document.referrer;
		if (dr.indexOf("/0,") != -1) dr = dr.substring(dr.indexOf("/0," + 3),dr.length);
		if (dr.indexOf("/1,") != -1) dr = dr.substring(dr.indexOf("/1," + 3),dr.length);
		if (dr.indexOf(",00.html") != -1) dr = dr.substring(0,dr.indexOf(",00.html"));
		if (dr.indexOf(oidParam) != -1) {
			oidValue = dr.substring(dr.indexOf(oidParam) + oidParam.length,dr.length);
			if (oidValue.indexOf("_") != -1) oidValue = oidValue.substring(0,oidValue.indexOf("_"));
			if (oidValue.indexOf(",") != -1) oidValue = oidValue.substring(0,oidValue.indexOf(","));
		}
		if(oidValue.length > 10) oidValue = 'X';
		return oidValue;
	}

	function JSwriteAdBanner(id, sitename, pagename, searchpage, size, keyword) {
	    var tile = id.charAt(id.length - 1); //This obtains the tile based on the id
	    sitename = (sitename.length > 0) ? sitename : ".com"; //When sitename is empty default to guide.com
	    pagename = (pagename.length > 0) ? pagename : "mainpage"; //When pagename is empty default to homepage
	    searchpage = (searchpage.length > 0) ? "/" + searchpage : searchpage; //When searchpage isn't empty make it /searchpage
	    size = (size.length > 0) ? size : "468x60"; //When size is empty default to 468x60
	    var width = size.substring(0, size.indexOf("x"));
	    var height = size.substring(size.indexOf("x") + 1, size.length);
	    var bbanner = "";
	    if (!document.layers) {
	    bbanner += "<iframe src='http://ad.doubleclick.net/adi/" + sitename + "/" + pagename + searchpage + ";kw=" + keyword + ";sz=" + size + ";tile=" + tile + ";ord='" + Math.random() * 10000000 + "?' name='frame" + id + "' width='" + width + "' height='" + height + "' border='0' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'>\n";
	    bbanner += "<a href='http://ad.doubleclick.net/jump/" + sitename + "/" + pagename + searchpage + ";kw=" + keyword + ";sz=" + size + ";tile=" + tile + ";ord='" + Math.random() * 10000000 + "?'>\n";
	    bbanner += "<img src='http://ad.doubleclick.net/ad/" + sitename + "/" + pagename + searchpage + ";kw=" + keyword + ";sz=" + size + ";tile=" + tile + ";ord='" + Math.random() * 10000000 + "?' width='" + width + "' height='" + height + "' border='0'></a>\n";
	    bbanner += "</iframe>\n";
	    }
	    if (document.layers) {
	    bbanner += "<ilayer id='layer" + id + "' visibility='hide' height='" + height + "' top='0' left='0'></ilayer>\n";
	    }
	    return bbanner;
	}
	function getURLParamValue(param) {
		var paramValue = param.toLowerCase() + "=";
		var searchValue = window.location.search.toLowerCase();
		var searchValueParam = "";
		if (searchValue.indexOf(paramValue) != -1) {
			searchValueParam = window.location.search.toLowerCase().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 JSwriteADJInterstitial(adPageID,adKeyword, adSiteValue) {
	
		var adj = "http://ad.doubleclick.net/adj/";
		if (typeof adSiteValue == "undefined") adSiteValue = "";
		adj += adSiteValue + "/";
		var cookie = document.cookie;
		var random = Math.round(Math.random() * 1000000000);
		if (typeof adPageID == "undefined") var adPageID = random; //used as ord value, cache-busting
		var wlp = window.location.pathname;
		
		//zone
		var zone = getURLParamValue("parentZone");
		if(zone != "") adZoneValue = zone;
		
		//ITKE values
		var itkeptag = getURLParamValue("ptag");
		var itkeblog = getURLParamValue("blog");
		var itketag = getURLParamValue("tag");

		//gci
		var gci = (getURLParamValue("parentGci") != "") ? getURLParamValue("parentGci") : getOIDValue("gci");

		//taxonomy
		var tax = "";
		if(typeof tt_dartTAX_id != "undefined") tax = tt_dartTAX_id;
		if (tax == "" && getURLParamValue("parentTax") != "") tax = getURLParamValue("parentTax");
		if (tax == "") tax = getOIDValue("tax");

		// tax override ad group
		var adg = getURLParamValue("adg");
		if ((typeof JSadTaxID != "undefined") && (adg == '')) adg = JSadTaxID;
		
		//taxomomy cluster;
		var clu = (getOIDValue("clu") != "") ? getOIDValue("clu") : getURLParamValue("parentClu");
		if (typeof tt_hbxCL_id != "undefined") clu = tt_hbxCL_id;
		if (typeof JSclusterId != "undefined") clu = JSclusterId;
		if (getURLParamValue("ovrClu") != "") clu = getURLParamValue("ovrClu");

		//path name
		var pth = getURLParamValue("parentPth");
		if (pth == "") {
			var wlp = window.location.pathname.substring(1,window.location.pathname.length);
			var pth = wlp.replace(eval("/\\//g"),".");
			if (pth.indexOf(".0,") != -1) pth = pth.substring(0,pth.indexOf(".0,"));
			if (pth.indexOf(".1,") != -1) pth = pth.substring(0,pth.indexOf(".1,"));
		}
		
		//keyword
		//var adKeyword = "";
		kw = getURLParamValue("parentKw");
		if (kw != '') adKeyword = kw;

		//infocenter id
		var iid = (getOIDValue("iid") != "") ? getOIDValue("iid") : getURLParamValue("parentIid");
		if ((iid == '') && (typeof JSinfoCenterID != "undefined")) iid = JSinfoCenterID;
		
		//resourcecenter id
		var rci = getURLParamValue("parentRci");
		//newsletter ad id
		var nlValue = "";
		if (window.location.search.indexOf("?ad=") != -1 || window.location.search.indexOf("&ad=") != -1) {
			var nlS = window.location.search;
			if (nlS.indexOf("?ad=") != -1) {
				nlValue = nlS.substring(nlS.indexOf("?ad=") + 4, nlS.length);
			} else {
				nlValue = nlS.substring(nlS.indexOf("&ad=") + 4, nlS.length);
			}
			if (nlValue.indexOf("&") != -1) nlValue = nlValue.substring(0, nlValue.indexOf("&"));
		}
		//track ad id
		var trackValue = "";
		if (window.location.search.indexOf("?track=") != -1 || window.location.search.indexOf("&track=") != -1) {
			var trackS = window.location.search;
			if (trackS.indexOf("?track=") != -1) {
				trackValue = trackS.substring(trackS.indexOf("?track=") + 7, trackS.length);
			} else {
				trackValue = trackS.substring(trackS.indexOf("&track=") + 7, trackS.length);
			}
			if (trackValue.indexOf("&") != -1) trackValue = trackValue.substring(0, trackValue.indexOf("&"));
		}
		//persistent ad id
		var sesValue = "";
		if (window.location.search.indexOf("?ses=") != -1 || window.location.search.indexOf("&ses=") != -1) {
			var sesS = window.location.search;
			if (sesS.indexOf("?ses=") != -1) {
				sesValue = sesS.substring(sesS.indexOf("?ses=") + 5, sesS.length);
			} else {
				sesValue = sesS.substring(sesS.indexOf("&ses=") + 5, sesS.length);
			}
			if (sesValue.indexOf("&") != -1) sesValue = sesValue.substring(0, sesValue.indexOf("&"));
		}
		
		// check if referring page is Topics and has tax id in the URL. if so override primary tax
		var overwriteTax = false;
		if (document.referrer.indexOf("/topic") != -1 && window.location.href.indexOf("doubleclick.net") == -1 && getReferOIDValue("tax") != "" && getOIDValue("tax") == "") {
			// overwrite the tax and cluster values for DART based on the tax value in the query string
			overwriteTax = true;
			topicValue = getReferOIDValue("tax");
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		else if (getCookieValue('topicTax') != '' && document.referrer.indexOf("informationCenter") != -1) // check for cookie set by CLT InfoCenter. if so, override primary tax
		{
			topicValue = getCookieValue('topicTax')
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		//welcome ad exclusionary clause, this suppresses certain ads when the welcome ad is shown
		var categoryExclusion = "";
		if (typeof prestitialTimeOut != "undefined" || getURLParamValue("parentPre")) {
			categoryExclusion = "!category=prestitial;";
		}
		
		//http://ad.doubleclick.net/adj/sitename/zone;abr=!webtv;sz=2x1;dcopt=ist;ptile=15;ses=sesValue;ord=adPageID
		//build return string
		
		adj += (typeof JSadCategory != "undefined") ? JSadCategory : "null";
		adj += ";abr!=webtv;sz=2x1;dcopt=ist;ptile=15;"; //force ptile to be last ad on page
		adj += "pth=" + pth + ";";
		adj += "kw=" + adKeyword + ";";
		adj += "gci=" + gci + ";";
		adj += "tax=" + tax + ";";
		adj += "clu=" + clu + ";";
		adj += "adg=" + adg + ";";
		adj += "iid=" + iid + ";";
		adj += "rci=" + rci + ";";
		adj += "nl=" + nlValue + ";";
		adj += "ses=" + sesValue + ";";
		adj += "track=" + trackValue + ";";
		adj += "ptag=" + itkeptag + ";";
		adj += "tag=" + itketag + ";";
		adj += "blog=" + itkeblog + ";";
		adj += categoryExclusion;
		adj += "ord=" + adPageID;
		
		if (window.location.search.indexOf("adString=on") != -1) window.alert("Ad: adj interstitial\n site= " + adSiteValue + " zone=" + JSadCategory + "\n ;pos=0;pth=" + pth + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=2x1;dcopt=ist;ptile=1;iid=" + iid + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + adPageID);
		
		return adj;
		
	}

function JSwriteADJ(adSiteValue, adZoneValue, width, height, adPosition, adKeyword, adDcopt, pageNum) {
	    var bbanner = "";
	    var lsKey = "off";
	    var allcookies = document.cookie;
		var adNumber = adPosition.substring(adPosition.indexOf("_")+1, adPosition.length);
		var random = Math.round(Math.random() * 100000000);
		if (!pageNum) pageNum = Math.round(Math.random() * 100000000);
		var aamsz = width + "x" + height;
		var wlp = window.location.pathname;

		//zone
		var zone = getURLParamValue("parentZone");
		if(zone != "") adZoneValue = zone;
		
		//ITKE values
		var itkeptag = getURLParamValue("ptag");
		var itkeblog = getURLParamValue("blog");
		var itketag = getURLParamValue("tag");

		//gci
		var gci = (getURLParamValue("parentGci") != "") ? getURLParamValue("parentGci") : getOIDValue("gci");

		//taxonomy
		var tax = "";
		if(typeof tt_dartTAX_id != "undefined") tax = tt_dartTAX_id;
		if (tax == "" && getURLParamValue("parentTax") != "") tax = getURLParamValue("parentTax");
		if (tax == "") tax = getOIDValue("tax");

		// tax override ad group
		var adg = getURLParamValue("adg");
		if ((typeof JSadTaxID != "undefined") && (adg == '')) adg = JSadTaxID;
		
		//taxomomy cluster;
		var clu = (getOIDValue("clu") != "") ? getOIDValue("clu") : getURLParamValue("parentClu");
		if (typeof tt_hbxCL_id != "undefined") clu = tt_hbxCL_id;
		if (typeof JSclusterId != "undefined") clu = JSclusterId;
		if (getURLParamValue("ovrClu") != "") clu = getURLParamValue("ovrClu");

		//path name
		var pth = getURLParamValue("parentPth");
		if (pth == "") {
			var wlp = window.location.pathname.substring(1,window.location.pathname.length);
			var pth = wlp.replace(eval("/\\//g"),".");
			if (pth.indexOf(".0,") != -1) pth = pth.substring(0,pth.indexOf(".0,"));
			if (pth.indexOf(".1,") != -1) pth = pth.substring(0,pth.indexOf(".1,"));
		}
		
		//ptile
		var ptile = (typeof adCounter == "undefined") ? adPosition.substring(adPosition.indexOf('_') + 1, adPosition.length) : adCounter;


		//keyword
		kw = getURLParamValue("parentKw");
		if (kw != '') adKeyword = kw;

		//infocenter id
		var iid = (getOIDValue("iid") != "") ? getOIDValue("iid") : getURLParamValue("parentIid");
		if ((iid == '') && (typeof JSinfoCenterID != "undefined")) iid = JSinfoCenterID;
		
		//infocenter name
		var iin = getURLParamValue("parentIin");
		if (iin == '') {
			if (typeof tt_rptInfoCenterMLC != "undefined") iin = tt_rptInfoCenterMLC;
			if ( (iin == '') && (typeof JSinfoCenterName != "undefined")) {
				iin = JSinfoCenterName;
			}
		}
		//resourcecenter id
		var rci = getURLParamValue("parentRci");
		//newsletter ad id
		var nlValue = "";
		if (window.location.search.indexOf("?ad=") != -1 || window.location.search.indexOf("&ad=") != -1) {
			var nlS = window.location.search;
			if (nlS.indexOf("?ad=") != -1) {
				nlValue = nlS.substring(nlS.indexOf("?ad=") + 4, nlS.length);
			} else {
				nlValue = nlS.substring(nlS.indexOf("&ad=") + 4, nlS.length);
			}
			if (nlValue.indexOf("&") != -1) nlValue = nlValue.substring(0, nlValue.indexOf("&"));
		}
		//track ad id
		var trackValue = "";
		if (window.location.search.indexOf("?track=") != -1 || window.location.search.indexOf("&track=") != -1) {
			var trackS = window.location.search;
			if (trackS.indexOf("?track=") != -1) {
				trackValue = trackS.substring(trackS.indexOf("?track=") + 7, trackS.length);
			} else {
				trackValue = trackS.substring(trackS.indexOf("&track=") + 7, trackS.length);
			}
			if (trackValue.indexOf("&") != -1) trackValue = trackValue.substring(0, trackValue.indexOf("&"));
		}
		//persistent ad id
		var sesValue = "";
		if (window.location.search.indexOf("?ses=") != -1 || window.location.search.indexOf("&ses=") != -1) {
			var sesS = window.location.search;
			if (sesS.indexOf("?ses=") != -1) {
				sesValue = sesS.substring(sesS.indexOf("?ses=") + 5, sesS.length);
			} else {
				sesValue = sesS.substring(sesS.indexOf("&ses=") + 5, sesS.length);
			}
			if (sesValue.indexOf("&") != -1) sesValue = sesValue.substring(0, sesValue.indexOf("&"));
		}
	    if (allcookies.indexOf("LS=") != -1 && allcookies.indexOf("LSA=") != -1) {
		var name = "LSA";
		var pos = allcookies.indexOf(name + "=");
		var start = pos + name.length + 1;
		var end = allcookies.indexOf(";",start);
		if (end == -1) end = allcookies.length;
		var LSAvalue = allcookies.substring(start, end);
		if (LSAvalue != 2) {
			name = "LS";
			pos = allcookies.indexOf(name + "=");
			start = pos + name.length + 1;
			end = allcookies.indexOf(";",start);
			if (end == -1) end = allcookies.length;
			var LSvalue = allcookies.substring(start, end);
			var LSuser = LSvalue.substr(LSvalue.indexOf(":")+1);
			LSvalue = LSvalue.substr(0,LSvalue.indexOf(":"));
			if (LSvalue.substring(LSvalue.length-1,LSvalue.length) == "A") lsKey = "on";
			LSvalue = LSvalue.substr(0,LSvalue.length-1);
			if (lsKey == "on") adKeyword = "ls" + LSvalue;
		}
	    }
		// check if referring page is Topics and has tax id in the URL. if so override primary tax
		var overwriteTax = false;
		if (document.referrer.indexOf("/topic") != -1 && window.location.href.indexOf("doubleclick.net") == -1 && getReferOIDValue("tax") != "" && getOIDValue("tax") == "") {
			// overwrite the tax and cluster values for DART based on the tax value in the query string
			overwriteTax = true;
			topicValue = getReferOIDValue("tax");
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		else if (getCookieValue('topicTax') != '' && document.referrer.indexOf("informationCenter") != -1) // check for cookie set by CLT InfoCenter. if so, override primary tax
		{
			topicValue = getCookieValue('topicTax')
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		//welcome ad exclusionary clause, this suppresses certain ads when the welcome ad is shown
		var categoryExclusion = "";
		if (typeof prestitialTimeOut != "undefined" || getURLParamValue("parentPre")) {
			categoryExclusion = "!category=prestitial;";
		}
	if (!document.layers) {
		bbanner += "<scr";
		bbanner += "ipt src='http://ad.doubleclick.net/adj/" + adSiteValue + "/" + adZoneValue + ";pos=" + adNumber + ";pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum + "'></scr";
		bbanner += "ipt>";
		}
	if (document.layers) {
		bbanner += "<ilayer id='" + adPosition + "' height='" + height + "' visibility='hide' top='0' left='0'></ilayer>\n";
		ADlayer[adPosition] = "http://ad.doubleclick.net/adl/" + adSiteValue + "/" + adZoneValue + ";pos=0;pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum + "?'";
		//if (isNS) window.alert(adPosition + " - " + ADlayer[adPosition]);
	}
		if (window.location.search.indexOf("adIframe=on") != -1) window.alert("Ad: " + adPosition + "\n" + bbanner);
		if (window.location.search.indexOf("adString=on") != -1) window.alert("Ad: " + adPosition + "\n site=" + adSiteValue + " zone=" + adZoneValue + "\n ;pos=" + adNumber + ";pth=" + pth + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum);
	    return bbanner;
	}


	function JSwriteAD2(adSiteValue, adZoneValue, width, height, adPosition, adKeyword, adDcopt, pageNum) {
	    var bbanner = "";
	    var lsKey = "off";
	    var allcookies = document.cookie;
    	var adNumber = adPosition.substring(adPosition.indexOf("_")+1, adPosition.length);
		var random = Math.round(Math.random() * 100000000);
		if (!pageNum) pageNum = Math.round(Math.random() * 100000000);
		var aamsz = width + "x" + height;
		var wlp = window.location.pathname;

		//zone
		var zone = getURLParamValue("parentZone");
		if(zone != "") adZoneValue = zone;
		
		//ITKE values
		var itkeptag = getURLParamValue("ptag");
		var itkeblog = getURLParamValue("blog");
		var itketag = getURLParamValue("tag");

		//gci
		var gci = (getURLParamValue("parentGci") != "") ? getURLParamValue("parentGci") : getOIDValue("gci");

		//taxonomy
		var tax = "";
		if(typeof tt_dartTAX_id != "undefined") tax = tt_dartTAX_id;
		if (tax == "" && getURLParamValue("parentTax") != "") tax = getURLParamValue("parentTax");
		if (tax == "") tax = getOIDValue("tax");

		// tax override ad group
		var adg = getURLParamValue("adg");
		if ((typeof JSadTaxID != "undefined") && (adg == '')) adg = JSadTaxID;
		
		//taxomomy cluster;
		var clu = (getOIDValue("clu") != "") ? getOIDValue("clu") : getURLParamValue("parentClu");
		if (typeof tt_hbxCL_id != "undefined") clu = tt_hbxCL_id;
		if (typeof JSclusterId != "undefined") clu = JSclusterId;
		if (getURLParamValue("ovrClu") != "") clu = getURLParamValue("ovrClu");

		//path name
		var pth = getURLParamValue("parentPth");
		if (pth == "") {
			var wlp = window.location.pathname.substring(1,window.location.pathname.length);
			var pth = wlp.replace(eval("/\\//g"),".");
			if (pth.indexOf(".0,") != -1) pth = pth.substring(0,pth.indexOf(".0,"));
			if (pth.indexOf(".1,") != -1) pth = pth.substring(0,pth.indexOf(".1,"));
		}
		
		//ptile
		var ptile = adPosition.substring(adPosition.indexOf('_') + 1, adPosition.length);


		//keyword
		kw = getURLParamValue("parentKw");
		if (kw != '') adKeyword = kw;

		//infocenter id
		var iid = (getOIDValue("iid") != "") ? getOIDValue("iid") : getURLParamValue("parentIid");
		if ((iid == '') && (typeof JSinfoCenterID != "undefined")) iid = JSinfoCenterID;
		
		//infocenter name
		var iin = getURLParamValue("parentIin");
		if (iin == '') {
			if (typeof tt_rptInfoCenterMLC != "undefined") iin = tt_rptInfoCenterMLC;
			if ( (iin == '') && (typeof JSinfoCenterName != "undefined")) {
				iin = JSinfoCenterName;
			}
		}
		//resourcecenter id
		var rci = getURLParamValue("parentRci");
		//newsletter ad id
		var nlValue = "";
		if (window.location.search.indexOf("?ad=") != -1 || window.location.search.indexOf("&ad=") != -1) {
			var nlS = window.location.search;
			if (nlS.indexOf("?ad=") != -1) {
				nlValue = nlS.substring(nlS.indexOf("?ad=") + 4, nlS.length);
			} else {
				nlValue = nlS.substring(nlS.indexOf("&ad=") + 4, nlS.length);
			}
			if (nlValue.indexOf("&") != -1) nlValue = nlValue.substring(0, nlValue.indexOf("&"));
		}
		//track ad id
		var trackValue = "";
		if (window.location.search.indexOf("?track=") != -1 || window.location.search.indexOf("&track=") != -1) {
			var trackS = window.location.search;
			if (trackS.indexOf("?track=") != -1) {
				trackValue = trackS.substring(trackS.indexOf("?track=") + 7, trackS.length);
			} else {
				trackValue = trackS.substring(trackS.indexOf("&track=") + 7, trackS.length);
			}
			if (trackValue.indexOf("&") != -1) trackValue = trackValue.substring(0, trackValue.indexOf("&"));
		}
		//persistent ad id
		var sesValue = "";
		if (window.location.search.indexOf("?ses=") != -1 || window.location.search.indexOf("&ses=") != -1) {
			var sesS = window.location.search;
			if (sesS.indexOf("?ses=") != -1) {
				sesValue = sesS.substring(sesS.indexOf("?ses=") + 5, sesS.length);
			} else {
				sesValue = sesS.substring(sesS.indexOf("&ses=") + 5, sesS.length);
			}
			if (sesValue.indexOf("&") != -1) sesValue = sesValue.substring(0, sesValue.indexOf("&"));
		}
	    if (allcookies.indexOf("LS=") != -1 && allcookies.indexOf("LSA=") != -1) {
		var name = "LSA";
		var pos = allcookies.indexOf(name + "=");
		var start = pos + name.length + 1;
		var end = allcookies.indexOf(";",start);
		if (end == -1) end = allcookies.length;
		var LSAvalue = allcookies.substring(start, end);
		if (LSAvalue != 2) {
			name = "LS";
			pos = allcookies.indexOf(name + "=");
			start = pos + name.length + 1;
			end = allcookies.indexOf(";",start);
			if (end == -1) end = allcookies.length;
			var LSvalue = allcookies.substring(start, end);
			var LSuser = LSvalue.substr(LSvalue.indexOf(":")+1);
			LSvalue = LSvalue.substr(0,LSvalue.indexOf(":"));
			if (LSvalue.substring(LSvalue.length-1,LSvalue.length) == "A") lsKey = "on";
			LSvalue = LSvalue.substr(0,LSvalue.length-1);
			if (lsKey == "on") adKeyword = "ls" + LSvalue;
		}
	    }
		// check if referring page is Topics and has tax id in the URL. if so override primary tax
		var overwriteTax = false;
		if (document.referrer.indexOf("/topic") != -1 && window.location.href.indexOf("doubleclick.net") == -1 && getReferOIDValue("tax") != "" && getOIDValue("tax") == "") {
			// overwrite the tax and cluster values for DART based on the tax value in the query string
			overwriteTax = true;
			topicValue = getReferOIDValue("tax");
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		else if (getCookieValue('topicTax') != '' && document.referrer.indexOf("informationCenter") != -1) // check for cookie set by CLT InfoCenter. if so, override primary tax
		{
			topicValue = getCookieValue('topicTax')
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		//welcome ad exclusionary clause, this suppresses certain ads when the welcome ad is shown
		var categoryExclusion = "";
		if (typeof prestitialTimeOut != "undefined" || getURLParamValue("parentPre")) {
			categoryExclusion = "!category=prestitial;";
		}
	if (!document.layers) {
		if (adPosition.search(/ctHugeAd/g) != -1) {
			deleteCookie('ugcCltHeight','/','.techtarget.');
			bbanner += "<iframe src='http://ad.doubleclick.net/adi/" + adSiteValue + "/" + adZoneValue + ";pos=0;pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum + "?' width='" + width + "' height='" + height + "' border='0' frameborder='0' marginheight='0' marginwidth='0' scrolling='no' onload='resizeCLT(this)'>\n";
		} else {
			bbanner += "<iframe src='http://ad.doubleclick.net/adi/" + adSiteValue + "/" + adZoneValue + ";pos=0;pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum + "?' width='" + width + "' height='" + height + "' border='0' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'>\n";
		}
			bbanner += "<a href='http://ad.doubleclick.net/jump/" + adSiteValue + "/" + adZoneValue + ";pos=0;pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum + "?'>\n";
			bbanner += "<img src='http://ad.doubleclick.net/ad/" + adSiteValue + "/" + adZoneValue + ";pos=0;pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum + "?' width='" + width + "' height='" + height + "' border='0'></a>\n";
			bbanner += "</iframe>\n";
		}
		if (document.layers) {
			bbanner += "<ilayer id='" + adPosition + "' height='" + height + "' visibility='hide' top='0' left='0'></ilayer>\n";
			ADlayer[adPosition] = "http://ad.doubleclick.net/adl/" + adSiteValue + "/" + adZoneValue + ";pos=0;pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum + "?'";
			//if (isNS) window.alert(adPosition + " - " + ADlayer[adPosition]);
		}
		if (window.location.search.indexOf("adIframe=on") != -1) window.alert("Ad: " + adPosition + "\n" + bbanner);
		if (window.location.search.indexOf("adString=on") != -1) window.alert("Ad: " + adPosition + "\n site=" + adSiteValue + " zone=" + adZoneValue + "\n ;pos=0;pth=" + pth + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum);
	    return bbanner;
	}
	
	function JSwriteAD3(adSiteValue, adZoneValue, width, height, adPosition, adKeyword, adDcopt, pageNum, sizes) {
	    // new features:
		// - allows for multiple ad sizes per placement
		// - sends user demographics as part of ad request
		// 'sizes' is an optional param - should be passed as a list of potential ad sizes for this slot
		// like "100x200,200x300". Dart can handle up to 4 potential ad sizes for the slot
		var bbanner = "";
	    var lsKey = "off";
	    var allcookies = document.cookie;
    	var adNumber = adPosition.substring(adPosition.indexOf("_")+1, adPosition.length);
		var random = Math.round(Math.random() * 100000000);
		if (!pageNum) pageNum = Math.round(Math.random() * 100000000);
		var aamsz = (typeof sizes != "undefined") ? sizes : width + "x" + height;
		var wlp = window.location.pathname;

		//zone
		var zone = getURLParamValue("parentZone");
		if(zone != "") adZoneValue = zone;
		
		//ITKE values
		var itkeptag = getURLParamValue("ptag");
		var itkeblog = getURLParamValue("blog");
		var itketag = getURLParamValue("tag");

		//gci
		var gci = (getURLParamValue("parentGci") != "") ? getURLParamValue("parentGci") : getOIDValue("gci");

		//taxonomy
		var tax = "";
		if(typeof tt_dartTAX_id != "undefined") tax = tt_dartTAX_id;
		if (tax == "" && getURLParamValue("parentTax") != "") tax = getURLParamValue("parentTax");
		if (tax == "") tax = getOIDValue("tax");

		// tax override ad group
		var adg = getURLParamValue("adg");
		if ((typeof JSadTaxID != "undefined") && (adg == '')) adg = JSadTaxID;
		
		//taxomomy cluster;
		var clu = (getOIDValue("clu") != "") ? getOIDValue("clu") : getURLParamValue("parentClu");
		if (typeof tt_hbxCL_id != "undefined") clu = tt_hbxCL_id;
		if (typeof JSclusterId != "undefined") clu = JSclusterId;
		if (getURLParamValue("ovrClu") != "") clu = getURLParamValue("ovrClu");

		//path name
		var pth = getURLParamValue("parentPth");
		if (pth == "") {
			var wlp = window.location.pathname.substring(1,window.location.pathname.length);
			var pth = wlp.replace(eval("/\\//g"),".");
			if (pth.indexOf(".0,") != -1) pth = pth.substring(0,pth.indexOf(".0,"));
			if (pth.indexOf(".1,") != -1) pth = pth.substring(0,pth.indexOf(".1,"));
		}
		
		//ptile
		var ptile = adPosition.substring(adPosition.indexOf('_') + 1, adPosition.length);


		//keyword
		kw = getURLParamValue("parentKw");
		if (kw != '') adKeyword = kw;

		//infocenter id
		var iid = (getOIDValue("iid") != "") ? getOIDValue("iid") : getURLParamValue("parentIid");
		if ((iid == '') && (typeof JSinfoCenterID != "undefined")) iid = JSinfoCenterID;
		
		//infocenter name
		var iin = getURLParamValue("parentIin");
		if (iin == '') {
			if (typeof tt_rptInfoCenterMLC != "undefined") iin = tt_rptInfoCenterMLC;
			if ( (iin == '') && (typeof JSinfoCenterName != "undefined")) {
				iin = JSinfoCenterName;
			}
		}
		//resourcecenter id
		var rci = getURLParamValue("parentRci");
		//newsletter ad id
		var nlValue = "";
		if (window.location.search.indexOf("?ad=") != -1 || window.location.search.indexOf("&ad=") != -1) {
			var nlS = window.location.search;
			if (nlS.indexOf("?ad=") != -1) {
				nlValue = nlS.substring(nlS.indexOf("?ad=") + 4, nlS.length);
			} else {
				nlValue = nlS.substring(nlS.indexOf("&ad=") + 4, nlS.length);
			}
			if (nlValue.indexOf("&") != -1) nlValue = nlValue.substring(0, nlValue.indexOf("&"));
		}
		//track ad id
		var trackValue = "";
		if (window.location.search.indexOf("?track=") != -1 || window.location.search.indexOf("&track=") != -1) {
			var trackS = window.location.search;
			if (trackS.indexOf("?track=") != -1) {
				trackValue = trackS.substring(trackS.indexOf("?track=") + 7, trackS.length);
			} else {
				trackValue = trackS.substring(trackS.indexOf("&track=") + 7, trackS.length);
			}
			if (trackValue.indexOf("&") != -1) trackValue = trackValue.substring(0, trackValue.indexOf("&"));
		}
		//persistent ad id
		var sesValue = "";
		if (window.location.search.indexOf("?ses=") != -1 || window.location.search.indexOf("&ses=") != -1) {
			var sesS = window.location.search;
			if (sesS.indexOf("?ses=") != -1) {
				sesValue = sesS.substring(sesS.indexOf("?ses=") + 5, sesS.length);
			} else {
				sesValue = sesS.substring(sesS.indexOf("&ses=") + 5, sesS.length);
			}
			if (sesValue.indexOf("&") != -1) sesValue = sesValue.substring(0, sesValue.indexOf("&"));
		}
	    if (allcookies.indexOf("LS=") != -1 && allcookies.indexOf("LSA=") != -1) {
		var name = "LSA";
		var pos = allcookies.indexOf(name + "=");
		var start = pos + name.length + 1;
		var end = allcookies.indexOf(";",start);
		if (end == -1) end = allcookies.length;
		var LSAvalue = allcookies.substring(start, end);
		if (LSAvalue != 2) {
			name = "LS";
			pos = allcookies.indexOf(name + "=");
			start = pos + name.length + 1;
			end = allcookies.indexOf(";",start);
			if (end == -1) end = allcookies.length;
			var LSvalue = allcookies.substring(start, end);
			var LSuser = LSvalue.substr(LSvalue.indexOf(":")+1);
			LSvalue = LSvalue.substr(0,LSvalue.indexOf(":"));
			if (LSvalue.substring(LSvalue.length-1,LSvalue.length) == "A") lsKey = "on";
			LSvalue = LSvalue.substr(0,LSvalue.length-1);
			if (lsKey == "on") adKeyword = "ls" + LSvalue;
		}
	    }
		// check if referring page is Topics and has tax id in the URL. if so override primary tax
		var overwriteTax = false;
		if (document.referrer.indexOf("/topic") != -1 && window.location.href.indexOf("doubleclick.net") == -1 && getReferOIDValue("tax") != "" && getOIDValue("tax") == "") {
			// overwrite the tax and cluster values for DART based on the tax value in the query string
			overwriteTax = true;
			topicValue = getReferOIDValue("tax");
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		else if (getCookieValue('topicTax') != '' && document.referrer.indexOf("informationCenter") != -1) // check for cookie set by CLT InfoCenter. if so, override primary tax
		{
			topicValue = getCookieValue('topicTax')
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		//welcome ad exclusionary clause, this suppresses certain ads when the welcome ad is shown
		var categoryExclusion = "";
		if (typeof prestitialTimeOut != "undefined" || getURLParamValue("parentPre")) {
			categoryExclusion = "!category=prestitial;";
		}
		
		// ad params string
		var adParamString = adSiteValue + "/" + adZoneValue + ";pos=0;pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";" + categoryExclusion + "ord=" + pageNum;
		
		// user demographics
		if (cookieExists('tt_ut') != -1) {
			adParamString += ";uid=" + getCookieValue('tt_ut');
		}
		if (cookieExists('prof') != -1) {
			// get 'prof' cookie value, each name/value pair is delmited by a "#" sign
			// 		ex: fname=#dname=rhennessey%40techtarget%2Ecom#company=TechTarget#title=CSO#channel_ind=Y#industry=14#
			// parse out each value and then append to adParamString
			var profVal = getCookieValue('prof');
			profArray = new Array();
			profArray = profVal.split("#");
			for(i=0;i<profArray.length;i++) {
				demos = profArray[i].split("=");
				demoField = demos[0];
				demoVal = demos[1];
				if ((demoField == "company") && (demoVal != "") ){
					adParamString += ";com=" + demoVal;
				} else if ((demoField == "title") && (demoVal != "") ){
					adParamString += ";ttl=" + demoVal;
				} else if ((demoField == "channel_ind") && (demoVal != "") ){
					adParamString += ";cha=" + demoVal;
				} else if ((demoField == "industry") && (demoVal != "") ){
					adParamString += ";ind=" + demoVal;
				} else if ((demoField == "fname") && (demoVal != "") ){
					adParamString += ";fnm=" + demoVal;
				} else if ((demoField == "dname") && (demoVal != "") ){
					adParamString += ";dnm=" + demoVal;
					
				}
			}
		}		
		
	if (!document.layers) {
	
		bbanner += "<iframe src='http://ad.doubleclick.net/adi/" + adParamString + "?' width='" + width + "' height='" + height + "' border='0' frameborder='0' marginheight='0' marginwidth='0' scrolling='no'>n";
		bbanner += "<a href='http://ad.doubleclick.net/jump/" + adParamString + "?'>n";
		bbanner += "<img src='http://ad.doubleclick.net/ad/" + adParamString + "?' width='" + width + "' height='" + height + "' border='0'></a>n";
		bbanner += "</iframe>n";
	 }
		if (document.layers) {
			bbanner += "<ilayer id='" + adPosition + "' height='" + height + "' visibility='hide' top='0' left='0'></ilayer>\n";
			ADlayer[adPosition] = "http://ad.doubleclick.net/adl/" + adParamString + "?'";
		}
		if (window.location.search.indexOf("adIframe=on") != -1) window.alert("Ad: " + adPosition + "\n" + bbanner);
		if (window.location.search.indexOf("adString=on") != -1) window.alert("Ad: " + adPosition + "\n site=" + adSiteValue + " zone=" + adZoneValue + "\n adParamString: " + adParamString);
	    return bbanner;
	}	
	
	
	function JSwriteDARTString(adSiteValue, adZoneValue, width, height, adPosition, adKeyword, adDcopt, pageNum) {
	    var bbanner = "";
	    var lsKey = "off";
	    var allcookies = document.cookie;
    	var adNumber = adPosition.substring(adPosition.indexOf("_")+1, adPosition.length);
		var random = Math.round(Math.random() * 100000000);
		if (!pageNum) pageNum = Math.round(Math.random() * 100000000);
		var aamsz = width + "x" + height;
		var wlp = window.location.pathname;

		//zone
		var zone = getURLParamValue("parentZone");
		if(zone != "") adZoneValue = zone;
		
		//ITKE values
		var itkeptag = getURLParamValue("ptag");
		var itkeblog = getURLParamValue("blog");
		var itketag = getURLParamValue("tag");

		//gci
		var gci = (getURLParamValue("parentGci") != "") ? getURLParamValue("parentGci") : getOIDValue("gci");

		//taxonomy
		var tax = "";
		if(typeof tt_dartTAX_id != "undefined") tax = tt_dartTAX_id;
		if (tax == "" && getURLParamValue("parentTax") != "") tax = getURLParamValue("parentTax");
		if (tax == "") tax = getOIDValue("tax");

		// tax override ad group
		var adg = getURLParamValue("adg");
		if ((typeof JSadTaxID != "undefined") && (adg == '')) adg = JSadTaxID;
		
		//taxomomy cluster;
		var clu = (getOIDValue("clu") != "") ? getOIDValue("clu") : getURLParamValue("parentClu");
		if (typeof tt_hbxCL_id != "undefined") clu = tt_hbxCL_id;
		if (typeof JSclusterId != "undefined") clu = JSclusterId;
		if (getURLParamValue("ovrClu") != "") clu = getURLParamValue("ovrClu");

		//path name
		var pth = getURLParamValue("parentPth");
		if (pth == "") {
			var wlp = window.location.pathname.substring(1,window.location.pathname.length);
			var pth = wlp.replace(eval("/\\//g"),".");
			if (pth.indexOf(".0,") != -1) pth = pth.substring(0,pth.indexOf(".0,"));
			if (pth.indexOf(".1,") != -1) pth = pth.substring(0,pth.indexOf(".1,"));
		}
		
		//ptile
		var ptile = adPosition.substring(adPosition.indexOf('_') + 1, adPosition.length);


		//keyword
		kw = getURLParamValue("parentKw");
		if (kw != '') adKeyword = kw;

		//infocenter id
		var iid = (getOIDValue("iid") != "") ? getOIDValue("iid") : getURLParamValue("parentIid");
		if ((iid == '') && (typeof JSinfoCenterID != "undefined")) iid = JSinfoCenterID;
		
		//infocenter name
		var iin = getURLParamValue("parentIin");
		if (iin == '') {
			if (typeof tt_rptInfoCenterMLC != "undefined") iin = tt_rptInfoCenterMLC;
			if ( (iin == '') && (typeof JSinfoCenterName != "undefined")) {
				iin = JSinfoCenterName;
			}
		}
		//resourcecenter id
		var rci = getURLParamValue("parentRci");
		//newsletter ad id
		var nlValue = "";
		if (window.location.search.indexOf("?ad=") != -1 || window.location.search.indexOf("&ad=") != -1) {
			var nlS = window.location.search;
			if (nlS.indexOf("?ad=") != -1) {
				nlValue = nlS.substring(nlS.indexOf("?ad=") + 4, nlS.length);
			} else {
				nlValue = nlS.substring(nlS.indexOf("&ad=") + 4, nlS.length);
			}
			if (nlValue.indexOf("&") != -1) nlValue = nlValue.substring(0, nlValue.indexOf("&"));
		}
		//track ad id
		var trackValue = "";
		if (window.location.search.indexOf("?track=") != -1 || window.location.search.indexOf("&track=") != -1) {
			var trackS = window.location.search;
			if (trackS.indexOf("?track=") != -1) {
				trackValue = trackS.substring(trackS.indexOf("?track=") + 7, trackS.length);
			} else {
				trackValue = trackS.substring(trackS.indexOf("&track=") + 7, trackS.length);
			}
			if (trackValue.indexOf("&") != -1) trackValue = trackValue.substring(0, trackValue.indexOf("&"));
		}
		//persistent ad id
		var sesValue = "";
		if (window.location.search.indexOf("?ses=") != -1 || window.location.search.indexOf("&ses=") != -1) {
			var sesS = window.location.search;
			if (sesS.indexOf("?ses=") != -1) {
				sesValue = sesS.substring(sesS.indexOf("?ses=") + 5, sesS.length);
			} else {
				sesValue = sesS.substring(sesS.indexOf("&ses=") + 5, sesS.length);
			}
			if (sesValue.indexOf("&") != -1) sesValue = sesValue.substring(0, sesValue.indexOf("&"));
		}
	    if (allcookies.indexOf("LS=") != -1 && allcookies.indexOf("LSA=") != -1) {
		var name = "LSA";
		var pos = allcookies.indexOf(name + "=");
		var start = pos + name.length + 1;
		var end = allcookies.indexOf(";",start);
		if (end == -1) end = allcookies.length;
		var LSAvalue = allcookies.substring(start, end);
		if (LSAvalue != 2) {
			name = "LS";
			pos = allcookies.indexOf(name + "=");
			start = pos + name.length + 1;
			end = allcookies.indexOf(";",start);
			if (end == -1) end = allcookies.length;
			var LSvalue = allcookies.substring(start, end);
			var LSuser = LSvalue.substr(LSvalue.indexOf(":")+1);
			LSvalue = LSvalue.substr(0,LSvalue.indexOf(":"));
			if (LSvalue.substring(LSvalue.length-1,LSvalue.length) == "A") lsKey = "on";
			LSvalue = LSvalue.substr(0,LSvalue.length-1);
			if (lsKey == "on") adKeyword = "ls" + LSvalue;
		}
	    }
		// check if we're accessing a piece of content that has "topic=XXXXX" in the URL
		var overwriteTax = false;
		if (document.referrer.indexOf("/topic") != -1 && window.location.href.indexOf("doubleclick.net") == -1 && getReferOIDValue("tax") != "" && getOIDValue("tax") == "") {
			// overwrite the tax and cluster values for DART based on the tax value in the query string

			overwriteTax = true;
			topicValue = getReferOIDValue("tax");
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
			bbanner += "http://ad.doubleclick.net/adi/" + adSiteValue + "/" + adZoneValue + ";pos=0;pth=" + pth  + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";ord=" + pageNum + "?";

		if (window.location.search.indexOf("adIframe=on") != -1) window.alert("Ad: " + adPosition + "\n" + bbanner);
		if (window.location.search.indexOf("adString=on") != -1) window.alert("Ad: " + adPosition + "\n site=" + adSiteValue + " zone=" + adZoneValue + "\n ;pos=0;pth=" + pth + ";kw=" + adKeyword + ";gci=" + gci + ";tax=" + tax + ";clu=" + clu + ";adg=" + adg + ";sz=" + aamsz + ";dcopt=" + adDcopt + ";ptile=" + ptile + ";iid=" + iid + ";iin=" + iin + ";rci=" + rci + ";nl=" + nlValue + ";ses=" + sesValue + ";track=" + trackValue + ";ptag=" + itkeptag + ";tag=" + itketag + ";blog=" + itkeblog + ";ord=" + pageNum);
	    return bbanner;
	}
	
	function JSwriteLeaderBoard2(adSiteValue, adZoneValue, width, height, adPosition, adKeyword, adDcopt, pageNum) {
		var width = (!width) ? 728 : width;
		var height = (!height) ? 90 : height;
	    var size = width + "x" + height;
	    var lsKey = "off";
	    var allcookies = document.cookie;
		var position = "0";
	    var sLdrBoard = new String();
		var adNumber = adPosition.substring(adPosition.indexOf("_")+1,adPosition.length);
		var rNum = Math.random() * 10000000;
		if (!pageNum) pageNum = Math.round(Math.random() * 100000000);
	
		//gci
		var gci = getOIDValue("gci");
		
		//taxonomy
		var tax = "";
		if(typeof tt_dartTAX_id != "undefined") tax = tt_dartTAX_id;
		if (tax == "") tax = getOIDValue("tax");

		//taxomomy cluster;
		var clu = "";
		if (typeof tt_hbxCL_id != "undefined") clu = tt_hbxCL_id;
		if (typeof JSclusterId != "undefined") clu = JSclusterId;
		if (getURLParamValue("ovrClu") != "") clu = getURLParamValue("ovrClu");
			
		// tax override ad group
		var adg = getURLParamValue("adg");
		if (typeof JSadTaxID != "undefined" && adg == '') adg = JSadTaxID;
		
		//path name
		var wlp = window.location.pathname.substring(1,window.location.pathname.length);
		var pth = wlp.replace(eval("/\\//g"),".");
		if (pth.indexOf(".0,") != -1) pth = pth.substring(0,pth.indexOf(".0,"));
		if (pth.indexOf(".1,") != -1) pth = pth.substring(0,pth.indexOf(".1,"));

		var ptile = adPosition.substring(adPosition.indexOf('_') + 1, adPosition.length);

		//infocenter id
		var iid = getOIDValue("iid");
		//infocenter name
		var iin = "";
		if (typeof tt_rptInfoCenterMLC != "undefined") iin = tt_rptInfoCenterMLC;
		//resourcecenter id
		var rci = "";
		//newsletter ad id
		var nlValue = "";
		if (window.location.search.indexOf("?ad=") != -1 || window.location.search.indexOf("&ad=") != -1) {
			var nlS = window.location.search;
			if (nlS.indexOf("?ad=") != -1) {
				nlValue = nlS.substring(nlS.indexOf("?ad=") + 4, nlS.length);
			} else {
				nlValue = nlS.substring(nlS.indexOf("&ad=") + 4, nlS.length);
			}
			if (nlValue.indexOf("&") != -1) nlValue = nlValue.substring(0, nlValue.indexOf("&"));
		}
		//track ad id
		var trackValue = "";
		if (window.location.search.indexOf("?track=") != -1 || window.location.search.indexOf("&track=") != -1) {
			var trackS = window.location.search;
			if (trackS.indexOf("?track=") != -1) {
				trackValue = trackS.substring(trackS.indexOf("?track=") + 7, trackS.length);
			} else {
				trackValue = trackS.substring(trackS.indexOf("&track=") + 7, trackS.length);
			}
			if (trackValue.indexOf("&") != -1) trackValue = trackValue.substring(0, trackValue.indexOf("&"));
		}
		//persistent ad id
		var sesValue = "";
		if (window.location.search.indexOf("?ses=") != -1 || window.location.search.indexOf("&ses=") != -1) {
			var sesS = window.location.search;
			if (sesS.indexOf("?ses=") != -1) {
				sesValue = sesS.substring(sesS.indexOf("?ses=") + 5, sesS.length);
			} else {
				sesValue = sesS.substring(sesS.indexOf("&ses=") + 5, sesS.length);
			}
			if (sesValue.indexOf("&") != -1) sesValue = sesValue.substring(0, sesValue.indexOf("&"));
		}
	    if (allcookies.indexOf("LS=") != -1 && allcookies.indexOf("LSA=") != -1) {
			var name = "LSA";
			var pos = allcookies.indexOf(name + "=");
			var start = pos + name.length + 1;
			var end = allcookies.indexOf(";",start);
			if (end == -1) end = allcookies.length;
			var LSAvalue = allcookies.substring(start, end);
			if (LSAvalue != 2) {
				name = "LS";
				pos = allcookies.indexOf(name + "=");
				start = pos + name.length + 1;
				end = allcookies.indexOf(";",start);
				if (end == -1) end = allcookies.length;
				var LSvalue = allcookies.substring(start, end);
				var LSuser = LSvalue.substr(LSvalue.indexOf(":")+1);
				LSvalue = LSvalue.substr(0,LSvalue.indexOf(":"));
				if (LSvalue.substring(LSvalue.length-1,LSvalue.length) == "A") lsKey = "on";
				LSvalue = LSvalue.substr(0,LSvalue.length-1);
				if (lsKey == "on") adKeyword = "ls" + LSvalue;
			}
	    }
		// check if we're accessing a piece of content that has "topic=XXXXX" in the URL
		var overwriteTax = false;
		if (document.referrer.indexOf("/topic") != -1 && window.location.href.indexOf("doubleclick.net") == -1 && getReferOIDValue("tax") != "" && getOIDValue("tax") == "") {
			// overwrite the tax and cluster values for DART based on the tax value in the query string

			overwriteTax = true;
			topicValue = getReferOIDValue("tax");
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		} else if (getCookieValue('topicTax') != '' && document.referrer.indexOf("informationCenter") != -1) // check for cookie set by CLT InfoCenter. if so, override primary tax
		{
			topicValue = getCookieValue('topicTax')
			var evalString = eval("typeof cl_id_" + topicValue);
			if( evalString == "undefined" ) {
				var clu = 'NONE';
			} else {
				var clu = eval("cl_id_" + topicValue);
			}
			var tax = topicValue;
		}
		//welcome ad exclusionary clause
		var categoryExclusion = "";
		if (typeof prestitialTimeOut != "undefined") {
			categoryExclusion = "!category=prestitial;";
		}
		if (isLayers) {
			sLdrBoard += '<ilayer id="'+adPosition+'" height="'+height+'" visibility="hide" top="0" left="0"></ilayer>';
			ADlayer[adPosition] = "http://ad.doubleclick.net/adl/"+adSiteValue+"/"+adZoneValue+";pos=0;pth="+pth+";kw="+adKeyword+";gci="+gci+";tax="+tax+";clu="+clu+";adg="+adg+";iid="+iid+";iin="+iin+";rci="+rci+";nl="+nlValue+";ses="+sesValue+";track="+trackValue+";sz="+size+";dcopt="+adDcopt+";ptile="+adNumber+";" + categoryExclusion + "ord="+pageNum+"?"
		} else {
			var sURL = new String();
			if (((isNS) && (apV < 6.2)) || (isOP) || (isXX) || (typeof JSleaderboardNF == "boolean" && JSleaderboardNF == true)) {
				sURL = "http://ad.doubleclick.net/adi/"+adSiteValue+"/"+adZoneValue+";pos=0;pth="+pth+";kw="+adKeyword+";gci="+gci+";tax="+tax+";clu="+clu+";adg="+adg+";iid="+iid+";iin="+iin+";rci="+rci+";nl="+nlValue+";ses="+sesValue+";track="+trackValue+";sz="+size+";dcopt="+adDcopt+";ptile="+adNumber+";" + categoryExclusion + "ord="+pageNum+"?";
			} else {
				if (window.location.pathname.indexOf("Rhythmyx/assembler/render") != "-1") sURL = "/Rhythmyx/web_resources";
				sURL += "/techtarget/leaderboard.html?" + escape("http://ad.doubleclick.net/adj/"+adSiteValue+"/"+adZoneValue+";pos=0;pth="+pth+";kw="+adKeyword+";gci="+gci+";tax="+tax+";clu="+clu+";adg="+adg+";iid="+iid+";iin="+iin+";rci="+rci+";nl="+nlValue+";ses="+sesValue+";track="+trackValue+";sz="+size+";dcopt="+adDcopt+";ptile="+adNumber+";" + categoryExclusion + "ord="+pageNum+"?");
			}
			sLdrBoard += '<iframe src="'+sURL+'" name="frame_'+adPosition+'" id="fra728x90" width="'+width+'" height="'+height+'" border="0" frameborder="0" marginheight="0" marginwidth="0" scrolling="no">';
			sLdrBoard += '<a href="http://ad.doubleclick.net/jump/'+adSiteValue+'/'+adZoneValue+';pos=0;pth='+pth+';kw='+adKeyword+';gci='+gci+';tax='+tax+';clu='+clu+';adg='+adg+';iid='+iid+';iin='+iin+';rci='+rci+';nl='+nlValue+';ses='+sesValue+';track='+trackValue+';sz='+size+';dcopt='+adDcopt+';ptile='+adNumber+';' + categoryExclusion + 'ord='+pageNum+'?">';
			sLdrBoard += '<img src="http://ad.doubleclick.net/ad/'+adSiteValue+'/'+adZoneValue+';pos=0;pth='+pth+';kw='+adKeyword+';gci='+gci+';tax='+tax+';clu='+clu+';adg='+adg+';iid='+iid+';iin='+iin+';rci='+rci+';nl='+nlValue+';ses='+sesValue+';track='+trackValue+';sz='+size+';dcopt='+adDcopt+';ptile='+adNumber+';' + categoryExclusion + 'ord='+pageNum+'?" width="'+width+'" height="'+height+'" border="0"></a>';
			sLdrBoard += '</iframe>';
		}
		if (window.location.search.indexOf("adIframe=on") != -1) window.alert("Ad: " + adPosition + "\n" + unescape(sLdrBoard));
		if (window.location.search.indexOf("adString=on") != -1) window.alert("Ad: " + adPosition + "\n" + "site="+adSiteValue+" zone="+ adZoneValue + "\n ;pos=0;pth="+pth+";kw="+adKeyword+";gci="+gci+";tax="+tax+";clu="+clu+";adg="+adg+";iid="+iid+";iin="+iin+";rci="+rci+";nl="+nlValue+";ses="+sesValue+";track="+trackValue+";sz="+size+";dcopt="+adDcopt+";ptile="+adNumber+";" + categoryExclusion + "ord="+pageNum);
	    return (sLdrBoard);
	}

	function JSwriteADInfo(sitevalue, areavalue, width, height, position, kw, category, vibe, pageNum) {
		var adNum = position.substring(position.indexOf("_")+1, position.length);
		var bbbanner = "";
		bbbanner += "<table cellspacing=0 cellpadding=0 border=0 width=100% bgcolor=#DFDFDF><tr><td>\n";
		bbbanner += "<a class=small href=\"/ADinfo?sitevalue=" + sitevalue + "&areavalue=" + areavalue + "&width=" + width + "&height=" + height + "&position=" + position + "&kw=" + kw + "&cat=" + JSadCategory + "&vibe=" + vibe + "&adpageid=" + pageNum + "\" target=\"ADwindow\">\n";
		bbbanner +="<img src=\"/digitalguide/images/Misc/arrow_sort_down_666666.gif\" border=0> Information for AD" + adNum + "</a>\n";
		bbbanner += "</td></tr></table>\n";
		return bbbanner;
	}

	function JSwriteAdLayer(id, sitename, pagename, searchpage, size, keyword) {
	    var ptile = id.charAt(id.length - 1); //This obtains the ptile based on the id
	    sitename = (sitename.length > 0) ? sitename : ".com"; //When sitename is empty default to guide.com
	    pagename = (pagename.length > 0) ? pagename : "homepage"; //When pagename is empty default to homepage
	    searchpage = (searchpage.length > 0) ? "/" + searchpage : searchpage; //When searchpage isn't empty make it /searchpage
	    size = (size.length > 0) ? size : "468x60"; //When size is empty default to 468x60
	    var llayer = "";
	    llayer += "<layer src=\"http://ad.doubleclick.net/adl/" + sitename + "/" + pagename + searchpage + ";kw=" + keyword + ";sz=" + size + ";ptile=" + ptile + ";ord=" + Math.random() * 10000000 + "?\" visibility=\"hide\" onload=\"moveToAbsolute(layer" + id + ".pageX, layer" + id + ".pageY); visibility='show'\"></layer>\n";
	    return llayer;
	}

	var LSValue = "";
	var lsbool = false;

	function JSwriteLSAdBanner(id, sitename, pagename, searchpage, size, keyword, adname) {
	
		var adname = (!adname) ? "ad" : adname;
		//var lsbool = false;
		if (allcookies.indexOf("LS=") != -1 && allcookies.indexOf("LSAD=") == -1) {
			
			var name = "LS";
			var pos = allcookies.indexOf(name + "=");
			var start = pos + name.length + 1;
			var end = allcookies.indexOf(";",start);
			if (end == -1) end = allcookies.length;
			//var LSvalue = allcookies.substring(start, end);
			LSvalue = allcookies.substring(start, end);
			
			var LSuser = LSvalue.substr(LSvalue.indexOf(":")+1);
			LSvalue = LSvalue.substr(0,LSvalue.indexOf(":"));
			if (LSvalue.substring(LSvalue.length-1,LSvalue.length) == "A") {
				lsbool = true;
			}
			LSvalue = LSvalue.substr(0,LSvalue.length-1);
		}
		size = (size.length > 0) ? size : "468x60"; //When size is empty default to 468x60
		var width = size.substring(0, size.indexOf("x"));
		var height = size.substring(size.indexOf("x") + 1, size.length);
		var bbanner = "";
		if (lsbool == true) {
			if (!document.layers) {
				bbanner += "<iframe src=\"/liftStudy/" + LSvalue + "/" + adname + "\" name=\"frame" + id + "\" width=\"" + width + "\" height=\"" + height + "\" border=\"0\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\">\n";
				bbanner += "<a href=\"/liftStudy/" + LSvalue + "/" + adname + "\">\n";
				bbanner += "<img src=\"/liftStudy/" + LSvalue + "/" + adname + "\" width=\"" + width + "\" height=\"" + height + "\" border=\"0\"></a>\n";
				bbanner += "</iframe>\n";
			}
	
			if (document.layers) {
				bbanner += "<ilayer id='layer" + id + "' visibility='hide' height='" + height + "' top='0' left='0'></ilayer>\n";
			}
		} else {
			bbanner += JSwriteAdBanner(id, sitename, pagename, searchpage, size, keyword);
		}
	
		return bbanner;
	}

	function JSwriteLSAdLayer(id, sitename, pagename, searchpage, size, keyword, adname) {
		var adname = (!adname) ? "ad" : adname;
		var llayer = "";
		if (lsbool == true) {
			llayer += "<layer src=\"/liftStudy/" + LSvalue + "/" + adname + "\" visibility=\"hide\" onload=\"moveToAbsolute(layer" + id + ".pageX, layer" + id + ".pageY); visibility='show'\"></layer>\n";
		
		} else {
			llayer += JSwriteAdLayer(id, sitename, pagename, searchpage, size, keyword);
	
		}
	
		return llayer;
	}

  /* Legacy Ad Variables Section - used on WebX and WhatIs SkyScraper */

	var adTag = Math.random() * 10000000;
	var adTag1 = Math.random() * 10000000;
	var adTag2 = Math.random() * 10000000;
	var adTag3 = Math.random() * 10000000;
	var dgSponsor = Math.random() * 10000000;
	var dgGiveAway = Math.random() * 10000000;
	var dgPromo = Math.random() * 10000000;
	var dgSkyScraper = Math.random() * 10000000;

	function getAdNumber(item) {
		return item;
	}

 /* Sponsor Move Function */

	function sponsorMove() {
		var moveX = 3;
		var moveY = 5;
		var oSponsor;
		var oHolder;
		if ((isNS) && (isLayers)) {
			oSponsor = getObj('layerMove');
			oHolder = getObj('layerHolder');
			if ((oSponsor) && (oHolder)) {
				oSponsor.moveToAbsolute(oHolder.pageX+moveX,oHolder.pageY+moveY);
				oSponsor.visibility = "show";
			}
		} else {
			oSponsor = getObj('divMove');
			oHolder = getObj('divHolder');
			if ((oSponsor) && (oHolder)) {
				moveObjectTo(oSponsor,findLeft(oHolder)+moveX,findTop(oHolder)+moveY);
				oSponsor.style.visibility = "visible";
			}
		}
	}

	function sponsorMove_old() {
		var moveX=3;
		var moveY=5;
		NN4=(document.layers) ? 1 : 0;
		NN6=(document.getElementById && !document.all) ? 1 : 0;
		IE=(document.all) ? 1 : 0;

		if (IE) {
			var agt=navigator.userAgent.toLowerCase();
			var is_mac=(agt.indexOf("mac")!=-1);
			var is_major=parseInt(navigator.appVersion);
			var msie_vers_start=agt.indexOf("msie")+5;
			var msie_real_vers=parseFloat(agt.substring(msie_vers_start, msie_vers_start+3));
			var mac45=(is_mac && (msie_real_vers < 5)) ? 1 : 0;

			if (mac45) {
				temp=document.all.divMove.innerHTML;
				//alert(temp);
				document.all.divMove.innerHTML="";
				document.all.divHolder.innerHTML=temp;
			} else {
				divHolder.getRealLeft = getRealLeft;
				divHolder.getRealTop = getRealTop;

				function getRealLeft() {
					xPos = this.offsetLeft;
					tempEl = this.offsetParent;
					while (tempEl != null) {
						xPos += tempEl.offsetLeft;
						tempEl = tempEl.offsetParent;
					}
					return xPos;
				}

				function getRealTop() {
					yPos = this.offsetTop;
					tempEl = this.offsetParent;
					while (tempEl != null) {
						yPos += tempEl.offsetTop;
						tempEl = tempEl.offsetParent;
					}
					return yPos;
				}

				Left=divHolder.getRealLeft();
				Top=divHolder.getRealTop();

				divMove.style.left=Left+moveX;
				divMove.style.top=Top+moveY;

				divMove.style.visibility="visible";
			}
		} else if (NN4) {
			document.layerMove.moveToAbsolute(document.layerHolder.pageX+moveX, document.layerHolder.pageY+moveY);
			document.layerMove.visibility='show';
		} else if (NN6) {
			tempDiv=document.getElementById("Holder");
			Top=document.defaultView.getComputedStyle(tempDiv, "").getPropertyValue("top");
			Left=document.defaultView.getComputedStyle(tempDiv, "").getPropertyValue("left");

			if (Top.indexOf("px")) {
				Top=Top.slice(0,-2);
				Top=Top*1;
			}

			if (Left.indexOf("px")) {
				Left=Left.slice(0,-2);
				Left=Left*1;
			}

			document.getElementById("divMove").style.top=Top+moveY;
			document.getElementById("divMove").style.left=Left+moveX;
			document.getElementById("divMove").style.visibility="visible";
		}
	}

  /* Check Email Function */

	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 == "") {
			// change to false
			return "An email address is required";
		} else {
			var NewemailStr=emailStr;
			// need to trim space beginning and the end each email, then pass back to the form. 
		}

		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.";
		}

// 05/27/03 BobH: Commented out below lines (see IT # 3424)
//		if(user.length>0)
//		{
//			if((user.charAt(0)=="-")||(user.charAt(0)=="_"))	
//			{
//				return "The username in the email address doesn't seem to be valid.";
//			} else if ((user.charAt(user.length-1)=="_")||(user.charAt(user.length-1)=="-")) {
//				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";
	}

  /* Validate Email Function */

	function validateEmail (emailAddr) 
	{
		var emailAlert = checkEmail(emailAddr)

		if (emailAlert == 'good')
			return true;
		else 
		{
			alert(emailAlert);
			return false;
		}
	}

  /* Build URL Function */

	function buildURL(form, site) {

		// search400 uses "AS/400" for it's short name, so regexp out the "/"
		var regexp = /(\/)/g;;
		var name = site.replace(regexp,"");
		var regexp = / /g;;
		var name = name.replace(regexp,"");	// Get rid of spaces, for "Systems Management"

		var URL = form.URL.value;
		URL += "&email=" + form.email.value;

		if (validateEmail(form.email.value)) {
			window.open( URL, name, 'height=400,width=285,scrollbars=yes');
		}
	}

  /* Add Redirect Function */

	function addRedirectString(aCollection) {
		//redirectString is built in JSvariables, this function is called from the Footer template
		var i = 0;
		for(i = 0; i < aCollection.length; i++) {
			if (aCollection[i].href.indexOf("mailto:") == -1 && aCollection[i].href.indexOf("javascript:") == -1 && pathCoBrand[aCollection[i].pathname.substring(0, aCollection[i].pathname.indexOf("/"))] == "on") {
				aCollection[i].href = redirectString + aCollection[i].href;
			}
		}	
	}

	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 validateHandle(handleStr) {
		// performs checks on illegal characters and minimun length 
		var ttalert = '';

		// Search for valid chars: A-Z, a-z, and 0-9
		var handlePat=/[^a-zA-Z0-9]/
		var handleResult=handleStr.search(handlePat)

		// Check to make sure the handle has valid characters in it
		if (handleResult != -1) {
			ttalert += "The handle name must contain ONLY alphanumeric characters. Spaces are NOT allowed. \n";
		}
		
		//Check the length of the username
		if (handleStr.length < 6) {
			ttalert += "The handle must be 6 characters or greater in length. \n";
		}
		return ttalert;
	}

	function popUp(url , name, params) {
		if (!name) {
			var winName = "popUp";
		} else {			
			var winName = name;
		}
		if (!params) {
			var winParams = "width=400,height=350,toolbar=no,menubar=no,location=no,scrollbars=yes,resize=no";
		} else {
			var winParams = params
		}			
		var OpenWindow = window.open(url, winName , winParams);
	}
	
	function reservedHandle(handleStr) {
		//Check reserved keywords
		var ttalert = '';
		var reservedList = 'ipc itpeer peerconnect techtarget itconnect itpeerconnect';
		reservedList += ' itknowledgeexchange itknowledgexchange itknowledge itexchange';
		reservedList += ' itxchange knowledgeexchange knowledgexchange itke ike';
		reservedList += ' itkexchange itknowledgex itkxchange kexchange kxchange';
		var checkHandle = handleStr.toLowerCase();
		if ( reservedList.indexOf(checkHandle) != -1 ) {
			ttalert += 'Handle: ' + handleStr + ' is already in use \n';
		}	
		return ttalert;		
	}
	
	function replaceSID0() {
		//replace sid0 with OID sid value
		var fCollection = document.forms;
		for(var fi = 0; fi < fCollection.length; fi++) {
			if (fCollection[fi].action.indexOf("sid0") != -1) {
				fCollection[fi].action = fCollection[fi].action.replace("sid0","sid");
			}
		}	
	}
	
	function replaceSID0onEvent() {
		//replace sid0 with OID sid value, for non-Netscape browsers
		var tempText = "";
		var eHref = (window.event.srcElement.tagName == "A") ? window.event.srcElement : window.event.srcElement.parentElement;
		if (eHref.parentElement && eHref.tagName != "A") eHref = eHref.parentElement;
		if (eHref.href) {
			if (eHref.href.indexOf("sid0") != -1) {
				tempText = eHref.innerText;
				eHref.href = eHref.href.replace("sid0", "sid");
				if (tempText) eHref.innerText = tempText;
				//return true;
			}
		}
	}
	function replaceSID0onEventN(e) {
		//replace sid0 with OID sid value, for Netscape browsers
		var tempText = "";
		var eHref = (e.target.tagName == "A") ? e.target : e.target.parentNode;
		if (eHref.parentNode && eHref.tagName != "A") eHref = eHref.parentNode;
		if (eHref.href) {
			if (eHref.href.indexOf("sid0") != -1) {
				tempText = eHref.innerText;
				eHref.href = eHref.href.replace("sid0", "sid");
				if (tempText) eHref.innerText = tempText;
				return true;
			}
		}
	}
	
	/* ClickThru Redirect Function */
	function clickThruValidate(form) {
		var clickPat=/[^a-zA-Z0-9]/;
		
		var clickResult=form.clickThruID.value.search(clickPat);

		if (clickResult != -1) {
			form.action = '/clickThruError';
		} else {
			form.action = '/clickThru/0,,'+'clk'+form.clickThruID.value+',00.html';
			form.submit();
		}
	}
	
	
	/* Read cookie and update CLT ad height */
	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;
	}
	
	/*
	 *          This function is called by the onload trigger in the CLT's <iframe>
	 *          It will check the cookie for a height value placed in it by some JS code on the StoryServer side
	 *          and will use that value to rsize the <iframe> element (this removes the occasional extra whitespace)
	 */
	 
	function resizeCLT(adHandle) {
		ugcCltHeight = readCookie('ugcCltHeight');
		
		var dbg = getURLParamValue('cltDbg')
		
		if(dbg==1) {
		var doc=adHandle.contentWindow.document;
		alert('Justin: '+ugcCltHeight+'\nscrollHeight: '+doc.body.scrollHeight+'\ndocument.height: '+doc.height);
		}
		
		//if(adHandle != null && ugcCltHeight != null) adHandle.height = ugcCltHeight;
		if(adHandle != null && (ugcCltHeight != null && ugcCltHeight.length > 0)) adHandle.height = ugcCltHeight;
	}	
