/*
// 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 customer ID field.
		var f = obj.elements['cid'];
		var e = document.getElementById('error--cid');
		if(f.value.match(/^[1-9][0-9]*$/)){
			// 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 company name field.
		var f = obj.elements['bedrijf'];
		var e = document.getElementById('error--bedrijf');
		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 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 phonenumber field.
		var f = obj.elements['telefoon'];
		var e = document.getElementById('error--telefoon');
		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 both condition checkboxes.
		var f = obj.elements['tos'];
		var g = obj.elements['atos'];
		var e = document.getElementById('error--voorwaarden');
		if(f.checked && g.checked){
			// No error, reset the field and error message.
			e.style.display = 'none';
			}
		else {
			// Errror detected, apply visual changes.
			e.style.display = 'block';
			check = false;
			}
		if(!check && focusfield){
			focusfield.focus();
			}
		}
	return check;
	}

// Functions to hide the Bioshop settings when "Nederland" is selected as country (default).

function hidebio(){
	if(document.getElementById){
		document.getElementById('bio1').style.display = 'none';
		document.getElementById('bio2').style.display = 'none';

		// Assign  toggle option to the select to show/hide the bioshop options.
	
		document.forms[0].elements['country'].onchange = function() { togglebio(this); }
		}
	}

// Run the above function on load.

setOnload(hidebio);

// Function to toggle the display of the Bioshop options based on the selected item.

function togglebio(obj){
	// Retrieve the value currently selected.
	
	var country = obj.options[obj.selectedIndex].value;

	// Change the display of the options based on the value.
	
	if(country == 'bel'){
		document.getElementById('bio1').style.display = 'block';
		document.getElementById('bio2').style.display = 'block';
		}
	else {
		document.getElementById('bio1').style.display = 'none';
		document.getElementById('bio2').style.display = 'none';
		}
	}
