function y2k(number) { 
	return (number < 1000) ? number + 1900 : number; 
}
function windowOpen(welkefile,width,height,menubar,scrollbars,status,toolbar,resizable) {
	var features =
		 'height='       + height +
		 ',width='       + width +
		 ',status='      + status +
		 ',toolbar='     + toolbar +
		 ',menubar='     + menubar +
		 ',scrollbars='  + scrollbars +
		 ',resizable='   + resizable;
	nieuw=window.open ('', 'nieuw', features);
	nieuw.location.href=welkefile
	if(nieuw.opener==null){
		nieuw.opener=self;

	}
	nieuw.focus();
}
function isValidDate (myDate,sep) {
// checks if date passed is in valid dd-mm-yyyy format
    if (myDate.length == 10) {
        if (myDate.substring(2,3) == sep && myDate.substring(5,6) == sep) {
            var date  = myDate.substring(0,2);
            var month = myDate.substring(3,5);
            var year  = myDate.substring(6,10);

            var test = new Date(year,month-1,date);

            if (year == y2k(test.getYear()) && (month-1 == test.getMonth()) && (date == test.getDate())) {
                return true;
            }
            else {
				reason = 'datum bestaat niet'
                return false;
            }
        }
        else {
            reason = 'gebruik - om dag, maand en jaar te scheiden.';
            return false;
        }
    }
    else {
        reason = 'onjuiste lengte';
        return false;
    }
}

function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function trim(strText) { 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
   return strText;
}
