// General functions for checking and manipulating input values in form fields
//
// Status: version 1.1
// Changed by: Jan-Willem Vaandrager (july 16, 2003)
//				functions isVisible and setVisible changed for use with Netscape
// Changed by: Boen Kie Hwan and Paul Hagg (march 18, 2003)
//				function formChanged
// Changed by: Jan-Willem Vaandrager (october 1, 2001)
// Changed by: Ingrid Stulp and Robert Guitink (november 14, 2001)

function isNumberLargerThan(inputObject,min) {
	return !isNaN(inputObject.value) && inputObject.value > min;
}
function isNumberLargerEqualThan(inputObject,min) {
	return !isNaN(inputObject.value) && inputObject.value >= min;
}

function isNumberSmallerThan(inputObject,max) {
	return !isNaN(inputObject.value) && inputObject.value < max;
}
function isNumberSmallerEqualThan(inputObject,max) {
	return !isNaN(inputObject.value) && inputObject.value <= max;
}

function isNumberBetween(inputObject,min,max) {
	return !isNaN(inputObject.value) && min <= inputObject.value && inputObject.value <= max;
}

function isFloat(inputObject) {
	return !isNaN(inputObject.value);
}

function isInteger(inputObject) {
	match = /^-?[0-9]*$/;
	return match.test(inputObject.value);
}

// is a time in 'uummss' or 'uu:mm:ss' format,
// where ":" may also be any other non-alphanumeric character
function isTime(inputObj) {
	var input = inputObj.value;
	var hour;
	var minute;
	var second;
	match1 = /^[0-9][0-9]\W[0-9][0-9]$/;
	match2 = /^[0-9][0-9]\W[0-9][0-9]\W[0-9][0-9]$/;
	match3 = /^[0-9][0-9][0-9][0-9]$/;
	match4 = /^[0-9][0-9][0-9][0-9][0-9][0-9]$/;

	match5 = /^[0-9]\W[0-9][0-9]$/;
	match6 = /^[0-9]\W[0-9][0-9]\W[0-9][0-9]$/;
	if (match5.test(input) || match6.test(input)) {
		input = "0" + input;
	}

	if (match1.test(input)) {
		hour = input.substring(0,2);
		minute = input.substring(3,5);
		second = "00";
	} else if (match2.test(input)) {
			hour = input.substring(0,2);
			minute = input.substring(3,5);
			second = input.substring(6,8);
	} else if (match3.test(input)) {
			hour = input.substring(0,2);
			minute = input.substring(2,4);
			second = "00";
	} else if (match4.test(input)) {
			hour = input.substring(0,2);
			minute = input.substring(2,4);
			second = input.substring(4,6);
	} else {
		return false;
	}

	if (hour > 23) {return false;}
	if (minute > 59) {return false;}
	if (second > 59) {return false;}
	inputObj.value = hour + ":" + minute + ":" + second;
	return true;
}

