function updateadres(postcode, huisnummer)
{
  new Ajax.Request('/postcodelookup', {
    parameters: {
      postcode: postcode,
      huisnummer: huisnummer
    },
    onComplete: function(response, json) {
      for (i in json) {
        if (i == 'straat') {
          $('straat').value = json[i];
        }
        if (i == 'plaats') {
          $('plaats').value = json[i];
        }
      }
    }
  });
}

function checkadres()
{
  var postcode = $F('postcode');
  var huisnummer = $F('huisnummer');
  if ((postcode != '') && (huisnummer != '')) {
    updateadres(postcode, huisnummer);
  }
}

function checkform()
{
  if ($F('land') == 'NL') {
    $('straat').className = 'readonly';
    $('straat').readOnly = true;
    $('plaats').className = 'readonly';
    $('plaats').readOnly = true;
  }
  else {
    $('straat').className = '';
    $('straat').readOnly = false;
    $('plaats').className = '';    
    $('plaats').readOnly = false;
  }
}

window.onload = function() { 
  checkform;
}