

ErrEmpty = 'Vult u a.u.b. de rood omrande velden in'; 
ErrMaxLen = 'The text you applied is too long, the maximum length is ';
Kar= ' characters'
ErrEmail = 'Vult u a.u.b. een geldig e-mailadres in';
ErrURL = 'U heeft geen internetadres ingevoerd, of de waarde die u heeft ingevoerd is geen geldig adres. Door met uw muis over de informatieknop te gaan, kunt u zien hoe het internetadres moet worden ingevoerd';
ErrRadio = 'U heeft bij de keuzerondjes geen optie aangeklikt, u moet hier 1 optie kiezen.';
ErrNum = 'You filed an invalid value, you can only use numeric values here (Check red field)';
ErrDatum = 'U heeft geen datum ingevoerd, of de waarde die u heeft ingevoerd voor de datum is niet goed. Door met uw muis over de informatieknop te gaan, kunt u zien hoe de datum moet worden ingevoerd';
ErrNoSpace = 'U hebt spaties gebruikt in een veld waar dit niet mag'
ErrWachtwoord = 'Dit is geen geldig wachtwoord';
ErrInlogNaam = 'Dit is geen geldige inlognaam';

NumPath = /^[0-9]+$/;
CijferPath = /^([0-9]+(\.|\,)][0-9]+)|([0-9]+)$/;
EmailPath = /^.+@.+\.[A-Za-z]{2,4}$/;
URLPath = /^.+\.[A-Za-z]{2,3}(\/[^\/]+)*\/?$/;
TimePath = /^(0*[0-9]|1[0-9]|2[0-3])(:|\.)[0-5]\d$/;
NoSpacePath = /^.+$/;
EmptyPath = /^(\s*\n?)*$/;  // alleen spaties of regeleinden
WachtwoordPath = /^\S{4,16}$/;

function PlaceFocus()
// Plaatst de focus op het eerste veld waar een waarde kan worden ingevoerd.
{
	if (document.forms.length > 0)
	{
		var field = document.forms[0];
		for (i = 0; i < field.length; i++)
		{
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s"))
			{
				document.forms[0].elements[i].focus();
				break;
         	}
      	}
   }
} //  Einde functie Focus

function ValidateOnSubmit(strInput, ErrMsg, Path, booMagLeegZijn)
// Controleert of de invoer leeg mag zijn, en voldoet aan invoervoorwaarden.
{
	if (((strInput.value == '') && (booMagLeegZijn)) || (Path.exec(strInput.value)))
			{return true;   }
	else 	
			{alert(ErrMsg); return false}
} // einde ValidateOnSubmit

function ValidateOnBlur(strInput, Path, booMagLeegZijn)
// Controleert of de invoer leeg mag zijn, en voldoet aan invoervoorwaarden.
{
	if (((strInput.value == '') && (booMagLeegZijn)) || (Path.exec(strInput.value)))
			{ strInput.className = 'nofocus';}
	else 	
			{ strInput.className = 'verplicht';}
} // einde ValidateOnBlur


function ValidateTextOnBlur(strInput)
{ if ((strInput.value == '') || EmptyPath.exec(strInput.value))
	// Fout! De invoerstring mag NIET leeg zijn.
			{ strInput.className = 'verplicht';}
	else
			{ strInput.className = 'nofocus';}
} // einde ValidateText OnBlur


function ValidateTextOnSubmit(strInput)
{	
	if ((strInput.value == '') || EmptyPath.exec(strInput.value))
	// Fout! De invoerstring mag NIET leeg zijn.
			{ alert(ErrEmpty); return false;}
	else
			{ return true;}
} // einde ValidateText OnSubmit

function ValidateTextareaOnBlur(strInput, intMaxLen, booMagLeegZijn)
{	if ( (strInput.value == '') || EmptyPath.exec(strInput.value) )
	// De invoerstring is leeg
	{	if (booMagLeegZijn)
		// Niets aan de hand, de invoerstring mag ook leeg zijn.
			{ strInput.className = 'nofocus';}
		else
		// Fout! De invoerstring mag NIET leeg zijn.
			{ strInput.className = 'verplicht';}
	}
	else
	// De invoerstring is niet leeg
	{	if (strInput.value.length > intMaxLen)
		// Fout! De invoerstring is te lang.
			{ strInput.className = 'verplicht';}
		else
		// De invoer is goed.
			{ strInput.className = 'nofocus';}
	}
} // einde ValidateText OnBlur


