var boolBusy = false;

function externalLinks() { 
  if (!document.getElementsByTagName) return; 
  var anchors = document.getElementsByTagName("a"); 
  for (var i=0; i<anchors.length; i++) { 
    var anchor = anchors[i]; 
    var relvalue = anchor.getAttribute("rel");
    if (anchor.getAttribute("href")) {
      var external = /external/;
      var relvalue = anchor.getAttribute("rel");
      if (external.test(relvalue)) { anchor.target = "_blank"; }
    }
  }
}
window.onload = externalLinks;

function setLetop(text) {
  document.getElementById('letopbetaal').innerHTML = text;
}

function showPrijs(prijsID) {
  document.getElementById(prijsID).style.display = 'block';
}

function hidePrijs(prijsID) {
  document.getElementById(prijsID).style.display = 'none';
}

function doCheckIntOnly(Etje, Obj) {
  var keyCode = Etje.keyCode ? Etje.keyCode : Etje.which ? Etje.which : Etje.charCode;
  if (keyCode >= 48 && keyCode <= 57 && Etje.ctrlKey == false && Obj.value.length < 3) {
    return true;
  } else {
    return false;
  }
}
function NuZoeken() {
  zoek_keywords = document.searchform.maat_id.options[document.searchform.maat_id.selectedIndex].value;
  if (zoek_keywords != "") {
    document.location.href = document.searchform.action + "$maat_id_" + zoek_keywords;
  }
}
var cust_bezorg_voornaam;
var cust_bezorg_achternaam;
var cust_bezorg_straat;
var cust_bezorg_huisnummer;
var cust_bezorg_postcode;
var cust_bezorg_plaats;

function checkAfleveradres(mObj) {
  if (mObj.checked == true) {
    document.getElementById('aflevergegevens').style.display = 'block';
			 cust_bezorg_voornaam = new Spry.Widget.ValidationTextField("cust_bezorg_voornaam", "none", {useCharacterMasking:true, validateOn:["change"]});
			 cust_bezorg_achternaam = new Spry.Widget.ValidationTextField("cust_bezorg_achternaam", "none", {useCharacterMasking:true, validateOn:["change"]});
			 cust_bezorg_straat = new Spry.Widget.ValidationTextField("cust_bezorg_straat", "none", {useCharacterMasking:true, validateOn:["change"]});
			 cust_bezorg_huisnummer = new Spry.Widget.ValidationTextField("cust_bezorg_huisnummer", "integer", {useCharacterMasking:true, validateOn:["change"]});
			 cust_bezorg_postcode = new Spry.Widget.ValidationTextField("cust_bezorg_postcode", "none", {useCharacterMasking:true, validateOn:["change"]});
			 cust_bezorg_plaats = new Spry.Widget.ValidationTextField("cust_bezorg_plaats", "none", {minChars:3, useCharacterMasking:true, validateOn:["change"]});
  } else {
    document.getElementById('aflevergegevens').style.display = 'none';
    if (cust_bezorg_voornaam)   { cust_bezorg_voornaam.reset(); cust_bezorg_voornaam.destroy(); }
    if (cust_bezorg_achternaam) { cust_bezorg_achternaam.reset(); cust_bezorg_achternaam.destroy(); }
    if (cust_bezorg_straat)     { cust_bezorg_straat.reset(); cust_bezorg_straat.destroy(); }
    if (cust_bezorg_huisnummer) { cust_bezorg_huisnummer.reset(); cust_bezorg_huisnummer.destroy(); }
    if (cust_bezorg_postcode)   { cust_bezorg_postcode.reset(); cust_bezorg_postcode.destroy(); }
    if (cust_bezorg_plaats)     { cust_bezorg_plaats.reset(); cust_bezorg_plaats.destroy(); }
  }  
}

function checkEmailValues(){
  if (document.accountaanmaken.cust_emailadres.value != document.accountaanmaken.cust_emailadres_2.value){
    alert('Controleer je emailadres deze is niet identiek');
    document.accountaanmaken.cust_emailadres_2.value = '';
  }
}
