 function prijscheck(aantal,prijs,gekozenConcert)
{
  document.getElementById(gekozenConcert).value = ((prijs.replace(',','.')*aantal).toFixed(2)).replace('.',',');
  displayNewYear();
  calculateNewPrice();
  
}

function calculateNewPrice()
{
  var concertPrices = document.getElementById("bestelAbonnement").getElementsByTagName("input");
  var totalPrice = 0;

  for (var i=0; i < concertPrices.length;i++)
  {
    if (concertPrices[i].className == "gekozenconcertBox" && concertPrices[i].value != '')
      totalPrice += parseFloat(concertPrices[i].value.replace(',','.'));
  }
  document.getElementById("totalCosts").value = (parseFloat(totalPrice+5.75).toFixed(2)).replace('.',',');
}

function displayNewYear()
{
  var count = 0;
  var concertPrices = document.getElementById("bestelAbonnementConcerts").getElementsByTagName("input");
  for (var i=0; i < concertPrices.length;i++)
  {
    if (concertPrices[i].className == "concertInputField" && concertPrices[i].value != '' && concertPrices[i].value != '0')
      count++;
  }

  var el = document.getElementById("newyearsconcert");
  var minimaleBestelling = document.getElementById("minimaleBestelling");
  if (count >= 3)
  {
    el.style.display = "block";
    minimaleBestelling.value="bestellenMogelijk";
    }
  else
  {
    el.style.display = "none";
      
     var els=el.getElementsByTagName('input');
     for(var i=0;i<els.length;i++)
     {
     els[i].value = "0";
     }
     minimaleBestelling.value="bestellenNietMogelijk";
   } 
}

function checkNaam(naam)
{
  if (naam=='')
    return false;
    else
    return true;
}

function checkAdres(adres)
{
  if (adres=='')
    return false;
    else
    return true;
}

function checkPostalcode(postcode)
{
  if (postcode=='')
    return false;
    else
    return true;
}

function checkPhone(telefoonnummer)
{
var telefoonRegEx = /^([0-9\-\+]{11})$/;
if (telefoonnummer=='')
  return false;
else
{
  return !telefoonnummer.match(telefoonRegEx);
}
}

function checkEmail(email)
{
var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (email=='')
  return false;
else
{
  return !email.match(emailRegEx);
}
}

function checkBankgiro(bankgiro)
{
var bankgiroRegEx = /^([0-9]{9})$/;
if (bankgiro=='')
  return false;
else
{
  return !bankgiro.match(bankgiroRegEx);
}
}


function checkValidatie()
{
if (AcceptatieMachtigingControle=='false')
  return false;
else
{
  return true;
}
}



function checkMinimaleBestelling(minimaleBestellingiro)
{
if (minimaleBestellingiro=="bestellenNietMogelijk")
{
  return false;
}
else
{
  return true;
}
}

function sendFormWithValidation(formulier)
{
var check = true;
var allroundCheck = true;
  var el = formulier.getElementsByTagName("input");  
  for(var i=0; i<el.length; i++)
  {
    if(el[i].className.indexOf('required') > -1)
    {       
    switch(el[i].id)
    {
        case "naam":
        check = checkNaam(el[i].value);        
        break;
        
        case "adres":
        check = checkAdres(el[i].value);        
        break;
        
        case "postcode":
        check = checkPostalcode(el[i].value);        
        break;
        
        case "telefoon":
        check = checkPhone(el[i].value);
        break;
        
        case "email":
        check = checkPhone(el[i].value);
        break;
        
        case "bankgiro":
        check = checkPhone(el[i].value);
        break;
        
        case "AcceptatieMachtigingControle":
        check = el[i].checked;
        break;
        
        case "minimaleBestelling":
        check = checkMinimaleBestelling(el[i].value);
        break;
        
        
//        case "AcceptatieMachtigingControle":
//        check = el[i].checked;
//        break;
        
        default:
        if(el[i].value == "")
          check = false;
        break;
        
    } 
        if(check == false)
        {       
          if(el[i].id == "minimaleBestelling"){
            document.getElementById(el[i].id + "ErrorText").innerHTML = "U dient minimaal 3 concerten te bestellen";}
          else if(el[i].id == "AcceptatieMachtigingControle"){
            document.getElementById(el[i].id + "ErrorText").innerHTML = "U hebt de éénmalige machtiging nog niet geaccepteerd";}
          else{
            document.getElementById(el[i].id + "ErrorText").innerHTML = "Onjuiste invoer";}

          allroundCheck = false;
        }
        else
        {
          document.getElementById(el[i].id + "ErrorText").innerHTML = "";
        }
      
      // hier je check uitvoeren
    }
  }
  
  if(allroundCheck == true)
    allroundCheck = document.getElementById("AcceptatieMachtigingControle").checked;
    
  return allroundCheck;
  /*
document.getElementById('bankgiroErrorText').innerHTML 
document.getElementById('telefoonErrorText').innerHTML
document.getElementById('emailErrorText').innerHTML
document.getElementById('bankgiroErrorText').innerHTML
*/
}

