function validate(aantallen){
  if (!CheckAantal(aantallen)) return false;
  if (!CheckNaam1()) return false;
  if (!CheckAdres()) return false;
  if (!CheckPostcode()) return false;
  if (!CheckWoonplaats()) return false;
  if (!CheckEmail()) return false;
  return true;
}

function validate2(){
  if (!CheckNaam1()) return false;
  if (!CheckAdres()) return false;
  if (!CheckPostcode()) return false;
  if (!CheckWoonplaats()) return false;
  if (!CheckEmail()) return false;
  return true;
}

function validateContact(){
  if (!CheckNaam2()) return false;
  if (!CheckEmail()) return false;
  return true;
}

function CheckNaam2(){
  var Resultaat=true;
  if (document.formklantgeg.Naam.value.length > 0)
     {
       Resultaat=true
     }
  else
     {
       var message="   Voer a.u.b. uw naam in!   \n"
       ResetFocus(document.formklantgeg.Naam, message)
       Resultaat=false
     }
  return (Resultaat);
}

function CheckNaam1(){
  var Resultaat=true;
  if (document.formklantgeg.Naam.value.length > 0)
     {
       Resultaat=true
     }
  else
     {
       var message="   Voer a.u.b. uw (bedrijfs) naam in!   \n"
       ResetFocus(document.formklantgeg.Naam, message)
       Resultaat=false
     }
  return (Resultaat);
}

function CheckAdres(){
  var Resultaat=true
  if (document.formklantgeg.Adres.value.length > 0)
     {
       Resultaat=true
     }
  else
     {
       var message="   Voer a.u.b. uw adres in!   \n"
       ResetFocus(document.formklantgeg.Adres, message)
       Resultaat=false
     }
  return (Resultaat);
}

function CheckPostcode(){
  var Resultaat=true;
  if (document.formklantgeg.Postcode.value.length > 0)
     {
       Resultaat=true
     }
  else
     {
       var message="   Voer a.u.b. uw postcode in!   \n"
       ResetFocus(document.formklantgeg.Postcode, message)
       Resultaat=false
     }
  return (Resultaat);
}

function CheckWoonplaats(){
  var Resultaat=true
  if (document.formklantgeg.Woonplaats.value.length > 0)
     {
       Resultaat=true
     }
  else
     {
       var message="   Voer a.u.b. uw woonplaats in!   \n"
       ResetFocus(document.formklantgeg.Woonplaats, message)
       Resultaat=false
     }
  return (Resultaat);
}

function CheckEmail(){
        var index=0
        var Resultaat=true
        var str=document.formklantgeg.Email.value.toLowerCase()
        var filter=/^.+@.+\..{2,3}$/
        var filter2=/\.\./
        if (filter.test(str)){
                if(filter2.test(str)){
                        var message="   Voer a.u.b. een geldig e-mail adres in!   \n"
                        ResetFocus(document.formklantgeg.Email, message);
                        Resultaat=false
                }
        } else {
                var message="   Voer a.u.b. een geldig e-mail adres in!   \n"
                ResetFocus(document.formklantgeg.Email, message)
                Resultaat=false
        }
        return (Resultaat)
}

function CheckAantal(aantallen){
  var Resultaat=true
  if (document.formklantgeg.Aantal.value >= aantallen)
     {
       Resultaat=true
     }
  else
     {
       var message="   Uw aantal is niet goed opgegeven!   \n"
       ResetFocus(document.formklantgeg.Aantal, message)
       Resultaat=false
     }
  return (Resultaat);
}

function ResetFocus(Element, Melding){
        alert (Melding);
        Element.focus();
        return;
}

function SetFocus(){
        document.formklantgeg.Naam.focus();
}

var popupHandle;

function popup(picUrlString, windowWidth, windowHeight){
  // always close the old one , so only one at a time is open
  if(popupHandle || popupHandle!=null){
    if (!popupHandle.closed) popupHandle.close();
  }
  popupHandle=null;
  // create a feature string for the popup
  var x=(screen.width-windowWidth)/2
  var y=(screen.height-windowHeight)/2
  var featureString = "toolbar=no,scrollbars=no,resizable=no,location=no,directories=no,menubar=no,address=no"
  featureString = ',left='+x + ',top='+y
  featureString += ',width='+windowWidth+',height='+windowHeight
  // open the popup
  // We use a php script to work arround some browser specific problems
  // Opera doesn't seem to handle document.close() correctly on the popup.
  popupHandle = window.open( "popup.php?windowWidth="+windowWidth+"&windowHeight="+windowHeight+"&picUrlString="+picUrlString ,"popup",featureString)
  return popupHandle;
}

function winclose(){
  if (window.popupHandle!=null && !window.popupHandle.closed){
    window.popupHandle.close();
  }
}

function doNothing(){
}
