// Controleer contactformulier
function checkPart() {
	var blnOk = true;
	if (blnOk) {
		if (document.particulier.partnaam.value=="")
			{
			alert("Vul uw naam in");
			blnOk = false;
			document.particulier.partnaam.focus();
			event.returnValue = false ;
			}
	}
	
	if (blnOk) {
		if (document.particulier.partadres.value=="")
			{
			alert("Vul uw adres in");
			blnOk = false;
			document.particulier.partadres.focus();
			event.returnValue = false ;
			}
	}
	
	if (blnOk) {
		if (document.particulier.partpostcode.value=="")
			{
			alert("Vul uw postcode in");
			blnOk = false;
			document.particulier.partpostcode.focus();
			event.returnValue = false ;
			} else {
				if (!checkPostcode(document.particulier.partpostcode.value))
				{
				alert("U heeft een ongeldige postcode ingevuld");
				blnOk = false;
				document.particulier.partpostcode.focus();
				document.particulier.partpostcode.value = '';
				event.returnValue = false;}
			}
	}
	
	if (blnOk) {
		if (document.particulier.partplaats.value=="")
			{
			alert("Vul uw woonplaats in");
			blnOk = false;
			document.particulier.partplaats.focus();
			event.returnValue = false ;
			}
	}
	
	if (blnOk) {
		if (document.particulier.parttel.value=="")
			{
			alert("Vul uw telefoonnummer in");
			blnOk = false;
			document.particulier.parttel.focus();
			event.returnValue = false ;
			} else {
				if (!isTelNummer(document.particulier.parttel.value))
				{
				alert("Het door u ingevulde telefoonummer is onjuist");
				blnOk = false;
				document.particulier.parttel.focus();
				document.particulier.parttel.value = '';
				event.returnValue = false;}
			}
	}
	
	if (blnOk) {
		if (document.particulier.partmail.value=="")
			{
			alert("Vul uw e-mailadres in.");
			blnOk = false;
			document.particulier.partmail.focus();
			event.returnValue = false ;
			} else {
				if (!checkEmail(document.particulier.partmail.value))
				{
				alert("U heeft een ongeldig e-mailadres ingevuld.");
				blnOk = false;
				document.particulier.partmail.focus();
				document.particulier.partmail.value = '';
				event.returnValue = false;}
			}
	}
	
	if (blnOk) {
		if (document.particulier.partaantal.value=="")
			{
			alert("Vul het gewenste aantal passen in");
			blnOk = false;
			document.particulier.partaantal.focus();
			event.returnValue = false ;
			} else {
				if (!isTelNummer(document.particulier.partaantal.value))
				{
				alert("Het aantal kan alleen uit cijfers bestaan");
				blnOk = false;
				document.particulier.partaantal.focus();
				document.particulier.partaantal.value = '';
				event.returnValue = false;}
			}
	}

	if (blnOk) {
		if (document.particulier.partverbruik.value=="")
			{
			alert("Vul het geschatte maandverbruik brandstof in");
			blnOk = false;
			document.particulier.partverbruik.focus();
			event.returnValue = false ;
			} else {
				if (!isTelNummer(document.particulier.partverbruik.value))
				{
				alert("Het aantal kan alleen uit cijfers bestaan");
				blnOk = false;
				document.particulier.partverbruik.focus();
				document.particulier.partverbruik.value = '';
				event.returnValue = false;}
			}
	}

if (blnOk) {
		document.particulier.submit();
	}
}

