(function(GLOBAL,self){if(window!=window.top)return;var DEBUG_MODE=false;var PREFIX='admaven_pop';var VERSION='1.0.1';var POPS_PER_DAY=2;var INTERVAL_BETWEEN_POP=360000;var TID=600141;var TAG_DOMAIN='t.booksuper.info';var SERVING_METHOD=16;var error=[];if(DEBUG_MODE){POPS_PER_DAY=2;TID=328500;INTERVAL_BETWEEN_POP=36E5;SERVING_METHOD=16;TAG_DOMAIN='t.booksuper.info'}var pop_url='http://'+TAG_DOMAIN+'?tid='+TID+'&red=1';var cachedOpen= window.open;var log=function(str,method){if(!DEBUG_MODE)return function(s){};if(!method)return console.log(str);return console[method](str)};var Time=function(){var self=this;self.dateObj=new Date;self.timestamp=function(){return self.dateObj.getTime()}();self.date=function(){return self.dateObj.getDate()}();self.hour=function(){return self.dateObj.getHours()}();self.minutes=function(){return self.dateObj.getMinutes()}();self.seconds=function(){return self.dateObj.getSeconds()}();return self};self.now= new Time;var Events=new function(){var self=this;self.cache=[];if(window.addEventListener)self.add=function(type,fn,bool,element,cache){if(typeof element=='undefined')element=window;element.addEventListener(type,fn,bool);if(cache)self.cache.push([type,fn,bool,element])};else if(window.attachEvent)self.add=function(type,fn,bool,element,cache){if(typeof element=='undefined')element=window;element['e'+type+fn]=fn;element[type+fn]=function(){element['e'+type+fn](window.event)};element.attachEvent('on'+ type,element[type+fn]);if(cache)self.cache.push([type,fn,bool,element])};else self.add=function(){};if(window.removeEventListener)self.remove=function(type,fn,bool,element){if(typeof element=='undefined')element=window;element.removeEventListener(type,fn,bool)};else if(window.detachEvent)self.remove=function(type,fn,bool,element){if(typeof element=='undefined')element=window;element.detachEvent('on'+type,element[type+fn]);element[type+fn]=null;element['e'+type+fn]=null};else self.remove=function(){}; self.flush=function(){for(var i=0;i<self.cache.length;i++)self.remove.apply(self,self.cache[i]);self.cache=[]}};var browser=function(){var n=navigator.userAgent.toLowerCase();var b={webkit:/webkit/.test(n),mozilla:/mozilla/.test(n)&&!/(compatible|webkit)/.test(n),chrome:/chrome/.test(n),msie:/msie/.test(n)&&!/opera/.test(n),firefox:/firefox/.test(n),safari:/safari/.test(n)&&!/chrome/.test(n),opera:/opera/.test(n)};b.version=b.safari?(n.match(/.+(?:ri)[\/: ]([\d.]+)/)||[])[1]:(n.match(/.+(?:ox|me|ra|ie)[\/: ]([\d.]+)/)|| [])[1];return b}();var Cookie=new function(){var self=this;self.setItem=function(name,value,days){if(days){var date=new Date;date.setTime(date.getTime()+days*24*60*60*1E3);var expires='; expires='+date.toGMTString()}else var expires='';document.cookie=name+'='+value+expires+'; path=/'};self.getItem=function(name){var nameEQ=name+'=';var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length, c.length)}return null};self.removeItem=function(name){self.setCookie(name,'',-1)}};var Storage=new function(){var self=this;try{self.engine=localStorage}catch(e){log('localStorage error: '+e.message)}if(typeof localStorage=='undefined')return false;else{log('localStorage undefined');return false}};var openPopUP=function(url,windowName,newTab){if(!newTab)return cachedOpen(url,windowName,'resizable=no, toolbar=no, scrollbars=no, menubar=no, status=no, directories=no, width='+screen.width+', height='+ screen.height);else return cachedOpen(url,windowName)};var setStorage=function(){self.total_pops++;Storage.engine.setItem(PREFIX+'_time',self.now.timestamp+INTERVAL_BETWEEN_POP);Storage.engine.setItem(PREFIX+'_date_totalPops',self.now.date+'_'+self.total_pops)};var resetData=function(){Storage.engine.removeItem(PREFIX+'_time');Storage.engine.removeItem(PREFIX+'_date_totalPops')};var openPop=new function(){var self=this;var afterClick=function(){setStorage();Events.flush()};var handleOpenedPop=function(pop){pop.name= PREFIX;pop.location.replace(pop_url);afterClick()};self['_3']=function(){try{log('start pop up function');var clickElement=document.documentElement;var pop;var popup=function(){log('click _3');pixel(2);pop=openPopUP('about:blank','',false);if(pop){log('successfully opened pop');handleOpenedPop(pop)}else log('pop up blocked')};Events.add('click',popup,false,clickElement,true)}catch(e){log(e)}};self['_16']=function(){var popup=function(){pixel(3);log('click');var pop=openPopUP('about:blank','',true); if(pop)handleOpenedPop(pop);else log('pop up blocked')};Events.add('click',popup,false,document.documentElement,true)}};var pixel=function(status){};var validFreq=function(){var dataIsCorrupt=function(last_date_pop_opened,next_time_to_open_pop){if(isNaN(last_date_pop_opened)||isNaN(next_time_to_open_pop))return true;if(!last_date_pop_opened||!next_time_to_open_pop)return true};var getDateAndTotalPops=function(){var handleError=function(){log('data corruption in data and total pop','warn');error.push('data corruption in data and total pop'); resetData()};var temp=Storage.engine.getItem(PREFIX+'_date_totalPops');if(!temp)return[0,0];if(typeof temp=='string'){temp=temp.split('_');if(temp.length=2){temp[0]=parseInt(temp[0]);temp[1]=parseInt(temp[1]);if(isNaN(temp[0])||isNaN(temp[1])){handleError();return[Time.date,0]}return temp}}else handleError()};if(!Storage){pixel(1);return false}if(POPS_PER_DAY===0&&INTERVAL_BETWEEN_POP===0)return true;var next_time_to_open_pop=Storage.engine.getItem(PREFIX+'_time');var total_pops_date=Storage.engine.getItem(PREFIX+ '_date_totalPops');var last_date_pop_opened;if(!next_time_to_open_pop&&!total_pops_date){log('first pop!');self.total_pops=0;return true}next_time_to_open_pop=parseInt(Storage.engine.getItem(PREFIX+'_time'));total_pops_date=getDateAndTotalPops();if(error.length)return error;last_date_pop_opened=total_pops_date[0];self.total_pops=total_pops_date[1];if(last_date_pop_opened!==self.now.date){self.total_pops=0;log('a new day','info');return true}if(self.total_pops>=POPS_PER_DAY&&POPS_PER_DAY!==0){log('the max pop per day has reached'); return false}if(dataIsCorrupt(last_date_pop_opened,next_time_to_open_pop)){Storage.removeItem(PREFIX+'_date');Storage.removeItem(PREFIX+'_time')}if(next_time_to_open_pop<self.now.timestamp){log('its to pop!','info');return true}else log('time left for next pop: '+new Date(next_time_to_open_pop),'info');return false};var init=function(){try{if(validFreq()){if(error.length)return error;try{if(typeof openPop['_'+SERVING_METHOD]=='function')openPop['_'+SERVING_METHOD]();else openPop['_3']()}catch(e){pixel(4)}}}catch(e){pixel(3)}}; init();if(typeof window[PREFIX]=='undefined')window[PREFIX]=self})(window,{}); 