// is a date. The format parameter should be either:
// "dd-MM-yyyy" -> accepts input formats ddMMyyyy or d(d)-M(M)-yyyy,
// "yyyy-MM-dd" -> accepts input formats yyyyMMdd or yyyy-M(M)-d(d),
// where '-' may also be any other non-alphanumerical character
function isDate(inputObj, format) {
	var f;
	if (format == "dd-MM-yyyy"){f=1;}
	else{if (format == "yyyy-MM-dd"){f=2;}else {return false;}}
	var input = inputObj.value;
	var day;
	var month;
	var year;
	match1 = /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/;
	match2 = /^[0-9][0-9]?\W[0-9][0-9]?\W[0-9][0-9][0-9][0-9]$/;
	match3 = /^[0-9][0-9][0-9][0-9]\W[0-9][0-9]?\W[0-9][0-9]?$/;
	match4 = /^[0-9][0-9][0-9][0-9][0-9][0-9]$/;
	match5 = /^[0-9][0-9]?\W[0-9][0-9]?\W[0-9][0-9]$/;
	if (match1.test(input)) {
		if (f == 1){
			day = input.substring(0,2);
			month = input.substring(2,4);
			year = input.substring(4,8);
		}
		if (f == 2){
			day = input.substring(6,8);
			month = input.substring(4,6);
			year = input.substring(0,4);
		}
	}else if ((match2.test(input) && f==1) || (match3.test(input) && f==2)) {
			sep = /\W/;
			var sep1, sep2;
			var i = 0;
			for(i=0;i<input.length;i++){
				if (sep.test(input.charAt(i))){sep1=i; break;}
				}
			for(var j=i+1;j<input.length;j++){
				if (sep.test(input.charAt(j))){sep2=j; break;}
				}
			if (f == 1){
				day = input.substring(0,sep1);
				month = input.substring(sep1+1,sep2);
				year = input.substring(sep2+1,input.length);
			}
			if (f == 2){
				year = input.substring(0,sep1);
				month = input.substring(sep1+1,sep2);
				day = input.substring(sep2+1,input.length);
			}
	}else if (match4.test(input)) {
		if (f == 1){
			day = input.substring(0,2);
			month = input.substring(2,4);
			year = input.substring(4,6);
			yearNow = (new Date()).getFullYear();
			centuryNow = Math.floor(yearNow / 100);
			year = centuryNow * 100 + (+year);
			if (year > yearNow + 20) year -= 100;
		}
	}else if (match5.test(input)) {
			sep = /\W/;
			var sep1, sep2;
			var i = 0;
			for(i=0;i<input.length;i++){
				if (sep.test(input.charAt(i))){sep1=i; break;}
				}
			for(var j=i+1;j<input.length;j++){
				if (sep.test(input.charAt(j))){sep2=j; break;}
				}
			if (f == 1){
				day = input.substring(0,sep1);
				month = input.substring(sep1+1,sep2);
				year = input.substring(sep2+1,input.length);
				if (year < 100) {
					yearNow = (new Date()).getFullYear();
					centuryNow = Math.floor(yearNow / 100);
					year = centuryNow * 100 + (+year);
					if (year > yearNow + 20) year -= 100;
				}
			}
	}else {return false;}

	//if (year < 1900) {return false;}
	if (month < 1 || month > 12) {return false;}
	var daymax;
	if (month==4 || month==6 || month==9 || month==11) {daymax = 30;}
	else {
		if (month==2) {
			if ((year%4==0 && year%100!=0) || year%400==0) {daymax = 29}
			else {daymax = 28;}
			}
		else {daymax = 31;}
	}
	if (day < 1 || day > daymax) {return false;}
	if (day.length == 1){day = "0" + day;}
	if (month.length == 1){month = "0" + month;}
	if (f == 1){inputObj.value = day + "-" + month + "-" + year;}
	if (f == 2){inputObj.value = year + "-" + month + "-" + day;}
	return true;
}

// Returns the current date as isDate(obj) would have filled it in it's input field
function currentDate() {
	// Get the current date&time
	var now   = new Date();

	// Get the day darts
	var day   = ''+now.getDate();
	var month = ''+now.getMonth();
	var year  = ''+now.getYear();

	// Adjust the day parts
	if (day.length == 1) {day = '0'+day;}
	if (month.length == 1) {month = '0'+month;}
	if (year < 100) {year = '19'+year;}

	// Return the current date
	return day + '-' + month + '-' + year;
}

// Removes white space from both ends of a string.
function trim(inputObject) {
	var input = inputObject.value;
	var left=0;
	var right = input.length;
	var i;
	var j;
	for(i=0;i<=right;i++){
		if (input.substring(i,i+1).search(/\u0020/)!=-1)
		{
			left++;
		} else {
			break;
		}
	}
	if (left != right)
	{
		for(j=input.length;j>left;j--){
			if (input.substring(right,right-1).search(/\u0020/)!=-1)
			{
				right--;
			} else {
				break;
			}
		}
	}
	inputObject.value = input.substring(left,right);
	return inputObject;
}

function removeWhitespace(inputObject) {
	var input = inputObject.value;
	var re = / /g;
	input = input.replace(re, '');
	inputObject.value = input;
	return inputObject;
}

function removeSpacesAndDashesAndPoints(inputObject) {
	var input = inputObject.value;
	var re1 = / /g;
	input = input.replace(re1, '');
	var re2 = /\./g;
	input = input.replace(re2, '');
	var re3 = /-/g;
	input = input.replace(re3, '');
	inputObject.value=input;
	return inputObject;
}