/////////////////////////////////////////////////////////////////////////
function checkZak() {
	var blnOk = true;
	if (blnOk) {
		if (document.zakelijk.zakbedrijfsnaam.value=="")
			{
			alert("Vul uw bedrijfsnaam in");
			blnOk = false;
			document.zakelijk.zakbedrijfsnaam.focus();
			event.returnValue = false ;
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakadres.value=="")
			{
			alert("Vul uw adres in");
			blnOk = false;
			document.zakelijk.zakadres.focus();
			event.returnValue = false ;
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakpostcode.value=="")
			{
			alert("Vul uw postcode in");
			blnOk = false;
			document.zakelijk.zakpostcode.focus();
			event.returnValue = false ;
			} else {
				if (!checkPostcode(document.zakelijk.zakpostcode.value))
				{
				alert("U heeft een ongeldige postcode ingevuld");
				blnOk = false;
				document.zakelijk.zakpostcode.focus();
				document.zakelijk.zakpostcode.value = '';
				event.returnValue = false;}
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakplaats.value=="")
			{
			alert("Vul uw vestigingsplaats in");
			blnOk = false;
			document.zakelijk.zakplaats.focus();
			event.returnValue = false ;
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zaktel.value=="")
			{
			alert("Vul uw algemeen telefoonnummer in");
			blnOk = false;
			document.zakelijk.zaktel.focus();
			event.returnValue = false ;
			} else {
				if (!isTelNummer(document.zakelijk.zaktel.value))
				{
				alert("Het door u ingevulde telefoonummer is onjuist");
				blnOk = false;
				document.zakelijk.zaktel.focus();
				document.zakelijk.zaktel.value = '';
				event.returnValue = false;}
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakbtw.value=="")
			{
			alert("Vul uw BTW-nummer in");
			blnOk = false;
			document.zakelijk.zakbtw.focus();
			event.returnValue = false ;
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakmail.value=="")
			{
			alert("Vul uw e-mailadres in.");
			blnOk = false;
			document.zakelijk.zakmail.focus();
			event.returnValue = false ;
			} else {
				if (!checkEmail(document.zakelijk.zakmail.value))
				{
				alert("U heeft een ongeldig e-mailadres ingevuld.");
				blnOk = false;
				document.zakelijk.zakmail.focus();
				document.zakelijk.zakmail.value = '';
				event.returnValue = false;}
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakcontactpers.value=="")
			{
			alert("Vul in wie het contactpersoon is");
			blnOk = false;
			document.zakelijk.zakcontactpers.focus();
			event.returnValue = false ;
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakdirecttel.value=="")
			{
			alert("Vul uw directe telefoonnummer in");
			blnOk = false;
			document.zakelijk.zakdirecttel.focus();
			event.returnValue = false ;
			} else {
				if (!isTelNummer(document.zakelijk.zakdirecttel.value))
				{
				alert("Het door u ingevulde telefoonummer is onjuist");
				blnOk = false;
				document.zakelijk.zakdirecttel.focus();
				document.zakelijk.zakdirecttel.value = '';
				event.returnValue = false;}
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakdirectmail.value=="")
			{
			alert("Vul uw directe e-mailadres in.");
			blnOk = false;
			document.zakelijk.zakdirectmail.focus();
			event.returnValue = false ;
			} else {
				if (!checkEmail(document.zakelijk.zakdirectmail.value))
				{
				alert("U heeft een ongeldig e-mailadres ingevuld.");
				blnOk = false;
				document.zakelijk.zakdirectmail.focus();
				document.zakelijk.zakdirectmail.value = '';
				event.returnValue = false;}
			}
	}
	
	if (blnOk) {
		if (document.zakelijk.zakvoertuig.value=="")
			{
			alert("Vul het aantal voertuigen passen in");
			blnOk = false;
			document.zakelijk.zakvoertuig.focus();
			event.returnValue = false ;
			} else {
				if (!isTelNummer(document.zakelijk.zakvoertuig.value))
				{
				alert("Het aantal kan alleen uit cijfers bestaan");
				blnOk = false;
				document.zakelijk.zakvoertuig.focus();
				document.zakelijk.zakvoertuig.value = '';
				event.returnValue = false;}
			}
	}

	if (blnOk) {
		if (document.zakelijk.zakverbruik.value=="")
			{
			alert("Vul het gemiddelde maandverbruik brandstof in");
			blnOk = false;
			document.zakelijk.zakverbruik.focus();
			event.returnValue = false ;
			} else {
				if (!isTelNummer(document.zakelijk.zakverbruik.value))
				{
				alert("Het aantal kan alleen uit cijfers bestaan");
				blnOk = false;
				document.zakelijk.zakverbruik.focus();
				document.zakelijk.zakverbruik.value = '';
				event.returnValue = false;}
			}
	}

if (blnOk) {
		document.zakelijk.submit();
	}
}


function checkEmail(strEmail)
{
	strtmpEmail = String(strEmail);
	
	// Er moet een @ en een . voorkomen in een emailadres
	if (strtmpEmail.indexOf("@")== -1 || strtmpEmail.indexOf(".")== -1)
	{
		return false;
	}
	nAt = strtmpEmail.indexOf("@")
	if (nAt > 0) {
		strCheck = strtmpEmail.slice(nAt + 1)
		// De @ komt voor de .  xxx.ppibv@nl, maar tim@ppibv.nl moet ook kunnen
		// Indien de . direct na de @ komt is dat ook fout  tim@.nl
		if (strCheck.indexOf(".") <= 0 )
		{
			return false;
		}
		else {
			// Na de punt minimaal 2 tekens tim@ppibv.n
			return ((parseInt(strCheck.length) -1) - parseInt(strCheck.indexOf("."))  > 1 );
		}	
	}
	else {
		return false;
	}
}

// Postcodecheck
  function checkPostcode(strPostcode, n)
  {
    var intCharCodeMin = 65;
    var intCharCodeMax = 122;
    var intCharCodeMinInside = 90;
    var intCharCodeMaxInside = 97;
    
    //convert postcode
    strPostcode = String(strPostcode);
      
    //check length min 6
    if (strPostcode.length < 6)
    {
      return false;
    }
    
    //check length max 7 
    if(strPostcode.length > 7)
    {
      return false;
    }

    //replace space;
    strPostcode = strPostcode.replace(" ","");

    //check 7 characters with space
    if (strPostcode.length == 7)
    {
      return false;
    }
      
    //Check if first four digits are numbers    
    if (String(parseInt(strPostcode.substr(0,4))).length != 4)
    {
      return false;
    }
          
    for (i=4;i<6;i++)
    { 
		if ( strPostcode.charCodeAt(i)< intCharCodeMin || strPostcode.charCodeAt(i)> intCharCodeMax || (strPostcode.charCodeAt(i) > intCharCodeMinInside && strPostcode.charCodeAt(i) < intCharCodeMaxInside  ))
		{
		  return false;
		}
    }
    return true;
  }
 
   // Telefoonnummercheck
function isTelNummer(str) {
  if(!str) return false;
  for(var i=0; i<str.length; i++){
    var ch=str.charAt(i);
    if ("0123456789-() +".indexOf(ch) ==-1) return false;
  }
  return true;
}
