$(function() { 
    $('#b_orgnr').live('keyup load', function() {
        var id = $("#b_orgnr").val();
        if(id.length == 9){
            //alert(id);
            $.ajax({
                type: "GET",
                dataType: "xml",
                url: "/script_engine.php?script=Business.Brreg&value=true&orgnr="+id,
                success: function(xml) {
                    $(xml).find('result').each(function(){
                        // $('#r_title').val($(this).find('Id').text());
                        $('#b_firmanavn').val($(this).find('Navn').text().replace("&nbsp;",""));
                        $('#b_kontaktperson').val($(this).find('Innehaver').text().replace("&nbsp;",""));
                        $('#b_postadr').val($(this).find('Adresse').text().replace("&nbsp;",""));
                        $('#b_postnr').val($(this).find('PostNr').text().replace("&nbsp;",""));
                        $('#b_poststed').val($(this).find('PostSted').text().replace("&nbsp;",""));
                        $('#b_tlf').val($(this).find('Telefon').text().replace("&nbsp;",""));
                        $('#b_fax').val($(this).find('Telefaks').text().replace("&nbsp;",""));
                        $('#b_mobil').val($(this).find('Mobil').text().replace("&nbsp;",""));
                        $('#b_epost').val($(this).find('Email').text().replace("&nbsp;",""));
                        $('#b_nettside').val($(this).find('Webpage').text().replace("&nbsp;",""));
                    }); //close each
                }
            }); //close $.ajax(*/

        }
    }); //close click(
}); //close $(


