
window.addEventListener("message", function (event) {
    if (event.origin !== window.location.origin) return;
    if (event.data && event.data.roadAddress) {
        if (window.kakaoPostcodeDotNetRef) {
            window.kakaoPostcodeDotNetRef.invokeMethodAsync(
                "SetAddress",
                event.data.roadAddress,
                event.data.jibunAddress,
                event.data.zonecode
            );
        }
    }
});

window.getKakaoPostcodeResult = function () {
    return window.kakaoPostcodeResult;
};

window.openKakaoPostcodePopup = function (dotNetObjRef) {
    window.kakaoPostcodeResult = null;
    window.kakaoPostcodeDotNetRef = dotNetObjRef;
    window.open(
        "/kakao-postcode.html",
        "kakaoPostcodePopup",
        "width=500,height=600,scrollbars=no,resizable=no"
    );
};