// directions for use:
// copy this file to its own directory,
// then edit the copy:
// 1. change the CFG section to your needs
// 2. erase all comment lines (saves bandwidth)
// CFG
var langDagen=30;

var popupurl = 'http://banners.resultonline.com/images/125.3popunder/index.htm' ;
var cookieName='Appelazijnpopup';
var cookieName_lang='Appelazijnpopup_lang';
var windowName='Appelazijnpopunder';
var popupBlocked = 1 ;
var w=700;
var h=450;
// EO CFG
if(popuplimiet<1)popuplimiet=3;
var today=new Date();
var expireDay=new Date();
function getCookieVal(offset){
 var endstr=document.cookie.indexOf(";",offset);
 if(endstr==-1)endstr=document.cookie.length;
 return unescape(document.cookie.substring(offset,endstr));
}
function GetCookie (name) {
 var arg=name+"=";
 var alen=arg.length;
 var clen=document.cookie.length;
 var i=0;
 while(i<clen){
  var j=i+alen;
  if (document.cookie.substring(i,j)==arg)return getCookieVal(j);
  i=document.cookie.indexOf(" ",i)+1;
  if(i==0)break;
 }
 return null;
}
function SetCookie(name,value,expires,path,domain,secure){
 document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");
}
var already1=GetCookie(cookieName);
var already2=GetCookie(cookieName_lang);
if(already1<1)already1=0;
if(already2<1)already2=0;
var already=(already1<already2)?already2:already1;
already++;
expireDay.setTime(today.getTime()+86400000*langDagen);
// only write cookie if we are going to launch the popup, or if the cookie
// was already in the browser.
// the goal is to prevent users from receiving a cookie warning from the
// browser without seeing a popup
// this could happen if the popup is banned because of the session cookie and
// the user has switched on interactive acceptance of long term cookies
// or the other way around, but this is very unusual
if(!popupBlocked && (already<=popuplimiet||already1>0))SetCookie(cookieName,''+already);
if(!popupBlocked && (already<=popuplimiet||already2>0))SetCookie(cookieName_lang,''+already,expireDay);
if(!popupBlocked && already<=popuplimiet){
 var t=window.screen.height/2-h/2;
 var l=window.screen.width/2-w/2;
 if(sid==null||!sid.match(/^[a-z]{8}$/))sid="unknown";
 if(pid==null)pid="pagelabel";
 pid=pid.replace(/[^a-zA-Z0-9]/,"_");
// var img = new Image() ;
// if (img) {
 // img.src = 'http://banners.resultonline.com/perl/aplaznbu?sid=' + sid + '&pid=' + pid ;
 //}
 var hid=escape(window.location.href);
 var popupWindow=window.open(popupurl+'?'+sid+'=yes&sid='+sid+'&pid='+pid+'&hid='+hid,windowName,'width='+w+',height='+h+',top='+t+',left='+l);
 if(popupWindow)popupWindow.blur();
 window.focus();
}