function isAlphaNumerical(inputObject) {
	var input = inputObject.value;
	match = /^[0-9a-zA-Z ,:;\.@!\(\)?%*+-=\/\'\"_\\\r\\\n\\\t]+$/;
	if (match.test(input)) {
		return true;
	}
	return false;
}

function isDutchMoney(inputObject) {
	var input = inputObject.value;

	var match = /^[0-9]{1,3}(\.?[0-9]{3})*(,[0-9]{1,2})?$/;

	if (match.test(input)) {
		return true;
	}
	return false;
}

function compareDates(dateValue1, dateValue2){
	if (dateValue1 == "" || dateValue2 == "") return 0;

	var day = dateValue1.substring(0,2);
	var month = dateValue1.substring(3,5);
	var year = dateValue1.substring(6,10);
	var date1 = year + month + day;

	day = dateValue2.substring(0,2);
	month = dateValue2.substring(3,5);
	year = dateValue2.substring(6,10);
	var date2 = year + month + day;

	if (date1 > date2) return 1;
	if (date1 < date2) return -1;
	if (date1 == date2) return 0;
}

function compareTimes(timeValue1, timeValue2){
	if (timeValue1 == "" || timeValue2 == "") return 0;

	var time1 = timeValue1;
	var time2 = timeValue2;

	if (time1 > time2) return 1;
	if (time1 < time2) return -1;
	if (time1 == time2) return 0;
}

// Checks if a number conforms to [0-9][0-9]* or [0-9][0-9]*\.[0-9][0-9]*
function isYearSequenceNumber(inputObj) {
	input = inputObj.value;
	year = new Date().getYear();
	if (year < 100) { year += 1900; }

	match1 = /^[0-9][0-9][0-9][0-9]\.[0-9]{1,4}$/;
	match2 = /^[0-9]{1,4}$/;
	if (match1.test(input)) {
		year = input.substr(0,4);
		sequenceNumber = "000"+input.substr(5);
		sequenceNumber = sequenceNumber.substr(sequenceNumber.length-4, sequenceNumber.length);
		inputObj.value = year+"."+sequenceNumber;
		return true;
	} else if (match2.test(input)) {
		sequenceNumber = "000"+input;
		sequenceNumber = sequenceNumber.substr(sequenceNumber.length-4, sequenceNumber.length);
		inputObj.value = year+"."+sequenceNumber;
		return true;
	} else {
		return false;
	}
}

function isDutchPhoneNumber(inputObject) {
	var input = inputObject.value;
	match1 = /^[0-9 -]+$/;
	if (!match1.test(input)) {
		return false;
	}

	var i;
	var num = 0;
	match2 = /^[0123456789]/;
	for(i=0;i<input.length;i++){
		var sub = input.substr(i,i+1);
		if (match2.test(sub)){num++;}
	}
	if (num != 10){return false;}
	return true;
}

function isPhoneNumber(inputObject) {
	var input = inputObject.value;
	match1 = /^[0-9]+$/;
	if (!match1.test(input)) {
		return false;
	}

	return true;
}

function isEmailAddress(inputObject) {
	// An email address contains (in this order):
	// - Some characters
	// - An at-sign (@)
	// - Some characters
	// - A period (.)
	// - Some characters
	//var legalchar = "[^ ,;\"\'\\(\\)\\[\\]<>\&]";
	//var legalcharNoPeriod = "[^ ,;\"\'\\(\\)\\[\\]\\.<>\&]";
	//return conformsToRegexp(inputObject, "^" + legalchar + "+\\@" + legalchar + "+\\." + legalchar + "*" + legalcharNoPeriod + "}}}$");
	// Onderstaande expressie is door Van Dijk aangeleverd en vervangt bovenstaande 3 regels.
	return conformsToRegexp(inputObject, "^([-!#$%*+/=?^_`{}~A-Za-z0-9]+[-!#$%*.+/=?^_`{}~A-Za-z0-9]*[-!#$%*+/=?^_`{}~A-Za-z0-9]+|[-!#$%*+/=?^_`{}~A-Za-z0-9])@([A-Za-z0-9_-][A-Za-z0-9._-]*[A-Za-z0-9_-])+[.][A-Za-z]{2,6}$");
}	


function isBankAccountNumber(inputObject) {
	if (!conformsToRegexp(inputObject, "^([0-9]{7}|[0-9]{6})([0-9]{3})?$"))
	{
		return false;
	}

	var accountNumberStr = inputObject.value;
	if (accountNumberStr.length > 8) {
		// We're dealing with a bank account number. Check againt the "11-proef":
		// Step 1: add these numbers:
		//     - The first digit times 10
		//     - The second digit times 9
		//       ...
		//     - The tenth digit times 1
		// Step 2: check if the result is divisible by 11. If so, the "11-proef" succeeds.

		// We need 10 digits; prefix a zero if nescessary.
		if (accountNumberStr.length == 9) {
			accountNumberStr = "0" + accountNumberStr;
		} else {
			// 10 cijferige rekeningnummers zijn tijdelijk nog niet toegestaan
			return false;
		}

		// Step 1
		var count, multiply, digit, total, temp;
		total = 0; // When we start adding numbers, we have nothing.
		for (count = 0; count < 10; count++) {
			multiply = 10 - count;								// Counts 10, 9, 8, ..., 1
			digit = parseInt(accountNumberStr.charAt(count));	// Gets a single digit.
			temp = multiply * digit;
			total = total + temp;								// Add to the sum
		}

		// Step 2
		var remainder = total % 11; // If remainder==0, total is divisible by 11.
		if (remainder != 0) {
			return false;
		}
	}

	return true;
}

function isISBNumber(inputObject) {	
	// Controleer de lengte van het veld
	if(inputObject.value.length != 10 && inputObject.value.length != 13) {
		return false;
	}
	
	// Controleer de inhoud van het veld, alleen de laatste char mag een 'x' zijn
	if (!conformsToRegexp(inputObject, "^([0-9])*([0-9Xx])$"))
	{
		return false;
	}
	
	var isbNumberStr = inputObject.value;
	// Controleren of lengte 10 is en laatste char geen x/X.
	if(isbNumberStr.length == 10 && isbNumberStr.charAt(9) != 'X' && isbNumberStr.charAt(9) != 'x') {
		
		// We're dealing with a 10 digit isb number. Check againt the "11-proef":
		// Step 1: add these numbers:
		//     - The first digit times 10
		//     - The second digit times 9
		//       ...
		//     - The tenth digit times 1
		// Step 2: check if the result is divisible by 11. If so, the "11-proef" succeeds.
	
		// Step 1
		var count, multiply, digit, total, temp;
		total = 0; // When we start adding numbers, we have nothing.
		for (count = 0; count < 9; count++) {
			multiply = 10 - count;								// Counts 10, 9, 8, ..., 1
			digit = parseInt(isbNumberStr.charAt(count));		// Gets a single digit.
			temp = multiply * digit;
			total = total + temp;								// Add to the sum
		}
		
		digit = parseInt(isbNumberStr.charAt(9));		// Gets a single digit.
		total = total + digit;		
	

		// Step 2
		var remainder = total % 11; // If remainder==0, total is divisible by 11.
		if (remainder != 0) {
			return false;
		}
	// Controleer of lengte 13 is en laatste char geen x/X.
	} else if(isbNumberStr.length == 13 && isbNumberStr.charAt(12) != 'X' && isbNumberStr.charAt(12) != 'x' ) {
		// We're dealing with a 13 digit isb number. Check againt the "11-proef":
		// Step 1: add these numbers:
		//     	- The first digit times 1
		//     	- The second digit times 3
		//		- The third ditit times 1
		//       ...
		//     	- The twelfth digit times 3
		// Step 2: Determine the remainder from the total from step 1 after dividing it with 10
		// Step 3: Check if the thirteenth digit equals 10 - the result from step 2.
	
		// Step 1
		var count, multiply, digit, total, temp;
		total = 0; // When we start adding numbers, we have nothing.
		for (count = 0; count < 12; count++) {
			
			if(multiply == 1) {
				multiply = 3;
			} else {
				multiply = 1;
			}
			digit = parseInt(isbNumberStr.charAt(count));		// Gets a single digit.
			temp = multiply * digit;
			total = total + temp;								// Add to the sum
		}
	
		// Step 2
		var remainder = total % 10; // If remainder==0, total is divisible by 10.

		// Step 3
		var checkNumber = 10 - remainder;
		if(checkNumber == 10) {
			checkNumber = 0;
		}
		if (parseInt(isbNumberStr.charAt(12)) - checkNumber != 0) {
			return false;
		}
	}
	return true;
}


function isDutchLicencePlate(inputObject) {
	return conformsToRegexp(inputObject, "^([0-9a-zA-Z]{2}[-]){2}[0-9a-zA-Z]{2}$");
}

// Checks if a string conforms to a given regular expression regexp. regexp can look like this in your code:
// /^[a-zA-Z][a-zA-z]$/ . Don't forget the /'s. Don't put "'s around it in your code, just the regular expression.
function conformsToRegexp(inputObject, regexp) {
	var input = inputObject.value;
	match = new RegExp(regexp);
	if (match.test(input))
	{
		return true;
	}
	else
	{
		return false;
	}
}

// This function determines the element type of a form element
function getFormElementType(el) {
	// If nescessary, resolve the first element of an array
	// (radio buttons are typically ordered this way)
	var el0 = el;
	if (typeof el0.tagName == "undefined") {
		el0 = el[0];
	}

	// Resolve the element type
	var eltype = el0.tagName;
	if (eltype == "INPUT") {
		eltype = "INPUT/"+el0.type.toUpperCase();
	}

	return eltype;
}

// This function checks whether the user has changed an input field
function formChanged(document){
	for (d = 0; d < document.forms.length; d++) {
		var formObj = document.forms[d];
		for (i = 0; i < formObj.length; i++) {
			var el = formObj.elements[i];
			if (el.disabled) continue;
			var eltype = getFormElementType(el);
			

			if (eltype == "INPUT/TEXT") {
				if (el.value != el.defaultValue) {
					return true;
				}
			}
			if (eltype == "INPUT/RADIO") {
				if (el.checked != el.defaultChecked) {
					return true;
				}
			}
			if (eltype == "INPUT/CHECKBOX") {			
				if (el.checked != el.defaultChecked) {
					return true;
				}
			}
			if (eltype == "SELECT") {
				for (j = 0; j < el.length; j++) {
					if (el[j].selected != el[j].defaultSelected) {
						return true;
					}
				}
			}
			if (el.tagName == "TEXTAREA") {
				if (el.value != el.defaultValue) {
					return true;
				}
			}
		}
	}
	return false;
}


function clearField(el){
	var eltype = getFormElementType(el);

	if (eltype == "INPUT/TEXT") {
		el.value = "";
	}
	if (eltype == "INPUT/RADIO") {
		for (j=0; j<el.length; j++) {
			el[j].checked = false;
		}
		// A radio button has a hidden field with the same prefix.
		// (the radio buttons themselves are suffixed with "_radio")
		var elementName = el[0].name;
		var companionName = elementName.substring(0, elementName.length-6);
		el[0].form.elements[companionName].value="";
	}
	if (eltype == "INPUT/CHECKBOX") {
		// Instead of deselecting manually, let the element take care of it.
		// The element will set the inevitable hidden field to the right value.
		if (el.checked) {
			el.click();
		}
	}
	if (eltype == "SELECT") {
		for (j = 0; j < el.length; j++) {
			if (el[j].value == "") {
				el[j].selected = true;
			} else {
				el[j].selected = false;
			}
		}
	}
	if (eltype == "TEXTAREA") {
		el.value = "";
	}
}

function resetField(el){
	var eltype = getFormElementType(el);

	if (eltype == "INPUT/TEXT") {
		el.value = el.defaultValue;
	}
	if (eltype == "INPUT/RADIO") {
		// A radio button has a hidden field with the same prefix.
		// (the radio buttons themselves are suffixed with "_radio")
		var elementName = el[0].name;
		var companionName = elementName.substring(0, elementName.length-6);
		var companionElement = el[0].form.elements[companionName];
		companionElement.value = "";

		// Now fill the cleared field
		for (j=0; j<el.length; j++) {
			if (el[j].defaultChecked) {
				companionElement.value = el[j].value;
			}
			el[j].checked = el[j].defaultChecked;
		}
	}
	if (eltype == "INPUT/CHECKBOX") {
		// Instead of (de)selecting manually, let the element take care of it.
		// The element will set the inevitable hidden field to the right value.
		if (el.checked != el.defaultChecked) {
			el.click();
		}
	}
	if (eltype == "SELECT") {
		for (j = 0; j < el.length; j++) {
			el[j].selected = el[j].defaultSelected;
		}
	}
	if (eltype == "TEXTAREA") {
		el.value = el.defaultValue;
	}
}

// Function that tells whether a form element is enabled.
function isEnabled(el) {
	var eltype = getFormElementType(el);

	// Get the disabled status of the element.
	if (
		eltype == "INPUT/TEXT"     ||
		eltype == "INPUT/CHECKBOX" ||
		eltype == "SELECT"         ||
		eltype == "TEXTAREA"
	) {
		return !el.disabled;
	}
	if (eltype == "INPUT/RADIO") {
		// A radio button array is enabled is all radio buttons are enabled.
		var enabled = true;
		for (j=0; j < el.length; j++) {
			if (el[j].disabled) {enable = false;}
		}
		return enabled;
	}
}

// Function that enables or disabled a form element.
function setEnabled(el, newEnabled) {
	var eltype = getFormElementType(el);

	// Set disabled status of the element.
	if (
		eltype == "INPUT/TEXT"     ||
		eltype == "INPUT/CHECKBOX" ||
		eltype == "SELECT"         ||
		eltype == "TEXTAREA"
	) {
		el.disabled = !newEnabled;
	}
	if (eltype == "INPUT/RADIO") {
		for (j=0; j < el.length; j++) {
			el[j].disabled = !newEnabled;
		}
	}
}

// Sets the focus to the specified form element.
// If the form element is an array, sets the focus to the first element.
function setFocus(el) {
	var eltype = getFormElementType(el);
	if (el.length != null && eltype != "SELECT"){
		eltype = getFormElementType(el[0]);
	}
	if (eltype == "INPUT/TEXT" ||
		eltype == "INPUT/CHECKBOX" ||
		eltype == "INPUT/PASSWORD" ||
		eltype == "INPUT/BUTTON" ||
		eltype == "SELECT" ||
		eltype == "TEXTAREA" ||
		eltype == "INPUT/RADIO") {
		// The timeout is to work around a bug in IE:
		// If you set the focus to a text field within 10ms from a focus switch, it doesn't work.
		// Result: you cannot refocus a field after an input check without this timeout.
		if (el.length != null && eltype != "SELECT") {
			setTimeout("document.forms['form']."+el[0].name+"[0].focus()", 10);
		}else{
			setTimeout("document.forms['form']."+el.name+".focus()", 10);
		}
	}
}


// Function to get the visibility of a named page element.
// A page element gets a name by speficying it's ID attribute: ID="name"
//
function isVisible(elementName) {
	var object;
	if (document.all){
		object = document.all(elementName);
	}
	if(!document.all && document.getElementById){
		object = document.getElementById(elementName);
	}

	if (object.style.visibility == "hidden") {
		return false;
	} else {
		return true;
	}
}

// Function to set the visibility of a named page element.
// A page element gets a name by speficying it's ID attribute: ID="name"
//
// The parameter usesSpaceIfHidden determines wether an invisible element
// is hidden (true), or not displayed at all (false).
//
function setVisible(elementName, usesSpaceIfHidden, isVisible) {
	var object;
	if (document.all){
		object = document.all(elementName);
	}
	if(!document.all && document.getElementById){
		object = document.getElementById(elementName);
	}

	object.style.display = (isVisible || usesSpaceIfHidden ? "inline" : "none");
	object.style.visibility = (isVisible ? "visible" : "hidden");
}

//Reset the fields on the form
function resetForm(resetButton){
	var formObj = resetButton.form;
	var i;
	for(i=0;i<formObj.elements.length;i++){
		if (formObj.elements[i].type == "text") formObj.elements[i].value = "";
		if (formObj.elements[i].type == "select-one") formObj.elements[i].value = "";
		if (formObj.elements[i].type == "radio") formObj.elements[i].checked = false;
		if (formObj.elements[i].type == "checkbox") formObj.elements[i].checked = false;
	}
}

function isDutchPostalCode(inputObj) {
	var input = inputObj.value;
	var part1;
	var part2;
	match1 = /^[0-9]{4}[a-zA-Z]{2}$/;		// Pairs must be 4 nummbers and 2 characters without ' '
	match2 = /^[0-9]{4} [a-zA-Z]{2}$/;		// Pairs must be 4 nummbers and 2 characters with ' '

	if (match1.test(input)) {
		part1 = input.substring(0,4).toUpperCase();
		part2 = input.substring(4,6).toUpperCase();
	} else if (match2.test(input)) {
		part1 = input.substring(0,4).toUpperCase();
		part2 = input.substring(5,7).toUpperCase();
	} else {
		return false;
	}

	inputObj.value = part1+" "+part2;
	return true;
}


/**
 * Van: http://www.aspnl.com/aspnl/nl/forums/ShowPost.aspx?PostID=4194
 * en aangepast.
 */
function isDutchBankAccountNumber(inputObj) {
	var val   = inputObj.value;
	var total = 0; 
	if(val.length != 9) return false;
	for(var c = 0; c < val.length; c++) 
		total = total + parseInt((val.substring(c, c + 1) * (9 - c))); 
	// totaal deelbaar door elf?
	//if (((total / 11) + '').indexOf('.') > 0) 
		//return false;
	return ((total % 11) == 0);
}

function isDutchGiroAccountNumber(inputObj) {
	return (inputObj.value.length < 8);
}