/*
// Project: De Nieuwe Band
// Redesign web site 2005/2006/2007

// JavaScript functions for product browser. Loaded on demand.

// Metalusions - Arjan Haringa
// De Nieuwe Band - Andre Bosma
// De Nieuwe Band - Theo Kerkhof
*/

function checkform(obj){
	var check = true;
	if(document.getElementById){
		var focusfield = false;
		// Check the first name field.
		var f = obj.elements['voornaam'];
		var e = document.getElementById('error--voornaam');
		if(f.value.match(/^..+$/)){
			// No error, reset the field and error message.
			f.style.color = '#000';
			f.style.borderColor = '#000';
			e.style.display = 'none';
			}
		else {
			// Errror detected, apply visual changes.
			f.style.color = '#f00';
			f.style.borderColor = '#f00';
			e.style.display = 'block';
			if(!focusfield){
				focusfield = f;
				}
			check = false;
			}
		// Check the last name field.
		var f = obj.elements['achternaam'];
		var e = document.getElementById('error--achternaam');
		if(f.value.match(/^..+$/)){
			// No error, reset the field and error message.
			f.style.color = '#000';
			f.style.borderColor = '#000';
			e.style.display = 'none';
			}
		else {
			// Errror detected, apply visual changes.
			f.style.color = '#f00';
			f.style.borderColor = '#f00';
			e.style.display = 'block';
			if(!focusfield){
				focusfield = f;
				}
			check = false;
			}
		// Check the first e-mail field.
		var f = obj.elements['email'];
		var e = document.getElementById('error--email');
		if(f.value.match(/^[^@\s]+@([-a-z0-9\u00c0-\u00ff]+\.)+[a-z]{2,}$/i)){
			// No error, reset the field and error message.
			f.style.color = '#000';
			f.style.borderColor = '#000';
			e.style.display = 'none';
			}
		else {
			// Errror detected, apply visual changes.
			f.style.color = '#f00';
			f.style.borderColor = '#f00';
			e.style.display = 'block';
			if(!focusfield){
				focusfield = f;
				}
			check = false;
			}
		// Check the second e-mail field.
		var f = obj.elements['emailcheck'];
		var e = document.getElementById('error--emailcheck');
		if(f.value.match(/^[^@\s]+@([-a-z0-9\u00c0-\u00ff]+\.)+[a-z]{2,}$/i)){
			// No error, reset the field and error message.
			f.style.color = '#000';
			f.style.borderColor = '#000';
			e.style.display = 'none';
			}
		else {
			// Errror detected, apply visual changes.
			f.style.color = '#f00';
			f.style.borderColor = '#f00';
			e.style.display = 'block';
			if(!focusfield){
				focusfield = f;
				}
			check = false;
			}
		// Check if both email addresses that were entered match.
		var f = obj.elements['email'];
		var g = obj.elements['emailcheck'];
		var e = document.getElementById('error--emailmismatch');
		if(f.value == g.value && f.value.length != 0 && g.value.length != 0){
			// No error, reset the field and error message.
			f.style.color = '#000';
			f.style.borderColor = '#000';
			g.style.color = '#000';
			g.style.borderColor = '#000';
			e.style.display = 'none';
			}
		else if(check === true && f.value != g.value){
			// Errror detected, apply visual changes.
			f.style.color = '#f00';
			f.style.borderColor = '#f00';
			g.style.color = '#f00';
			g.style.borderColor = '#f00';
			g.value = '';
			e.style.display = 'block';
			if(!focusfield){
				focusfield = f;
				}
			check = false;
			}
		// Check the type field.
		var f = obj.elements['type'];
		var e = document.getElementById('error--type');
		if(f.options[0].selected === false){
			// No error, reset the field and error message.
			f.style.color = '#000';
			f.style.borderColor = '#000';
			e.style.display = 'none';
			}
		else {
			// Errror detected, apply visual changes.
			f.style.color = '#f00';
			f.style.borderColor = '#f00';
			e.style.display = 'block';
			if(!focusfield){
				focusfield = f;
				}
			check = false;
			}
		// Check the subject field.
		var f = obj.elements['onderwerp'];
		var e = document.getElementById('error--onderwerp');
		if(f.options[0].selected === false){
			// No error, reset the field and error message.
			f.style.color = '#000';
			f.style.borderColor = '#000';
			e.style.display = 'none';
			}
		else {
			// Errror detected, apply visual changes.
			f.style.color = '#f00';
			f.style.borderColor = '#f00';
			e.style.display = 'block';
			if(!focusfield){
				focusfield = f;
				}
			check = false;
			}
		// Check the length of the message field, to check if a message was entered.
		var f = obj.elements['bericht'];
		var e = document.getElementById('error--bericht');
		if(f.value.length > 5){
			// No error, reset the field and error message.
			f.style.color = '#000';
			f.style.borderColor = '#000';
			e.style.display = 'none';
			}
		else {
			// Errror detected, apply visual changes.
			f.style.color = '#f00';
			f.style.borderColor = '#f00';
			e.style.display = 'block';
			if(!focusfield){
				focusfield = f;
				}
			check = false;
			}
		if(!check && focusfield){
			focusfield.focus();
			}
		}
	if(check === true){
		obj.elements[obj.elements.length - 1].disabled = true;
		}
	return check;
	}
