/* BEG: Code to determine Protocol. */ var allScripts = document.getElementsByTagName("script") ,currScript = allScripts[allScripts.length - 1] ,currSrc = currScript.src || "" ,srcHasProtocol = currSrc.indexOf("://") > 0 ,protocol = window["PubMatic"] && window.PubMatic["secure"] === false ? window.PubMatic["protocol"] || "" : "" ,secure = false ,adTagUrl = "//ads.pubmatic.com/AdServer/js/showad.js" ,pmBusterId = "pmbust"; if ( !protocol ) { /* IF : - Script src has protocol. ELSE IF : - currSrc is empty string - Global Variable PubMatic is defined - PubMatic variable has a property called protocol ELSE: Lets determine the protocol from the page. */ if(srcHasProtocol){ protocol = currSrc.indexOf("https://") == 0 ? "https:" : "http:"; } else if(!currSrc && window["PubMatic"] && window.PubMatic["protocol"]) { protocol = PubMatic.protocol; } else { protocol = document.location.protocol != "https:"? "http:" : "https:"; } //Finally : Update the PubMatic.protocol if protocol is http or PubMatic not defined. secure = protocol == 'https:'; window.PubMatic = window.PubMatic || {}; if(!secure || !window["PubMatic"]){ PubMatic.protocol = protocol; PubMatic.secure = secure; } } adTagUrl = protocol + adTagUrl; /* END: Code to determine Protocol. */ window.PubMatic = window["PubMatic"] || {}; /* BEG : PubMatic Util Class Definaion*/ PubMatic.UtilClass = PubMatic["UtilClass"] || function(){}; PubMatic.UtilClass.prototype = { /* BEG : URL Params Util */ urlCollection : {} ,parseUrlForParams : function(locScope){ var searchStr = locScope.location.search ,l = searchStr.length ,params = searchStr.substring(1,l).split("&") ,c ,pColl = {} ,pName ,pVal ,param; l = params.length; for(c=0;c= 0) { this.readParamsFromHashMsg(); return false; } */ //Set isSingleFrame conf. this.adConf.isSingleFrame = parent == top; //Correct Buster Url. if (pmibuster.indexOf("://") > 0) { pmibuster = pmibuster.split("://")[1]; } //Set the property. this.busterUrl = protocol + "//" + pmibuster; return true; } ,setBustingMode : function () { this.adConf[this.modeParamName] = this.busterMode = window[this.modeParamName] || 0; } ,setAdTagConf : function () { var pAr = this.otherParams ,l = pAr.length ,pName; while (l--) { pName = pAr[l]; if (pName in window) { this.adConf[pName] = window[pName]; } } //Set refurl. this.adConf.refurl = document.referrer; //Set cache buster. -- See if it is required. this.adConf.rnz = Math.floor(Math.random()*10000); } ,bustIframe : function () { var modes = PubMatic.IBTagClass.BusterModes; switch (this.busterMode) { case modes.REUSE: this.bustInReuseMode(); break; case modes.RELOAD: this.bustInReloadMode(); break; default: this.bustInIFrameMode(); } } ,getBusterUrl : function () { var adConf = this.adConf ,pAr = []; for(k in adConf) { if (adConf.hasOwnProperty(k)) { pAr.push( k + "=" + encodeURIComponent(adConf[k]) ); }} return this.busterUrl + "?" + pAr.join('&'); } ,bustInReuseMode : function () { var newUrl = this.getBusterUrl(); window.location.replace(newUrl); } ,bustInIFrameMode : function () { var newUrl = this.getBusterUrl(); var conf = this.adConf; document.write( '' + '' ); } ,bustInReloadMode : function () { /* TBD: Not implimenting reload use-case as it may lead to 2x discripency. */ } ,readParamsFromHashMsg : function () { /* TBD: Not implimenting reload use-case as it may lead to 2x discripency. */ } ,includeShowAd : function () { document.writeln('' + ''); } ,readParamsFromTop : function () { //WARNING : Always ensure this method is called inside try catch block. window.kadpageurl = top.location.href; window.refurl = top.document.referrer; } }; PubMatic.ibTag = new PubMatic.IBTagClass();