var $currentVersion = "1.1.5";
String.prototype._endsWith = function(str) {return (this.match(str + "$") == str);};
String.prototype._startsWith = function(str) {return (this.substring(0,1) == str);};
String.prototype._right = function($c) {return this.substring(this.length - parseInt($c, 10));};
Date.prototype._trkToDateInt = function() {var $di = '';$di += this.getUTCFullYear().toString();$di += ('0' + (this.getUTCMonth() + 1).toString())._right(2);$di += ('0' + this.getUTCDate().toString())._right(2);$di += ('0' + this.getUTCHours().toString())._right(2);$di += ('0' + this.getUTCMinutes().toString())._right(2);$di += ('0' + this.getUTCSeconds().toString())._right(2);return $di;};
Date.prototype._trkDateAdd = function($p, $u) {var $cr = 1;switch ($u) {case 's': $cr = 1000;break;case 'm': $cr = 1000 * 60;break;case 'h': $cr = 1000 * 3600;break;case 'd': $cr = 1000 * 3600 * 24;break;}var $xp = $cr * $p, $nd = new Date(this);$nd.setTime($nd.getTime() + ($xp));return $nd;};var TrkClkGuid = function() {this.ad = '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z'.split(',');this.cookies = [];this.siteId = '2085';this.guid = '';this.setGuid();};
TrkClkGuid.prototype.ckRefresh = function() {var $cks = unescape(document.cookie.replace(/; /g, ';')).split(';');var $cka = [], $i;this.cookies = [];for ($i = 0; $i < $cks.length; $i++) {if ($cks[$i].length !== 0) {$cka = $cks[$i].split('=');this.cookies.push($cka);}}};
TrkClkGuid.prototype.ckGet = function($ck) {this.ckRefresh();var $cv = '', $i;for ($i = 0; $i < this.cookies.length; $i++) {if (this.cookies[$i][0] == $ck) {if (this.cookies[$i][1] === undefined) {return '';}else {return this.cookies[$i][1];}}}return $cv;};
TrkClkGuid.prototype.ckSet = function($ck, $xp, $nv) {var $ov = this.ckGet($ck), $dm = document.domain;$nv = $nv || $ov;var $rck = $ck + '=' + escape($nv);if ($xp.toString().length > 0) {$rck += '; expires=' + $xp.toGMTString();}if ($dm != 'localhost') {$rck += '; domain=' + $dm;}$rck += '; path=/';document.cookie = $rck;return $nv;};
TrkClkGuid.prototype.revString = function($str) {var $rev = '';for (var $i = $str.length; $i > 0; $i--) {$rev += $str.substring($i - 1, $i);}return $rev;};
TrkClkGuid.prototype.numToBase = function($num, $base) {var $res = '';while ($num !== 0) {$res += this.ad[($num % $base)];$num = Math.floor($num / $base);}return this.revString($res);};
TrkClkGuid.prototype.genGuid = function($base) {var rd1 = Math.random().toString().substring(10);var dt = new Date()._trkToDateInt().toString()._right(10);var rd2 = ((window.navigator.userAgent.length + document.documentElement.innerHTML.length + 1) * Math.random()).toString().replace(/\./g, '');var gid = ("000" + this.numToBase(this.siteId, $base).toString())._right(3) + this.numToBase(rd1, $base) + "*" + this.numToBase(dt, $base) + "*" + this.numToBase(rd2, $base);return (gid.length < 21) ? gid : gid.substring(0, 20);};
TrkClkGuid.prototype.setGuid = function() {var $u = "_#clkid";this.guid = this.ckGet($u);if (this.guid === "") {this.guid = this.ckSet($u, new Date()._trkDateAdd(365, 'd'), this.genGuid(36));}};
TrkClkGuid.prototype.getVarAndType = function(strurl) {var lEnc = "";var rEnc = "";var vName = "";var iType = 0;if (strurl.indexOf("s2d6.com/x") > 0) {vName = "k=";iType = 1;}else if (strurl.indexOf("track.omguk.com/") > 0 || strurl.indexOf("www2.smart-quotes.com") > 0 || strurl.indexOf("www.clg1.info/") > 0) {vName = "UID=";iType = 1;}else if (strurl.indexOf("scripts.affiliatefuture.com") > 0) {vName = "tracking=";iType = 1;}else if (strurl.indexOf(".at/") > 0) {vName = "LID=";iType = 1;}else if ((strurl.indexOf("clkuk.tradedoubler.com") > 0 || strurl.indexOf("impgb.tradedoubler.com") > 0 || strurl.indexOf("impgb.pvnsolutions.com") > 0 || strurl.indexOf("clkde.tradedoubler.com") > 0) && (strurl.indexOf("p(") > 0 || strurl.indexOf("type(js)") > 0)) {vName = "epi(";iType = 2;}else if ((strurl.indexOf("clkuk.tradedoubler.com") > 0 || strurl.indexOf("impgb.tradedoubler.com") > 0 || strurl.indexOf("impgb.pvnsolutions.com") > 0 || strurl.indexOf("clkde.tradedoubler.com") > 0) && (strurl.indexOf("p=") > 0 || strurl.indexOf("type=js") > 0)) {vName = "epi=";iType = 1;}else if (strurl.indexOf("www.awin1.com") > 0 || strurl.indexOf("track.webgains.com") > 0) {vName = "clickref=";iType = 1;}else if (strurl.indexOf("being.successfultogether.co.uk") > 0 || strurl.indexOf("become.successfultogether.co.uk") > 0 || strurl.indexOf("partners.webmasterplan.com") > 0 || strurl.indexOf("mats.silvertap.com") > 0) {vName = "subid=";iType = 1;}else if (strurl.indexOf("www.e-financialaffiliates.com/track.aspx") > 0) {vName = "sub=";iType = 1;}else if (strurl.indexOf("tr.premieraffiliates.com") > 0) {vName = "storm_guid";iType = 3;}else if (strurl.indexOf("www.anrdoezrs.net") > 0 || strurl.indexOf("www.jdoqocy.com") > 0 || strurl.indexOf("www.tkqlhce.com") > 0) {vName = "sid=";iType = 1;}else if (strurl.indexOf("commissionmonster.com") > 0) {vName = "";iType = 4;}else if (strurl.indexOf("www.paidonresults.net") > 0) {vName = "";iType = 5;}else if (strurl.indexOf("ad.zanox.com") > 0 || strurl.indexOf("zanox-affiliate.de") > 0) {vName = "zpar4=";iType = 1;}else if (strurl.indexOf("ad.uk.doubleclick.net") > 0) {iType = 7;}else if (strurl.indexOf("3-mobile-affiliate.com/") > 0) {iType = 8;}else if (strurl.indexOf("track.profitistic.com/") > 0 || strurl.indexOf("affiliates.phd.co.uk/") > 0) {vName = "subid1=";iType = 1;}else if (strurl.indexOf(".clixGalore.com/") > 0) {vName = "OID=";iType = 1;}else if (strurl.indexOf("aflite.co.uk") > 0) {vName = "aref=";iType = 1;}else if (strurl.indexOf("click.linksynergy.com") > 0) {vName = 'u1=';iType = 1;}else if (strurl.indexOf('clickserve.cc-dt.com') > 0) {vName = 'mid=';iType = 1;} else if (strurl.indexOf('www.pntrac.com') > 0 || strurl.indexOf('www.gopjn.com') > 0) {vName = 'sid=';iType = 1;} else if (strurl.indexOf('www.shareasale.com') > 0) {vName = 'afftrack=';iType = 1;} else if (strurl.indexOf('www.linkconnector.com') > 0) {vName = 'atid=';iType = 1;} else if (strurl.indexOf('www.adcell.de') > 0) {vName = '-';iType = 9;} else if (strurl.indexOf('action.metaffiliation.com') > 0) {vName = 'argsite=';iType = 1;} else if (strurl.indexOf('belboon.de') > 0) {vName = 'subid=';iType = 10;}return (vName + "," + iType.toString() + "," + lEnc + "," + rEnc).split(",");};
TrkClkGuid.prototype.pType1 = function(url, myDelim, varName, lEnc, rEnc) {if (url.indexOf("?") == -1) {url += "?" + varName + lEnc + this.guid + rEnc;}else if (url.indexOf(varName) == -1) {url = url.substring(0, url.indexOf('?') + 1) + varName + lEnc + this.guid + rEnc + '&' + url.substring(url.indexOf('?') + 1);}else {if (url._endsWith(varName)) {url += lEnc + this.guid + rEnc;}else {if (url.indexOf(varName + lEnc) != url.indexOf(varName)) {url = url.replace(varName, varName + lEnc);var te = (url.indexOf("&", url.indexOf(varName) + varName.length) == -1) ? url.length : url.indexOf("&", url.indexOf(varName) + varName.length);url = url.replace(url.substring(0, te), url.substring(0, te) + rEnc);}if (lEnc === "") {var st = url.indexOf(varName);var en = (url.indexOf("&", st) == -1) ? url.length : url.indexOf("&", st);myDelim = (url.indexOf(varName) + varName.length == en) ? "" : myDelim;var pre = url.substring(0, en);url = pre + url.replace(pre, myDelim + this.guid);}else {url = url.replace(rEnc, myDelim + this.guid + rEnc);}}}return url.replace(varName + lEnc + myDelim, varName + lEnc);};
TrkClkGuid.prototype.pType2 = function(url, myDelim, vName) {if (url.indexOf(vName) < 0) {url = url + vName + this.guid + ")";}else if (url.indexOf(vName + ")") > 0) {url = url.replace(vName + ")", vName + this.guid + ")");}else {var ins = url.indexOf(")", url.indexOf(vName));var pre = url.substring(0, ins);url = pre + url.replace(pre, myDelim + this.guid);}return url;};
TrkClkGuid.prototype.insertGuid = function(strurl, strmyDelim) {var varType, iType, vName;varType = this.getVarAndType(strurl);if (varType === null) {return strurl;}vName = varType[0];iType = varType[1];var lEnc = varType[2];var rEnc = varType[3];iType = varType[1];if (iType == 1 || iType == 6) {strurl = this.pType1(strurl, strmyDelim, vName, lEnc, rEnc);}else if (iType == 2) {strurl = this.pType2(strurl, strmyDelim, vName);}else if (iType == 3) {if (strurl._endsWith("/")) {strurl = strurl + vName + "/" + this.guid;}else {strurl = strurl + "/" + vName + "/" + this.guid;}}else if (iType == 4) {if (strurl._endsWith("/")) {strurl = strurl + this.guid;}else {strurl = strurl + "/" + this.guid;}}else if (iType == 5) {var endofurl = strurl.substring(strurl.length - 2);var startofurl = strurl.substring(0, strurl.length - 2);if (endofurl == "/0") {strurl = startofurl + "/" + this.guid;}else {strurl = strurl + strmyDelim + this.guid;}}else if (iType == 6) {}else if (iType == 7) {strurl = strurl.replace(';d?', ';d?' + this.guid + '&');}else if (iType == 8) {if (strurl.indexOf('&subid') > -1) {strurl = strurl.replace('&subid', strmyDelim + this.guid + '&subid');} else {strurl += strmyDelim + this.guid;}}else if (iType == 9) {strurl += '-' + this.guid;}else if (iType == 10) {if (strurl._endsWith('html') || strurl._endsWith('img')) { strurl += '/'; }if (strurl.toLowerCase().indexOf(vName) == -1) {var ext = '.html';if (strurl.indexOf('.img') > -1) { ext = '.img'; }var uri = strurl.substring(0, strurl.indexOf(ext) + ext.length);var app = strurl.replace(uri, "");if (!uri._endsWith("/")) { uri += "/"; }if (!app._startsWith("/") && !app._startsWith("&")) { app = "/" + app; }strurl = uri + vName + this.guid + app;if (strurl._endsWith("/")) { strurl = strurl.substring(0, strurl.length - 1); }}else {var spos = strurl.toLowerCase().indexOf(vName);var epos = strurl.length;if (strurl.indexOf('&', spos) > -1 && strurl.indexOf('&', spos) < epos) { epos = strurl.indexOf('&', spos); }if (strurl.indexOf('/', spos) > -1 && strurl.indexOf('/', spos) < epos) { epos = strurl.indexOf('/', spos); }var rep = strurl.substring(spos, epos);var repWith = rep;var parms = rep.split('=');if (parms.length == 2 && parms[1].length > 0) {repWith += strmyDelim;}repWith += this.guid;strurl = strurl.replace(rep, repWith);}}return strurl;};
TrkClkGuid.prototype.richmediaGUID = function(strrmcode, strurl, strmyDelim) {var newurl = this.insertGuid(strurl, strmyDelim);return strrmcode.replace(strurl, newurl);};
