<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function checkContactForm(form)
{
	//reset inputboxes
	inputBoxBorderReset(form.naam);
	inputBoxBorderReset(form.adres);
	//inputBoxBorderReset(form.postcode1);
	//inputBoxBorderReset(form.postcode2);
	inputBoxBorderReset(form.plaatsnaam);
	inputBoxBorderReset(form.netnummer);
	inputBoxBorderReset(form.telefoon);
	inputBoxBorderReset(form.mobiel1);
	inputBoxBorderReset(form.mobiel2);
	inputBoxBorderReset(form.email);
	inputBoxBorderReset(form.opmerkingen);
	
	//First input checks
	if(!checkInputBox(form.naam)) { return false; } else
	if(!checkInputBox(form.adres)) { return false; } else
	
	//Zip check
	//if(!checkInputBox(form.postcode1)) { return false; } else
	//if(!checkInputBox(form.postcode2)) { return false; } else
	//if(inputBoxNotEmpty(form.postcode1) && !checkInputBoxZipCode(form.postcode1, form.postcode2)) { return false; } else
	//if(inputBoxNotEmpty(form.postcode2) && !checkInputBoxZipCode(form.postcode1, form.postcode2)) { return false; } else
	
	//Second input checks
	if(!checkInputBox(form.plaatsnaam)) { return false; } else
	
	//Als telefoonnummer is ingevuld maar niet goed dan error
	if((inputBoxNotEmpty(form.netnummer) || inputBoxNotEmpty(form.telefoon)) && 
		!checkInputBoxPhonenumber(form.netnummer, form.telefoon, true)) { return false; } else
	
	//Als mobielnummer is ingevuld maar niet goed dan error
	if(inputBoxNotEmpty(form.mobiel2) && 
		!checkInputBoxPhonenumber(form.mobiel1, form.mobiel2, true)) { return false; } else
	
	//Als er geen nummer is dan error
	if(!checkInputBoxPhonenumber(form.mobiel1, form.mobiel2, false) &&
		!checkInputBoxPhonenumber(form.netnummer, form.telefoon, false)) 
	{
		alert('U moet minimaal een telefoonnummer of mobielnummer invoeren!');
		return false; 
	} else
	inputBoxBorderReset(form.mobiel1);
	inputBoxBorderReset(form.mobiel2);	
		
	//Email check
	if(!checkInputBoxEmail(form.email)) { return false; } else
	
	//Third input checks
	if(!checkInputBox(form.opmerkingen)) { return false; } else	
	
	//return
	{ return true; }
}

function inputBoxBorderReset(inputBox)
{
	inputBox.style.border = "1px solid #000000";
}

function checkLength(word)
{
	return (word.length >= 1);
}

function inputBoxErrorBorder(inputBox)
{
	inputBox.style.border = "2px solid #FF0000";
	inputBox.focus();
}

function inputBoxNotEmpty(inputBox)
{
	return checkLength(inputBox.value);
}

function checkInputBox(inputBox)
{
	if(!checkLength(inputBox.value)) 
	{
		inputBoxErrorBorder(inputBox);
		return false;
	} else {
		return true;
	}
}

function checkIntputBoxNoInts(inputBox)
{
	if(inputBox.value.indexOf('0') != -1) { return false; } else
	if(inputBox.value.indexOf('1') != -1) { return false; } else
	if(inputBox.value.indexOf('2') != -1) { return false; } else
	if(inputBox.value.indexOf('3') != -1) { return false; } else
	if(inputBox.value.indexOf('4') != -1) { return false; } else
	if(inputBox.value.indexOf('5') != -1) { return false; } else
	if(inputBox.value.indexOf('6') != -1) { return false; } else
	if(inputBox.value.indexOf('7') != -1) { return false; } else
	if(inputBox.value.indexOf('8') != -1) { return false; } else
	if(inputBox.value.indexOf('9') != -1) { return false; } else
	{ return true; }
}

function checkIntputBoxInt(inputBox)
{
	//calc modulo
	var modulo = inputBox.value % 1;
	
	//alert
	if(modulo != 0) 
	{
		inputBoxErrorBorder(inputBox);
		alert("In dit veld is alleen een getal mogelijk!");
		return false;
	} else {
		return true;
	}
}

function checkIntputBoxString(inputBox)
{
	//calc modulo
	var modulo = inputBox.value % 1;
	
	//alert
	if(modulo != 0) 
	{
		return true;
	} else {
		inputBoxErrorBorder(inputBox);
		alert("In dit veld is geen getal mogelijk!");
		return false;
	}
}

function checkInputBoxZipCode(regionCodeInputBox, areaCodeInputBox) 
{
	//totalcount
	var totalcount = (regionCodeInputBox.value.length + areaCodeInputBox.value.length);
	
	//check
	if(checkIntputBoxInt(regionCodeInputBox) && checkIntputBoxNoInts(areaCodeInputBox) && totalcount == 6)
	{ 
		return true;
	} else {
		inputBoxErrorBorder(regionCodeInputBox);
		inputBoxErrorBorder(areaCodeInputBox);
		alert("De combinatie van deze velden bevatten geen geldige postcode!");
		return false;
	}
}

function checkInputBoxPhonenumber(netnumberInputBox, phonenumberInputBox, raise_error)
{
	//totalcount
	var totalcount = (netnumberInputBox.value.length + phonenumberInputBox.value.length);
	//check
	if(checkIntputBoxInt(netnumberInputBox) && checkIntputBoxInt(phonenumberInputBox) && totalcount == 10)
	{ 
		return true;
	} else {
		inputBoxErrorBorder(phonenumberInputBox);
		inputBoxErrorBorder(netnumberInputBox);
		if(raise_error) 
		{
			alert("De combinatie van deze velden bevatten geen geldig telefoonnummer!");
		}
		return false;
	}
}

function checkInputBoxEmail(inputBox) 
{
	if(inputBox.value.indexOf('@') > 0 && inputBox.value.indexOf('.') > 0 && inputBox.value.length > 3 )
	{
		return true;
	} else {
		inputBoxErrorBorder(inputBox);
		alert("In dit veld bevat geen geldig emailadres!");
		return false;
	}
}
