//LSF Interactive Javascript Tracking
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {}, i   = 14;
	while (i--) uri[o.key[i]] = m[i] || "";
	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});
	return uri;
};
parseUri.options = { strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   { name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};

/********************************************************************************************/
//Updated 2012-01-05 v 2.1.1
(function (w,doc) { // window, document, 'guarnteed undefined'
	w.lsfver = "0.0.7";
	var d_dom = doc.domain, d_loc = doc.location,
		lsf_url="ec2-t1.lsfinteractive.com";
	var mergeObj = function (ob1, ob2){var i=0,z;for(z in ob2){if (ob2.hasOwnProperty(z)) {ob1[z] = ob2[z];}}return ob2;};

	var umtLog = function umtLog(pageId){
		if (!(this instanceof umtLog)) {
			return new umtLog();
		}

		mergeObj(this, {
			useSelectedPageNames: false,
			gDt: new Date(),
			gtrimSubdomain: 0,
			path: "/",
			gVidExpDate: "Sat, 01 Jan 2022 00:00:00 GMT",
			gMAINpixel: [(d_loc.protocol=='https:'?"https:":"http:"),"//",lsf_url,"/umt.gif"].join(""),
			cmpExpInSecond: "15768000",
			session_timeout: "1800",
			gSrc: "umt_pub",
			gVen: "umt_ven",
			gCmp: "umt_cmp",
			gMdm: "umt_mdm",
			gTrm: "umt_trm",
			gCtnt: "umt_ctnt",
			gAdgp: "umt_adgp",
			gAdcp: "umt_adcp",
			gProd: "umt_prod",
			gId: "umt_id",
			gExt: "umt_extra",
			gTid: "umt_tid",
			doTransfer: false,
			myDn: "",
			itemInfo: []
		});
	};
	//window['umtLog']=umtLog;

	umtLog.prototype.init = function init(){
		var logString, delimiter, gUrlTid, myDn_array, tmpmdm, noover, umt_id = 0;

		this.ums_overwrite=((typeof this.ums_overwrite===undefined)?'':this.ums_overwrite);
		
		if (typeof this.myDn !== "undefined") {
			if (this.myDn.indexOf("/") != -1) {
				myDn_array = this.myDn.split("/");
				this.myDn = myDn_array[0];
			}
			if ((d_loc.host).indexOf(this.myDn) == -1) {
				this.myDn = "";
			}
		}
		if (d_loc.search.indexOf("noover=") > 0) {
			noover = this.gGetpara(d_loc.search, "noover=", "&");
		}
		if (d_loc.search) {
			this.gSrc = ((d_loc.search).indexOf('umt_pub') > 0) ? "umt_pub" : "utm_source";
			this.gMdm = ((d_loc.search).indexOf('umt_mdm') > 0) ? "umt_mdm" : "utm_medium";
			this.gTid = "umt_tid";
			this.gSource = this.gGetpara(d_loc.search, this.gSrc + "=", "&");
			tmpmdm = this.gGetpara(d_loc.search, this.gMdm + "=", "&");
			this.gMedium = (tmpmdm) ? tmpmdm : "";
			gUrlTid = this.gGetpara(d_loc.search, this.gTid + "=", "&");
			this.cmpValue_from_URL = d_loc.search;
			if (this.gSource == "yahoo-ssp") {
				this.keywordFromRef = this._umsRefKeyword(doc.referrer, "p");
				this.gMediumPos = (d_loc.search).indexOf(this.gMdm);
				this.cmpValue_from_URL = [this.cmpValue_from_URL.substring(0, this.gMediumPos), 
					"umt_trm=", this.keywordFromRef, "&", 
					this.cmpValue_from_URL.substring(this.gMediumPos)].join("");
			}

			var ums_mdum = this.gMedium;
			var ums_src = this.gSource;
			var umt_tid = gUrlTid;

			if (d_loc.search.indexOf("utm_id=") > 0) {
				this.umsid = this.gGetpara(d_loc.search, "utm_id=", "&");
				if (this.umsid == "1") {
					this.cmpValue_from_URL = [this.cmpValue_from_URL, "&", this.gSrc, 
								  "=", this._umsRefSource(doc.referrer, ums_src, 
								  ums_mdum)].join("");
				}
			}
			if (this.cmpValue_from_URL.indexOf(this.gSrc) > 0) {
				this.gSource = "1";
			}
			if (this.cmpValue_from_URL.indexOf(this.gMdm) > 0) {
				this.gMedium = "1";
			}
		}
		this.gTs = Math.round(this.gDt.getTime() / 1000);
		this.g3Ts = this.gThreetimestamps();
		this.gUsr = Math.round(Math.random() * 6106646805);
		this.gHD = this.gHashdomain(d_dom);
		this.gSTO = new Date(this.gDt.getTime() + (this.session_timeout * 1000));
		var currenttime = new Date(this.gDt.getTime());
		this.gCmpExpDate = new Date(this.gDt.getTime() + (this.cmpExpInSecond * 1000));
		var gRfdn = "" + this.getDomainName(doc.referrer);
		var gDL = doc.location.hostname;
		var gDLdn = gDL;
		this.gCDn = ((gDL.match(/^(([1-9][0-9]{0,2})|0)\.(([1-9][0-9]{0,2})|0)\.(([1-9][0-9]{0,2})|0)\.(([1-9][0-9]{0,2})|0)$/)) ? gDL : "."+gDL);
// then append '.' at the front of domain
// if it is not an IP
		var gIntRf;
		if (this.myDn && this.myDn != "" && this.myDn.indexOf(".")!=0) {
			this.gCDn = "." + this.myDn;
		}
		if (gDLdn == gRfdn || gRfdn == 'undefined.' || this.noover == "1") {
			if (doc.referrer != doc.location) {
				var intupRf = this.gGetpara(doc.referrer, ".", " ");
				var upRf = this.gGetpara(intupRf, "/", "&");
				gIntRf = upRf;
			}
		} else {
			this.gRf = "" + doc.referrer;
		}
		var gCk = (this.gGetcookie("__GTSv2"));

		if ((!this.gRf || this.gRf == "") && (!gCk || gCk == "")) {
			this.newCookieEmpty("direct");

		} else if ((!this.gRf || this.gRf == "") && (gCk && gCk != "")) {
			if ((this.gSource && this.gSource != "") || (gUrlTid && gUrlTid != "")) {
				this.updateCookie();
			} else {
				this.refreshCookieTimeStamp();
				this.refresh_session();
			}


		} else if ((this.gRf && this.gRf != "") && (!gCk || gCk == "")) {
			if ((this.gSource && this.gSource != "") || (gUrlTid && gUrlTid != "")) {
				this.newCookie();
			} else {
				if (this.myDn && this.myDn != "") {
					if (this.gRf.indexOf(this.myDn) > 0) {
						this.refreshCookieTimeStamp();
						this.refresh_session();
					} else {
						this.newCookieEmpty(this.gRf);
					}
				} else {
					this.newCookieEmpty(this.gRf);
				}
			}
		} else if ((this.gRf && this.gRf != "") && (gCk && gCk != "")) {
			if (this.myDn && this.myDn != "") {
				if (this.gRf.indexOf(this.myDn) > 0) {
					this.refreshCookieTimeStamp();
					this.refresh_session();
				} else {
					this.updateCookie(this.gRf);
				}
			} else {
				this.updateCookie(this.gRf);
			}

		}
		if (this.doTransfer && ((d_loc.search.indexOf("umtGTS=") > 0) || (d_loc.search.indexOf("__utmz=") > 0))) {
			if (d_loc.search.indexOf("umtGTS=") > 0) {
				doc.cookie = ["__GTSv2=", unescape(this.gGetpara(d_loc.search, 
					"umtGTS=", " ")), "; expires=", this.gCmpExpDate.toGMTString(), 
					"; path=/; domain=", this.gCDn, "; "].join("");
			} else if (d_loc.search.indexOf("__utmz") > 0) {
				utmA = this.gGetpara(d_loc.search, "__utma=", "&");
				uid = (utmA.split("."))[0];
				vtid = utmA.substring(0, utmA.lastIndexOf("."));
				utmzArr = this.gGetpara(d_loc.search, "__utmz=", " ").split(".");
				appendChar = ".";
				for (ind = 0; ind < utmzArr.length; ind++) {
					if (!this.IsNumeric(utmzArr[ind])) {
						if ((ind + 1) == utmzArr.length) {
							appendChar = "";
						}
						mytxt = mytxt + utmzArr[ind] + appendChar;
					}
				}
				cmpInfo = mytxt;
				m0 = "campaignGTS=?" + cmpInfo;
				m1 = m0.replace(/utmcsr/, "umt_pub");
				m2 = m1.replace(/utmccn/, "umt_cmp");
				m3 = m2.replace(/utmcmd/, "umt_mdm");
				m4 = m3.replace(/utmctr/, "umt_trm");
				m5 = m4.replace(/utmcct/, "umt_ctnt");
				umtString = m5.replace(/utmextra/, "umt_extra");
				umtString = umtString.replace(/\|/g, "&");
				cookieGTS = vtid + "." + umtString;
				doc.cookie = ["__GTSv2=", cookieGTS, "; expires=", this.gCmpExpDate.toGMTString(), 
					"; path=/; domain=", this.gCDn, "; "].join("");
			}
		}
		var _umt_r, _umt_hn = d_dom, _umt_p, _umt_ir, pageID;
		if (typeof pageID == 'undefined') {
			pageID = "";
		}
		if (this.gRf && this.gRf != "") {
			_umt_r = this.gRf;
		} else if (!this.gRf || this.gRf == "") {
			_umt_r = "none";
		}
		if (gIntRf && gIntRf != "") {
			_umt_ir = gIntRf;
			doc.cookie = ["__GTSv2UPath=", gIntRf, "; expires=", this.gSTO, "; path=", 
				this.path, "; domain=", this.gCDn, "; "].join("");
		} else if (!gIntRf || gIntRf == "") {
			_umt_ir = "none";
			doc.cookie = ["__GTSv2UPath=", "none", "; expires=", this.gSTO, "; path=", this.path, "; domain=", this.gCDn, "; "].join("");
		}
		if (pageID && pageID != "") {
			_umt_p = this.getPageID(pageID);
		} else {
			_umt_p = this.getPageID(this.ums_overwrite);
		}
		doc.cookie = ["__CONFIRMCOOKIE=confirm.cookie; expires=",this.gCmpExpDate.toGMTString(),"; path=/; domain=",this.gCDn,";"].join("");
		var con_c = this.gGetcookie("__CONFIRMCOOKIE"),
			lsfver = w.lsfver,
			logArr = ["_umt_hn", "_umt_r", "_umt_ir", "_umt_p", "_umt_cc","lsfver", "con_c"],
			_umt_cc = this.gGetcookie("__GTSv2");
		if (!_umt_cc || _umt_cc == "") {
			_umt_cc = "0.0.0.0.0.campaignGTS=direct";
		}
		if (typeof _umt_orderinfo != 'undefined') {
			pushed = logArr.push("_umt_orderinfo");
		}
		if ((typeof _umt_ecom_info != 'undefined') && (_umt_ecom_info != "")) {
			for (m = 0; m < _umt_ecom_info.length; m++) {
				logString = "";
				delimiter = "&";
				for (var i = 0; i < logArr.length; i++) {
					if (i == ((logArr.length) - 1)) {
						delimiter = "";
					}
					if ((typeof logArr[i] != 'undefined') && (logArr[i].length > 0)) {
						logString = [logString, logArr[i], "=", eval(logArr[i]), delimiter].join("");
					}
				}
				if (m == 0) {
					logString = "_umt_orderinfo=" + _umt_ecom_info[m] + logString;
				} else {
					logString = "_umt_iteminfo=" + _umt_ecom_info[m] + logString;
				}
				this.createImage(this.gMAINpixel, this.umt_acct, this.gUsr, logString);
			}
		} else if (this.orderInfo && this.orderInfo != "") {
			logString = "";
			delimiter = "&";
			for (i = 0; i < logArr.length; i++) {
				if (i == (logArr.length) - 1) {
					delimiter = "";
				}
				if ((typeof logArr[i] != 'undefined') && (logArr[i].length > 0)) {
					logString = [logString, logArr[i], "=", eval(logArr[i]), delimiter].join("");
				}
			}
			logString = "_umt_orderinfo=" + this.orderInfo + logString;
			this.createImage(this.gMAINpixel, this.umt_acct, this.gUsr, logString);
			if (typeof this.itemInfo != "undefined") {
				for (m = 0; m < this.itemInfo.length; m++) {
					logString = "";
					delimiter = "&";
					for (i = 0; i < logArr.length; i++) {
						if (i == (logArr.length) - 1) {
							delimiter = "";
						}
						if ((typeof logArr[i] != 'undefined') && (logArr[i].length > 0)) {
							logString = [logString, logArr[i], "=", eval(logArr[i]), 
								delimiter].join("");
						}
					}
					logString = "_umt_iteminfo=" + this.itemInfo[m] + logString;
					this.createImage(this.gMAINpixel, this.umt_acct, this.gUsr, logString);
				}
			}
		} else if (this.regInfo && this.regInfo != "") {
			logString = "";
			delimiter = "&";
			for (i = 0; i < logArr.length; i++) {
				if (i == (logArr.length) - 1) {
					delimiter = "";
				}
				if ((typeof logArr[i] != 'undefined') && (logArr[i].length > 0)) {
					logString = [logString, logArr[i], "=", eval(logArr[i]), delimiter].join("");
				}
			}
			logString = "_umt_reginfo=" + this.regInfo + logString;
			this.createImage(this.gMAINpixel, this.umt_acct, this.gUsr, logString);
		} else {
			logString = ""; delimiter = "&";
			var pageGoal = eval("_umt_p"),
			pageGoalLowerCase = pageGoal.toLowerCase();
			for (i = 0; i < logArr.length; i++) {
				if (i == (logArr.length) - 1) {
					delimiter = "";
				}
				if ((typeof logArr[i] != 'undefined') && (logArr[i].length > 0)) {
					logString = [logString, logArr[i], "=", eval(logArr[i]), delimiter].join("");
				}
			}
			if (this.useSelectedPageNames) {
				if ((typeof __umtSelectedPageNames != "undefined") && (__umtSelectedPageNames != "")) {
					for (i = 0; i < __umtSelectedPageNames.length; i++) {
						if (pageGoalLowerCase.indexOf(__umtSelectedPageNames[i]) > -1) {
							this.createImage(this.gMAINpixel, this.umt_acct, this.gUsr, logString);
						}
					}
				}
				if ((pageGoalLowerCase.indexOf("umt_mdm") > -1) || (pageGoalLowerCase.indexOf("utm_medium") > -1)) {
					this.createImage(this.gMAINpixel, this.umt_acct, this.gUsr, logString);
				}
			} else {
				this.createImage(this.gMAINpixel, this.umt_acct, this.gUsr, logString);
			}
		}

	} // end umtLog

	umtLog.prototype.newCookie = function () {
		if (!this.gGetcookie("__GTSv2") || this.gGetcookie("__GTSv2") === "") {
			if (this.gGetcookie("__GTSv2vtid") && this.gGetcookie("__GTSv2vtid") != "") {
				gOv = this.gOldvisitor();
				this.gUsr = gOv;
			}
			var gVid_TS = [this.gHD, ".", this.gUsr, ".", this.g3Ts].join(""),
				l_cookie = ["__GTSv2sid0="+this.gHD, "path=/", "domain="+this.gCDn, 
					"__GTSv2sid1="+this.gHD, "expires="+this.gSTO, "path=/", "domain="+this.gCDn, 
					"__GTSv2vtid="+gVid_TS, "expires="+this.gVidExpDate, "path="+this.path, 
					"domain="+this.gCDn, "__GTSv2="+gVid_TS+".campaignGTS="+this.cmpValue_from_URL, 
					"expires="+this.gCmpExpDate.toGMTString(), "path="+this.path, "domain="+this.gCDn+"; "].join("; ");
			doc.cookie = l_cookie;
		}
		return this.gGetcookie("__GTSv2");
	};

	umtLog.prototype.newCookieEmpty = function (gNewRef) {
		if (this.gGetcookie("__GTSv2vtid") && this.gGetcookie("__GTSv2vtid") != "") {
			gOv = this.gOldvisitor();
			this.gUsr = gOv;
		}
		l_cookie = ["__GTSv2sid0="+this.gHD, "path=/", "domain="+this.gCDn, "__GTSv2sid1="+this.gHD, 
			"expires="+this.gSTO, "path=/", "domain="+this.gCDn, 
			["__GTSv2vtid=",this.gHD,".",this.gUsr,".",this.g3Ts].join(""), 
			"expires="+this.gVidExpDate, "path="+this.path, "domain="+this.gCDn+"; "].join("; ");
		if (this.gSource && this.gSource != "") {
			this.newCookie();
		} else {
			doc.cookie = ["__GTSv2=", this.gHD, ".", this.gUsr, ".", this.g3Ts, ".campaignGTS=", gNewRef, "; expires=", this.gCmpExpDate.toGMTString(), "; path=", this.path, "; domain=", this.gCDn, "; "].join("");
		}
	};

	umtLog.prototype.updateCookie = function (gRef) {
		var cookieArr = (this.gGetcookie("__GTSv2")).split("campaignGTS="),
			part1 = cookieArr[0],
			part2 = cookieArr[1],
			curHD = (part1.split("."))[0],
			curUsr = (part1.split("."))[1],
			newTs = this.gThreetimestamps();
		if ((this.gSource && this.gMedium) && (this.gSource != "-" && this.gMedium != "-") && (this.gSource != "" && this.gMedium != "")) {
			newCookieValue = [curHD, ".", curUsr, ".", newTs, ".campaignGTS=", this.cmpValue_from_URL].join("");
		} else if (gRef && gRef != "") {
			current_cookied_cmp = "campaignGTS=" + gRef;
			newCookieValue = [curHD, ".", curUsr, ".", newTs, ".", current_cookied_cmp].join("");
		} else {
			current_cookied_cmp = "campaignGTS=" + part2;
			newCookieValue = [curHD, ".", curUsr, ".", newTs, ".", current_cookied_cmp].join("");
		}
		doc.cookie = ["__GTSv2="+newCookieValue, "expires="+this.gCmpExpDate.toGMTString(), "path="+this.path, 
			"domain="+this.gCDn, ["__GTSv2vtid=",curHD,".",curUsr,".",newTs].join(""), 
			"expires="+this.gVidExpDate, "path="+this.path, "domain="+this.gCDn+"; "].join("; ");
		this.refresh_session();
	};

	umtLog.prototype.refreshCookieTimeStamp = function () {
		var cookieArr = (this.gGetcookie("__GTSv2")).split("campaignGTS="),
			part1 = cookieArr[0], part2 = cookieArr[1],
			curHD = (part1.split("."))[0], curUsr = (part1.split("."))[1],
			curCmp = "campaignGTS=" + part2, newTs = this.gThreetimestamps(),
			newCookieValue = [curHD, ".", curUsr, ".", newTs, ".", curCmp].join("");
		doc.cookie = ["__GTSv2="+newCookieValue, "expires="+this.gCmpExpDate.toGMTString(), "path="+this.path, 
			"domain="+this.gCDn, ["__GTSv2vtid="+this.gHD+"."+this.gUsr+"."+this.g3Ts].join(""), 
			"expires="+this.gVidExpDate, "path="+this.path, "domain="+this.gCDn+"; "].join("; ");
	};

	umtLog.prototype.refresh_session = function () {
		var curHD = ((this.gGetcookie("__GTSv2")).split("."))[0],
			gSTO = new Date(this.gDt.getTime() + (this.session_timeout * 1000));
		doc.cookie = ["__GTSv2sid0="+curHD, "path=/", "domain="+this.gCDn, "__GTSv2sid1="+curHD, 
			"expires="+gSTO, "path=/", "domain="+this.gCDn+"; "].join("; ");
	};

	umtLog.prototype.gThreetimestamps = function () {
		var nts = 0, tmp,
			gCookie = this.gGetcookie("__GTSv2"),
			gVisitor = this.gGetcookie("__GTSv2vtid"),
			gSess0 = this.gGetcookie("__GTSv2sid0"),
			gSess1 = this.gGetcookie("__GTSv2sid1");
		if (!gCookie) {
			if (gVisitor) {
				tmp = gVisitor.split(".");
				return [tmp[2], ".", tmp[4], ".", this.gTs].join("");
			} else {
				return [this.gTs, ".", this.gTs, ".", this.gTs].join("");
			}
		} else {
			if (gSess0 && gSess1) {
				tmp = gCookie.split(".");
				return [tmp[2], ".", tmp[3], ".", tmp[4]].join("");
			} else {
				tmp = gCookie.split(".");
				return [tmp[2], ".", tmp[4], ".", this.gTs].join("");
			}
		}
	};

	umtLog.prototype.gOldvisitor = function () {
		if (ttt = this.gGetcookie("__GTSv2vtid")) {
			return (ttt.split("."))[1];
		} else {
			return "NULL";
		}
	};

	/* get paramater:
		str (query string to search through),
		node (the keyword + separating delimeter for each pair, ie: 'keyword='),
		del (delimeter between each pair, ie the endpoint)
	 */
	umtLog.prototype.gGetpara = function (str, node, del) {
		if (!str || str==="" || !node || node==="" || !del || del==="") return "";
		var x, y, z, c = "";
		x = str.indexOf(node);
		z = node.indexOf("=") + 1;
		if (x > -1) {
			y = str.indexOf(del, x);
			if (y < 0) {
				y = str.length;
			}
			c = str.substring((x + z), y);
		}
		return c;
	};

	umtLog.prototype.gHashdomain = function() {
		var domain = doc.domain;
		if (domain.substring(0, 4) == "www.") {
			var d = domain.substring(4, domain.length);
		}

		return this.gHash(d);
	};

	umtLog.prototype.gHash = function (d) {
		if (!d || d == "") return 1;
		var h = 0,
			g = 0;
		for (var i = doc.length - 1; i >= 0; i--) {
			var c = parseInt(doc.charCodeAt(i));
			h = ((h << 6) & 0xfffffff) + c + (c << 14);
			if ((g = h & 0xfe00000) != 0) h = (h ^ (g >> 21));
		}
		return h;
	};

	umtLog.prototype.gGetcookie = function (cookie_name) {
		var results = doc.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
		if (results && results != "") { 
			return (unescape(results[2]));
		} else {
			return null;
		}
	};

//	umtLog.prototype.gDelcookie = function (cookie_name) {
//		var results = doc.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
//		if (results && results != "") { 
//			
//	};
//
//	umtLog.prototype.gTestcookies = function (cookie_name) {
//	};
//
	umtLog.prototype.umtTransfer = function (l) {
		var thisCookie = "umtGTS=" + escape(this.gGetcookie("__GTSv2"));
		if (thisCookie) {
			if (l.indexOf("?") <= -1) {
				return (l + "?" + thisCookie);
			} else {
				return (l + "&" + thisCookie);
			}
		} else {
			return (l);
		}
	};

	umtLog.prototype.umtLinkPost = function (m) {
		thisAction = m.action;
		m.action = this.umtTransfer(thisAction);
	};

	umtLog.prototype.getPageID = function (pID) {
		if (!pID || pID == "") {
			var returnPID = d_loc.pathname + d_loc.search;
			if (returnPID.indexOf("krypto") > -1) {
				returnPID = returnPID.substring(0, returnPID.indexOf("krypto="));
			}
			return returnPID;
		} else {
			return pID;
		}
	};

	umtLog.prototype.umtPhone = function (defaultnumber) {
		var campaignphonenumber = "", noncampaign = "-", phone = "-", keyvaluepairs, extradimkey, extradimvalue,
			extradimpair,
			myutmz, gQueryString = d_loc.search, documentCookie = this.gGetcookie("__GTSv2"), phonearray = [];
		if (documentCookie && documentCookie != "") {
			myutmz = unescape(this.gGetcookie("__GTSv2"));
			keyvaluepairs = [];
			for (var i = 0; i < myutmz.split("&").length; i++) {
				keyvaluepairs = myutmz.split("&")[i];
				if (keyvaluepairs.split("=").length > 0) {
					keyname = keyvaluepairs.split("=")[0]
					keyvalue = keyvaluepairs.split("=")[1];
					if ((keyname == "utm_extra") || (keyname == "umt_extra")) {
						if (keyvalue != "-") {
							if (keyvalue.indexOf("%3D") > 0) {
								campaignphonenumber = keyvalue.split("%3D")[1];
							} else if (keyvalue.indexOf("%3d") > 0) {
								campaignphonenumber = keyvalue.split("%3d")[1];
							} else if (keyvalue.indexOf("//") > 0) {
								for (var count = 0; count < keyvalue.split("//").length; count++) {
									extradimpair = keyvalue.split("//")[count];
									if (extradimpair.split("/").length > 0) {
										extradimkey = extradimpair.split("/")[0];
										extradimvalue = extradimpair.split("/")[1];
										if ((extradimkey.indexOf("phone") > -1) || (extradimkey.indexOf("Phone") > -1) || (extradimkey.indexOf("PHONE") > -1)) {
											if ((extradimkey == "phone") || (extradimkey == "Phone") || (extradimkey == "PHONE")) {
												campaignphonenumber = extradimvalue;
											}
											if ((extradimkey == "phone1") || (extradimkey == "Phone1") || (extradimkey == "PHONE1")) {
												phonearray[0] = extradimvalue;
											}
											if ((extradimkey == "phone2") || (extradimkey == "Phone2") || (extradimkey == "PHONE2")) {
												phonearray[1] = extradimvalue;
											}
											if ((extradimkey == "phone3") || (extradimkey == "Phone3") || (extradimkey == "PHONE3")) {
												phonearray[2] = extradimvalue;
											}
											if ((extradimkey == "phone4") || (extradimkey == "Phone4") || (extradimkey == "PHONE4")) {
												phonearray[3] = extradimvalue;
											}
											if ((extradimkey == "phone5") || (extradimkey == "Phone5") || (extradimkey == "PHONE5")) {
												phonearray[4] = extradimvalue;
											}
										}
									}
								}
							} else {
								if (keyvalue.split("/").length > 0) {
									extradimkey = keyvalue.split("/")[0];
									extradimvalue = keyvalue.split("/")[1];
									if ((extradimkey.indexOf("phone") > -1) || (extradimkey.indexOf("Phone") > -1) || (extradimkey.indexOf("PHONE") > -1)) {
										if ((extradimkey == "phone") || (extradimkey == "Phone") || (extradimkey == "PHONE")) {
											campaignphonenumber = extradimvalue;
										}
										if ((extradimkey == "phone1") || (extradimkey == "Phone1") || (extradimkey == "PHONE1")) {
											phonearray[0] = extradimvalue;
										}
										if ((extradimkey == "phone2") || (extradimkey == "Phone2") || (extradimkey == "PHONE2")) {
											phonearray[1] = extradimvalue;
										}
										if ((extradimkey == "phone3") || (extradimkey == "Phone3") || (extradimkey == "PHONE3")) {
											phonearray[2] = extradimvalue;
										}
										if ((extradimkey == "phone4") || (extradimkey == "Phone4") || (extradimkey == "PHONE4")) {
											phonearray[3] = extradimvalue;
										}
										if ((extradimkey == "phone5") || (extradimkey == "Phone5") || (extradimkey == "PHONE5")) {
											phonearray[4] = extradimvalue;
										}
									}
								}
							}
						}
					}
				}
			}
			if (!((myutmz.search("utm_medium") > 0) || (myutmz.search("umt_mdm") > 0))) {
				phone = defaultnumber;
			} else if (campaignphonenumber.length > 0) {
				phone = campaignphonenumber;
			} else {
				phone = defaultnumber;
			}
		} else if (gQueryString && gQueryString != "") {
			myutmz = unescape(gQueryString);
			keyvaluepairs = [];
			for (var i = 0; i < myutmz.split("&").length; i++) {
				keyvaluepairs = myutmz.split("&")[i];
				if (keyvaluepairs.split("=").length > 0) {
					keyname = keyvaluepairs.split("=")[0]
					keyvalue = keyvaluepairs.split("=")[1];
					if ((keyname == "utm_extra") || (keyname == "umt_extra")) {
						if (keyvalue != "-") {
							if (keyvalue.indexOf("%3D") > 0) {
								campaignphonenumber = keyvalue.split("%3D")[1];
							} else if (keyvalue.indexOf("%3d") > 0) {
								campaignphonenumber = keyvalue.split("%3d")[1];
							} else if (keyvalue.indexOf("//") > 0) {
								for (var count = 0; count < keyvalue.split("//").length; count++) {
									extradimpair = keyvalue.split("//")[count];
									if (extradimpair.split("/").length > 0) {
										extradimkey = extradimpair.split("/")[0];
										extradimvalue = extradimpair.split("/")[1];
										if ((extradimkey.indexOf("phone") > -1) || (extradimkey.indexOf("Phone") > -1) || (extradimkey.indexOf("PHONE") > -1)) {
											if ((extradimkey == "phone") || (extradimkey == "Phone") || (extradimkey == "PHONE")) {
												campaignphonenumber = extradimvalue;
											}
											if ((extradimkey == "phone1") || (extradimkey == "Phone1") || (extradimkey == "PHONE1")) {
												phonearray[0] = extradimvalue;
											}
											if ((extradimkey == "phone2") || (extradimkey == "Phone2") || (extradimkey == "PHONE2")) {
												phonearray[1] = extradimvalue;
											}
											if ((extradimkey == "phone3") || (extradimkey == "Phone3") || (extradimkey == "PHONE3")) {
												phonearray[2] = extradimvalue;
											}
											if ((extradimkey == "phone4") || (extradimkey == "Phone4") || (extradimkey == "PHONE4")) {
												phonearray[3] = extradimvalue;
											}
											if ((extradimkey == "phone5") || (extradimkey == "Phone5") || (extradimkey == "PHONE5")) {
												phonearray[4] = extradimvalue;
											}
										}
									}
								}
							} else {
								if (keyvalue.split("/").length > 0) {
									extradimkey = keyvalue.split("/")[0];
									extradimvalue = keyvalue.split("/")[1];
									if ((extradimkey.indexOf("phone") > -1) || (extradimkey.indexOf("Phone") > -1) || (extradimkey.indexOf("PHONE") > -1)) {
										if ((extradimkey == "phone") || (extradimkey == "Phone") || (extradimkey == "PHONE")) {
											campaignphonenumber = extradimvalue;
										}
										if ((extradimkey == "phone1") || (extradimkey == "Phone1") || (extradimkey == "PHONE1")) {
											phonearray[0] = extradimvalue;
										}
										if ((extradimkey == "phone2") || (extradimkey == "Phone2") || (extradimkey == "PHONE2")) {
											phonearray[1] = extradimvalue;
										}
										if ((extradimkey == "phone3") || (extradimkey == "Phone3") || (extradimkey == "PHONE3")) {
											phonearray[2] = extradimvalue;
										}
										if ((extradimkey == "phone4") || (extradimkey == "Phone4") || (extradimkey == "PHONE4")) {
											phonearray[3] = extradimvalue;
										}
										if ((extradimkey == "phone5") || (extradimkey == "Phone5") || (extradimkey == "PHONE5")) {
											phonearray[4] = extradimvalue;
										}
									}
								}
							}
						}
					}
				}
			}
			if (!((myutmz.search("utm_medium") > 0) || (myutmz.search("umt_mdm") > 0))) {
				phone = defaultnumber;
			} else if (campaignphonenumber.length > 0) {
				phone = campaignphonenumber;
			} else {
				phone = defaultnumber;
			}
		} else {
			phone = defaultnumber;
		}
		if (typeof(phone) == "undefined") {
			return phonearray;
		} else {
			return phone;
		}

}

	umtLog.prototype.getDomainName = function (gURL) {
		var gDomainPart, queryPart, dnArr, i;
		if ((i = gURL.indexOf("://")) < 0) {
			gDomainPart = gURL;
		} else {
			gDomainPart = gURL.substring(i + 3, gURL.length);
		}
		if (gDomainPart.indexOf("/") > -1) {
			queryPart = gDomainPart.substring(gDomainPart.indexOf("/"), gDomainPart.length);
			if (queryPart.indexOf("?") > -1) {
				queryPart = queryPart.substring(0, queryPart.indexOf("?"));
			}
			gDomainPart = gDomainPart.substring(0, gDomainPart.indexOf("/"));
		}
		gDomainPart = gDomainPart.toLowerCase();
		if (this.gtrimSubdomain && gtrimSubdomain != "") {
			dnArr = gDomainPart.split(".");
			gDomainPart = dnArr[dnArr.length - 2] + "." + dnArr[dnArr.length - 1];
		}
		if (gDomainPart.indexOf("www.") == 0) {
			gDomainPart = gDomainPart.substring(4, gDomainPart.length);
		}
		return (gDomainPart);
	};

	umtLog.prototype._umsRefSource = function (_ur, ums_src, ums_mdum) {
		if (_ur == "0" || _ur == "" || _ur == "-") {
			if (ums_src != "" && ums_src != "-") {
				return ums_src;
			} else {
				if (ums_mdum != "" && ums_mdum != "-") {
					return "UDRF";
				} else {
					return "";
				}
			}
		}
		var i = 0,
			h, k, n;
		if ((i = _ur.indexOf("://")) < 0) return "";
		h = _ur.substring(i + 3, _ur.length);
		if (h.indexOf("/") > -1) {
			h = h.substring(0, h.indexOf("/"));
		}
		h = h.toLowerCase();
		n = h;
		if ((i = n.indexOf(":")) > -1) n = n.substring(0, i);
		if (h.indexOf("www.") == 0) h = h.substring(4, h.length);
		return h;
	};

	umtLog.prototype._umsRefKeyword = function (_ur, searchKey) {
		if (_ur === "0" || _ur === "" || _ur === "-" || _ur === "none") {
			return "none";
		}
		var getPara = searchKey + "=",
			refKeyword = this.gGetpara(_ur, getPara, "&");
		if (refKeyword && refKeyword != "") {
			return refKeyword;
		} else {
			return "none";
		}
	};

	umtLog.prototype.createOrder = function (orderId, affiliation, orderTotal, tax, shipping, city, state, country) {
		this.orderInfo = [orderId, affiliation, orderTotal, tax, shipping, city, state, country].join("|");
	};

	umtLog.prototype.createProduct = function (orderId, productSKU, productName, category, productPrice, productQuantity) {
		var itemString = [orderId, productSKU, productName, category, productPrice, productQuantity].join("|");
		if (itemString && itemString != "") {
			var itemCount = this.itemInfo.push(itemString);
		}
	};

	umtLog.prototype.createReg = function (regId, regPhrase, city, state, country) {
		this.regInfo = regId + "|" + regPhrase + "|" + city + "|" + state + "|" + country;
		return true;
	};
	

	umtLog.prototype.createImage = function (mainPixel, acct, usrID, log, onload_callback) {
		// var img = new Image(1, 1);  // Using instead document.createElement('img')
		// http://stackoverflow.com/questions/6241716/is-there-a-difference-between-new-image-and-document-createelementimg/6241897#6241897
		var img = document.createElement('img');

		img.onerror = function () {
			this.createImage(mainPixel, acct, usrID, log, onload_callback);
		}
		var mnRequestLine = mainPixel + "?" + escape(["_umt_un=", usrID, "&_umt_acct=", acct, "&", log].join("")),
			mnLineLength = mnRequestLine.length;
		if (mnLineLength > 2048) {
			mnRequestLine = mnRequestLine.substring(0, 2047);
		}
		if (!!onload_callback) {
			img.onload=onload_callback;
		}
		img.src = mnRequestLine;

		if(typeof this.trkimgs != "object") { this.trkimgs=[]; } // for tracking and debugging built images
		this.trkimgs.push(img);

		return true;
	};

	umtLog.prototype.IsNumeric = function (sText) {
		if (typeof sText === "number") { return true; }
		return sText.match(/^\d+$/);
	};

	w.umtLog = (function(args){
		if (typeof args == "undefined") {
			return umtLog();
		} else {
			return (function(ums_overwrite){ 
				var ct=new Date(), ds=[(ct.getMonth()+1).toString(),ct.getDate().toString(),ct.getFullYear().toString()].join("");
				if(!w["__umt"+ds]){ w["__umt"+ds]=new umtLog(); }
				var ul=w["__umt"+ds];
				ul.ums_overwrite=window.ums_overwrite;
				ul.umt_acct=window.umt_acct;
				ul.myDn=window.myDn;
				ul.init();
			})(args);
		}
	});
	// These two functions were previously in the public namespace.  this is necessarry to support the legacy interface
	w.createOrder = (function(){
		var ct=new Date(), ds=[(ct.getMonth()+1).toString(),ct.getDate().toString(),ct.getFullYear().toString()].join("");
		if(!w["__umt"+ds]){ w["__umt"+ds]=new umtLog(); }
		var ul=w["__umt"+ds]; 
		var args = Array.prototype.slice.apply(arguments);
		ul.createOrder.apply(ul, args); // the built-in catchall
	});
	w.createProduct = (function(){
		var ct=new Date(), ds=[(ct.getMonth()+1).toString(),ct.getDate().toString(),ct.getFullYear().toString()].join("");
		if(!w["__umt"+ds]){ w["__umt"+ds]=new umtLog(); }
		var ul=w["__umt"+ds]; 
		var args = Array.prototype.slice.apply(arguments);
		ul.createProduct.apply(ul, args); // the built-in catchall
	});
	w.umtPhone = (function(defaultnumber){
		var ct=new Date(), ds=[(ct.getMonth()+1).toString(),ct.getDate().toString(),ct.getFullYear().toString()].join("");
		if(!w["__umt"+ds]){ throw "umtLog() must be called before umtPhone()"; }
		var ul=w["__umt"+ds]; 
		return ul.umtPhone(defaultnumber);
	});

})(window,window.document);


