function check_zip(zip) {
    if (zip.length==6) {
        //document.getElementById("street").innerHTML='<input type="text" name="street" value="" disabled/>';
        get_addr(zip);
    } else {
        return false;
    }
}

function get_addr(zip) {
    AjaxRequest.get( {
        'url':'rpc_NL.php?zip='+zip
        ,'onLoading':function() { document.getElementById('city_field').innerHTML='<img src="/images/loader.gif" alt="Loading..."/>'; }
        ,'onSuccess': function(req) {
            fill_address(req)}
        }
    )
}

function fill_address(req) {
    var item=req.responseXML.getElementsByTagName('item');
    if (item.length>0) {
      document.getElementById('city_field').innerHTML=item[0].getAttribute("pc_wpnaam_nen");
      document.getElementById('street_field').innerHTML=item[0].getAttribute("pc_strnaam_nen");
      document.getElementById('city').value=item[0].getAttribute("pc_wpnaam_nen");
      document.getElementById('street').value=item[0].getAttribute("pc_strnaam_nen");
      document.getElementById('pc_id').value=item[0].getAttribute("pc_id");
    } else {
      alert('postcode onbekend');
    }
}
