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;i1){parameters=parts[1].split('&');for(var i=0;i0){var sale='';for(var i=0;i=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;i0){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