﻿// JScript File


function ShowHideMenuTreeSub(MenuSubToShow)
{
    if (document.getElementById(MenuSubToShow).style.display=='none')
	    {document.getElementById(MenuSubToShow).style.display='block';}
    else
        {document.getElementById(MenuSubToShow).style.display='none';}
}

function confirmDelete() {
    return confirm('Bent u zeker?');
}

function isValidDate(sender,args) {

    var dateStr = args.Value;
	var datePat = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/;

	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
	alert("Foutieve datum")
    args.IsValid = false;
    return;
	}

	year = matchArray[1]; // parse date into variables
	month = matchArray[3];
	day = matchArray[5];

	if (month < 1 || month > 12) { // check month range
	alert("Foutieve maand (1-12)");
    args.IsValid = false;
    return;
	}
	if (day < 1 || day > 31) {
	alert("Foutieve dag (1-31)");
    args.IsValid = false;
    return;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
	alert("Maand "+month+" heeft geen 31 dagen!")
    args.IsValid = false;
    return;
	}
	if (month == 2) { // check for february 29th
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day>29 || (day==29 && !isleap)) {
	alert("Februari " + year + " heeft geen " + day + " dagen!");
    args.IsValid = false;
    return;
	   }
	}
	args.IsValid = true;  // date is valid
}
