// JavaScript Document

/*
 * getPuCookie
 * -----------
 * If the cookie is set it returns the username, in this case 
 * if it does, it returns the value of user, else it returns an empty string.
 * 
 */
function getPuCookie(c_name){
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
	   		if (c_end==-1) c_end=document.cookie.length;
    		return unescape(document.cookie.substring(c_start,c_end));
    	}
  	}
	return "";
}

/*
 * setPuCookie
 * -----------
 * Set the cookie with the given information in checkPuCookie
 * in this case: 
 * - Set the cookie name: user
 * - Set the value: PuShown
 * - Set the expiration date
 */
function setPuCookie(c_name,value,expiredays,domain){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	path = "/";

	document.cookie=c_name+"="+escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toUTCString()) + 
	((path) ? ";path=" + path : "" ) + 
	((domain) ? ";domain=" + domain : "" );
}

/*
 * checkPuCookie
 * -------------
 * Check if cookie is set, if not, document write the popunder tag (NOTICE!: the placement ID in the tag only needs to be changed)
 * then create a cookie, in this case the cookie is set for 1 dag ('ligatusPU',ligatusPU,1)
 * To set the cookie for 2 or more days, just change the 1 into a 2.
 * 
 * NOTICE:
 * - Don't forget to set the placement ID in the tag! 
 * - Don't forget to set the correct domain name without trailing www but with the dot!
 * 
 */
function checkPuCookie(){
	ligatusPU=getPuCookie('ligatusPU');
	
	//CHANGE DOMAIN NAME
	domain = '.kaartenhuis.nl';
	if (ligatusPU==null || ligatusPU==""){
		
		//CHANGE POPUNDER PLACEMENT ID
		document.write('<script type="text\/javascript" src="http://d.ligatus.com/?ids=23909&t=js"><\/script>');
		ligatusPU="PuShown";
		if (ligatusPU!=null && ligatusPU!=""){			
			setPuCookie('ligatusPU',ligatusPU,1,domain);
		}
	}
}
