window.onload=function(){insertPopup();updateCookie("showpopupt=NO;path=/")}
window.onunload=function(){updateCookie("showpopupt=YES;path=/");}

function isSelected(total){
	if(Math.floor(Math.random()*total)==1){
		return true;
	}
	else{
		return false;
	}
}

function removePopup(){
	var n = document.getElementById('belastingdienst.nl');
	n.parentNode.parentNode.removeChild(n.parentNode);
}

function updateCookie(value){
	var today = new Date();
	today.setTime( today.getTime() )
	var expires_date = new Date( today.getTime() + 31 * 24 * 60 * 60 * 1000 );
	document.cookie=value+";expires="+expires_date.toGMTString();
}

function CheckForInvite(){
	removePopup();
	updateCookie("displayPopupt=NO;path=/");
	updateCookie("showpopupt=NO;path=/");
	child=window.open('http://research.opiniecentrum.nl/10047_2','questions');
	window.focus();
}

function CancelForInvite(){
	removePopup();
	updateCookie("displayPopupt=NO;path=/");
	updateCookie("showpopupt=NO;path=/");
	window.focus();
}

function insertPopup(){
	if(document.cookie.indexOf("displayPopupt")<0){
		if(isSelected(55)){
			var popup= '';
			popup += '<div id="belastingdienst.nl" style="color:#FFFFFF;text-align:left;position:absolute;top:175px;left:300px;width:480px;height:280px;font-family:Arial, Helvetica, sans-serif;font-size:12px;padding:0;margin:0;z-index:8000;">';
			popup += '<div id="op3" style="background-image:url(http://www.opiniecentrum.nl/oc-module/topt2012.png);background-repeat:repeat;background-color:#e4e4e4;min-height:60px;padding:0 10px 0 20px; padding-top:220px">';
			popup += '<p style="margin:0; text-align:center;padding:14px 0px 0 0;"><input type=button onclick="CheckForInvite();" value="Ja"><input type="button" onCLick="CancelForInvite()" value="Nee"></p></div></div>';
			var divTag = document.createElement("div");
			divTag.id = "popupDiv";
			divTag.innerHTML = popup;
			document.body.appendChild(divTag);
		}
	}
}
	
