
	function Form (sId) {
		
		this.id = sId;
		
		OnLoadObject (this);
		
	}
	
	
	Form.prototype.init = function () {
		
		this.form = document.getElementById (this.id);
		this.message = new Melding ();
		
	}
	
	
	Form.prototype.checkAndSubmit = function () 
	{		
		this.preSubmit ();		
		var sSubmitData = '';
		
		for (var i = 0; i < this.form.length; i++) 
		{
					sSubmitData += this.form[i].name + ' = ' + this.form[i].value + '\n';
		}
		
		if (oPage.debug)
		{
			alert (sSubmitData);
		}
		if (this.valuesCheck ())
		{
			this.form.submit ();
		}		
	}
	
	
	Form.prototype.preSubmit = function () 
	{		
	}
		
	Form.prototype.valuesCheck = function () 
	{
	}
		
	Form.prototype.fieldError = function (oField, sMessage) {
		
		var errorField = oField;
		var sDebugMessage = '';
		
		if (errorField) {
			
			if (errorField.length > 1) {
				
				errorField = errorField[0];
				
				sDebugMessage = ' (fout: ' + oField.length + ' velden gevonden)';
				
			}
			
		}
		
		this.message.openDialog (sMessage + sDebugMessage);
		
		if (errorField) {
			errorField.focus ();
			errorField.select ();
		}
		
		return false;
		
	}
	
	
	Form.prototype.IsEmpty = function (sValue) {
		
		var sValueTrimmed = sValue.replace(/^\s*|\s*$/g, '');
		
		if (sValueTrimmed.length == 0)
			return true;
		else
			return false;
		
	}
	
	
	Form.prototype.IsPostalCode = function (sValue) {
		
		var sPostcodeClean = sValue; //.replace(/\s/g, '');
		var rePattern = /\d{4}[ ]?[a-zA-Z]{2}/;
		
		if (rePattern.exec(sPostcodeClean) == null)
			return false;
		else 
			return true;
		
	}


	Form.prototype.IsPercentage = function (sValue) {
		
		if (isNaN (sValue))
			return false;
		
		var iValue = parseInt (sValue);
		
		if (iValue >= 0 && iValue <= 100)
			return true;
		else
			return false;
		
	}
	

	Form.prototype.IsAmount = function (sValue) {
		
		var sDecimalSeperator = ',';
		var arrayAmount = sValue.split (sDecimalSeperator);
		
		if (arrayAmount.length > 2)
			return false;
		
		if (sValue.length == 0)
			return false;
		
		if (isNaN (sValue))
			return false;
		
		return true;
		
	}


	Form.prototype.IsDate = function (sValue) {
		
		var arrayDateString = sValue.split ('.');
		
		var iDay = parseInt (arrayDateString[0]);
		var iMonth = parseInt (arrayDateString[1]) - 1;
		var iYear = parseInt (arrayDateString[2]);
		
		var dDate = new Date ();
		
		dDate.setFullYear (iYear);
		dDate.setMonth (iMonth);
		dDate.setDate (iDay);
		
		if (dDate.getDate () != iDay || dDate.getMonth () != iMonth || dDate.getFullYear () != iYear)
			return false;
		
		return true;
		
	}
	
	
	Form.prototype.IsEmail = function (str) {
		var supported = 0;
		if (window.RegExp) {
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if (tempReg.test(tempStr)) supported = 1;
		}
		if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,6}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(str) && r2.test(str));
	}
	
	
	Form.prototype.IsURL = function (sValue) {
		
		var rePattern = /(http|https|ftp)(:\/\/)(.)*/;
		
		if (rePattern.exec(sValue) == null) 
			return false;
		else 
			return true;
		
	}