function ValidateTextareaOnSubmit(strInput, intMaxLen, booMagLeegZijn)
{ if ( (strInput.value == '') || EmptyPath.exec(strInput.value) )
	// De invoerstring is leeg
	{ if (booMagLeegZijn)
		// Niets aan de hand, de invoerstring mag ook leeg zijn.
		{ return true; }
		else
		// Fout! De invoerstring mag NIET leeg zijn.
		{ alert (ErrEmpty);
		  return false;  }
	}
	else
	// De invoerstring is niet leeg
	{	if (strInput.value.length > intMaxLen)
		// Fout! De invoerstring is te lang.
		{ alert (ErrMaxLen + intMaxLen + Kar);
		  return false;	}
		else
		// De invoer is goed.
		{ return true; }
	}
} // einde ValidateText OnSubmit


function ValidateRadioOnSubmit(arrInput)
{
	booAangeklikt = false;
	for (i=0; i<arrInput.length; i++)
		{ if (arrInput[i].checked == true) {return true;}}
	alert(ErrRadio);
	return false;
} // einde ValidateRadio OnSubmit

function SearchSeparator(Datum)
// Deze functie bekijkt welke separator is gebruikt in het datumveld
{
	strSeparatorArray = new Array("-"," ","/",".");
	for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++)
	{
		if (Datum.indexOf(strSeparatorArray[intElementNr]) != -1) 
		{	
			formulier.separator.value = (strSeparatorArray[intElementNr]);
			return (strSeparatorArray[intElementNr]);
		}
	}	
	return "*";
}


function MaxDayPerMonth(Month, Year)
// Deze functie kijkt hoeveel dagen er in een bepaalde maand zitten
{
	if ((Month == 4) || (Month == 6) || (Month == 9) || (Month == 11)) 
		return 30;
	else
	{
		if ((Month == 2) && ((Year%4) != 0))
		// Geen schikkeljaar
			return 28;
		else
		{	
			if ((Month == 2) && ((Year%4) == 0))
		// Schikkeljaar
				return 29;
			else
		//Alle overige maanden hebben 31 dagen
				return 31;
		}
	}
} // einde functie MaxDayPerMonth


function CheckDatum (strDate) 
{ // begin functie
	
	strSeperator = SearchSeparator(strDate.value);
	if (strSeperator == "*")
		{ return false; }
	strDateArray = strDate.value.split(strSeperator);
	Len = strDateArray.length;
	if ((Len != 2) && (Len != 3)) 
		{ return false; }
	else 
		{
		// Als er een jaartal is, controleer deze:
		if ( Len == 3)        
		{	
			intYear = parseInt(strDateArray[2],10);
			if ( (isNaN(intYear)) || (intYear > 3000) || (intYear < 0) )
				return false
		}
		else
		// Er is geen jaartal ingevoerd, neem huidige jaar
		{
			Today = new Date();
			intYear = Today.getYear();
		}
		
		// Controleren van de invoer voor de maand:		
		intMonth = parseInt(strDateArray[1],10);
		if ( (isNaN(intMonth)) || (intMonth > 12) || (intMonth < 1) )
			return false;
		else
		{	// Controleren van de invoer voor de dag:
			MaxDay = MaxDayPerMonth(intMonth, intYear);
			intDay = parseInt(strDateArray[0],10);
			if ( (isNaN(intDay)) || (intDay > MaxDay) || (intDay < 1) )
			{
				alert (ErrDatum);
				return false;
			}
			else
				return true;
		}
	} // goede aantal arrays
} // einde functie


function ValidateDateOnSubmit(strInput, booMagLeegZijn)
// Controleert of de invoer leeg mag zijn, en voldoet aan invoervoorwaarden.
{
	if (((strInput.value == '') && (booMagLeegZijn)) || (CheckDatum(strInput)))
			{return true;   }
	else 	
			{alert(ErrDatum); return false}
} // einde ValidateDateOnSubmit


function ValidateDateOnBlur(strInput, booMagLeegZijn)
// Controleert of de invoer leeg mag zijn, en voldoet aan invoervoorwaarden.
{	
	if (((strInput.value == '') && (booMagLeegZijn)) || (CheckDatum(strInput)))
			{ strInput.className = 'nofocus';}
	else 	
			{  strInput.className = 'verplicht';}
} // einde ValidateDateOnBlur

