function openURI() {
var control = document.snelmenu.documentkeuze;
if (control.options[control.selectedIndex].value != 'geen-url') {
location.href = control.options[control.selectedIndex].value;
}
}

function ImageWindow(url, width, height) {
popWin(url,width,height,"toolbar = no, resizable = no");
}

function NewsWindow() {
popWin("news.htm",600,400,"toolbar = no");
}

function DisclaimerWindow() {
popWin("../../disclaimer.htm",760,400,"toolbar = no");
}

// auto-centering popup windows

function popWin(url, width, height, options)
{
	var w = (width) ? width : 400;
	var h = (height) ? height : 400;

	var t = (screen.height) ? (screen.height - h) / 2 : 0;
	var l =	 (screen.width) ? (screen.width - w) / 2 : 0;

	var opt = (options) ? options : 'toolbar = no, location = no, directories = no, '+
		'status = yes, menubalk = no, scrollbars = yes, copyhistory = no, resizable = yes';

	var popped = window.open(url, 'popupwindow',
		'top = '+t+', left = '+l+', width = '+w+', height = '+h+',' + opt);

	popped.focus();
}

function changeDisplayState (id) {
    eDS=document.getElementById(id);
    if (eDS.style.display == 'none' || eDS.style.display == "") {
      eDS.style.display = 'block';
    } else {
      eDS.style.display = 'none';
	}
}


var lastvisit=new Object();
lastvisit.fmsg="welkom";
lastvisit.smsg="welkom terug";

lastvisit.getCookie=function(Name){ //get cookie value
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
	return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

lastvisit.setCookie=function(name, value, days){ //set cookei value
	var expireDate = new Date()
	//set "expstring" to either future or past date, to set or delete cookie, respectively
	var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days))
	document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

lastvisit.showmessage=function(){
	if (lastvisit.getCookie("visitcounter")==""){ //if first visit
	lastvisit.setCookie("visitcounter", 2, 730); //set "visitcounter" to 2 and for 730 days (2 years)
	return lastvisit.fmsg;
	}
else
	 return lastvisit.smsg;
}

lastvisit.nomessage=function(){
	if (lastvisit.getCookie("visitcounter")==""){ //if first visit
	lastvisit.setCookie("visitcounter", 2, 730); //set "visitcounter" to 2 and for 730 days (2 years)
	}
}


function lastMod(taal) {
	arI = 2;
	var iLang = new Array('en','fr','nl');
	var iDays = new Array('days','jours','dagen');
	var iWeeks = new Array('weeks','semaines','weken');
	var iNow = new Array("today","aujourd'hui","vandaag");
	var iYest = new Array('yesterday','hier','gisteren');
	var iHead = new Array('Last update: ','Dernière mis en jour: ','Laatste aanpassing: ')
	var iAgo = new Array('ago ',' avant',' geleden')
	for (var i=0; i<iLang.length; i++) {
    	if (iLang[i] == taal) arI = i;
	}
	var x = new Date (document.lastModified);
	Modif = new Date(x.toGMTString());
	Year = takeYear(Modif);
	Month = Modif.getMonth();
	Day = Modif.getDate();
	Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
	x = new Date();
	today = new Date(x.toGMTString());
	Year2 = takeYear(today);
	Month2 = today.getMonth();
	Day2 = today.getDate();
	now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
	daysago = now - Mod;
	if (daysago < 0) return '';
	unit = iDays[arI];
	if (daysago > 14) {
		daysago = Math.floor(daysago/7);
		unit = iWeeks[arI];
	}
	var towrite = iHead[arI];
	if (daysago == 0) towrite += iNow[arI];
	else if (daysago < 2) towrite += iYest[arI];
	else {
		if (arI == 1) towrite += iAgo[arI] + daysago + ' ' + unit ;
		else towrite += daysago + ' ' + unit + iAgo[arI];
	} 
	return towrite;
}


function takeYear(theDate) {
	var x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

function doFoot(taal) {
	document.write(lastMod(taal)); //
	lastvisit.nomessage();
}

var DDSPEED = 10;
var DDTIMER = 15;

// main function to handle the mouse events //
function ddMenu(id,d,lft){
	var h = document.getElementById(id + '-ddheader');
	var c = document.getElementById(id + '-ddcontent');
	clearInterval(c.timer);
	if (d == 1){
    	clearTimeout(h.timer);
    	if(c.maxh && c.maxh <= c.offsetHeight){return}
    	else if(!c.maxh){
    		c.style.display = 'block';
    		c.style.height = 'auto';
			c.maxh = c.offsetHeight;
			c.style.height = '0px';
			c.style.left= lft+'px';
	    }
	    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
	}else{
		h.timer = setTimeout(function(){ddCollapse(c)},50);
	}
}

// collapse the menu //
function ddCollapse(c){
	c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
	var h = document.getElementById(id + '-ddheader');
	var c = document.getElementById(id + '-ddcontent');
	clearTimeout(h.timer);
	clearInterval(c.timer);
	if(c.offsetHeight < c.maxh){
		c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
	}
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
	var currh = c.offsetHeight;
	var dist;
	if(d == 1){
		dist = (Math.round((c.maxh - currh) / DDSPEED));
	}else{
		dist = (Math.round(currh / DDSPEED));
	}
	if(dist <= 1 && d == 1){
		dist = 1;
	}
	c.style.height = currh + (dist * d) + 'px';
	c.style.opacity = currh / c.maxh;
	c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
	if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
		clearInterval(c.timer);
	}
}

var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

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) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
