
	function getCookieValue(cookieName) {
		var cookies = document.cookie;
		if (typeof cookieName == 'undefined' || !cookieName)
			cookieName = "ADT";
		cookieName += "=";
		var pos = cookies.indexOf(cookieName);
/*		alert("cookies = "+cookies+" \ncookieName = "+cookieName+"\npos = "+pos);*/
		if ( pos != -1 ) {
			var start = pos + 4;
			var end = cookies.indexOf(";", start);
			if (end == -1) { end = cookies.length; }
			var value = cookies.substring(start, end);
			value = unescape(value);
			if (value.indexOf(".."))
				value = value.substring(0, value.length-2);
			return value;
		}
	}

	// account: semicolon delimited list of HBX accounts.
	// pageName: semicolon delimited list of page name as referenced in HBX reports.  If multiple page names are used, list them in the order in which your accounts are listed.
	// category: semicolon delimited list of content groups.  The grouping should always start with a forward-slash and never end with one.
	// sessionID: the Adteractive session id.  If this is omitted, the default session ID taken from the ADT cookie will be used.
	// override: if this is true, then don't import the HBX script and let the page override additional parameters.
	function trackPage(account, pageName, category, sessionID, override){
		_writeHBXVars();
		if (typeof account != 'undefined' && account) {
			hbx.acct = hbxStrip(account);
		}
		if (typeof pageName != 'undefined' && pageName) {
			hbx.pn = hbxStrip(pageName);
		}
		if (typeof category != 'undefined' && category) {
			hbx.mlc = hbxStrip(category);
		}
		if (typeof sessionID != 'undefined' && sessionID) {
			hbx.ci = sessionID;
		}
		else if (getCookieValue("ADT") != null) {
			hbx.ci = getCookieValue("ADT");
		} else {
			hbx.ci = "";
		}
/*		alert("account: "+hbx.acct+"\npageName: "+hbx.pn+"\ncategory: "+hbx.mlc+"\nsessionID: "+hbx.ci+"\noverride: "+override);*/
		if (typeof override == 'undefined' || !override) {
			_writeHBXScript();
		}
	}

	function _writeHBXScript() {
		document.write('<script language="javascript1.1" defer src="http://cb.adprofile.net/global/js/hbx.js"><\/script>');
	}

	function _writeHBXVars() {
		document.write('<script language="javascript1.1">');
		document.write('var _hbEC=0,_hbE=new Array;function _hbEvent(a,b){b=_hbE[_hbEC++]=new Object();b._N=a;b._C=0;return b;}');
		document.write('var hbx=_hbEvent("pv");hbx.vpc="HBX0100u";hbx.gn="ehg-adteractive.hitbox.com";');

//BEGIN EDITABLE SECTION
//CONFIGURATION VARIABLES
		document.write('hbx.acct="";//ACCOUNT NUMBER(S)');
		document.write('hbx.pn="PUT+PAGE+NAME+HERE";');//PAGE NAME(S)
		document.write('hbx.mlc="CONTENT+CATEGORY";');//MULTI-LEVEL CONTENT CATEGORY
		document.write('hbx.pndef="title";');//DEFAULT PAGE NAME
		document.write('hbx.ctdef="full";');//DEFAULT CONTENT CATEGORY

//OPTIONAL PAGE VARIABLES
//ACTION SETTINGS
		document.write('hbx.fv="";');//FORM VALIDATION MINIMUM ELEMENTS OR SUBMIT FUNCTION NAME
		document.write('hbx.lt="none";');//LINK TRACKING
		document.write('hbx.dlf="n";');//DOWNLOAD FILTER
		document.write('hbx.dft="n";');//DOWNLOAD FILE NAMING
		document.write('hbx.elf="n";');//EXIT LINK FILTER

//SEGMENTS AND FUNNELS
		document.write('hbx.seg="";');//VISITOR SEGMENTATION
		document.write('hbx.fnl="";');//FUNNELS

//CAMPAIGNS
		document.write('hbx.cmp="";');//CAMPAIGN ID
		document.write('hbx.cmpn="";');//CAMPAIGN ID IN QUERY
		document.write('hbx.dcmp="";');//DYNAMIC CAMPAIGN ID
		document.write('hbx.dcmpn="";');//DYNAMIC CAMPAIGN ID IN QUERY
		document.write('hbx.dcmpe="";');//DYNAMIC CAMPAIGN EXPIRATION
		document.write('hbx.dcmpre="";');//DYNAMIC CAMPAIGN RESPONSE EXPIRATION
		document.write('hbx.hra="";');//RESPONSE ATTRIBUTE
		document.write('hbx.hqsr="";');//RESPONSE ATTRIBUTE IN REFERRAL QUERY
		document.write('hbx.hqsp="";');//RESPONSE ATTRIBUTE IN QUERY
		document.write('hbx.hlt="";');//LEAD TRACKING
		document.write('hbx.hla="";');//LEAD ATTRIBUTE
		document.write('hbx.gp="";');//CAMPAIGN GOAL
		document.write('hbx.gpn="";');//CAMPAIGN GOAL IN QUERY
		document.write('hbx.hcn="";');//CONVERSION ATTRIBUTE
		document.write('hbx.hcv="";');//CONVERSION VALUE
		document.write('hbx.cp="null";');//LEGACY CAMPAIGN
		document.write('hbx.cpd="";');//CAMPAIGN DOMAIN

//CUSTOM VARIABLES

		document.write('hbx.ci="";');//CUSTOMER ID
		document.write('hbx.hc1="";');//CUSTOM 1
		document.write('hbx.hc2="";');//CUSTOM 2
		document.write('hbx.hc3="";');//CUSTOM 3
		document.write('hbx.hc4="";');//CUSTOM 4
		document.write('hbx.hrf="";');//CUSTOM REFERRER
		document.write('hbx.pec="";');//ERROR CODES
		document.write('</script>');
	}

	function hbxStrip(a){
		a = a.split("|").join("");
		a = a.split("&").join("");
		a = a.split("'").join("");
		a = a.split("#").join("");
		a = a.split("$").join("");
		a = a.split("%").join("");
		a = a.split("^").join("");
		a = a.split("*").join("");
		a = a.split(":").join("");
		a = a.split("!").join("");
		a = a.split("<").join("");
		a = a.split(">").join("");
		a = a.split("~").join("");
		a = a.split(",").join("");
		a = a.split(" ").join("+");
		return a;
	}

	function hbxStripNames(a) {
		a = a.split(";").join("");
		return hbxStrip(a);
	}

	var incentiveRollupAccount = "DM55061764BV";
	var FGWAccount = ";DM550708J8EN";
	var FGGWAccount = ";DM550708MEAM";
	var SPGAccount = ";DM5507083BME";
	var COGAccount = ";DM550708A7ZE";
	var CROAccount = ";DM550708D2BE";


	function incentiveHbxTracking(incenreg, pageType, identifier, formName, hc1, hc2, hc3, hc4) {
/*
		var hbxAccount = incentiveRollupAccount;
		var hbxSubAccount = "";
		if (incenreg == "FGGW") { hbxSubAccount = FGGWAccount; }
		else if (incenreg == "SPG") { hbxSubAccount = SPGAccount; }
		else if (incenreg == "FGW") { hbxSubAccount = FGWAccount; }
		else if (incenreg == "COG") { hbxSubAccount = COGAccount; }
		else if (incenreg == "CRO") { hbxSubAccount = CROAccount; }
		if ( hbxSubAccount != "") { hbxAccount = hbxAccount+hbxSubAccount; }

		var pageName = incenreg+" "+pageType;
		var contentGroup = "/"+incenreg+"/"+pageType;

		if (typeof identifier != 'undefined' && identifier != null && identifier != "") {
			pageName += " "+identifier;
			contentGroup += "/"+identifier;
		}
		if (typeof formName != 'undefined' && formName != null && formName != "") {
			pageName += " "+formName;
			contentGroup += "/"+formName;
		}

		if ((typeof hc1 == 'undefined' || hc1 == null || hc1 =="")&&
		   (typeof hc2 == 'undefined' || hc2 == null || hc2 =="")&&
		   (typeof hc3 == 'undefined' || hc3 == null || hc3 =="")&&
		   (typeof hc4 == 'undefined' || hc4 == null || hc4 =="")) {
		   	trackPage(hbxAccount, pageName, contentGroup, getCookieValue('FGW'), false);
		} else {
			trackPage(hbxAccount, pageName, contentGroup, getCookieValue('FGW'), true);
			if (typeof hc1 != 'undefined' && hc1) {
				hbx.hc1 = hc1;
			}
			if (typeof hc2 != 'undefined' && hc2) {
				hbx.hc2 = hc2;
			}
			if (typeof hc3 != 'undefined' && hc3) {
				hbx.hc3 = hc3;
			}
			if (typeof hc4 != 'undefined' && hc4) {
				hbx.hc4 = hc4;
			}
			_writeHBXScript();
		}
*/
		return;
	}

	function educationHbxTracking(account, pageType, identifier, hc1, hc2, hc3, hc4)
	{
		var hbxAccount = "DM550617O2AD";
		if(typeof account != "undefined" && account != null && account != hbxAccount) {
			hbxAccount += ";" + account;
		}

		var pageName = account + " " + pageType;
		var contentGroup = "/" + account + pageType;

		if(typeof identifier != 'undefined' && identifier != null && identifier != "") {
			pageName += " " + identifier;
			contentGroup += "/" + identifier;
		}

		if((typeof hc1 == 'undefined' || hc1 == null || hc1 == "") &&
		   (typeof hc2 == 'undefined' || hc2 == null || hc2 == "") &&
		   (typeof hc3 == 'undefined' || hc3 == null || hc3 == "") &&
		   (typeof hc4 == 'undefined' || hc4 == null || hc4 == ""))
		{
		   	trackPage(hbxAccount, pageName, contentGroup, getCookieValue(), false);
		}
		else
		{
			trackPage(hbxAccount, pageName, contentGroup, getCookieValue(), true);
			if(typeof hc1 != 'undefined' && hc1) {
				hbx.hc1 = hc1;
			}
			if(typeof hc2 != 'undefined' && hc2) {
				hbx.hc2 = hc2;
			}
			if(typeof hc3 != 'undefined' && hc3) {
				hbx.hc3 = hc3;
			}
			if(typeof hc4 != 'undefined' && hc4) {
				hbx.hc4 = hc4;
			}
			_writeHBXScript();
//			alert("whatever!" + hc1);
		}
	}
