	function checkForm(form)
	{
		var alertMsgArr = new Array();
		var noError = true;
		
		if( form.id == 'aanmelden' )
		{
			
			if( !checkInputText( form.gebruikersnaam.value, 'Gewenste inlognaam', alertMsgArr ) ) noError = false;
			else if( !checkInputTextLength( form.gebruikersnaam.value, 8, 'Gewenste inlognaam', alertMsgArr ) ) noError = false;
			else if( !checkChar( form.gebruikersnaam.value, ' ', 'Gewenste inlognaam', alertMsgArr ) ) noError = false;
			
			if( !checkInputText( form.password.value, 'Gewenste password', alertMsgArr ) ) noError = false;
			
			else if( !checkInputTextLength( form.password.value, 6, 'Gewenste password', alertMsgArr ) ) noError = false;
			else if( !checkChar( form.password.value, ' ', 'Gewenste password', alertMsgArr ) ) noError = false;
			
			if( !checkInputText( form.achternaam.value, 'Achternaam', alertMsgArr ) ) noError = false;
			if( !checkInputText( form.voornaam.value, 'Voornaam', alertMsgArr ) ) noError = false;
			
			if( !checkInputText2( form.p_email.value, form.z_email.value, 'Privé emailadres', 'Zakelijk emailadres', alertMsgArr ) ) noError = false;
			
			if( noError ) alert( 'U bent aangemeld. Wij nemen zo snel mogelijk contact met u op als uw account is geactiveerd.' );
			
		}
		if( form.id == 'pz_gegevens' )
		{
			if( !checkInputText( form.achternaam.value, 'Achternaam', alertMsgArr ) ) noError = false;
			if( !checkInputText( form.voornaam.value, 'Voornaam', alertMsgArr ) ) noError = false;
			
			if( !checkInputText2( form.p_email.value, form.z_email.value, 'Privé emailadres', 'Zakelijk emailadres', alertMsgArr ) ) noError = false;
			
		}
		
		if( !noError ) alert( alertMsgArr.join( '\n' ) );
		
		return noError;
	}
	
	function checkInputText( value, name, alertMsgArr )
	{
		if( Trim( value ) == '' )
		{
			add( alertMsgArr, 'U bent verplicht iets in te vullen bij \'' + name + '\'' );
			return false;
		}
		else return true;
	}
	
	function checkInputText2( value1, value2, name1, name2, alertMsgArr )
	{
		if( Trim( value1 ) == '' && Trim( value2 ) == '' )
		{
			add( alertMsgArr, 'U bent verplicht iets in te vullen bij \'' + name1 + '\' of \'' + name2 + '\'' );
			return false;
		}
		else return true;
	}
	
	function checkChar( value, chr, name, alertMsgArr )
	{
		if( value.indexOf( chr ) >= 0 )
		{
			add( alertMsgArr, 'U kunt geen spaties gebruiken bij \'' + name + '\'' );
			return false;
		}
		else return true;
	}
	
	function checkInputTextLength( value, minLength, name, alertMsgArr )
	{
		if( value.length < minLength )
		{
			add( alertMsgArr, 'Bij \'' + name + '\' moet u minimaal ' + minLength + ' karakters invullen' );
			return false;
		}
		else return true;
	}
	
	function add( array, value )
	{
		var alength = array.length;
		array[alength] = value;
	}
	
	function Trim(TRIM_VALUE)
	{
		if(TRIM_VALUE.length < 1) return"";
	
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);
		
		if(TRIM_VALUE=="") return "";
		else return TRIM_VALUE;
	}
	
	function RTrim(VALUE)
	{
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0) return"";
		
		var iTemp = v_length -1;
		
		while(iTemp > -1)
		{
			if(VALUE.charAt(iTemp) == w_space) {}
			else
			{
				strTemp = VALUE.substring(0,iTemp +1);
				break;
			}
			iTemp = iTemp-1;
		}
		
		return strTemp;
	
	}
	
	function LTrim(VALUE)
	{
		var w_space = String.fromCharCode(32);
		if(v_length < 1) return"";
		
		var v_length = VALUE.length;
		var strTemp = "";
		
		var iTemp = 0;
		
		while(iTemp < v_length)
		{
			if(VALUE.charAt(iTemp) == w_space) {}
			else
			{
				strTemp = VALUE.substring(iTemp,v_length);
				break;
			}
			iTemp = iTemp + 1;
		}
		
		return strTemp;
	}
