You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
27 KiB
Plaintext

1 year ago
var PostAssoc=function(){};var PostAffAction=function(actionCode){if(actionCode==undefined){actionCode='';}
this.ac=actionCode;};PostAffAction.prototype.quote=function(string){var escapable=/[\\\"\/\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\','/':'\\/'};escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';};PostAffAction.prototype.toString=function(){var output='';for(var property in this){var value=this[property];if(typeof value=='string'){output+='"'+property+'":'+this.quote(value)+',';}}
return'{'+output.substring(0,output.length-1)+'}';}
PostAffAction.prototype._correctString=function(value,regexp){if(typeof(value)=='undefined'){return null;}
var strValue=new String(value);strValue=strValue.replace(/,/g,".");strValue=this._removeDotButLast(strValue);var a=new RegExp('['+regexp+']','gi');strValue=strValue.replace(a,"");strValue=strValue.replace(/^0+(?!$)/g,"");return strValue;};PostAffAction.prototype._correctCurrency=function(valueIn){var value=this._correctString(valueIn,'^0-9\.\-');if(value.indexOf('-')==0){return'-'+this._correctString(value.substring(1),'^0-9\.');}
return this._correctString(value,'^0-9\.');};PostAffAction.prototype._removeDotButLast=function(source){var pos=source.lastIndexOf('.');return source.substring(0,pos).replace(/\./gi,'')+source.substring(pos);}
PostAffAction.prototype._correctCommission=function(value){if(value=='0'){return value;}
value=this._correctString(value,'^\-0-9\.\%');if(value==null){return null;}
if(value.charAt(value.length-1)=='%'){return this._correctCurrency(value.substring(0,value.length-1))+'%';}
if(value.indexOf('%')>=0){return'%'+this._correctCurrency(value);}
return this._correctCurrency(value);};PostAffAction.prototype._correctText=function(value){if(typeof value=='undefined'){return null;}
var s=new String(value);return s.toString();};PostAffAction.prototype.setTotalCost=function(value){this.t=this._correctCurrency(value);};PostAffAction.prototype.setCoupon=function(value){this.cp=this._correctText(value);};PostAffAction.prototype.setFixedCost=function(value){this.f=this._correctCommission(value);};PostAffAction.prototype.setOrderID=function(value){this.o=this._correctText(value);};PostAffAction.prototype.setProductID=function(value){this.p=this._correctText(value);};PostAffAction.prototype.setAffiliateID=function(value){this.a=this._correctText(value);};PostAffAction.prototype.setBannerID=function(value){this.b=this._correctText(value);};PostAffAction.prototype.setCampaignID=function(value){this.c=this._correctText(value);};PostAffAction.prototype.setChannelID=function(value){this.ch=this._correctText(value);};PostAffAction.prototype.setCurrency=function(value){this.cr=this._correctText(value);};PostAffAction.prototype.doNotDeleteCookies=function(){this.dndc='Y';};PostAffAction.prototype.setCustomCommission=function(value){if(typeof value=='number'){this.cc=value+"";return;}
var valueArray=value.split(";");this.cc="";for(var i=0;i<valueArray.length;i++){this.cc+=this._correctCommission(valueArray[i]);if((i+1)<valueArray.length){this.cc+=";";}}};PostAffAction.prototype.changeCommissionBy=function(value){if(typeof value=='number'){this.chc=value+"";return;}
var valueArray=value.split(";");this.chc="";for(var i=0;i<valueArray.length;i++){this.chc+=this._correctCommission(valueArray[i]);if((i+1)<valueArray.length){this.chc+=";";}}};PostAffAction.prototype.setCustomCommissionNextTiersFromCampaign=function(value){this.ccfc=value;};PostAffAction.prototype.setStatus=function(value){this.s=value;};PostAffAction.prototype.setData1=function(value){this.d1=this._correctText(value);};PostAffAction.prototype.setData2=function(value){this.d2=this._correctText(value);};PostAffAction.prototype.setData3=function(value){this.d3=this._correctText(value);};PostAffAction.prototype.setData4=function(value){this.d4=this._correctText(value);};PostAffAction.prototype.setData5=function(value){this.d5=this._correctText(value);};PostAffAction.prototype.setTimeStamp=function(value){this.ts=this._correctText(value);};
var PostAffAttributeWriter=function(idIn,attributeNameIn,urlParamNameIn,separatorIn){var id=idIn;var attributeName=attributeNameIn;var urlParamName=urlParamNameIn;var separator=getSeparator(separatorIn);var value;if(typeof urlParamName=='string'&&urlParamName!=''){value=new PostUrlReplacer(urlParamName,separator,true);}else{value=new PostValueReplacer(separator);}
function getSeparator(separatorIn){if(separatorIn==undefined||separatorIn==''){return null;}
return separatorIn;}
this.getElementsById=function(elementId){var nodes=new Array();var tmpNode=document.getElementById(elementId);while(tmpNode){nodes.push(tmpNode);tmpNode.id="";tmpNode=document.getElementById(elementId);for(var x=0;x<nodes.length;x++){if(nodes[x]==tmpNode){tmpNode=false;}}}
for(var x=0;x<nodes.length;x++){nodes[x].id=elementId;}
return nodes;};this.getElementsByClassName=function(className){var nodes=document.getElementsByClassName(className);return nodes;};this.writeAttribute=function(valueIn){if(valueIn==null||valueIn==''){return;}
var elements=this.getElementsById(id);if(elements.length==0){elements=this.getElementsByClassName(id);}
for(var i=0;i<elements.length;i++){switch(attributeName){case'href':elements[i].href=value.replace(elements[i].href,valueIn);break;case'value':elements[i].value=value.replace(elements[i].value,valueIn);break;case'action':elements[i].action=value.replace(elements[i].action,valueIn);break;default:elements[i].setAttribute(attributeName,value.replace(elements[i].getAttribute(attributeName),valueIn));break;}}};};var PostUrlReplacer=function(urlParameterNameIn,separatorIn,notEncodeURI){var storedBefore=false;var parameterName=urlParameterNameIn;var separator=separatorIn;var notEncodeURI=notEncodeURI;this.replace=function(oldValue,newValue){var url=PostAffParams.parse(oldValue);oldParamValue=url.getParamValue(parameterName);if(separator==null){if(oldParamValue!=newValue){url.addParam(parameterName,newValue);}
storedBefore=true;return url.toString(notEncodeURI);}
if(oldParamValue==undefined){oldParamValue='';}
if(storedBefore){if(oldParamValue.indexOf(separator)!=-1){oldParamValue=oldParamValue.substring(0,oldParamValue.lastIndexOf(separator));}else{oldParamValue='';}}
var newParamValue=newValue;if(oldParamValue!=''){newParamValue=oldParamValue+separator+newValue;}
if(newValue==''||newValue==undefined){newParamValue=oldParamValue;}
url.addParam(parameterName,newParamValue);storedBefore=true;return url.toString();}};var PostValueReplacer=function(separatorIn){var storedBefore=false;var separator=separatorIn;this.replace=function(oldValue,newValue){if(separator==null||oldValue==''){storedBefore=true;return newValue;}
if(storedBefore){oldValue=oldValue.substring(0,oldValue.lastIndexOf(separator));}
storedBefore=true;if(newValue==''||newValue==undefined){return oldValue;}
if(oldValue==''||oldValue==undefined){return newValue;}
return oldValue+separator+newValue;}};
var PostAffCookieManager=function(){var visitorCookie=new PostAffCookie('PAPVisitorId');var _doNotUseHttpCookie=false;var _doNotUseHttpCookie3rd=false;var _doNotUseHTML5LocalStorage=false;this.setDoNotUseHttpCookie=function(value){_doNotUseHttpCookie=value;}
this.setDoNotUseHttpCookie3rd=function(value){_doNotUseHttpCookie3rd=value;}
this.is3rdPartyCookieDisabled=function(value){return _doNotUseHttpCookie3rd;}
this.setDoNotUseHTML5LocalStorage=function(value){_doNotUseHTML5LocalStorage=value;}
this.setCookieDomain=function(domain){this._domain=domain;}
this.readAllFlashCookies=function(){}
this.loadHttpCookies=function(){visitorCookie.load();}
this.loadRestoreHtmlStorageCookies=function(){try{if(localStorage.getItem('PAPVisitorId')!=null&&localStorage.getItem('PAPVisitorId')!='null'){if(visitorCookie.value==null){visitorCookie.value=localStorage.getItem('PAPVisitorId');visitorCookie.trackingMethod='S';}}else{if(_doNotUseHTML5LocalStorage){return;}
if(visitorCookie.value!=null){localStorage.setItem('PAPVisitorId',visitorCookie.value);}}}catch(e){}}
this.saveVisitorToHttpCookie=function(visitorId){if(_doNotUseHttpCookie){return;}
PostAffCookie.setHttpCookie(visitorCookie.name,visitorId,null,this._domain);};this.writeVisitorIdToHTMLStorage=function(visitorId){if(_doNotUseHTML5LocalStorage){return;}
try{localStorage.setItem('PAPVisitorId',visitorId);}catch(e){}};this.getVisitorCookie=function(){return visitorCookie;};this.getVisitorId=function(){return this.getVisitorCookie().value;}
this.getVisitorIdOrSaleCookieValue=function(){return this.getVisitorCookie().value;}
this.setVisitorId=function(visitorId){visitorCookie.value=visitorId;visitorCookie.trackingMethod='';this.saveVisitorToHttpCookie(visitorId);this.writeVisitorIdToHTMLStorage(visitorId);};};var PostAffParams=function(scriptName){var params=new PostAssoc();this.script=scriptName;this.addParam=function(name,value,isDuplicateNames){if(name=='#'){this.addAnchorParam('',value);return;}
if(name.charAt(0)=='#'){this.addAnchorParam(name.substring(1),value);return;}
if(typeof(params[name])=='undefined'||isDuplicateNames!=true){params[name]=[];}
params[name].push(value);};this.getParamValue=function(name){if(params[name]instanceof Array){return params[name][0];}
return params[name];}
this.addAnchorParam=function(name,value){if(name!=''){name+='=';}
if(this.script.indexOf('#')!=-1){this.script=this.script+'&'+name+value;}else{this.script=this.script+'#'+name+value;}};this.encodeParams=function(notEncodeURI){var uri='?';for(var name in params){for(var i=0;i<params[name].length;i++){if(notEncodeURI==null||notEncodeURI==false){var paramValue=encodeURIComponent(params[name][i]);}else{var paramValue=params[name][i];}
uri+=name+"="+paramValue+"&";}}
return uri.substr(0,uri.length-1);};this.toString=function(notEncodeURI){return this.script+this.encodeParams(notEncodeURI);};};PostAffParams.parse=function(url){var parseParam;var parts=url.split('?');var params=new PostAffParams(parts[0]);if(parts.length>1){parameters=parts[1].split('&');for(var i=0;i<parameters.length;i++){parseParam=parameters[i].split('=');params.addParam(parseParam[0],parseParam[1],true);}}
return params;}
PostAffParams.replaceHttpInText=function(text){if(text==null){return"";}
text=text.replace("http://","H_");text=text.replace("https://","S_");return text;};PostAffParams.getReferrer=function(){var referrerParam=PostAffParams.parse(document.location.search).getParamValue("refx2s6d");if(referrerParam!=null&&referrerParam!=""){return referrerParam;}else if(document.location.href.split("refx2s6d=")[1]){return document.location.href.split("refx2s6d=")[1];}
return document.referrer;};var PostAffCookie=function(name){this.name=name;this.value=null;this.trackingMethod='';var dontOverwrite='1';this.load=function(){let tempValue=PostAffCookie.getHttpCookie(this.name);if(tempValue!=null){this.trackingMethod='1';this.value=tempValue;}};this.setOverwrite=function(){dontOverwrite='0';}
this.getOverwrite=function(){return dontOverwrite;}
this.deleteCookie=function(){PostAffCookie.deleteHttpCookie(this.name,this._domain);};};PostAffCookie.getHttpCookie=function(name){var value=document.cookie.match('(^|;) ?'+name+'=([^;]*)(;|$)');if(value&&value[2]!=''){return decodeURIComponent(value[2]);}
return null;};PostAffCookie.setHttpCookie=function(name,value,expired,domain){if(expired==null){var theDate=new Date();expired=new Date(theDate.getTime()+31536000000);}
if(domain==null){var url=document.domain;var i=0;var separatedUrl=url.split('.');while(i<(separatedUrl.length)){url=separatedUrl.slice(-(++i)).join('.');PostAffCookie.setHttpCookieInner(name,value,expired,url);}
return;}
PostAffCookie.setHttpCookieInner(name,value,expired,domain);};PostAffCookie.setHttpCookieInner=function(name,value,expired,domain){var secureCookieString='SameSite=Lax'
if(document.location.protocol=='https:'){secureCookieString='Secure;SameSite=None';}
document.cookie=name+'='+encodeURIComponent(value)+';expires='+expired.toGMTString()+';domain='+domain+';path=/;'+secureCookieString;};PostAffCookie.deleteHttpCookie=function(name,domain){expired=new Date(0);PostAffCookie.setHttpCookie(name,'',expired,domain);};
var PostAffRequest=function(cookieManager){this.cookieManager=cookieManager;this.sendCalled=false;this.send=function(){this.sendCalled=true;this.loadHttpCookies();this.loadRestoreHtmlStorageCookies();this.callTrackScript();};};PostAffRequest.prototype.accountId;PostAffRequest.prototype.setAccountId=function(accountIdIn){this.accountId=accountIdIn;}
PostAffRequest.prototype.loadHttpCookies=function(){this.cookieManager.loadHttpCookies();}
PostAffRequest.prototype.loadRestoreHtmlStorageCookies=function(){this.cookieManager.loadRestoreHtmlStorageCookies();}
PostAffRequest.prototype.getTrackingParams=function(){alert("getTrackingParams parent");}
PostAffRequest.prototype.fillTrackingParams=function(){var params=this.getTrackingParams();var visitorId=this.cookieManager.getVisitorId();if(visitorId!=null&&visitorId!='null'){params.addParam('visitorId',visitorId);}
if(this.accountId!=null&&this.accountId!='null'&&this.accountId!=''){params.addParam('accountId',this.accountId);}
if(typeof AffiliateID=='string'){params.addParam('userId',AffiliateID);}else if(PostAffTrackingRequest.getGetParams().getParamValue(PostAffTracker.getParamNameUserId())!=undefined){params.addParam('userId',PostAffTrackingRequest.getGetParams().getParamValue(PostAffTracker.getParamNameUserId()));}else if(PostAffTrackingRequest.getAnchorParams()!=""){var anchorParams=PostAffParams.parse("?"+PostAffTrackingRequest.getAnchorParams());if(anchorParams.getParamValue(PostAffTracker.getParamNameUserId())!=undefined){params.addParam('userId',anchorParams.getParamValue(PostAffTracker.getParamNameUserId()));}else if(PostAffTrackingRequest.getAnchorParams().indexOf("=")==-1){params.addParam('userId',PostAffTrackingRequest.getAnchorParams());}}
return params;}
PostAffRequest.prototype.callTrackScript=function(){var params=this.fillTrackingParams();var trackingScriptElement=document.createElement('script');trackingScriptElement.type='text/javascript';trackingScriptElement.src=PostAffTracker.getRequestUrl()+params.toString();var scriptElement=document.getElementById(PostAffTracker.getIntegrationElementId());scriptElement.parentNode.insertBefore(trackingScriptElement,scriptElement.nextSibling);};
var PostAffInfo=function(cookieManager){this.cookieManager=cookieManager;var affiliateId,campaignId,accountId,overwriteCookies,lastClickAffiliateId;var received=false;var pendingCallbacks=new Array();this.onResponseReceived=function(){received=true;for(var i=0;i<pendingCallbacks.length;i++){pendingCallbacks[i]();}
pendingCallbacks=new Array();}
this.call=function(callback){if(received){callback();return;}
pendingCallbacks[pendingCallbacks.length]=callback;if(!this.sendCalled){this.send();}}
this.setAccountId=function(accountIdIn){this.accountId=accountIdIn;}
this.setAffiliateInfo=function(affiliateIdIn,campaignIdIn,overwriteCookiesIn){affiliateId=affiliateIdIn;campaignId=campaignIdIn;overwriteCookies=overwriteCookiesIn;this.onResponseReceived();}
this.setLastClickAffiliateId=function(affiliateIdIn){lastClickAffiliateId=affiliateIdIn;}
this.getAffiliateId=function(){if(overwriteCookies=='Y'&&lastClickAffiliateId!=undefined&&lastClickAffiliateId!=''){return lastClickAffiliateId;}
if(affiliateId==''&&lastClickAffiliateId!=undefined&&lastClickAffiliateId!=''){return lastClickAffiliateId;}
return affiliateId;}
this.getCampaignId=function(){return campaignId;}};PostAffInfo.prototype=new PostAffRequest;PostAffInfo.prototype.constructor=PostAffInfo;PostAffInfo.prototype.getTrackingParams=function(){return new PostAffParams("get_affinfo.php");}
PostAffInfo.prototype.fillTrackingParams=function(){return PostAffRequest.prototype.fillTrackingParams.call(this);}
PostAffInfo.prototype.callTrackScript=function(){visitorId=this.cookieManager.getVisitorId();if(visitorId==undefined||visitorId==''){return;}
PostAffRequest.prototype.callTrackScript.call(this);}
var PostAffTrackingRequest=function(cookieManager,actions,accountId,skipIframeCheck){this.cookieManager=cookieManager;this.actions=actions;this.accountId=accountId;this.skipIframeCheck=skipIframeCheck;};PostAffTrackingRequest.prototype=new PostAffRequest;PostAffTrackingRequest.prototype.constructor=PostAffTrackingRequest;PostAffTrackingRequest.prototype.loadHttpCookies=function(){this.cookieManager.loadHttpCookies();}
PostAffTrackingRequest.prototype.getTrackingParams=function(){return new PostAffParams(PostAffTrackingRequest.getTrackFileName());}
PostAffTrackingRequest.getTrackFileName=function(){if(PostAffTracker.isScriptNameHashed()){return PostAffTrackingRequest.correctHashName(PostAffTracker.getScriptName(),'r')}
return'track.php';}
PostAffTrackingRequest.correctHashName=function(scriptName,specialCharacter){return scriptName.replace('j',specialCharacter).replace('p',specialCharacter);}
PostAffTrackingRequest.prototype.fillTrackingParams=function(){var params=PostAffRequest.prototype.fillTrackingParams.call(this);var visitorId=this.cookieManager.getVisitorId();if(visitorId!=null&&visitorId!='null'){params.addParam('tracking',this.cookieManager.getVisitorCookie().trackingMethod);}
if(this.cookieManager.is3rdPartyCookieDisabled()){params.addParam('mode','SC');}
var pathname=(window.location.pathname.charAt(0)=="/")?window.location.pathname:"/"+window.location.pathname;params.addParam('url',PostAffParams.replaceHttpInText(window.location.protocol+"//"+window.location.host+pathname));params.addParam('referrer',PostAffParams.replaceHttpInText(PostAffParams.getReferrer()));params.addParam('isInIframe',(!this.skipIframeCheck&&window.location!=window.parent.location)?true:false);if(this.accountId!=undefined){params.addParam('accountId',this.accountId);}
if(typeof this.actions=="object"&&this.actions.length>0){var sale='';for(var i=0;i<this.actions.length;i++){sale+=this.actions[i].toString()+',';}
params.addParam('sale','['+sale.substring(0,sale.length-1)+']');}else{params.addParam('getParams',PostAffTrackingRequest.getGetParams().toString(true));params.addParam('anchor',PostAffTrackingRequest.getAnchorParams());}
return params;}
PostAffTrackingRequest.getGetParams=function(){var getParams=PostAffParams.parse(document.location.search);if(typeof AffiliateID=='string'){getParams.addParam('AffiliateID',AffiliateID);}
if(typeof BannerID=='string'){getParams.addParam('BannerID',BannerID);}
if(typeof CampaignID=='string'){getParams.addParam('CampaignID',CampaignID);}
if(typeof Channel=='string'){getParams.addParam('Channel',Channel);}
if(typeof Data1=='string'){getParams.addParam('pd1',Data1);}
if(typeof Data2=='string'){getParams.addParam('pd2',Data2);}
return getParams;}
PostAffTrackingRequest.getAnchorParams=function(){if(document.location.href.split("#")[1]){return document.location.href.split("#")[1].split("refx2s6d=")[0];}
return"";}
if(PostAffTracker==undefined){var PostAffTracker=new function(){var integrationElementId='pap_x2s6df8d';var requestUrl,scriptName,scriptDomain;var isScriptNameHashed=false;this._cmanager=new PostAffCookieManager();var affInfo=new PostAffInfo(this._cmanager);var separator;var actionObjects=new Array();var latestActionObjects=new Array();var accountId;var paramNameUserId="a_aid";this.executeOnResponse=new Array();this.executeOnResponseFinished=new Array();this.executeOnResponceFinished=new Array();var executeAfterSetAffResponse=new Array();var skipIframeCheck=false;var waitingOnTracingRequest=false;this.afterSetAffResponseCounter=0;function computeUrl(){var url=new String(document.getElementById(integrationElementId).src);requestUrl=url.substr(0,url.lastIndexOf('/')+1);scriptDomain=url.substr(url.indexOf('//')+2);scriptDomain=scriptDomain.substr(0,scriptDomain.indexOf('/'));scriptName=url.substr(url.lastIndexOf('/')+1);if(scriptName.indexOf('?')>=0){scriptName=scriptName.substr(0,scriptName.indexOf('?'));}
isScriptNameHashed=(scriptName!='trackjs.js'&&scriptName!='trackjs.php'&&scriptName!='clickjs.php'&&scriptName!='salejs.php');}
computeUrl();function writeValueToAttribute(value,id,attributeName,urlParamName,separator){var writer=new PostAffAttributeWriter(id,attributeName,urlParamName,separator);writer.writeAttribute(value);}
this.getIntegrationElementId=function(){return integrationElementId;}
this.setSkipIframeCheck=function(skip){skipIframeCheck=skip;}
this.getRequestUrl=function(){return requestUrl;}
this.getScriptName=function(){return scriptName;}
this.getScriptDomain=function(){return scriptDomain;}
this.isScriptNameHashed=function(){return isScriptNameHashed;}
this.setRequestUrl=function(url){requestUrl=url;}
this.setAccountId=function(value){accountId=value;};this.setParamNameUserId=function(value){paramNameUserId=value;};this.getParamNameUserId=function(){return paramNameUserId;}
this.setCookieDomain=function(domain){this._cmanager.setCookieDomain(domain);}
this.enableTrackingMethods=function(){this._cmanager.setDoNotUseHttpCookie(false);this._cmanager.setDoNotUseHttpCookie3rd(false);this._cmanager.setDoNotUseHTML5LocalStorage(false);}
this.disableTrackingMethod=function(type){switch(type){case'1':this._cmanager.setDoNotUseHttpCookie(true);break;case'3':this._cmanager.setDoNotUseHttpCookie3rd(true);break;case'S':this._cmanager.setDoNotUseHTML5LocalStorage(true);break;case'C':this._cmanager.setDoNotUseHttpCookie(true);this._cmanager.setDoNotUseHttpCookie3rd(true);this._cmanager.setDoNotUseHTML5LocalStorage(true);break;default:break;}}
this.track=function(){var request=new PostAffTrackingRequest(this._cmanager,actionObjects,accountId,skipIframeCheck);waitingOnTracingRequest=true;request.send();latestActionObjects=latestActionObjects.concat(actionObjects);actionObjects=new Array();};this.register=function(){return this.track();};this.registerOnAllFinished=function(){if(waitingOnTracingRequest==true){this.executeOnResponseFinished.push(function(){PostAffTracker.track();});return;}
return this.track();};this.createAction=function(actionCode){var obj=new PostAffAction(actionCode);actionObjects[actionObjects.length]=obj;return obj;};this.getLatestActionObjects=function(){return latestActionObjects;};this.createSale=function(){return this.createAction();};this.notifySale=function(){return this.writeVisitorIdToAttribute('pap_dx8vc2s5','value');};this.writeVisitorIdToAttribute=function(id,attributeName,urlParamName,separatorIn,addAccountId){if(addAccountId==undefined){addAccountId=true;}
this._cmanager.loadHttpCookies();this._cmanager.loadRestoreHtmlStorageCookies();var writer=new PostAffAttributeWriter(id,attributeName,urlParamName,this._getSeparator(separatorIn));writer.writeAttribute((addAccountId?this._getAccountId():'')
+this._cmanager.getVisitorIdOrSaleCookieValue());if(this._cmanager.getVisitorIdOrSaleCookieValue()==null||this._cmanager.getVisitorIdOrSaleCookieValue()=='null'){this.executeOnResponseFinished.push(function(){writer.writeAttribute((addAccountId?PostAffTracker._getAccountId():'')
+PostAffTracker._cmanager.getVisitorIdOrSaleCookieValue());});}};this.writeCookieToCustomField=function(id,separatorIn,urlParamName,addAccountId){if(urlParamName==undefined){urlParamName=null;}
if(addAccountId==undefined){addAccountId=true;}
this.writeVisitorIdToAttribute(id,'value',urlParamName,separatorIn,addAccountId);};this.writeCookieToLink=function(id,urlParamName,separatorIn,addAccountId){if(addAccountId==undefined){addAccountId=true;}
this.writeVisitorIdToAttribute(id,'href',urlParamName,separatorIn,addAccountId);};this.getVisitorId=function(){return this._cmanager.getVisitorId();};this.setVisitorId=function(id){this._cmanager.setVisitorId(id);this.afterSetVisitorId();};this.afterSetVisitorId=function(){for(var i=0;i<this.executeOnResponse.length;i++){this.executeOnResponse[i]();}}
this.onTrackingFinished=function(){waitingOnTracingRequest=false;while(this.executeOnResponseFinished.length>0){let executeRequest=this.executeOnResponseFinished.shift();executeRequest();}
while(this.executeOnResponceFinished.length>0){let executeRequest=this.executeOnResponceFinished.shift();executeRequest();}}
this.writeAffiliateToCustomFieldNow=function(id){affInfo.setAccountId(this._getAccountId());affInfo.call(function(){writeValueToAttribute(affInfo.getAffiliateId(),id,'value',null,separator);});};this.writeAffiliateToCustomField=function(id){if(!waitingOnTracingRequest){PostAffTracker.writeAffiliateToCustomFieldNow(id);return;}
this.executeOnResponseFinished.push(function(){PostAffTracker.writeAffiliateToCustomFieldNow(id);});};this.getAffInfo=function(){return affInfo;};this.writeCampaignToCustomFieldNow=function(id){affInfo.setAccountId(this._getAccountId());affInfo.call(function(){writeValueToAttribute(affInfo.getCampaignId(),id,'value',null,separator);});};this.writeCampaignToCustomField=function(id){if(!waitingOnTracingRequest){PostAffTracker.writeCampaignToCustomFieldNow(id);return;}
this.executeOnResponseFinished.push(function(){PostAffTracker.writeCampaignToCustomFieldNow(id);});};this.writeAffiliateToLinkNow=function(id,urlParamName,separatorIn){var localSeparator=this._getSeparator(separatorIn);affInfo.setAccountId(this._getAccountId());affInfo.call(function(){writeValueToAttribute(affInfo.getAffiliateId(),id,'href',urlParamName,localSeparator);});};this.writeAffiliateToLink=function(id,urlParamName,separatorIn){if(!waitingOnTracingRequest){PostAffTracker.writeAffiliateToLinkNow(id,urlParamName,separatorIn);return;}
this.executeOnResponseFinished.push(function(){PostAffTracker.writeAffiliateToLinkNow(id,urlParamName,separatorIn);});};this._setAffiliateInfo=function(affiliateId,campaignId,overwriteCookies){affInfo.setAffiliateInfo(affiliateId,campaignId,overwriteCookies);this.afterSetAffiliate();};this.setLastClickAffiliateId=function(affiliateId){affInfo.setLastClickAffiliateId(affiliateId);};this.afterSetAffiliate=function(){for(var i=0;i<this.afterSetAffResponseCounter;i++){try{executeAfterSetAffResponse['PostAff_'+i]();}catch(e){alert('Error during running user function after setAffInfo callback: '+e);}}}
this.addAfterSetAffiliateFunction=function(functionBody){if(functionBody instanceof Function){executeAfterSetAffResponse['PostAff_'+this.afterSetAffResponseCounter]=functionBody;this.afterSetAffResponseCounter++;}}
this._getSeparator=function(separatorIn){if(separatorIn==null||separatorIn==undefined||separatorIn==''){return separator;}
return separatorIn;};this._getAccountId=function(){if(accountId!=undefined&&accountId!=null){return accountId;}
return'';}
this.setAppendValuesToField=function(separatorIn){return separator=separatorIn;};};}
function setVisitor(v){PostAffTracker.setVisitorId(v);}
function setAffiliate(aid){PostAffTracker.setLastClickAffiliateId(aid);}
function trackingFinished(){PostAffTracker.onTrackingFinished();}
function setAffiliateInfo(userId,campaignId,overwriteCookies){PostAffTracker._setAffiliateInfo(userId,campaignId,overwriteCookies);}
function papTrack(){PostAffTracker.track();}