/* Functies die aangeroepen kunnen worden vanuit de formulier specifieke validatie */

	function validateEmpty(field){
		$(field).blur(function(){
			if (!emptyTextfield($(this)))
			{
				$(this).css({
					'border' : '1px solid Red'
				});
			}
			else
			{
				$(this).css({
					'border' : border
				});
			}
		});
	}
	
	function validateEmail(field){
		$(field).blur(function(){
			if (!checkEmail($(this)))
			{
				$(this).css({
					'border' : '1px solid Red'
				});
			}
			else
			{
				$(this).css({
					'border' : border
				});
			}
		});
	}
	
	function validateNumeric(field){
		$(field).blur(function(){			
			if (!isNumeric($(this)))
			{
				$(this).css({
					'border' : '1px solid Red'
				});
			}
			else
			{
				$(this).css({
					'border' : border
				});
			}
			
			
		});
	}


/* Hulp functies voor het validaten van velden */





	function emptyTextfield(input){
		if ($(input).val() != "")
			return true;
		else
			return false;
	}
	
	function emptyCheckbox(checkbox){
		if ($(input).attr('checked') != false)
			return true;
		else
			return false;
	}
	
	function checkEmail(input){
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return pattern.test($(input).val());
	}
	
	function isNumeric(input){
		var validChars = "0123456789.";
		var string = $(input).val();
		var isNumber = true;
		var Char;
		
		if (string.length == 0)
			isNumber = false;
		else
		{
			for (var i = 0; i < string.length; i++)
			{
				if (validChars.indexOf(string.charAt(i)) == -1)
					isNumber = false;
			}
		}
		return isNumber;
	}
	
	function isPhoneNumber(input){
		var string = $(input).val();
		var isPhoneNumber = true;
		
		if (string.length == 0)
			isPhoneNumber = false;
		else
		{
			var reg = /^[0-9- ]$/;
			if (reg.test(string) == false)
				isPhoneNumber = false;
			else
				isPhoneNumber = true;
		}
		
		return isPhoneNumber;
	}

