// JavaScript Document

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}


function toonverberg(item, form){

	var ah = form.cursusplaats.selectedIndex;
    choice = form.cursusplaats.options[ah].value;
	var pl = choice.substr(2,2)
	if(pl == "-")
	{
			item = new getObj(item)
			if(item.style.display == 'block'){
				item.style.display = 'none'
			} else {
				item.style.display = 'block'
			}
	}
	else
	{
			item = new getObj(item)
			item.style.display = 'none'
				}
}

function toonverbergtransfer(item, form){
	for (i=0; i < form.transfer.length; i++){
	if (form.transfer[i].checked==true){
	choice = i }
	}

	if(choice == 1)
	{
			item = new getObj(item)
			if(item.style.display == 'block'){
				item.style.display = 'none'
			} else {
				item.style.display = 'block'
			}
	}
	else
	{
			item = new getObj(item)
			item.style.display = 'none'
				}
}



function FrontPage_Form1_Validator(theForm)
{

  if (theForm.naam.value == "")
  {
    alert("Vul je achternaam in.");
    theForm.naam.focus();
    return (false);
  }
  
	
  if (theForm.naam.value.length < 2)
  {
    alert("Geef ten minste 2 tekens in het veld Achternaam op.");
    theForm.naam.focus();
    return (false);
  }

  if (theForm.voorletters.value.length == "")
  {
    alert("Geef ten minste 2 tekens in het veld voorletters op.");
    theForm.voorletters.focus();
    return (false);
  }

  if (theForm.voornaam.value == "")
  {
    alert("Vul je voornaam in.");
    theForm.voornaam.focus();
    return (false);
  }

  if (theForm.voornaam.value.length < 1)
  {
    alert("Geef ten minste 2 tekens in het veld Voornaam op.");
    theForm.voornaam.focus();
    return (false);
  }

  var radioSelected = false;
  for (i = 0;  i < theForm.sexe.length;  i++)
  {
    if (theForm.sexe[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Selecteer een van de opties voor Geslacht.");
    return (false);
  }

  if (theForm.straat.value == "")
  {
    alert("Vul de straatnaam in.");
    theForm.straat.focus();
    return (false);
  }

  if (theForm.straat.value.length < 2)
  {
    alert("Geef ten minste 2 tekens in het veld straat op.");
    theForm.straat.focus();
    return (false);
  }
  
 
	
  if (theForm.nummer.value == "")
  {
    alert("Voer je huisnummer in.");
    theForm.nummer.focus();
    return (false);
  }

  if (theForm.nummer.value.length < 1)
  {
    alert("Geef ten minste 2 tekens in het veld nummer op.");
    theForm.nummer.focus();
    return (false);
  }

  if (theForm.postcode.value == "")
  {
    alert("Voer je postcode in.");
    theForm.postcode.focus();
    return (false);
  }
  


  if (theForm.postcode.value.length < 4)
  {
    alert("Geef ten minste 4 tekens in het veld postcode op.");
    theForm.postcode.focus();
    return (false);
  }

  if (theForm.woonplaats.value == "")
  {
    alert("Vul je woonplaats in.");
    theForm.woonplaats.focus();
    return (false);
  }

  if (theForm.woonplaats.value.length < 2)
  {
    alert("Geef ten minste 2 tekens in het veld woonplaats op.");
    theForm.woonplaats.focus();
    return (false);
  }

  if (theForm.email_adres.value == "")
  {
    alert("Vul je emailadres in.");
    theForm.email_adres.focus();
    return (false);
  }

  if (theForm.email_adres.value.length < 5)
  {
    alert("Geef ten minste 5 tekens in het veld emailadres op.");
    theForm.email_adres.focus();
    return (false);
  }

  if (theForm.geboortedatum.value == "")
  {
    alert("Voer je geboortedatum in.");
    theForm.geboortedatum.focus();
    return (false);
  }

  if (theForm.geboortedatum.value.length < 10)
  {
    alert("Geef ten minste 10 tekens in het veld geboortedatum op.");
    theForm.geboortedatum.focus();
    return (false);
  }

  if (theForm.geboortedatum.value.length > 10)
  {
    alert("Geef maximaal 10 tekens op in het veld geboortedatum.");
    theForm.geboortedatum.focus();
    return (false);
  }

  var chkVal = theForm.geboortedatum.value;
  var prsVal = chkVal;
  if (chkVal != "" && !(prsVal != "dd-mm-jaar"))
  {
    alert("Geef een waarde niet gelijk aan dd-mm-jaar op in het veld geboortedatum.");
    theForm.geboortedatum.focus();
    return (false);
  }

  if (theForm.cursusplaats.selectedIndex < 0)
  {
    alert("Selecteer een van de opties voor Cursusplaats.");
    theForm.cursusplaats.focus();
    return (false);
  }

  if (theForm.cursusplaats.selectedIndex == 0)
  {
    alert("De eerste optie voor Cursusplaats is geen geldige selectie. Kies een van de andere opties.");
    theForm.cursusplaats.focus();
    return (false);
  }

  if (theForm.cursustype.selectedIndex < 0)
  {
    alert("Selecteer een van de opties voor cursus-type.");
    theForm.cursustype.focus();
    return (false);
  }

  if (theForm.cursustype.selectedIndex == 0)
  {
    alert("De eerste optie voor cursustype is geen geldige selectie. Kies een van de andere opties.");
    theForm.cursustype.focus();
    return (false);
  }

   var chkVal = theForm.startdatum.value;
  var prsVal = chkVal;
  if (chkVal != "" && !(prsVal != "dd-mm-jaar"))
  {
    alert("De startdatum van de cursus is niet goed ingevuld.");
    theForm.startdatum.focus();
    return (false);
  }


  if (theForm.startdatum.value.length < 10)
  {
    alert("Geef ten minste 10 tekens in het veld startdatum op.");
    theForm.startdatum.focus();
    return (false);
  }

 
  if (theForm.weken.value == "")
  {
    alert("Geef een waarde voor het veld weken op.");
    theForm.weken.focus();
    return (false);
  }

  if (theForm.weken.value.length > 2)
  {
    alert("Geef maximaal 2 tekens op in het veld weken.");
    theForm.weken.focus();
    return (false);
  }

  if (theForm.kennisniveau.selectedIndex < 0)
  {
    alert("Selecteer een van de opties voor kennisniveau.");
    theForm.kennisniveau.focus();
    return (false);
  }

  if (theForm.kennisniveau.selectedIndex == 0)
  {
    alert("De eerste optie voor kennisniveau is geen geldige selectie. Kies een van de andere opties.");
    theForm.kennisniveau.focus();
    return (false);
  }

  
  if (theForm.voorwaarden_datum.value == "")
  {
    alert("Geef een waarde voor het veld voorwaarden_datum op.");
    theForm.voorwaarden_datum.focus();
    return (false);
  }


	var ah = theForm.cursusplaats.selectedIndex;
    choice = theForm.cursusplaats.options[ah].value;
	var pl = choice.substr(2,2)
	if(pl == "-")
	{
		 
		  if (theForm.bank_giro.checked != 1)
		  {
		  		  if (theForm.cvccode.value == "")
		  {
			alert("Deze school vraagt als garantie voor de reservering je creditcardgegevens. Vul deze in of kies voor betaling per bank.");
			theForm.cvccode.focus();
			return (false);
		  }
		
		  if (theForm.creditcard_naam.value == "")
		  {
			alert("Vul de naam waarop de creditcard staat in.");
			theForm.creditcard_naam.focus();
			return (false);
		  }
		  
		   if (theForm.creditcard_einddatum.value == "mm-jaar")
		  {
			alert("Vul de naam waarop de creditcard staat in.");
			theForm.creditcard_naam.focus();
			return (false);
		  }
		  if (theForm.creditcard_nummer.value == "")
		  {
			alert("Vul de creditcardnummer in.");
			theForm.creditcard_nummer.focus();
			return (false);
		  }

			return (true);
		  }
	}

  if (theForm.voorwaarden_datum.value.length < 10)
  {
    alert("Geef ten minste 10 tekens in het veld voorwaarden_datum op.");
    theForm.voorwaarden_datum.focus();
    return (false);
  }
  
  
  
    if (theForm.akkoord_av.checked == false )
    {
        alert ( "Je kan alleen het formulier verzenden indien je akkoord gaat met de Algemene Voorwaarden." );
       return (false);
    }


  if (theForm.voorwaarden_datum.value.length > 10)
  {
    alert("Geef maximaal 10 tekens op in het veld voorwaarden_datum.");
    theForm.voorwaarden_datum.focus();
    return (false);
  }
  

  var chkVal = theForm.voorwaarden_datum.value;
  var prsVal = chkVal;
  if (chkVal != "" && !(prsVal != "dd-mm-jaar"))
  {
    alert("Geef een waarde niet gelijk aan dd-mm-jaar op in het veld voorwaarden_datum.");
    theForm.voorwaarden_datum.focus();
    return (false);
  }
  
   if(theForm.capt.value != theForm.c_hid.value)
  { alert("Type de code onderaan de pagina juist over.");
	return (false);
  }
  return (true);
}