<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css?v=" . filemtime(__DIR__.'/style.css') . "\">";

require_once(G5_PATH.'/shoppoint/settle_'.$default['de_pg_service'].'.inc.php');
require_once(G5_PATH.'/shoppoint/settle_kakaopay.inc.php');
?>

<?php
if (G5_IS_MOBILE) {
    echo "<div style='display:flex; justify-content:center; items-align:ccenter;width:100%;'><div id='wrapper_title' style='width:auto; font-size:1.2em; margin: 10px 0px 10px'>{$g5['title']}</div><div style='flex:1 0 auto; text-align:right;'><a href='{$at_href['buyingpointsinquiry']}' class='btn-g12 point-charge-inquiry-btn'>포인트 충전 내역조회</a></div></div>";
} else {
    echo "<div style='display:flex; justify-content:center; items-align:ccenter;width:100%;'><div id='wrapper_title' style='width:auto;'>{$g5['title']}</div><div style='flex:1 0 auto; text-align:right;'><a href='{$at_href['buyingpointsinquiry']}' class='btn-g12 point-charge-inquiry-btn'>포인트 충전 내역조회</a></div></div>";
}
?>

<div id="point_charge_toast" class="point-charge-toast" style="display:none;" aria-live="polite"></div>

<!-- 환율정보 티커 시작 { -->
<?php
    $LAST_UPDATE_TIME_RAW = get_exchange_rate("LUPDTIME");
    $LAST_UPDATE_TIME = trim(preg_replace('/\s+/', ' ', (string)$LAST_UPDATE_TIME_RAW));
    $KRWKRW = get_exchange_rate("KRWKRW");
    $KRWUSD = get_exchange_rate("KRWUSD");
    $KRWEUR = get_exchange_rate("KRWEUR");
    $KRWCNY = get_exchange_rate("KRWCNY");
    $KRWJPY = get_exchange_rate("KRWJPY");
    $KRWVND = get_exchange_rate("KRWVND");
?>
<script>
    const LAST_UPDATE_TIME = "<?php echo addslashes($LAST_UPDATE_TIME) ?>";
    const KRWKRW = <?php echo $KRWKRW ?>;
    const KRWUSD = <?php echo $KRWUSD ?>;
    const KRWEUR = <?php echo $KRWEUR ?>;
    const KRWCNY = <?php echo $KRWCNY ?>;
    const KRWJPY = <?php echo $KRWJPY ?>;
    const KRWVND = <?php echo $KRWVND ?>;
    var nationpay = 'KRW';
</script>

<?php
if ($KRWKRW == 0 || $KRWUSD == 0 || $KRWEUR == 0 || $KRWCNY == 0 || $KRWJPY == 0 || $KRWVND == 0) {
    alert("환율정보를 가져오지 못했습니다. 잠시 후 다시 시도해 주세요.");
    exit;
}
?>

<?php
    // 포인트 충전/출금 한도 정보를 가져오는 파일입니다.
    require_once(G5_PATH.'/mylib/point_charge_withdraw_info_inc.php');
?>

<?php if (G5_IS_MOBILE) { ?>
    <div style="display:flex; justify-content:center; items-align:center; width:100%;">
        <div class="point-charge-rate-update" style="width:100%; margin:0 auto 0; font-size:0.9em; color:#333; background:#eceff4; text-align:center;">
                환율정보 업데이트 : <?php echo $LAST_UPDATE_TIME; ?> KST
        </div>
    </div>
    <div class="point-charge-rate-ticker" style="display:flex; justify-content:center; items-align:center; width:100%;">
        <div style="width:50%; margin-left:0px;">
            <div id="newsticker1" class="newsticker1">
                <ul>
                    <li>1 Point = 1 KRW</li>
                    <li>1 Point = <?php echo $KRWUSD ?> USD</li>
                    <li>1 Point = <?php echo $KRWEUR ?> EUR</li>
                    <li>1 Point = <?php echo $KRWCNY ?> CNY</li>
                    <li>1 Point = <?php echo $KRWJPY ?> JPY</li>
                    <li>1 Point = <?php echo $KRWVND ?> VND</li>
                </ul>
            </div>
        </div>

        <div style="width:50%; margin-right:0px;">
            <div id="newsticker2" class="newsticker2">
                <ul>
                    <li>1000 KRW = 1000 Point</li>
                    <li>1 USD = <?php echo round(1/$KRWUSD*1) ?> Point</li>
                    <li>1 EUR = <?php echo round(1/$KRWEUR*1) ?> Point</li>
                    <li>1 CNY = <?php echo round(1/$KRWCNY*1) ?> Point</li>
                    <li>100 JPY = <?php echo round(1/$KRWJPY*100) ?> Point</li>
                    <li>10000 VND = <?php echo round(1/$KRWVND*10000) ?> Point</li>
                </ul>
            </div>
        </div>
    </div>

    <style>
        .newsticker1 {float:left;position:relative;overflow:hidden;width:150px;height:21px;text-align:left;border:none;}
        .newsticker1 ul {padding:0;margin:0}
        .newsticker1 ul li {float:left;width:150px;padding:0;font-size:1em;color:#333;letter-spacing:0px;height:21px;line-height:21px;list-style:none;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;}
        .newsticker1 ul li a {color:#333}
        .newsticker1 ul li strong {color:#111}

        .newsticker2 {float:right;position:relative;overflow:hidden;width:150px;height:21px;text-align:right;border:none;}
        .newsticker2 ul {padding:0;margin:0}
        .newsticker2 ul li {float:right;width:150px;padding:0;font-size:1em;color:#333;letter-spacing:0px;height:21px;line-height:21px;list-style:none;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;}
        .newsticker2 ul li a {color:#333}
        .newsticker2 ul li strong {color:#111}
    </style>

<?php } else { ?>
    <div class="point-charge-rate-ticker" style="display:flex; justify-content:center; items-align:center; width:100%;">
        <div style="width:40%; margin-left:0px;">
            <div id="newsticker1" class="newsticker1">
                <ul>
                    <li>1 Point = 1 KRW</li>
                    <li>1 Point = <?php echo $KRWUSD ?> USD</li>
                    <li>1 Point = <?php echo $KRWEUR ?> EUR</li>
                    <li>1 Point = <?php echo $KRWCNY ?> CNY</li>
                    <li>1 Point = <?php echo $KRWJPY ?> JPY</li>
                    <li>1 Point = <?php echo $KRWVND ?> VND</li>
                </ul>
            </div>
        </div>
        <div class="point-charge-rate-update" style="width:20%; margin:0 auto 0; font-size:0.9em; color:#333; text-align:center;">
            환율정보 업데이트 : <?php echo $LAST_UPDATE_TIME; ?> KST
        </div>
        <div style="width:40%; margin-right:0px;">
            <div id="newsticker2" class="newsticker2">
                <ul>
                    <li>1000 KRW = 1000 Point</li>
                    <li>1 USD = <?php echo round(1/$KRWUSD*1) ?> Point</li>
                    <li>1 EUR = <?php echo round(1/$KRWEUR*1) ?> Point</li>
                    <li>1 CNY = <?php echo round(1/$KRWCNY*1) ?> Point</li>
                    <li>100 JPY = <?php echo round(1/$KRWJPY*100) ?> Point</li>
                    <li>10000 VND = <?php echo round(1/$KRWVND*10000) ?> Point</li>
                </ul>
            </div>
        </div>
    </div>


    <style>
        .newsticker1 {float:left;position:relative;overflow:hidden;width:150px;height:21px;text-align:left;border:none;}
        .newsticker1 ul {padding:0;margin:0}
        .newsticker1 ul li {float:left;width:150px;padding:0;font-size:12px;color:#333;letter-spacing:0px;height:21px;line-height:21px;list-style:none;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;}
        .newsticker1 ul li a {color:#333}
        .newsticker1 ul li strong {color:#111}

        .newsticker2 {float:right;position:relative;overflow:hidden;width:150px;height:21px;text-align:right;border:none;}
        .newsticker2 ul {padding:0;margin:0}
        .newsticker2 ul li {float:right;width:150px;padding:0;font-size:12px;color:#333;letter-spacing:0px;height:21px;line-height:21px;list-style:none;overflow:hidden;text-overflow: ellipsis;white-space: nowrap;}
        .newsticker2 ul li a {color:#333}
        .newsticker2 ul li strong {color:#111}
    </style>

<?php } ?>


<script>
    jQuery(function(){
        jQuery('#newsticker1').Vnewsticker({
            speed: 700,         //스크롤 스피드
            pause: 2000,        //잠시 대기 시간
            mousePause: true,   //마우스 오버시 일시정지(true=일시정지)
            showItems: 1,       //스크롤 목록 갯수 지정(1=한줄만 보임)
            direction : "Up"    //left=옆으로스크롤, up=위로스크롤, 공란=아래로 스크롤
        });

        jQuery('#newsticker2').Vnewsticker({
            speed: 700,         //스크롤 스피드
            pause: 2000,        //잠시 대기 시간
            mousePause: true,   //마우스 오버시 일시정지(true=일시정지)
            showItems: 1,       //스크롤 목록 갯수 지정(1=한줄만 보임)
            direction : "Up"    //left=옆으로스크롤, up=위로스크롤, 공란=아래로 스크롤
        });

        jQuery('#newsticker3').Vnewsticker({
            speed: 700,         //스크롤 스피드
            pause: 2000,        //잠시 대기 시간
            mousePause: true,   //마우스 오버시 일시정지(true=일시정지)
            showItems: 3,       //스크롤 목록 갯수 지정(1=한줄만 보임)
            direction : "Up"    //left=옆으로스크롤, up=위로스크롤, 공란=아래로 스크롤
        });

        jQuery('#newsticker4').Vnewsticker({
            speed: 700,         //스크롤 스피드
            pause: 2000,        //잠시 대기 시간
            mousePause: true,   //마우스 오버시 일시정지(true=일시정지)
            showItems: 2,       //스크롤 목록 갯수 지정(1=한줄만 보임)
            direction : ""    //left=옆으로스크롤, up=위로스크롤, 공란=아래로 스크롤
        });
    });


    (function (a)
    {
        a.fn.Vnewsticker = function (b)
        {
            var c =
            {
                speed : 700,
                pause : 4000,
                showItems : 3,
                mousePause : true,
                isPaused : false,
                direction : "left",
                width : 0
            };
            var b = a.extend(c, b);
            moveSlide = function (g, d, e)
            {
                if (e.isPaused) {
                    return
                }
                var f = g.children("ul");
                var h = f.children("li:first").clone(true);
                if (e.width > 0) {
                    d = f.children("li:first").width()

                }
                f.animate({
                    left : "-=" + d + "px"

                },
                e.speed, function ()
                {
                    a(this).children("li:first").remove();
                    a(this).css("left", "0px")
                });
                h.appendTo(f)

            };
                    moveUp = function (g, d, e)
            {
                if (e.isPaused) {
                    return
                }
                var f = g.children("ul");
                var h = f.children("li:first").clone(true);
                if (e.height > 0) {
                    d = f.children("li:first").height()
                }
                f.animate({
                    top : "-=" + d + "px"
                },
                e.speed, function ()
                {
                    a(this).children("li:first").remove();
                    a(this).css("top", "0px")
                });
                h.appendTo(f)
            };
                    moveDown = function (g, d, e)
            {
                if (e.isPaused) {
                    return
                }
                var f = g.children("ul");
                var h = f.children("li:last").clone(true);
                if (e.height > 0) {
                    d = f.children("li:first").height()
                }
                f.css("top", "-" + d + "px").prepend(h);
                f.animate({
                    top : 0
                },
                e.speed, function ()
                {
                    a(this).children("li:last").remove()
                });
            };
            return this.each(function ()
            {
                var f = a(this);
                var e = 0;
                            var u = f.children("ul");
                            var l = u.children("li").length;
                            var w = u.children("li").width();
                            var ulw = l * w + "px";
                f.css({overflow : "hidden"})
                            .children("ul").css({position : "absolute" });

                if (b.width == 0)
                {
                    f.children("ul").children("li").each(function ()
                    {
                        if (a(this).width() > e) {
                            e = a(this).height();
                                                    e2 = a(this).width();
                        }
                    });
                    f.children("ul").children("li").each(function ()
                    {
                        a(this).height(e)
                    });
                    f.height(e * b.showItems)
                }
                else {
                    f.width(b.width)
                }
                var d = setInterval(function ()
                {
                    if (b.direction == "left") {
                        moveSlide(f, e2, b)
                                        u.css({width : ulw})
                    } else if (b.direction == "Up") {
                        moveUp(f, e, b)
                    }
                    else {
                        moveDown(f, e, b)
                    }
                },
                b.pause);
                if (b.mousePause)
                {
                    f.bind("mouseenter", function ()
                    {
                        b.isPaused = true;
                    }).bind("mouseleave", function ()
                    {
                        b.isPaused = false;
                    })
                }
            })
        }
    })(jQuery);
</script>
<!-- } 환율정보 티커 끝 -->

<table style="width:100%; border-top:2px solid #333;">
    <tr>
        <?php if (G5_IS_MOBILE) { ?>
            <th scope="col" class="point-charge-guide-text" style="text-align:center; width:100%; letter-spacing: 0px; font-size:0.8em; padding-top:20px; color:#7f6a40;">결제 통화를 먼저 선택한 후 충전할 포인트를 입력하세요</th>
        <?php } else { ?>
            <th scope="col" class="point-charge-guide-text" style="text-align:center; width:100%; letter-spacing: 0px; padding-top:20px; color:#7f6a40;">결제 통화를 먼저 선택한 후 충전할 포인트를 입력하세요</th>
        <?php } ?>
    </tr>
</table>

<?php
if (G5_IS_MOBILE) {
?>

<style>

    .nationpay-container {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        margin: 20px 0;
        padding: 10px;
        background-color: #f9f9f9;
        border-radius: 10px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        gap: 0; /* 항목 간의 간격 */
    }

    .nationpay-item_title {
        width: 100%;
        font-weight: bold;
        margin-bottom: 10px;
        font-size: 1.2em;
        text-align: center;
    }

    .nationpay-item {
        display: flex;
        align-items: center;
        margin: 5px 0;
        width: calc(33.333% - 10px); /* 2 items per row with 10px total margin */
    }

    .nationpay-item input[type="radio"] {
        display: none;
    }

    .nationpay-item label {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 5px;
        cursor: pointer;
        transition: background-color 0.3s, border-color 0.3s;
    }

    .nationpay-item img {
        margin-right: 10px;
        height: 20px;
        width: auto;
    }

    .nationpay-item input[type="radio"]:checked + label {
        background-color: #fff;
        color: #333;
        border-color: #28a745;
        border: 2px dashed #28a745;
    }

    @media screen and (max-width: 768px) {
        body { font-size: 1.0em; }

        .nationpay-container {
            margin: 10px 0;
        }

        .nationpay-item {
            width: calc(33.333% - 10px); /* 2 items per row on smaller screens */
        }

        .nationpay-item label {
            padding: 8px;
        }
    }

    .disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .disabled input[type="radio"] {
        pointer-events: none;
    }

    .disabled label {
        cursor: not-allowed;
    }

    .disabled img {
        opacity: 0.5;
    }
</style>

<!-- 모바일 -->
<div class="nationpay-container point-charge-nationpay">
    <div class="nationpay-item_title">결제 통화 선택</div>
    <div class="nationpay-item">
        <input type="radio" name="nationpay" id="nationpay_KRW" value="KRW" checked>
        <label for="nationpay_KRW"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/kr.svg" class='nation_flag_img2'>KRW</label>
    </div>
    <div class="nationpay-item">
        <input type="radio" name="nationpay" id="nationpay_CNY" value="CNY" disabled>
        <label for="nationpay_CNY" class="disabled"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/cn.svg" class='nation_flag_img1'>CNY</label>
    </div>
    <div class="nationpay-item">
        <input type="radio" name="nationpay" id="nationpay_USD" value="USD" disabled>
        <label for="nationpay_USD" class="disabled"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/us.svg" class='nation_flag_img1'>USD</label>
    </div>
    <div class="nationpay-item">
        <input type="radio" name="nationpay" id="nationpay_EUR" value="EUR" disabled>
        <label for="nationpay_EUR" class="disabled"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/eu.svg" class='nation_flag_img1'>EUR</label>
    </div>
    <div class="nationpay-item">
        <input type="radio" name="nationpay" id="nationpay_JPY" value="JPY" disabled>
        <label for="nationpay_JPY" class="disabled"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/jp.svg" class='nation_flag_img2'>JPY</label>
    </div>
    <div class="nationpay-item">
        <input type="radio" name="nationpay" id="nationpay_VND" value="VND" disabled>
        <label for="nationpay_VND" class="disabled"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/vn.svg" class='nation_flag_img1'>VND</label>
    </div>
</div>


<?php
} else { // PC버전
?>

<style>

    .nationpay-container {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        margin: 20px 0;
        padding: 10px;
        background-color: #f9f9f9;
        border-radius: 10px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        gap: 0px; /* 항목 간의 간격 */
    }

    .nationpay-item_title {
        width: 100%;
        font-weight: bold;
        margin-bottom: 10px;
        font-size: 1.2em;
        text-align: center;
    }

    .nationpay-item {
        display: flex;
        align-items: center;
        margin: 5px 0;
        width: calc(16.666% - 10px); /* 3 items per row with 10px total margin */
    }

    .nationpay-item input[type="radio"] {
        display: none;
    }

    .nationpay-item label {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 5px;
        cursor: pointer;
        transition: background-color 0.3s, border-color 0.3s;
    }

    .nationpay-item img {
        margin-right: 10px;
        height: 20px;
        width: auto;
    }

    .nationpay-item input[type="radio"]:checked + label {
        background-color: #fff;
        color: #333;
        border-color: #28a745;
        border: 2px dashed #28a745;
    }

    @media screen and (max-width: 768px) {
        body { font-size: 1.0em; }

        .nationpay-container {
            margin: 10px 0;
        }

        .nationpay-item {
            width: calc(50% - 10px); /* 2 items per row on smaller screens */
        }

        .nationpay-item label {
            padding: 8px;
        }
    }

    .disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .disabled input[type="radio"] {
        pointer-events: none;
    }

    .disabled label {
        cursor: not-allowed;
    }

    .disabled img {
        opacity: 0.5;
    }
</style>

<!-- PC -->
<div class="nationpay-container point-charge-nationpay">
    <!-- <div class="nationpay-item_title">입금 통화 / けっさいつうか / Tiền tệ thanh toán</div> -->
    <div class="nationpay-item_title">결제 통화 선택</div>
    <div class="nationpay-item">
        <input type="radio" name="nationpay" id="nationpay_KRW" value="KRW" checked>
        <label for="nationpay_KRW"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/kr.svg" class='nation_flag_img2'>KRW</label>
    </div>
    <div class="nationpay-item disabled">
        <input type="radio" name="nationpay" id="nationpay_CNY" value="CNY" disabled>
        <label for="nationpay_CNY"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/cn.svg" class='nation_flag_img1'>CNY</label>
    </div>
    <div class="nationpay-item disabled">
        <input type="radio" name="nationpay" id="nationpay_USD" value="USD" disabled>
        <label for="nationpay_USD"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/us.svg" class='nation_flag_img1'>USD</label>
    </div>
    <div class="nationpay-item disabled">
        <input type="radio" name="nationpay" id="nationpay_EUR" value="EUR" disabled>
        <label for="nationpay_EUR"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/eu.svg" class='nation_flag_img1'>EUR</label>
    </div>
    <div class="nationpay-item disabled">
        <input type="radio" name="nationpay" id="nationpay_JPY" value="JPY" disabled>
        <label for="nationpay_JPY"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/jp.svg" class='nation_flag_img2'>JPY</label>
    </div>
    <div class="nationpay-item disabled">
        <input type="radio" name="nationpay" id="nationpay_VND" value="VND" disabled>
        <label for="nationpay_VND"><img src="<?php echo G5_DATA_URL; ?>/item/img_nation_flag/svg/vn.svg" class='nation_flag_img1'>VND</label>
    </div>
</div>

<?php
}


if( $default['de_inicis_lpay_use'] ){   //이니시스 Lpay 사용시
    require_once(G5_PATH.'/shoppoint/inicis/lpay_common.php');
}

// 결제대행사별 코드 include (스크립트 등)
require_once(G5_PATH.'/shoppoint/'.$default['de_pg_service'].'/orderform.1.php');

if( $default['de_inicis_lpay_use'] ){   //이니시스 L.pay 사용시
    require_once(G5_PATH.'/shoppoint/inicis/lpay_form.1.php');
}

if($is_kakaopay_use) {
    require_once(G5_PATH.'/shoppoint/kakaopay/orderform.1.php');
}
?>

<form name="forderform" id="forderform" method="post" action="<?php echo $order_action_url; ?>" autocomplete="off">
<script>
    $(function() {
        $('#od_fx_type').val('KRWKRW');
    window.lastValidPointCharge = "0";

        $("input[name='nationpay']").change(function() {
            nationpay = $(this).val();
            document.getElementById('od_settle_bank').checked = false; // 무통장 선택 checked 해제
            $("#settle_bank").hide(); // 무통장 선택을 해제하여 다른 통화의 계좌번호 노출을 막음
            var odPriceInput = document.querySelector('input[name="od_price"]');
            odPriceInput.value = "0";
            var org_odPriceInput = document.querySelector('input[name="org_od_price"]');
            org_odPriceInput.value = "0";
            $("#tot_sell_price").html(number_format("0")); // 주문란 화면표시금액 변경
            $(".print_price").html(number_format("0")+" "+nationpay);
            $("#ct_tot_price").html(number_format("0"));
            $("#point_charge_select").val("0");
            window.lastValidPointCharge = "0";
            calculate_order_price();
            $("#point_charge_select").focus();
            switch (nationpay) {
                case 'KRW':
                    $('#od_fx_rate_disp').html("1 Point = "+ KRWKRW + " " + nationpay);
                    break;
                case 'USD':
                    $('#od_fx_rate_disp').html("1 Point = "+ KRWUSD + " " + nationpay);
                    break;
                case 'EUR':
                    $('#od_fx_rate_disp').html("1 Point = "+ KRWEUR + " " + nationpay);
                    break;
                case 'CNY':
                    $('#od_fx_rate_disp').html("1 Point = "+ KRWCNY + " " + nationpay);
                    break;
                case 'JPY':
                    $('#od_fx_rate_disp').html("1 Point = "+ KRWJPY + " " + nationpay);
                    break;
                case 'VND':
                    $('#od_fx_rate_disp').html("1 Point = "+ KRWVND + " " + nationpay);
                    break;
            }
            //var nationpay = $(this).attr('id').replace('nationpay_', '');

        });

        // 비활성화 통화 클릭 시 안내 메시지
        $(document).on('click', '.nationpay-item.disabled label, .nationpay-item label.disabled', function(e) {
            e.preventDefault();
            var $item = $(this).closest('.nationpay-item');
            var currency = $item.find('input[type="radio"]').val() || $(this).attr('for').replace('nationpay_', '');
            showPointChargeToast(currency + '는 현재 지원되지 않는 통화입니다. 현재는 KRW만 이용 가능합니다.');
        });

        document.getElementById('point_charge_select').focus({ preventScroll: true });
    });
</script>

<div id="sod_frm" class="point-charge-theme">

    <!-- 주문상품 확인 시작 { -->
    <div class="tbl_head03 tbl_wrap od_prd_list">
    <table id="sod_list" style="font-size:1.3rem;">

    <thead>

        <tr>
                <td scope="col" class="point-charge-input-cell" style="text-align:center; background:rgba(40,167,69,0.7); color:#111; font-size:1.5rem; font-weight:bold;">
                <div class="point-charge-input-wrap">
                <span class="point-charge-input-left">충전</span>
                <input type="text" name="point_charge_select" id="point_charge_select" value="0" min="0" max="10000000"
                    oninput="updateLabelValue(); validateRange();"
                    onblur="validateRange(true);"
                    onkeydown="validateInput(event)"
                    placeholder="구매하실 포인트 입력"
                    style="text-align:center; padding:10px; font-size:1.5rem; font-weight:bold; color:#218838;">
                <span class="point-charge-input-right">Point</span>
                </div>
            </td>
        </tr>
        <tr>
            <?php if (G5_IS_MOBILE) { ?>
                <?php /*
                <th scope="col" style="text-align:center; width:50%; letter-spacing: 0px; font-size:0.8em;">[보유포인트 <?php echo number_format($member['mb_point']);?> Point]&nbsp; [출금수수료 <?php echo ((double)$member['mb_withdraw_fee'] <= 100.0)?$member['mb_withdraw_fee']."%": number_format($member['mb_withdraw_fee'])." Point";?>]&nbsp; [출금가능 <?php echo number_format($member['mb_point']-$withdraw_limit);?> Point]</th>
                */ ?>
                <th scope="col" style="text-align:center; width:50%; letter-spacing: 0px; font-size:0.8em;">보유포인트 <?php echo number_format($member['mb_point']);?> Point</th>
            <?php } else { ?>
                <?php /*
                <th scope="col" style="text-align:center; width:50%; letter-spacing: 0px;">[보유포인트 <?php echo number_format($member['mb_point']);?> Point]&nbsp; [출금수수료 <?php echo ((double)$member['mb_withdraw_fee'] <= 100.0)?$member['mb_withdraw_fee']."%": number_format($member['mb_withdraw_fee'])." Point";?>]&nbsp; [출금가능 <?php echo number_format($member['mb_point']-$withdraw_limit);?> Point]</th>
                */ ?>
                <th scope="col" style="text-align:center; width:50%; letter-spacing: 0px;">보유포인트 <?php echo number_format($member['mb_point']);?> Point</th>
            <?php } ?>
        </tr>

        <script>
            var exchangeRate = 0.0;
            var exchangeRateHead = "";
            var currecncy_unit_type = 1;

            function updateLabelValue() {

                if(nationpay == 'KRW' || nationpay == '') {
                    exchangeRate = KRWKRW;
                    exchangeRateHead = "<img src='<?php echo G5_DATA_URL?>/item/img_nation_flag/svg/kr.svg' class='nation_flag_img2'>";
                    currecncy_unit_type = 1;
                } else if(nationpay == 'USD') {
                    exchangeRate = KRWUSD;
                    exchangeRateHead = "<img src='<?php echo G5_DATA_URL?>/item/img_nation_flag/svg/us.svg' class='nation_flag_img1'>";
                    currecncy_unit_type = 2;
                } else if(nationpay == 'EUR') {
                    exchangeRate = KRWEUR;
                    exchangeRateHead = "<img src='<?php echo G5_DATA_URL?>/item/img_nation_flag/svg/eu.svg' class='nation_flag_img1'>";
                    currecncy_unit_type = 2;
                } else if(nationpay == 'CNY') {
                    exchangeRate = KRWCNY;
                    exchangeRateHead = "<img src='<?php echo G5_DATA_URL?>/item/img_nation_flag/svg/cn.svg' class='nation_flag_img1'>";
                    currecncy_unit_type = 2;
                } else if(nationpay == 'JPY') {
                    exchangeRate = KRWJPY;
                    exchangeRateHead = "<img src='<?php echo G5_DATA_URL?>/item/img_nation_flag/svg/jp.svg' class='nation_flag_img2'>";
                    currecncy_unit_type = 1;
                } else if(nationpay == 'VND') {
                    exchangeRate = KRWVND;
                    exchangeRateHead = "<img src='<?php echo G5_DATA_URL?>/item/img_nation_flag/svg/vn.svg' class='nation_flag_img1'>";
                    currecncy_unit_type = 0;
                }

                var inputField = document.getElementById('point_charge_select');
                let inputValue = inputField.value;

                if (inputValue.length === 1 && inputValue === "0") {
                    inputField.value = "";
                    inputValue = "";
                }
                // 입력 값이 NaN이거나 공백일 때 0으로 채우기
                if (isNaN(inputValue) || inputValue.trim() === "") {
                    inputField.value = "0";
                    inputValue = "0";
                }
                calculate_order_price();
            }

            function showPointChargeToast(message) {
                var $toast = $('#point_charge_toast');
                if (!$toast.length) {
                    return;
                }
                $toast.text(message).stop(true, true).slideDown(180).delay(2200).slideUp(220);
            }

            function validateRange(fromBlur) {
                var inputField = document.getElementById("point_charge_select");
                var value = parseInt(inputField.value, 10);
                var min = parseInt(inputField.getAttribute("min"), 10);
                var max = parseInt(inputField.getAttribute("max"), 10);

                if (isNaN(value)) {
                    inputField.value = (window.lastValidPointCharge || "0");
                    calculate_order_price();
                    if (!fromBlur) inputField.focus({ preventScroll: true });
                    return;
                }

                if (value < min || value > max) {
                    showPointChargeToast("입력 값은 " + (min+1) + "과 " + max + " 사이여야 합니다.");
                    inputField.value = (window.lastValidPointCharge || "0");
                    calculate_order_price();
                    if (!fromBlur) inputField.focus({ preventScroll: true });
                    return;
                }

                window.lastValidPointCharge = String(value);
            }

            function validateInput(event) {
                const inputField = document.getElementById('point_charge_select');
                const key = event.key;
                const keyCode = event.keyCode;

                const isNumberKey = key >= '0' && key <= '9';
                const isBackspaceKey = keyCode === 8;
                const isArrowKey = keyCode === 37 || keyCode === 39;

                if (isNumberKey || isBackspaceKey || isArrowKey) {
                    if (inputField.value.length === 1 && inputField.value === "0" && isNumberKey) {
                        inputField.value = key;
                        event.preventDefault();
                    }
                } else {
                    event.preventDefault();
                }
            }
        </script>


<tbody>
<?php
// 복합과세처리
if($default['de_tax_flag_use']) {
    $comm_tax_mny = round(($tot_tax_mny) / 1.1);
    $comm_vat_mny = ($tot_tax_mny) - $comm_tax_mny;
}
?>
</tbody>
</table>
    </div>


    <!-- } 주문상품 확인 끝 -->

    <?php if (G5_IS_MOBILE) { ?>
        <div style="display:flex; justify-content:center; items-align:center; flex-direction:column; width:100%;">
            <div class="sod_left" style="width:100%;padding:0px;">
                <input type="hidden" name="od_price">
                <input type="hidden" name="org_od_price">
                <input type="hidden" name="od_send_cost" value="0">
                <input type="hidden" name="od_send_cost2" value="0">
                <input type="hidden" name="item_coupon" value="0">
                <input type="hidden" name="od_coupon" value="0">
                <input type="hidden" name="od_send_coupon" value="0">
                <input type="hidden" name="od_goods_name" value="<?php echo $goods?>">

                <?php
                // 결제대행사별 코드 include (결제대행사 정보 필드)
                require_once(G5_PATH.'/shoppoint/'.$default['de_pg_service'].'/orderform.2.php');

                if($is_kakaopay_use) {
                    require_once(G5_PATH.'/shoppoint/kakaopay/orderform.2.php');
                }
                ?>

                <!-- 포인트 충전 하시는 분 입력 시작 { -->
                <section id="sod_frm_orderer" style="display:none;">
                    <h2 style="font-size:1.2em; font-weight:bold;">포인트 충전 하시는 분</h2>

                    <div class="tbl_frm01 tbl_wrap">
                        <table style="font-size:1.1rem;">
                        <tbody>
                        <tr>
                            <th scope="row"><label for="od_name">이름<strong class="sound_only"> 필수</strong></label></th>
                            <td><input type="text" name="od_name" value="<?php echo get_text($member['mb_name']); ?>" id="od_name" required class="frm_input required" maxLength="32" readonly></td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_email">E-mail<strong class="sound_only"> 필수</strong></label></th>
                            <td><input type="text" name="od_email" value="<?php echo $member['mb_email']; ?>" id="od_email" required class="frm_input required" size="35" maxlength="100" readonly></td>
                        </tr>

                        <?php if (!$is_member) { // 비회원이면 ?>
                        <tr>
                            <th scope="row"><label for="od_pwd">비밀번호</label></th>
                            <td>
                                <span class="frm_info">영,숫자 3~20자 (주문서 조회시 필요)</span>
                                <input type="password" name="od_pwd" id="od_pwd" required class="frm_input required" maxLength="32">
                            </td>
                        </tr>
                        <?php } ?>

                        <tr style="display:none;">
                            <th scope="row"><label for="od_tel">전화번호<strong class="sound_only"> 필수</strong></label></th>
                            <td>
                                <input type="text" name="od_tel" value="<?php echo get_text($member['mb_tel']); ?>" id="od_tel" required class="frm_input" maxLength="32">
                            </td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_sns_name">메신저</label></th>
                            <td>
                                <?php
                                // SNS 배열
                                // $snslist = [
                                //     "WhatsApp", "Facebook", "WeChat", "LINE", "Skype", "Viber", "Tango", "Nimbuzz", "KakaoTalk", "kik", "Telegram", "Hike", "Zalo"
                                // ];
                                ?>
                                <select name="od_sns_name" id="od_sns_name" style="width:45%; max-width:144.4px; margin-right:5px;" class="frm_input" maxlength="30">
                                    <option value="">- 메신저 선택 -</option>
                                    <?php
                                    $member_sns_name = isset($member['mb_sns_name']) ? trim((string)$member['mb_sns_name']) : '';
                                    foreach ($snslist as $key => $val) {
                                        $selected = (strcasecmp($member_sns_name, (string)$key) === 0 || strcasecmp($member_sns_name, (string)$val) === 0) ? ' selected' : '';
                                        echo "<option value=\"$key\"$selected>$val</option>";
                                    }
                                    ?>
                                </select>
                                <input type="text" name="od_sns_id" id="od_sns_id" style="width:46%; max-width:144.4px;" placeholder="메신저ID 입력" oninput="this.value=this.value.replace(/\s/g, '');" value="<?php echo get_text($member['mb_sns_id']); ?>" class="frm_input" maxlength="30">
                            </td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_hp">휴대폰</label></th>
                            <td>
                                <?php
                                // 국가 배열
                                // $countries = [
                                //     "AFGHANISTAN", "ALBANIA", "ALGERIA", "ANDORRA", "ANGOLA", "ANTIGUA AND BARBUDA", "ARGENTINA", "ARMENIA", "AUSTRALIA",
                                //     "AUSTRIA", "AZERBAIJAN", "BAHAMAS", "BAHRAIN", "BANGLADESH", "BARBADOS", "BELARUS", "BELGIUM", "BELIZE", "BENIN",
                                //     "BHUTAN", "BOLIVIA", "BOSNIA AND HERZEGOVINA", "BOTSWANA", "BRAZIL", "BRUNEI", "BULGARIA", "BURKINA FASO", "BURUNDI",
                                //     "CABO VERDE", "CAMBODIA", "CAMEROON", "CANADA", "CENTRAL AFRICAN REPUBLIC", "CHAD", "CHILE", "CHINA", "COLOMBIA",
                                //     "COMOROS", "CONGO", "COSTA RICA", "COTE D'IVOIRE", "CROATIA", "CUBA", "CYPRUS", "CZECH REPUBLIC", "DENMARK", "DJIBOUTI",
                                //     "DOMINICA", "DOMINICAN REPUBLIC", "ECUADOR", "EGYPT", "EL SALVADOR", "EQUATORIAL GUINEA", "ERITREA", "ESTONIA", "ESWATINI",
                                //     "ETHIOPIA", "FIJI", "FINLAND", "FRANCE", "GABON", "GAMBIA", "GEORGIA", "GERMANY", "GHANA", "GREECE", "GRENADA", "GUATEMALA",
                                //     "GUINEA", "GUINEA-BISSAU", "GUYANA", "HAITI", "HONDURAS", "HUNGARY", "ICELAND", "INDIA", "INDONESIA", "IRAN", "IRAQ",
                                //     "IRELAND", "ISRAEL", "ITALY", "JAMAICA", "JAPAN", "JORDAN", "KAZAKHSTAN", "KENYA", "KIRIBATI", "KOREA", "KOSOVO", "KUWAIT",
                                //     "KYRGYZSTAN", "LAOS", "LATVIA", "LEBANON", "LESOTHO", "LIBERIA", "LIBYA", "LIECHTENSTEIN", "LITHUANIA", "LUXEMBOURG",
                                //     "MADAGASCAR", "MALAWI", "MALAYSIA", "MALDIVES", "MALI", "MALTA", "MARSHALL ISLANDS", "MAURITANIA", "MAURITIUS", "MEXICO",
                                //     "MICRONESIA", "MOLDOVA", "MONACO", "MONGOLIA", "MONTENEGRO", "MOROCCO", "MOZAMBIQUE", "MYANMAR", "NAMIBIA", "NAURU",
                                //     "NEPAL", "NETHERLANDS", "NEW ZEALAND", "NICARAGUA", "NIGER", "NIGERIA", "NORTH KOREA", "NORTH MACEDONIA", "NORWAY", "OMAN",
                                //     "PAKISTAN", "PALAU", "PALESTINE", "PANAMA", "PAPUA NEW GUINEA", "PARAGUAY", "PERU", "PHILIPPINES", "POLAND", "PORTUGAL",
                                //     "QATAR", "ROMANIA", "RUSSIA", "RWANDA", "SAINT KITTS AND NEVIS", "SAINT LUCIA", "SAINT VINCENT AND THE GRENADINES", "SAMOA",
                                //     "SAN MARINO", "SAO TOME AND PRINCIPE", "SAUDI ARABIA", "SENEGAL", "SERBIA", "SEYCHELLES", "SIERRA LEONE", "SINGAPORE",
                                //     "SLOVAKIA", "SLOVENIA", "SOLOMON ISLANDS", "SOMALIA", "SOUTH AFRICA", "SOUTH KOREA", "SOUTH SUDAN", "SPAIN", "SRI LANKA",
                                //     "SUDAN", "SURINAME", "SWEDEN", "SWITZERLAND", "SYRIA", "TAIWAN", "TAJIKISTAN", "TANZANIA", "THAILAND", "TIMOR-LESTE",
                                //     "TOGO", "TONGA", "TRINIDAD AND TOBAGO", "TUNISIA", "TURKEY", "TURKMENISTAN", "TUVALU", "UGANDA", "UKRAINE", "UNITED ARAB EMIRATES",
                                //     "UNITED KINGDOM", "UNITED STATES", "URUGUAY", "UZBEKISTAN", "VANUATU", "VATICAN CITY", "VENEZUELA", "VIETNAM", "YEMEN", "ZAMBIA", "ZIMBABWE"
                                // ];
                                ?>
                                <select name="od_hp_nation" id="od_hp_nation" style="width:45%; max-width:144.4px; margin-right:5px;" class="frm_input" maxlength="30">
                                    <option value="">- 국가 선택 -</option>
                                    <?php
                                    $user_nation = (isset($member['mb_hp_nation']) && $member['mb_hp_nation']) ? $member['mb_hp_nation'] : 'KOREA';
                                    foreach ($countries as $country => $code) {
                        $selected = strtolower($user_nation) == strtolower($country) ? ' selected' : '';
                        $display_name = $country;
                        if (isset($country_local_names[$country])) {
                            $display_name = $country . ' (' . $country_local_names[$country] . ')';
                        }
                        echo "<option value=\"$country\"$selected>$display_name ($code)</option>";
									}
                                    ?>
                                </select>
                                <input type="text" name="od_hp" value="<?php echo get_text($member['mb_hp']); ?>" id="od_hp" class="frm_input" maxLength="12" style="width:46%; max-width:144.4px;" inputmode="numeric" pattern="[0-9]*" oninput="this.value=this.value.replace(/[^0-9]/g, '').slice(0, 12);">
                            </td>
                        </tr>
                        <tr style="display:none;">
                            <th scope="row">주소</th>
                            <td>
                                <label for="od_zip" class="sound_only">우편번호<strong class="sound_only"> 필수</strong></label>
                                <input type="text" name="od_zip" value="<?php echo $member['mb_zip1'].$member['mb_zip2']; ?>" id="od_zip" required class="frm_input" size="8" maxlength="6" placeholder="우편번호">
                                <button type="button" class="btn_address" onclick="win_zip('forderform', 'od_zip', 'od_addr1', 'od_addr2', 'od_addr3', 'od_addr_jibeon');">주소 검색</button><br>
                                <input type="text" name="od_addr1" value="<?php echo get_text($member['mb_addr1']) ?>" id="od_addr1" required class="frm_input frm_address" size="60" placeholder="기본주소">
                                <label for="od_addr1" class="sound_only">기본주소<strong class="sound_only"> 필수</strong></label><br>
                                <input type="text" name="od_addr2" value="<?php echo get_text($member['mb_addr2']) ?>" id="od_addr2" class="frm_input frm_address" size="60" placeholder="상세주소">
                                <label for="od_addr2" class="sound_only">상세주소</label>
                                <br>
                                <input type="text" name="od_addr3" value="<?php echo get_text($member['mb_addr3']) ?>" id="od_addr3" class="frm_input frm_address" size="60" readonly="readonly" placeholder="참고항목">
                                <label for="od_addr3" class="sound_only">참고항목</label><br>
                                <input type="hidden" name="od_addr_jibeon" value="<?php echo get_text($member['mb_addr_jibeon']); ?>">
                            </td>
                        </tr>

                        <?php if ($default['de_hope_date_use']) { // 배송희망일 사용 ?>
                        <tr>
                            <th scope="row"><label for="od_hope_date">희망배송일</label></th>
                            <td>
                                <!-- <select name="od_hope_date" id="od_hope_date">
                                <option value="">선택하십시오.</option>
                                <?php
                                for ($i=0; $i<7; $i++) {
                                    $sdate = date("Y-m-d", time()+86400*($default['de_hope_date_after']+$i));
                                    echo '<option value="'.$sdate.'">'.$sdate.' ('.get_yoil($sdate).')</option>'.PHP_EOL;
                                }
                                ?>
                                </select> -->
                                <input type="text" name="od_hope_date" value="" id="od_hope_date" required class="frm_input required" size="11" maxlength="10" readonly="readonly"> 이후로 배송 바랍니다.
                            </td>
                        </tr>
                        <?php } ?>
                        </tbody>
                        </table>
                    </div>
                </section>
                <!-- } 포인트 충전 하시는 분 입력 끝 -->

                <!-- 받으시는 분 입력 시작 { -->
                <section id="sod_frm_taker" style="display:none;">
                    <h2>받으시는 분</h2>

                    <div class="tbl_frm01 tbl_wrap">
                        <table>
                        <tbody>
                        <?php
                        if($is_member) {
                            // 배송지 이력
                            $addr_list = '';
                            $sep = chr(30);

                            // 주문자와 동일
                            $addr_list .= '<input type="radio" name="ad_sel_addr" value="same" id="ad_sel_addr_same">'.PHP_EOL;
                            $addr_list .= '<label for="ad_sel_addr_same">주문자와 동일</label>'.PHP_EOL;

                            // 기본배송지
                            $sql = " select *
                                        from {$g5['g5_shop_order_address_table']}
                                        where mb_id = '{$member['mb_id']}'
                                        and ad_default = '1' ";
                            $row = sql_fetch($sql);
                            if($row['ad_id']) {
                                $val1 = $row['ad_name'].$sep.$row['ad_tel'].$sep.$row['ad_hp'].$sep.$row['ad_zip1'].$sep.$row['ad_zip2'].$sep.$row['ad_addr1'].$sep.$row['ad_addr2'].$sep.$row['ad_addr3'].$sep.$row['ad_jibeon'].$sep.$row['ad_subject'];
                                $addr_list .= '<input type="radio" name="ad_sel_addr" value="'.get_text($val1).'" id="ad_sel_addr_def">'.PHP_EOL;
                                $addr_list .= '<label for="ad_sel_addr_def">기본배송지</label>'.PHP_EOL;
                            }

                            // 최근배송지
                            $sql = " select *
                                        from {$g5['g5_shop_order_address_table']}
                                        where mb_id = '{$member['mb_id']}'
                                        and ad_default = '0'
                                        order by ad_id desc
                                        limit 1 ";
                            $result = sql_query($sql);
                            for($i=0; $row=sql_fetch_array($result); $i++) {
                                $val1 = $row['ad_name'].$sep.$row['ad_tel'].$sep.$row['ad_hp'].$sep.$row['ad_zip1'].$sep.$row['ad_zip2'].$sep.$row['ad_addr1'].$sep.$row['ad_addr2'].$sep.$row['ad_addr3'].$sep.$row['ad_jibeon'].$sep.$row['ad_subject'];
                                $val2 = '<label for="ad_sel_addr_'.($i+1).'">최근배송지('.($row['ad_subject'] ? get_text($row['ad_subject']) : get_text($row['ad_name'])).')</label>';
                                $addr_list .= '<input type="radio" name="ad_sel_addr" value="'.get_text($val1).'" id="ad_sel_addr_'.($i+1).'"> '.PHP_EOL.$val2.PHP_EOL;
                            }

                            $addr_list .= '<input type="radio" name="ad_sel_addr" value="new" id="od_sel_addr_new">'.PHP_EOL;
                            $addr_list .= '<label for="od_sel_addr_new">신규배송지</label>'.PHP_EOL;

                            $addr_list .='<a href="'.G5_SHOP_URL.'/orderaddress.php" id="order_address" class="btn_frmline">배송지목록</a>';
                        } else {
                            // 주문자와 동일
                            $addr_list .= '<input type="checkbox" name="ad_sel_addr" value="same" id="ad_sel_addr_same">'.PHP_EOL;
                            $addr_list .= '<label for="ad_sel_addr_same">주문자와 동일</label>'.PHP_EOL;
                        }
                        ?>
                        <tr>
                            <th scope="row">배송지선택</th>
                            <td>
                                <?php echo $addr_list; ?>
                            </td>
                        </tr>
                        <?php if($is_member) { ?>
                        <tr>
                            <th scope="row"><label for="ad_subject">배송지명</label></th>
                            <td>
                                <input type="text" name="ad_subject" id="ad_subject" class="frm_input" maxLength="32">
                                <input type="checkbox" name="ad_default" id="ad_default" value="1">
                                <label for="ad_default">기본배송지로 설정</label>
                            </td>
                        </tr>
                        <?php } ?>
                        <tr>
                            <th scope="row"><label for="od_b_name">이름<strong class="sound_only"> 필수</strong></label></th>
                            <td><input type="text" name="od_b_name" id="od_b_name" required class="frm_input" maxLength="32"></td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_b_tel">전화번호<strong class="sound_only"> 필수</strong></label></th>
                            <td><input type="text" name="od_b_tel" id="od_b_tel" required class="frm_input" maxLength="32"></td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_b_hp">휴대폰</label></th>
                            <td><input type="text" name="od_b_hp" id="od_b_hp" class="frm_input" maxLength="32"></td>
                        </tr>
                        <tr>
                            <th scope="row">주소</th>
                            <td id="sod_frm_addr">
                                <label for="od_b_zip" class="sound_only">우편번호<strong class="sound_only"> 필수</strong></label>
                                <input type="text" name="od_b_zip" id="od_b_zip" required class="frm_input" size="8" maxlength="6" placeholder="우편번호">
                                <button type="button" class="btn_address" onclick="win_zip('forderform', 'od_b_zip', 'od_b_addr1', 'od_b_addr2', 'od_b_addr3', 'od_b_addr_jibeon');">주소 검색</button><br>
                                <input type="text" name="od_b_addr1" id="od_b_addr1" required class="frm_input frm_address" size="60" placeholder="기본주소">
                                <label for="od_b_addr1" class="sound_only">기본주소<strong> 필수</strong></label><br>
                                <input type="text" name="od_b_addr2" id="od_b_addr2" class="frm_input frm_address" size="60" placeholder="상세주소">
                                <label for="od_b_addr2" class="sound_only">상세주소</label>
                                <br>
                                <input type="text" name="od_b_addr3" id="od_b_addr3" readonly="readonly" class="frm_input frm_address" size="60" placeholder="참고항목">
                                <label for="od_b_addr3" class="sound_only">참고항목</label><br>
                                <input type="hidden" name="od_b_addr_jibeon" value="">
                            </td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_memo">전하실말씀</label></th>
                            <td><textarea name="od_memo" id="od_memo"></textarea></td>
                        </tr>
                        </tbody>
                        </table>
                    </div>
                </section>
                <!-- } 받으시는 분 입력 끝 -->
            </div>

            <div class="sod_right" style="width:100%;">
                <!-- 주문상품 합계 시작 { -->
                <div id="sod_bsk_tot">
                    <ul>
                        <li class="sod_bsk_sell" style="width:100%; height:auto; padding:5px;">
                            <span style="height:12px;">포인트 충전</span>
                            <strong id="tot_sell_price" style="font-size:1.5em;"></strong><strong style="font-size:1.5em;"> Point</strong>
                        </li>
                    </ul>
                </div>
                <!-- } 주문상품 합계 끝 -->


                <!-- 결제정보 입력 시작 { -->
                <section id="sod_frm_pay">
                    <h2>결제정보</h2>

                    <div class="pay_tbl">
                        <table>
                        <tbody>
                        <?php if($oc_cnt > 0) { ?>
                        <tr>
                            <th scope="row">주문할인</th>
                            <td>
                                <strong id="od_cp_price">0</strong>원
                                <input type="hidden" name="od_cp_id" value="">
                                <button type="button" id="od_coupon_btn" class="btn_frmline">쿠폰적용</button>
                            </td>
                        </tr>
                        <?php } ?>
                        <?php if($sc_cnt > 0) { ?>
                        <tr>
                            <th scope="row">배송비할인</th>
                            <td>
                                <strong id="sc_cp_price">0</strong>원
                                <input type="hidden" name="sc_cp_id" value="">
                                <button type="button" id="sc_coupon_btn" class="btn_frmline">쿠폰적용</button>
                            </td>
                        </tr>
                        <?php } ?>

                        <!--
                        <tr>
                            <th>추가배송비</th>
                            <td><strong id="od_send_cost2">0</strong>원<br>(지역에 따라 추가되는 도선료 등의 배송비입니다.)</td>
                        </tr>
                        -->
                        </tbody>
                        </table>
                    </div>

                    <div id="od_tot_price">
                        <span>적용 환율</span>
                        <strong class="print_fx_rate" id="od_fx_rate_disp" style="color:#333; font-size:1em;">1 Point = 1 KRW</strong>
                    </div>

                    <div id="od_tot_price">
                        <span>결제하실금액</span>
                        <strong class="print_price"></strong>
                    </div>

                    <div>
                        <?php echo '<p id="sod_frm_pt_alert">통화국가의 <strong>은행계좌</strong> 또는 <strong>암호화폐, 전자화폐</strong>로 결제 가능합니다.<br>입금하실 <strong>계좌번호</strong> 또는 <strong>QR코드</strong>는 <strong>주문완료</strong>후 확인하실 수 있습니다.</p>'; ?>
                    </div>

                    <div id="od_pay_sl" style="display:none;"> <!-- 모바일 버전 -->
                        <h3>결제방법</h3>
                        <?php
                        if (!$default['de_card_point']) {
                            //echo '<p id="sod_frm_pt_alert"><strong>무통장입금</strong> 이외의 결제 수단으로 결제하시는 경우 포인트를 적립해드리지 않습니다.</p>';
                            echo '<p id="sod_frm_pt_alert">통화국가의 <strong>은행계좌</strong> 또는 <strong>암호화폐, 전자화폐</strong>로 결제 가능합니다.<br>입금하실 <strong>계좌번호</strong> 또는 <strong>QR코드</strong>는 <strong>주문완료</strong>후 확인하실 수 있습니다.</p>';
                        }

                        $multi_settle = 0;
                        $checked = '';

                        $escrow_title = "";
                        if ($default['de_escrow_use']) {
                            $escrow_title = "에스크로<br>";
                        }

                        if ($is_kakaopay_use || $default['de_bank_use'] || $default['de_vbank_use'] || $default['de_iche_use'] || $default['de_card_use'] || $default['de_hp_use'] || $default['de_easy_pay_use'] || $default['de_inicis_lpay_use']) {
                            echo '<fieldset id="sod_frm_paysel">';
                            echo '<legend>결제방법 선택</legend>';
                        }

                        // 카카오페이
                        if($is_kakaopay_use) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_kakaopay" name="od_settle_case" value="KAKAOPAY" '.$checked.'> <label for="od_settle_kakaopay" class="kakaopay_icon lb_icon">KAKAOPAY</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 무통장입금 사용
                        if ($default['de_bank_use']) {
                            $multi_settle++;
                            //echo '<input type="radio" id="od_settle_bank" name="od_settle_case" value="무통장" '.$checked.'> <label for="od_settle_bank" class="lb_icon bank_icon" style="width:100%;">무통장입금</label>'.PHP_EOL;
                            echo '<input type="radio" id="od_settle_bank" name="od_settle_case" value="무통장" checked'.$checked.'> <label for="od_settle_bank" class="lb_icon bank_icon" style="width:100%;">무통장입금</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 가상계좌 사용
                        if ($default['de_vbank_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_vbank" name="od_settle_case" value="가상계좌" '.$checked.'> <label for="od_settle_vbank" class="lb_icon vbank_icon">'.$escrow_title.'가상계좌</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 계좌이체 사용
                        if ($default['de_iche_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_iche" name="od_settle_case" value="계좌이체" '.$checked.'> <label for="od_settle_iche" class="lb_icon iche_icon">'.$escrow_title.'계좌이체</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 휴대폰 사용
                        if ($default['de_hp_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_hp" name="od_settle_case" value="휴대폰" '.$checked.'> <label for="od_settle_hp" class="lb_icon hp_icon">휴대폰</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 신용카드 사용
                        if ($default['de_card_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_card" name="od_settle_case" value="신용카드" '.$checked.'> <label for="od_settle_card" class="lb_icon card_icon">신용카드</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // PG 간편결제
                        if($default['de_easy_pay_use']) {
                            switch($default['de_pg_service']) {
                                case 'lg':
                                    $pg_easy_pay_name = 'PAYNOW';
                                    break;
                                case 'inicis':
                                    $pg_easy_pay_name = 'KPAY';
                                    break;
                                default:
                                    $pg_easy_pay_name = 'PAYCO';
                                    break;
                            }

                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_easy_pay" name="od_settle_case" value="간편결제" '.$checked.'> <label for="od_settle_easy_pay" class="'.$pg_easy_pay_name.' lb_icon">'.$pg_easy_pay_name.'</label>'.PHP_EOL;
                            $checked = '';
                        }

                        //이니시스 Lpay
                        if($default['de_inicis_lpay_use']) {
                            echo '<input type="radio" id="od_settle_inicislpay" data-case="lpay" name="od_settle_case" value="lpay" '.$checked.'> <label for="od_settle_inicislpay" class="inicis_lpay lb_icon">L.pay</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 포인트 전액결제
                        if (1) {
                            $multi_settle++;
                            echo '<div id="div_od_settle_point" style="display:none;"><input type="radio" id="od_settle_point" name="od_settle_case" value="포인트" '.$checked.'> <label for="od_settle_point" class="lb_icon point_icon">포인트 전액결제</label></div>'.PHP_EOL;
                            $checked = '';
                        }

                        $temp_point = 0;
                        // 회원이면서 포인트사용이면
                        if ($is_member && $config['cf_use_point'])
                        {
                            // 포인트 결제 사용 포인트보다 회원의 포인트가 크다면
                            if ($member['mb_point'] >= $default['de_settle_min_point'])
                            {
                        ?>
                            <div class="sod_frm_point">
                                <div id="sod_frm_pt">
                                    <span><strong>보유포인트</strong><?php echo display_point($member['mb_point']); ?></span>
                                </div>
                            </div>
                        <?php
                            $multi_settle++;
                            }
                        }

                        // 이것은 기본 소스코드 임 JSLEE (아래에 수정된 소스코드가 있음)
                        // if ($default['de_bank_use']) {
                        // 	// 은행계좌를 배열로 만든후
                        // 	$str = explode("\n", trim($default['de_bank_account']));
                        // 	if (count($str) <= 1)
                        // 	{
                        // 		$bank_account = '<input type="hidden" name="od_bank_account" value="'.$str[0].'">'.$str[0].PHP_EOL;
                        // 	}
                        // 	else
                        // 	{
                        // 		$bank_account = '<select name="od_bank_account" id="od_bank_account">'.PHP_EOL;
                        // 		$bank_account .= '<option value="">선택하십시오.</option>';
                        // 		for ($i=0; $i<count($str); $i++)
                        // 		{
                        // 			//$str[$i] = str_replace("\r", "", $str[$i]);
                        // 			$str[$i] = trim($str[$i]);
                        // 			$bank_account .= '<option value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                        // 		}
                        // 		$bank_account .= '</select>'.PHP_EOL;
                        // 	}
                        // 	echo '<div id="settle_bank" style="display:none">';
                        // 	echo '<label for="od_bank_account" class="sound_only">입금할 계좌</label>';
                        // 	echo $bank_account;
                        // 	echo '<br><label for="od_deposit_name">입금자명</label> ';
                        // 	echo '<input type="text" name="od_deposit_name" id="od_deposit_name" size="10" maxLength="32">';
                        // 	echo '</div>';
                        // }

                        // 외화 계좌 취급을 위해 코드 변경 JSLEE
                        if ($default['de_bank_use']) {
                            // 은행계좌를 배열로 만든후
                            $str = explode("\n", trim($default['de_bank_account']));
                            if (count($str) <= 1)
                            {
                                $bank_account = '<input type="hidden" name="od_bank_account" value="'.$str[0].'">'.$str[0].PHP_EOL;
                            }
                            else
                            {
                                $bank_account = '<select name="od_bank_account" id="od_bank_account" style="background:yellow; font-weight:bold;">'.PHP_EOL;
                                //$bank_account .= '<option value="">선택하십시오.</option>';
                                for ($i=0; $i<count($str); $i++)
                                {
                                    //$str[$i] = str_replace("\r", "", $str[$i]);
                                    $str[$i] = trim($str[$i]);
                                    if (stripos($str[$i], "[KRW]") !== false) {
                                        $bank_account .= '<option class="KRW" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[USD]") !== false) {
                                        $bank_account .= '<option class="USD" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[EUR]") !== false) {
                                        $bank_account .= '<option class="EUR" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[CNY]") !== false) {
                                        $bank_account .= '<option class="CNY" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[JPY]") !== false) {
                                        $bank_account .= '<option class="JPY" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[VND]") !== false) {
                                        $bank_account .= '<option class="VND" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    }
                                }
                                $bank_account .= '</select>'.PHP_EOL;
                            }
                            echo '<div id="settle_bank" style="display:none">';
                            echo '<label for="od_bank_account" class="sound_only">입금할 계좌</label>';
                            echo $bank_account;
                            echo '<div style="display:flex; justify-content:center; align-items:center; width:100%; background-color: lightgray; padding: 10px;">' .
                                '<label for="od_deposit_name" style="margin-right: 5px;">입금자명</label>' .
                                '<input type="text" name="od_deposit_name" id="od_deposit_name" maxLength="32" readonly style="background:yellow; font-weight:bold; flex:1 1 auto; cursor:default;">' .
                                '</div>';
                            echo '</div>';
                        }

                        if ($is_kakaopay_use || $default['de_bank_use'] || $default['de_vbank_use'] || $default['de_iche_use'] || $default['de_card_use'] || $default['de_hp_use'] || $default['de_easy_pay_use'] || $default['de_inicis_lpay_use'] ) {
                            echo '</fieldset>';
                        }

                        if ($multi_settle == 0)
                            echo '<p>결제할 방법이 없습니다.<br>운영자에게 알려주시면 감사하겠습니다.</p>';
                        ?>
                    </div>
                </section>
                <!-- } 결제 정보 입력 끝 -->

                <?php
                // 통신판매중개 플랫폼 주문 전 확인사항 (결제하기 버튼 바로 위)
                if(function_exists('vpnlink_platform_notice')) echo vpnlink_platform_notice('order');

                // 결제대행사별 코드 include (주문버튼)
                require_once(G5_PATH.'/shoppoint/'.$default['de_pg_service'].'/orderform.3.php');

                if($is_kakaopay_use) {
                    require_once(G5_PATH.'/shoppoint/kakaopay/orderform.3.php');
                }
                ?>

                <?php
                if ($default['de_escrow_use']) {
                    // 결제대행사별 코드 include (에스크로 안내)
                    require_once(G5_PATH.'/shoppoint/'.$default['de_pg_service'].'/orderform.4.php');
                }
                ?>
            </div>
        </div>

        <div style="margin-top:20px;">
            <style>
                .limit_table {
                    width: 100%;
                    border-collapse: collapse;
                    --lt-border: #ddd;
                    --lt-bg: transparent;
                    --lt-bg-th: #fafafa;
                    --lt-color: inherit;
                    --lt-color-th: inherit;
                }
                [data-site-theme="dark"] .limit_table {
                    --lt-border: #2d2d42;
                    --lt-bg: #252535;
                    --lt-bg-th: #1e1e2e;
                    --lt-color: #e2e8f0;
                    --lt-color-th: #94a3b8;
                }
                .limit_table tr, .limit_table th, .limit_table td {
                    border: 1px solid var(--lt-border);
                    padding: 3px;
                    text-align: center;
                }
                .limit_table td { background-color: var(--lt-bg); color: var(--lt-color); }
                .limit_table th { background-color: var(--lt-bg-th); color: var(--lt-color-th); }
            </style>
            <table class="limit_table">
                <tr>
                    <th>포인트 충전</th>
                    <th>나의 충전한도</th>
                    <th>현재 가용한도</th>
                </tr>
                <tr>
                    <th>1회</th>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1try']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1try']-$row_point_limit_info['point_limit_charge_1try_used']) ?> Point</td>
                </tr>
                <tr>
                    <th>1일</th>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1day']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1day']-$row_point_limit_info['point_limit_charge_1day_used']) ?> Point</td>
                </tr>
                <tr>
                    <th>월간</th>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1month']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1month']-$row_point_limit_info['point_limit_charge_1month_used']) ?> Point</td>
                </tr>
                <tr>
                    <th>연간</th>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1year']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1year']-$row_point_limit_info['point_limit_charge_1year_used']) ?> Point</td>
                </tr>
            </table>
        </div>


















    <?php } else { // PC버전 ?>















        <div class="point-charge-cards" style="display:flex; justify-content:center; items-align:center; width:100%;">
            <div class="sod_left" style="width:65%;">
                <input type="hidden" name="od_price">
                <input type="hidden" name="org_od_price">
                <input type="hidden" name="od_send_cost" value="0">
                <input type="hidden" name="od_send_cost2" value="0">
                <input type="hidden" name="item_coupon" value="0">
                <input type="hidden" name="od_coupon" value="0">
                <input type="hidden" name="od_send_coupon" value="0">
                <input type="hidden" name="od_goods_name" value="<?php echo $goods?>">

                <?php
                // 결제대행사별 코드 include (결제대행사 정보 필드)
                require_once(G5_PATH.'/shoppoint/'.$default['de_pg_service'].'/orderform.2.php');

                if($is_kakaopay_use) {
                    require_once(G5_PATH.'/shoppoint/kakaopay/orderform.2.php');
                }
                ?>

                <!-- 포인트 충전 하시는 분 입력 시작 { -->
                <section id="sod_frm_orderer">
                    <h2 style="font-size:1.2em; font-weight:bold;">포인트 충전 하시는 분</h2>

                    <div class="tbl_frm01 tbl_wrap">
                        <table style="font-size:1.1rem;">
                        <tbody>
                        <tr>
                            <th scope="row"><label for="od_name">이름<strong class="sound_only"> 필수</strong></label></th>
                            <td><input type="text" name="od_name" value="<?php echo get_text($member['mb_name']); ?>" id="od_name" required class="frm_input required" maxLength="32" readonly></td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_email">E-mail<strong class="sound_only"> 필수</strong></label></th>
                            <td><input type="text" name="od_email" value="<?php echo $member['mb_email']; ?>" id="od_email" required class="frm_input required" size="35" maxlength="100" readonly></td>
                        </tr>

                        <?php if (!$is_member) { // 비회원이면 ?>
                        <tr>
                            <th scope="row"><label for="od_pwd">비밀번호</label></th>
                            <td>
                                <span class="frm_info">영,숫자 3~20자 (주문서 조회시 필요)</span>
                                <input type="password" name="od_pwd" id="od_pwd" required class="frm_input required" maxLength="32">
                            </td>
                        </tr>
                        <?php } ?>

                        <tr style="display:none;">
                            <th scope="row"><label for="od_tel">전화번호<strong class="sound_only"> 필수</strong></label></th>
                            <td>
                                <input type="text" name="od_tel" value="<?php echo get_text($member['mb_tel']); ?>" id="od_tel" required class="frm_input" maxLength="32">
                            </td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_sns_name">메신저</label></th>
                            <td>
                                <?php
                                // SNS 배열
                                // $snslist = [
                                //     "WhatsApp", "Facebook", "WeChat", "LINE", "Skype", "Viber", "Tango", "Nimbuzz", "KakaoTalk", "kik", "Telegram", "Hike", "Zalo"
                                // ];
                                ?>
                                <select name="od_sns_name" id="od_sns_name" style="width:50%; max-width:144.4px; margin-right:5px;" class="frm_input" maxlength="30">
                                    <option value="">- 메신저 선택 -</option>
                                    <?php
                                    $member_sns_name = isset($member['mb_sns_name']) ? trim((string)$member['mb_sns_name']) : '';
                                    foreach ($snslist as $key => $val) {
                                        $selected = (strcasecmp($member_sns_name, (string)$key) === 0 || strcasecmp($member_sns_name, (string)$val) === 0) ? ' selected' : '';
                                        echo "<option value=\"$key\"$selected>$val</option>";
                                    }
                                    ?>
                                </select>
                                <input type="text" name="od_sns_id" id="od_sns_id" style="width:50%; max-width:144.4px;" placeholder="메신저ID 입력" oninput="this.value=this.value.replace(/\s/g, '');" value="<?php echo get_text($member['mb_sns_id']); ?>" class="frm_input" maxlength="30">
                            </td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_hp">휴대폰</label></th>
                            <td>
                                <?php
                                // 국가 배열
                                // $countries = [
                                //     "AFGHANISTAN", "ALBANIA", "ALGERIA", "ANDORRA", "ANGOLA", "ANTIGUA AND BARBUDA", "ARGENTINA", "ARMENIA", "AUSTRALIA",
                                //     "AUSTRIA", "AZERBAIJAN", "BAHAMAS", "BAHRAIN", "BANGLADESH", "BARBADOS", "BELARUS", "BELGIUM", "BELIZE", "BENIN",
                                //     "BHUTAN", "BOLIVIA", "BOSNIA AND HERZEGOVINA", "BOTSWANA", "BRAZIL", "BRUNEI", "BULGARIA", "BURKINA FASO", "BURUNDI",
                                //     "CABO VERDE", "CAMBODIA", "CAMEROON", "CANADA", "CENTRAL AFRICAN REPUBLIC", "CHAD", "CHILE", "CHINA", "COLOMBIA",
                                //     "COMOROS", "CONGO", "COSTA RICA", "COTE D'IVOIRE", "CROATIA", "CUBA", "CYPRUS", "CZECH REPUBLIC", "DENMARK", "DJIBOUTI",
                                //     "DOMINICA", "DOMINICAN REPUBLIC", "ECUADOR", "EGYPT", "EL SALVADOR", "EQUATORIAL GUINEA", "ERITREA", "ESTONIA", "ESWATINI",
                                //     "ETHIOPIA", "FIJI", "FINLAND", "FRANCE", "GABON", "GAMBIA", "GEORGIA", "GERMANY", "GHANA", "GREECE", "GRENADA", "GUATEMALA",
                                //     "GUINEA", "GUINEA-BISSAU", "GUYANA", "HAITI", "HONDURAS", "HUNGARY", "ICELAND", "INDIA", "INDONESIA", "IRAN", "IRAQ",
                                //     "IRELAND", "ISRAEL", "ITALY", "JAMAICA", "JAPAN", "JORDAN", "KAZAKHSTAN", "KENYA", "KIRIBATI", "KOREA", "KOSOVO", "KUWAIT",
                                //     "KYRGYZSTAN", "LAOS", "LATVIA", "LEBANON", "LESOTHO", "LIBERIA", "LIBYA", "LIECHTENSTEIN", "LITHUANIA", "LUXEMBOURG",
                                //     "MADAGASCAR", "MALAWI", "MALAYSIA", "MALDIVES", "MALI", "MALTA", "MARSHALL ISLANDS", "MAURITANIA", "MAURITIUS", "MEXICO",
                                //     "MICRONESIA", "MOLDOVA", "MONACO", "MONGOLIA", "MONTENEGRO", "MOROCCO", "MOZAMBIQUE", "MYANMAR", "NAMIBIA", "NAURU",
                                //     "NEPAL", "NETHERLANDS", "NEW ZEALAND", "NICARAGUA", "NIGER", "NIGERIA", "NORTH KOREA", "NORTH MACEDONIA", "NORWAY", "OMAN",
                                //     "PAKISTAN", "PALAU", "PALESTINE", "PANAMA", "PAPUA NEW GUINEA", "PARAGUAY", "PERU", "PHILIPPINES", "POLAND", "PORTUGAL",
                                //     "QATAR", "ROMANIA", "RUSSIA", "RWANDA", "SAINT KITTS AND NEVIS", "SAINT LUCIA", "SAINT VINCENT AND THE GRENADINES", "SAMOA",
                                //     "SAN MARINO", "SAO TOME AND PRINCIPE", "SAUDI ARABIA", "SENEGAL", "SERBIA", "SEYCHELLES", "SIERRA LEONE", "SINGAPORE",
                                //     "SLOVAKIA", "SLOVENIA", "SOLOMON ISLANDS", "SOMALIA", "SOUTH AFRICA", "SOUTH KOREA", "SOUTH SUDAN", "SPAIN", "SRI LANKA",
                                //     "SUDAN", "SURINAME", "SWEDEN", "SWITZERLAND", "SYRIA", "TAIWAN", "TAJIKISTAN", "TANZANIA", "THAILAND", "TIMOR-LESTE",
                                //     "TOGO", "TONGA", "TRINIDAD AND TOBAGO", "TUNISIA", "TURKEY", "TURKMENISTAN", "TUVALU", "UGANDA", "UKRAINE", "UNITED ARAB EMIRATES",
                                //     "UNITED KINGDOM", "UNITED STATES", "URUGUAY", "UZBEKISTAN", "VANUATU", "VATICAN CITY", "VENEZUELA", "VIETNAM", "YEMEN", "ZAMBIA", "ZIMBABWE"
                                // ];
                                ?>
                                <select name="od_hp_nation" id="od_hp_nation" style="width:50%; max-width:144.4px; margin-right:5px;" class="frm_input" maxlength="30">
                                    <option value="">- 국가 선택 -</option>
                                    <?php
                                    $user_nation = (isset($member['mb_hp_nation']) && $member['mb_hp_nation']) ? $member['mb_hp_nation'] : 'KOREA';
                                    foreach ($countries as $country => $code) {
                        $selected = strtolower($user_nation) == strtolower($country) ? ' selected' : '';
                        $display_name = $country;
                        if (isset($country_local_names[$country])) {
                            $display_name = $country . ' (' . $country_local_names[$country] . ')';
                        }
                        echo "<option value=\"$country\"$selected>$display_name ($code)</option>";
									}
                                    ?>
                                </select>
                                <input type="text" name="od_hp" value="<?php echo get_text($member['mb_hp']); ?>" id="od_hp" class="frm_input" maxLength="12" inputmode="numeric" pattern="[0-9]*" oninput="this.value=this.value.replace(/[^0-9]/g, '').slice(0, 12);">
                            </td>
                        </tr>
                        <tr style="display:none;">
                            <th scope="row">주소</th>
                            <td>
                                <label for="od_zip" class="sound_only">우편번호<strong class="sound_only"> 필수</strong></label>
                                <input type="text" name="od_zip" value="<?php echo $member['mb_zip1'].$member['mb_zip2']; ?>" id="od_zip" required class="frm_input" size="8" maxlength="6" placeholder="우편번호">
                                <button type="button" class="btn_address" onclick="win_zip('forderform', 'od_zip', 'od_addr1', 'od_addr2', 'od_addr3', 'od_addr_jibeon');">주소 검색</button><br>
                                <input type="text" name="od_addr1" value="<?php echo get_text($member['mb_addr1']) ?>" id="od_addr1" required class="frm_input frm_address" size="60" placeholder="기본주소">
                                <label for="od_addr1" class="sound_only">기본주소<strong class="sound_only"> 필수</strong></label><br>
                                <input type="text" name="od_addr2" value="<?php echo get_text($member['mb_addr2']) ?>" id="od_addr2" class="frm_input frm_address" size="60" placeholder="상세주소">
                                <label for="od_addr2" class="sound_only">상세주소</label>
                                <br>
                                <input type="text" name="od_addr3" value="<?php echo get_text($member['mb_addr3']) ?>" id="od_addr3" class="frm_input frm_address" size="60" readonly="readonly" placeholder="참고항목">
                                <label for="od_addr3" class="sound_only">참고항목</label><br>
                                <input type="hidden" name="od_addr_jibeon" value="<?php echo get_text($member['mb_addr_jibeon']); ?>">
                            </td>
                        </tr>

                        <?php if ($default['de_hope_date_use']) { // 배송희망일 사용 ?>
                        <tr>
                            <th scope="row"><label for="od_hope_date">희망배송일</label></th>
                            <td>
                                <!-- <select name="od_hope_date" id="od_hope_date">
                                <option value="">선택하십시오.</option>
                                <?php
                                for ($i=0; $i<7; $i++) {
                                    $sdate = date("Y-m-d", time()+86400*($default['de_hope_date_after']+$i));
                                    echo '<option value="'.$sdate.'">'.$sdate.' ('.get_yoil($sdate).')</option>'.PHP_EOL;
                                }
                                ?>
                                </select> -->
                                <input type="text" name="od_hope_date" value="" id="od_hope_date" required class="frm_input required" size="11" maxlength="10" readonly="readonly"> 이후로 배송 바랍니다.
                            </td>
                        </tr>
                        <?php } ?>
                        </tbody>
                        </table>
                    </div>
                </section>
                <!-- } 포인트 충전 하시는 분 입력 끝 -->

                <!-- 받으시는 분 입력 시작 { -->
                <section id="sod_frm_taker" style="display:none;">
                    <h2>받으시는 분</h2>

                    <div class="tbl_frm01 tbl_wrap">
                        <table>
                        <tbody>
                        <?php
                        if($is_member) {
                            // 배송지 이력
                            $addr_list = '';
                            $sep = chr(30);

                            // 주문자와 동일
                            $addr_list .= '<input type="radio" name="ad_sel_addr" value="same" id="ad_sel_addr_same">'.PHP_EOL;
                            $addr_list .= '<label for="ad_sel_addr_same">주문자와 동일</label>'.PHP_EOL;

                            // 기본배송지
                            $sql = " select *
                                        from {$g5['g5_shop_order_address_table']}
                                        where mb_id = '{$member['mb_id']}'
                                        and ad_default = '1' ";
                            $row = sql_fetch($sql);
                            if($row['ad_id']) {
                                $val1 = $row['ad_name'].$sep.$row['ad_tel'].$sep.$row['ad_hp'].$sep.$row['ad_zip1'].$sep.$row['ad_zip2'].$sep.$row['ad_addr1'].$sep.$row['ad_addr2'].$sep.$row['ad_addr3'].$sep.$row['ad_jibeon'].$sep.$row['ad_subject'];
                                $addr_list .= '<input type="radio" name="ad_sel_addr" value="'.get_text($val1).'" id="ad_sel_addr_def">'.PHP_EOL;
                                $addr_list .= '<label for="ad_sel_addr_def">기본배송지</label>'.PHP_EOL;
                            }

                            // 최근배송지
                            $sql = " select *
                                        from {$g5['g5_shop_order_address_table']}
                                        where mb_id = '{$member['mb_id']}'
                                        and ad_default = '0'
                                        order by ad_id desc
                                        limit 1 ";
                            $result = sql_query($sql);
                            for($i=0; $row=sql_fetch_array($result); $i++) {
                                $val1 = $row['ad_name'].$sep.$row['ad_tel'].$sep.$row['ad_hp'].$sep.$row['ad_zip1'].$sep.$row['ad_zip2'].$sep.$row['ad_addr1'].$sep.$row['ad_addr2'].$sep.$row['ad_addr3'].$sep.$row['ad_jibeon'].$sep.$row['ad_subject'];
                                $val2 = '<label for="ad_sel_addr_'.($i+1).'">최근배송지('.($row['ad_subject'] ? get_text($row['ad_subject']) : get_text($row['ad_name'])).')</label>';
                                $addr_list .= '<input type="radio" name="ad_sel_addr" value="'.get_text($val1).'" id="ad_sel_addr_'.($i+1).'"> '.PHP_EOL.$val2.PHP_EOL;
                            }

                            $addr_list .= '<input type="radio" name="ad_sel_addr" value="new" id="od_sel_addr_new">'.PHP_EOL;
                            $addr_list .= '<label for="od_sel_addr_new">신규배송지</label>'.PHP_EOL;

                            $addr_list .='<a href="'.G5_SHOP_URL.'/orderaddress.php" id="order_address" class="btn_frmline">배송지목록</a>';
                        } else {
                            // 주문자와 동일
                            $addr_list .= '<input type="checkbox" name="ad_sel_addr" value="same" id="ad_sel_addr_same">'.PHP_EOL;
                            $addr_list .= '<label for="ad_sel_addr_same">주문자와 동일</label>'.PHP_EOL;
                        }
                        ?>
                        <tr>
                            <th scope="row">배송지선택</th>
                            <td>
                                <?php echo $addr_list; ?>
                            </td>
                        </tr>
                        <?php if($is_member) { ?>
                        <tr>
                            <th scope="row"><label for="ad_subject">배송지명</label></th>
                            <td>
                                <input type="text" name="ad_subject" id="ad_subject" class="frm_input" maxLength="32">
                                <input type="checkbox" name="ad_default" id="ad_default" value="1">
                                <label for="ad_default">기본배송지로 설정</label>
                            </td>
                        </tr>
                        <?php } ?>
                        <tr>
                            <th scope="row"><label for="od_b_name">이름<strong class="sound_only"> 필수</strong></label></th>
                            <td><input type="text" name="od_b_name" id="od_b_name" required class="frm_input" maxLength="32"></td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_b_tel">전화번호<strong class="sound_only"> 필수</strong></label></th>
                            <td><input type="text" name="od_b_tel" id="od_b_tel" required class="frm_input" maxLength="32"></td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_b_hp">휴대폰</label></th>
                            <td><input type="text" name="od_b_hp" id="od_b_hp" class="frm_input" maxLength="32"></td>
                        </tr>
                        <tr>
                            <th scope="row">주소</th>
                            <td id="sod_frm_addr">
                                <label for="od_b_zip" class="sound_only">우편번호<strong class="sound_only"> 필수</strong></label>
                                <input type="text" name="od_b_zip" id="od_b_zip" required class="frm_input" size="8" maxlength="6" placeholder="우편번호">
                                <button type="button" class="btn_address" onclick="win_zip('forderform', 'od_b_zip', 'od_b_addr1', 'od_b_addr2', 'od_b_addr3', 'od_b_addr_jibeon');">주소 검색</button><br>
                                <input type="text" name="od_b_addr1" id="od_b_addr1" required class="frm_input frm_address" size="60" placeholder="기본주소">
                                <label for="od_b_addr1" class="sound_only">기본주소<strong> 필수</strong></label><br>
                                <input type="text" name="od_b_addr2" id="od_b_addr2" class="frm_input frm_address" size="60" placeholder="상세주소">
                                <label for="od_b_addr2" class="sound_only">상세주소</label>
                                <br>
                                <input type="text" name="od_b_addr3" id="od_b_addr3" readonly="readonly" class="frm_input frm_address" size="60" placeholder="참고항목">
                                <label for="od_b_addr3" class="sound_only">참고항목</label><br>
                                <input type="hidden" name="od_b_addr_jibeon" value="">
                            </td>
                        </tr>
                        <tr>
                            <th scope="row"><label for="od_memo">전하실말씀</label></th>
                            <td><textarea name="od_memo" id="od_memo"></textarea></td>
                        </tr>
                        </tbody>
                        </table>
                    </div>
                </section>
                <!-- } 받으시는 분 입력 끝 -->
            </div>

            <div class="sod_right" style="width:35%;">
                <!-- 주문상품 합계 시작 { -->
                <div id="sod_bsk_tot">
                    <ul>
                        <li class="sod_bsk_sell" style="width:100%; height:auto; padding: 15px;">
                            <span>포인트 충전</span>
                            <strong id="tot_sell_price" style="font-size:1.5em;"></strong><strong style="font-size:1.5em;"> Point</strong>
                        </li>
                    </ul>
                </div>
                <!-- } 주문상품 합계 끝 -->


                <!-- 결제정보 입력 시작 { -->
                <section id="sod_frm_pay">
                    <h2>결제정보</h2>

                    <div class="pay_tbl">
                        <table>
                        <tbody>
                        <?php if($oc_cnt > 0) { ?>
                        <tr>
                            <th scope="row">주문할인</th>
                            <td>
                                <strong id="od_cp_price">0</strong>원
                                <input type="hidden" name="od_cp_id" value="">
                                <button type="button" id="od_coupon_btn" class="btn_frmline">쿠폰적용</button>
                            </td>
                        </tr>
                        <?php } ?>
                        <?php if($sc_cnt > 0) { ?>
                        <tr>
                            <th scope="row">배송비할인</th>
                            <td>
                                <strong id="sc_cp_price">0</strong>원
                                <input type="hidden" name="sc_cp_id" value="">
                                <button type="button" id="sc_coupon_btn" class="btn_frmline">쿠폰적용</button>
                            </td>
                        </tr>
                        <?php } ?>

                        <!--
                        <tr>
                            <th>추가배송비</th>
                            <td><strong id="od_send_cost2">0</strong>원<br>(지역에 따라 추가되는 도선료 등의 배송비입니다.)</td>
                        </tr>
                        -->
                        </tbody>
                        </table>
                    </div>

                    <div id="od_tot_price">
                        <span>적용 환율</span>
                        <strong class="print_fx_rate" id="od_fx_rate_disp" style="color:#333; font-size:1em;">1 Point = 1 KRW</strong>
                    </div>

                    <div id="od_tot_price">
                        <span>결제하실 금액</span>
                        <strong class="print_price"></strong>
                    </div>

                    <div>
                        <?php echo '<p id="sod_frm_pt_alert">통화국가의 <strong>은행계좌</strong> 또는 <strong>암호화폐, 전자화폐</strong>로 결제 가능합니다.<br>입금하실 <strong>계좌번호</strong> 또는 <strong>QR코드</strong>는 <strong>주문완료</strong>후 확인하실 수 있습니다.</p>'; ?>
                    </div>

                    <div id="od_pay_sl" style="display:none;"> <!-- PC버전 -->
                        <h3>결제방법</h3>
                        <?php
                        if (!$default['de_card_point']) {
                            //echo '<p id="sod_frm_pt_alert"><strong>무통장입금</strong> 이외의 결제 수단으로 결제하시는 경우 포인트를 적립해드리지 않습니다.</p>';
                            echo '<p id="sod_frm_pt_alert">통화국가의 <strong>은행계좌</strong> 또는 <strong>암호화폐, 전자화폐</strong>로 결제 가능합니다.<br>입금하실 <strong>계좌번호</strong> 또는 <strong>QR코드</strong>는 <strong>주문완료</strong>후 확인하실 수 있습니다.</p>';
                        }

                        $multi_settle = 0;
                        $checked = '';

                        $escrow_title = "";
                        if ($default['de_escrow_use']) {
                            $escrow_title = "에스크로<br>";
                        }

                        if ($is_kakaopay_use || $default['de_bank_use'] || $default['de_vbank_use'] || $default['de_iche_use'] || $default['de_card_use'] || $default['de_hp_use'] || $default['de_easy_pay_use'] || $default['de_inicis_lpay_use']) {
                            echo '<fieldset id="sod_frm_paysel">';
                            echo '<legend>결제방법 선택</legend>';
                        }

                        // 카카오페이
                        if($is_kakaopay_use) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_kakaopay" name="od_settle_case" value="KAKAOPAY" '.$checked.'> <label for="od_settle_kakaopay" class="kakaopay_icon lb_icon">KAKAOPAY</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 무통장입금 사용
                        if ($default['de_bank_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_bank" name="od_settle_case" value="무통장" '.$checked.'> <label for="od_settle_bank" class="lb_icon bank_icon" style="width:100%;">무통장입금</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 가상계좌 사용
                        if ($default['de_vbank_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_vbank" name="od_settle_case" value="가상계좌" '.$checked.'> <label for="od_settle_vbank" class="lb_icon vbank_icon">'.$escrow_title.'가상계좌</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 계좌이체 사용
                        if ($default['de_iche_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_iche" name="od_settle_case" value="계좌이체" '.$checked.'> <label for="od_settle_iche" class="lb_icon iche_icon">'.$escrow_title.'계좌이체</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 휴대폰 사용
                        if ($default['de_hp_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_hp" name="od_settle_case" value="휴대폰" '.$checked.'> <label for="od_settle_hp" class="lb_icon hp_icon">휴대폰</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 신용카드 사용
                        if ($default['de_card_use']) {
                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_card" name="od_settle_case" value="신용카드" '.$checked.'> <label for="od_settle_card" class="lb_icon card_icon">신용카드</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // PG 간편결제
                        if($default['de_easy_pay_use']) {
                            switch($default['de_pg_service']) {
                                case 'lg':
                                    $pg_easy_pay_name = 'PAYNOW';
                                    break;
                                case 'inicis':
                                    $pg_easy_pay_name = 'KPAY';
                                    break;
                                default:
                                    $pg_easy_pay_name = 'PAYCO';
                                    break;
                            }

                            $multi_settle++;
                            echo '<input type="radio" id="od_settle_easy_pay" name="od_settle_case" value="간편결제" '.$checked.'> <label for="od_settle_easy_pay" class="'.$pg_easy_pay_name.' lb_icon">'.$pg_easy_pay_name.'</label>'.PHP_EOL;
                            $checked = '';
                        }

                        //이니시스 Lpay
                        if($default['de_inicis_lpay_use']) {
                            echo '<input type="radio" id="od_settle_inicislpay" data-case="lpay" name="od_settle_case" value="lpay" '.$checked.'> <label for="od_settle_inicislpay" class="inicis_lpay lb_icon">L.pay</label>'.PHP_EOL;
                            $checked = '';
                        }

                        // 포인트 전액결제
                        if (1) {
                            $multi_settle++;
                            echo '<div id="div_od_settle_point" style="display:none;"><input type="radio" id="od_settle_point" name="od_settle_case" value="포인트" '.$checked.'> <label for="od_settle_point" class="lb_icon point_icon">포인트 전액결제</label></div>'.PHP_EOL;
                            $checked = '';
                        }

                        $temp_point = 0;
                        // 회원이면서 포인트사용이면
                        if ($is_member && $config['cf_use_point'])
                        {
                            // 포인트 결제 사용 포인트보다 회원의 포인트가 크다면
                            if ($member['mb_point'] >= $default['de_settle_min_point'])
                            {
                        ?>
                            <div class="sod_frm_point">
                                <div id="sod_frm_pt">
                                    <span><strong>보유포인트</strong><?php echo display_point($member['mb_point']); ?></span>
                                </div>
                            </div>
                        <?php
                            $multi_settle++;
                            }
                        }

                        // 이것은 기본 소스코드 임 JSLEE (아래에 수정된 소스코드가 있음)
                        // if ($default['de_bank_use']) {
                        // 	// 은행계좌를 배열로 만든후
                        // 	$str = explode("\n", trim($default['de_bank_account']));
                        // 	if (count($str) <= 1)
                        // 	{
                        // 		$bank_account = '<input type="hidden" name="od_bank_account" value="'.$str[0].'">'.$str[0].PHP_EOL;
                        // 	}
                        // 	else
                        // 	{
                        // 		$bank_account = '<select name="od_bank_account" id="od_bank_account">'.PHP_EOL;
                        // 		$bank_account .= '<option value="">선택하십시오.</option>';
                        // 		for ($i=0; $i<count($str); $i++)
                        // 		{
                        // 			//$str[$i] = str_replace("\r", "", $str[$i]);
                        // 			$str[$i] = trim($str[$i]);
                        // 			$bank_account .= '<option value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                        // 		}
                        // 		$bank_account .= '</select>'.PHP_EOL;
                        // 	}
                        // 	echo '<div id="settle_bank" style="display:none">';
                        // 	echo '<label for="od_bank_account" class="sound_only">입금할 계좌</label>';
                        // 	echo $bank_account;
                        // 	echo '<br><label for="od_deposit_name">입금자명</label> ';
                        // 	echo '<input type="text" name="od_deposit_name" id="od_deposit_name" size="10" maxLength="32">';
                        // 	echo '</div>';
                        // }

                        // 외화 계좌 취급을 위해 코드 변경 JSLEE
                        if ($default['de_bank_use']) {
                            // 은행계좌를 배열로 만든후
                            $str = explode("\n", trim($default['de_bank_account']));
                            if (count($str) <= 1)
                            {
                                $bank_account = '<input type="hidden" name="od_bank_account" value="'.$str[0].'">'.$str[0].PHP_EOL;
                            }
                            else
                            {
                                $bank_account = '<select name="od_bank_account" id="od_bank_account" style="background:yellow; font-weight:bold;">'.PHP_EOL;
                                //$bank_account .= '<option value="">선택하십시오.</option>';
                                for ($i=0; $i<count($str); $i++)
                                {
                                    //$str[$i] = str_replace("\r", "", $str[$i]);
                                    $str[$i] = trim($str[$i]);
                                    if (stripos($str[$i], "[KRW]") !== false) {
                                        $bank_account .= '<option class="KRW" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[USD]") !== false) {
                                        $bank_account .= '<option class="USD" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[EUR]") !== false) {
                                        $bank_account .= '<option class="EUR" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[CNY]") !== false) {
                                        $bank_account .= '<option class="CNY" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[JPY]") !== false) {
                                        $bank_account .= '<option class="JPY" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    } else if (stripos($str[$i], "[VND]") !== false) {
                                        $bank_account .= '<option class="VND" value="'.$str[$i].'">'.$str[$i].'</option>'.PHP_EOL;
                                    }
                                }
                                $bank_account .= '</select>'.PHP_EOL;
                            }
                            echo '<div id="settle_bank" style="display:none">';
                            echo '<label for="od_bank_account" class="sound_only">입금할 계좌</label>';
                            echo $bank_account;
                            echo '<div style="display:flex; justify-content:center; align-items:center; width:100%; background-color: lightgray; padding: 10px;">' .
                                '<label for="od_deposit_name" style="margin-right: 5px;">입금자명</label>' .
                                '<input type="text" name="od_deposit_name" id="od_deposit_name" maxLength="32" readonly style="background:yellow; font-weight:bold; flex:1 1 auto; cursor:default;">' .
                                '</div>';
                            echo '</div>';
                        }

                        if ($is_kakaopay_use || $default['de_bank_use'] || $default['de_vbank_use'] || $default['de_iche_use'] || $default['de_card_use'] || $default['de_hp_use'] || $default['de_easy_pay_use'] || $default['de_inicis_lpay_use'] ) {
                            echo '</fieldset>';
                        }

                        if ($multi_settle == 0)
                            echo '<p>결제할 방법이 없습니다.<br>운영자에게 알려주시면 감사하겠습니다.</p>';
                        ?>
                    </div>
                </section>
                <!-- } 결제 정보 입력 끝 -->

                <?php
                // 통신판매중개 플랫폼 주문 전 확인사항 (결제하기 버튼 바로 위)
                if(function_exists('vpnlink_platform_notice')) echo vpnlink_platform_notice('order');

                // 결제대행사별 코드 include (주문버튼)
                require_once(G5_PATH.'/shoppoint/'.$default['de_pg_service'].'/orderform.3.php');

                if($is_kakaopay_use) {
                    require_once(G5_PATH.'/shoppoint/kakaopay/orderform.3.php');
                }
                ?>

                <?php
                if ($default['de_escrow_use']) {
                    // 결제대행사별 코드 include (에스크로 안내)
                    require_once(G5_PATH.'/shoppoint/'.$default['de_pg_service'].'/orderform.4.php');
                }
                ?>
            </div>
        </div>

        <div style="margin-top:10px;">
            <style>
                .limit_table {
                    width: 100%;
                    border-collapse: collapse;
                    --lt-border: #ddd;
                    --lt-bg: transparent;
                    --lt-bg-th: #fafafa;
                    --lt-color: inherit;
                    --lt-color-th: inherit;
                }
                [data-site-theme="dark"] .limit_table {
                    --lt-border: #2d2d42;
                    --lt-bg: #252535;
                    --lt-bg-th: #1e1e2e;
                    --lt-color: #e2e8f0;
                    --lt-color-th: #94a3b8;
                }
                .limit_table tr, .limit_table th, .limit_table td {
                    border: 1px solid var(--lt-border);
                    padding: 3px;
                    text-align: center;
                }
                .limit_table td { background-color: var(--lt-bg); color: var(--lt-color); }
                .limit_table th { background-color: var(--lt-bg-th); color: var(--lt-color-th); }
            </style>
            <table class="limit_table">
                <tr>
                    <th>포인트 충전 한도</th>
                    <th>1회</th>
                    <th>1일</th>
                    <th>월간</th>
                    <th>연간</th>
                </tr>
                <tr>
                    <th>현재 가용한도</th>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1try']-$row_point_limit_info['point_limit_charge_1try_used']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1day']-$row_point_limit_info['point_limit_charge_1day_used']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1month']-$row_point_limit_info['point_limit_charge_1month_used']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1year']-$row_point_limit_info['point_limit_charge_1year_used']) ?> Point</td>
                </tr>
                <tr>
                    <th>나의 충전한도</th>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1try']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1day']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1month']) ?> Point</td>
                    <td><?php echo number_format($row_point_limit_info['point_limit_charge_1year']) ?> Point</td>
                </tr>
            </table>
        </div>






    <?php } // PC버전 끝 ?>

</div>
<input type="hidden" name="od_fx_type" id="od_fx_type">
<input type="hidden" name="od_fx_rate" id="od_fx_rate">
<input type="hidden" name="od_fx_amount" id="od_fx_amount">
</form>

<?php
if( $default['de_inicis_lpay_use'] ){   //이니시스 L.pay 사용시
    require_once(G5_PATH.'/shoppoint/inicis/lpay_order.script.php');
}
?>
<script>
var zipcode = "";
var form_action_url = "<?php echo $order_action_url; ?>"; // https://comviewers.com/shoppoint/orderformupdate.php

$(function() {
    var $cp_btn_el;
    var $cp_row_el;

    $(".cp_btn").click(function() {
        $cp_btn_el = $(this);
        $cp_row_el = $(this).closest("tr");
        $("#cp_frm").remove();
        var it_id = $cp_btn_el.closest("tr").find("input[name^=it_id]").val();

        $.post(
            "./orderitemcoupon.php",
            { it_id: it_id,  sw_direct: "<?php echo $sw_direct; ?>" },
            function(data) {
                $cp_btn_el.after(data);
            }
        );
    });

    $(document).on("click", ".cp_apply", function() {

        // 쿠폰과 포인트전액사용이 동시에 적용되지 않도록 하는 프로세스 때문에 코드 추가 (포인트사용 전액사용 해제 하는 기능) JSLEE {
        $("#od_temp_point").val(0);
        $("input:radio[id='od_settle_point']").prop('checked', false);
        $("input:checkbox[id='my_point_entire_pay']").prop('checked', false);
        $("#div_od_settle_point").fadeOut("fast");
        $("#od_temp_point").prop('readonly', false);
        // 쿠폰과 포인트전액사용이 동시에 적용되지 않도록 하는 프로세스 때문에 코드 추가 (포인트사용 전액사용 해제 하는 기능) JSLEE }

        var $el = $(this).closest("tr");
        var cp_id = $el.find("input[name='f_cp_id[]']").val();
        var price = $el.find("input[name='f_cp_prc[]']").val();
        var subj = $el.find("input[name='f_cp_subj[]']").val();
        var sell_price;

        if(parseInt(price) == 0) {
            if(!confirm(subj+"쿠폰의 할인 금액은 "+price+"원입니다.\n쿠폰을 적용하시겠습니까?")) {
                return false;
            }
        }

        // 이미 사용한 쿠폰이 있는지
        var cp_dup = false;
        var cp_dup_idx;
        var $cp_dup_el;
        $("input[name^=cp_id]").each(function(index) {
            var id = $(this).val();

            if(id == cp_id) {
                cp_dup_idx = index;
                cp_dup = true;
                $cp_dup_el = $(this).closest("tr");;

                return false;
            }
        });

        if(cp_dup) {
            var it_name = $("input[name='it_name["+cp_dup_idx+"]']").val();
            if(!confirm(subj+ "쿠폰은 "+it_name+"에 사용되었습니다.\n"+it_name+"의 쿠폰을 취소한 후 적용하시겠습니까?")) {
                return false;
            } else {
                coupon_cancel($cp_dup_el);
                $("#cp_frm").remove();
                $cp_dup_el.find(".cp_btn").text("적용").focus();
                $cp_dup_el.find(".cp_cancel").remove();
            }
        }

        var $s_el = $cp_row_el.find(".total_price");;
        sell_price = parseInt($cp_row_el.find("input[name^=it_price]").val());
        sell_price = sell_price - parseInt(price);
        if(sell_price < 0) {
            alert("쿠폰할인금액이 상품 주문금액보다 크므로 쿠폰을 적용할 수 없습니다.");
            return false;
        }
        $s_el.text(number_format(String(sell_price)));
        $cp_row_el.find("input[name^=cp_id]").val(cp_id);
        $cp_row_el.find("input[name^=cp_price]").val(price);

        calculate_total_price();
        $("#cp_frm").remove();
        $cp_btn_el.text("변경").focus();
        if(!$cp_row_el.find(".cp_cancel").size())
            $cp_btn_el.after("<button type=\"button\" class=\"cp_cancel\">취소</button>");
    });

    $(document).on("click", "#cp_close", function() {
        $("#cp_frm").remove();
        $cp_btn_el.focus();
    });

    $(document).on("click", ".cp_cancel", function() {
        coupon_cancel($(this).closest("tr"));
        calculate_total_price();
        $("#cp_frm").remove();
        $(this).closest("tr").find(".cp_btn").text("적용").focus();
        $(this).remove();
    });

    $("#od_coupon_btn").click(function() {
        $("#od_coupon_frm").remove();
        var $this = $(this);
        var price = parseInt($("input[name=org_od_price]").val()) - parseInt($("input[name=item_coupon]").val());
        if(price <= 0) {
            alert('상품금액이 0원이므로 쿠폰을 사용할 수 없습니다.');
            return false;
        }
        $.post(
            "./ordercoupon.php",
            { price: price },
            function(data) {
                $this.after(data);
            }
        );
    });

    $(document).on("click", ".od_cp_apply", function() {
        var $el = $(this).closest("tr");
        var cp_id = $el.find("input[name='o_cp_id[]']").val();
        var price = parseInt($el.find("input[name='o_cp_prc[]']").val());
        var subj = $el.find("input[name='o_cp_subj[]']").val();
        var send_cost = $("input[name=od_send_cost]").val();
        var item_coupon = parseInt($("input[name=item_coupon]").val());
        var od_price = parseInt($("input[name=org_od_price]").val()) - item_coupon;

        if(price == 0) {
            if(!confirm(subj+"쿠폰의 할인 금액은 "+price+"원입니다.\n쿠폰을 적용하시겠습니까?")) {
                return false;
            }
        }

        if(od_price - price <= 0) {
            alert("쿠폰할인금액이 주문금액보다 크므로 쿠폰을 적용할 수 없습니다.");
            return false;
        }

        $("input[name=sc_cp_id]").val("");
        $("#sc_coupon_btn").text("쿠폰적용");
        $("#sc_coupon_cancel").remove();

        $("input[name=od_price]").val(od_price - price);
        $("input[name=od_cp_id]").val(cp_id);
        $("input[name=od_coupon]").val(price);
        $("input[name=od_send_coupon]").val(0);
        $("#od_cp_price").text(number_format(String(price)));
        $("#sc_cp_price").text(0);
        calculate_order_price();
        $("#od_coupon_frm").remove();
        $("#od_coupon_btn").text("변경").focus();
        if(!$("#od_coupon_cancel").size())
            $("#od_coupon_btn").after("<button type=\"button\" id=\"od_coupon_cancel\" class=\"cp_cancel\">취소</button>");
    });

    $(document).on("click", "#od_coupon_close", function() {
        $("#od_coupon_frm").remove();
        $("#od_coupon_btn").focus();
    });

    $(document).on("click", "#od_coupon_cancel", function() {
        var org_price = $("input[name=org_od_price]").val();
        var item_coupon = parseInt($("input[name=item_coupon]").val());
        $("input[name=od_price]").val(org_price - item_coupon);
        $("input[name=sc_cp_id]").val("");
        $("input[name=od_coupon]").val(0);
        $("input[name=od_send_coupon]").val(0);
        $("#od_cp_price").text(0);
        $("#sc_cp_price").text(0);
        calculate_order_price();
        $("#od_coupon_frm").remove();
        $("#od_coupon_btn").text("쿠폰적용").focus();
        $(this).remove();
        $("#sc_coupon_btn").text("쿠폰적용");
        $("#sc_coupon_cancel").remove();
    });

    $("#sc_coupon_btn").click(function() {
        $("#sc_coupon_frm").remove();
        var $this = $(this);
        var price = parseInt($("input[name=od_price]").val());
        var send_cost = parseInt($("input[name=od_send_cost]").val());
        $.post(
            "./ordersendcostcoupon.php",
            { price: price, send_cost: send_cost },
            function(data) {
                $this.after(data);
            }
        );
    });

    $(document).on("click", ".sc_cp_apply", function() {
        var $el = $(this).closest("tr");
        var cp_id = $el.find("input[name='s_cp_id[]']").val();
        var price = parseInt($el.find("input[name='s_cp_prc[]']").val());
        var subj = $el.find("input[name='s_cp_subj[]']").val();
        var send_cost = parseInt($("input[name=od_send_cost]").val());

        if(parseInt(price) == 0) {
            if(!confirm(subj+"쿠폰의 할인 금액은 "+price+"원입니다.\n쿠폰을 적용하시겠습니까?")) {
                return false;
            }
        }

        $("input[name=sc_cp_id]").val(cp_id);
        $("input[name=od_send_coupon]").val(price);
        $("#sc_cp_price").text(number_format(String(price)));
        calculate_order_price();
        $("#sc_coupon_frm").remove();
        $("#sc_coupon_btn").text("변경").focus();
        if(!$("#sc_coupon_cancel").size())
            $("#sc_coupon_btn").after("<button type=\"button\" id=\"sc_coupon_cancel\" class=\"cp_cancel\">취소</button>");
    });

    $(document).on("click", "#sc_coupon_close", function() {
        $("#sc_coupon_frm").remove();
        $("#sc_coupon_btn").focus();
    });

    $(document).on("click", "#sc_coupon_cancel", function() {
        $("input[name=od_send_coupon]").val(0);
        $("#sc_cp_price").text(0);
        calculate_order_price();
        $("#sc_coupon_frm").remove();
        $("#sc_coupon_btn").text("쿠폰적용").focus();
        $(this).remove();
    });

    $("#od_b_addr2").focus(function() {
        var zip = $("#od_b_zip").val().replace(/[^0-9]/g, "");
        if(zip == "")
            return false;

        var code = String(zip);

        if(zipcode == code)
            return false;

        zipcode = code;
        calculate_sendcost(code);
    });

    // 입금자명: 주문번호 끝 4자리(PHP 주입) + 실명 — 서버/앱과 동일 규칙
    var _snpc_od_prefix = "<?php
        $__sess_od = function_exists('get_session') ? get_session('ss_order_id') : '';
        echo $__sess_od ? htmlspecialchars(substr($__sess_od, -4), ENT_QUOTES) : '';
    ?>";
    $("#od_settle_bank").on("click", function() {
        var _dep = _snpc_od_prefix + $("[name=od_name]").val();
        $("[name=od_deposit_name]").val(_dep).prop("readonly", true).css("cursor", "default");
        // $("#settle_bank").show(); // 포인트 구매액 선택시 무통장입금 계좌 선택창 노출되는 코드 중지시킴 - 사유: 주문결과 페이지에서 무통장계좌번호를 알수 있게 함 JSLEE
    });

    $("#od_settle_iche,#od_settle_card,#od_settle_vbank,#od_settle_hp,#od_settle_easy_pay,#od_settle_kakaopay").bind("click", function() {
        $("#settle_bank").hide();
    });

    // 배송지선택
    $("input[name=ad_sel_addr]").on("click", function() {
        var addr = $(this).val().split(String.fromCharCode(30));

        if (addr[0] == "same") {
            gumae2baesong();
        } else {
            if(addr[0] == "new") {
                for(i=0; i<10; i++) {
                    addr[i] = "";
                }
            }

            var f = document.forderform;
            f.od_b_name.value        = addr[0];
            f.od_b_tel.value         = addr[1];
            f.od_b_hp.value          = addr[2];
            f.od_b_zip.value         = addr[3] + addr[4];
            f.od_b_addr1.value       = addr[5];
            f.od_b_addr2.value       = addr[6];
            f.od_b_addr3.value       = addr[7];
            f.od_b_addr_jibeon.value = addr[8];
            f.ad_subject.value       = addr[9];

            var zip1 = addr[3].replace(/[^0-9]/g, "");
            var zip2 = addr[4].replace(/[^0-9]/g, "");

            var code = String(zip1) + String(zip2);

            if(zipcode != code) {
                calculate_sendcost(code);
            }
        }
    });

    // 배송지목록
    $("#order_address").on("click", function() {
        var url = this.href;
        window.open(url, "win_address", "left=100,top=100,width=800,height=600,scrollbars=1");
        return false;
    });

    // 결제방법선택과 동시에 배송지 주문자와 동일 자동선택 되도록 추가 (결제진행시 PG사 오류메시지 예방목적) JSLEE
    $("input[name=od_settle_case]").on("click", function() {
		$("#ad_sel_addr_same").trigger('click');
    });
    // 포인트 금액 radio 박스 선택될 때 해당 통화에 맞는 무통장입금 계좌 지정/선택되도록 추가 JSLEE
    $("input[name=point_charge_select]").on("change", function() {
        $("#od_settle_bank").trigger('click');

        const radios = document.querySelectorAll('input[name="nationpay"]');
        const select = document.getElementById('od_bank_account');
        const options = select.querySelectorAll('option');

        radios.forEach(radio => {
            const selectedCurrency = $('input[name="nationpay"]:checked').val();
            options.forEach(option => {
                if (option.classList.contains(selectedCurrency)) {
                    option.style.display = "block";
                } else {
                    option.style.display = "none";
                }
            });

            // Select the first visible option or reset to default
            select.value = "";
            options.forEach(option => {
                if (option.style.display !== "none") {
                    const newValue = option.value.replace('['+selectedCurrency+']', '').trim();
                    select.value = newValue;
                    option.value = newValue;
                    option.text = newValue;
                    return false;
                }
            });
        });

    });});

function truncateString(str, maxLength) {
    return str.slice(0, maxLength);
}

function randomcode(length) {
    const alphabet = 'ABCDEFGHJKLMNPQRSTWXYZ'; // 알파벳문자중에 숫자와 혼돈될 우려가 있는 I, O, U, V는 제외 시킴
    let code = '';
    for (let i = 0; i < length; i++) {
        code += alphabet.charAt(Math.floor(Math.random() * alphabet.length));
    }
    return code;
}

function coupon_cancel($el)
{
    var $dup_sell_el = $el.find(".total_price");
    var $dup_price_el = $el.find("input[name^=cp_price]");
    var org_sell_price = $el.find("input[name^=it_price]").val();

    $dup_sell_el.text(number_format(String(org_sell_price)));
    $dup_price_el.val(0);
    $el.find("input[name^=cp_id]").val("");
}

function calculate_total_price()
{
    var $it_prc = $("input[name^=it_price]");
    var $cp_prc = $("input[name^=cp_price]");
    var tot_sell_price = sell_price = tot_cp_price = 0;
    var it_price, cp_price, it_notax;
    var tot_mny = comm_tax_mny = comm_vat_mny = comm_free_mny = tax_mny = vat_mny = 0;
    var send_cost = parseInt($("input[name=od_send_cost]").val());

    $it_prc.each(function(index) {
        it_price = parseInt($(this).val());
        cp_price = parseInt($cp_prc.eq(index).val());
        sell_price += it_price;
        tot_cp_price += cp_price;
    });

    tot_sell_price = sell_price - tot_cp_price + send_cost;

    $("#ct_tot_coupon").text(number_format(String(tot_cp_price)));
    $("#ct_tot_price").text(number_format(String(tot_sell_price)));

    $("input[name=good_mny]").val(tot_sell_price);
    $("input[name=od_price]").val(sell_price - tot_cp_price);
    $("input[name=item_coupon]").val(tot_cp_price);
    $("input[name=od_coupon]").val(0);
    $("input[name=od_send_coupon]").val(0);
    <?php if($oc_cnt > 0) { ?>
    $("input[name=od_cp_id]").val("");
    $("#od_cp_price").text(0);
    if($("#od_coupon_cancel").size()) {
        $("#od_coupon_btn").text("쿠폰적용");
        $("#od_coupon_cancel").remove();
    }
    <?php } ?>
    <?php if($sc_cnt > 0) { ?>
    $("input[name=sc_cp_id]").val("");
    $("#sc_cp_price").text(0);
    if($("#sc_coupon_cancel").size()) {
        $("#sc_coupon_btn").text("쿠폰적용");
        $("#sc_coupon_cancel").remove();
    }
    <?php } ?>
    $("input[name=od_temp_point]").val(0);
    <?php if($temp_point > 0 && $is_member) { ?>
    calculate_temp_point();
    <?php } ?>
    calculate_order_price();
}

function calculate_order_price()
{
    // nationpay 에서 어떤 통화를 선택했는지 체크 추가 JSLEE
    selectedValue = $('input[name="nationpay"]:checked').val();
    var point_charge_select = parseInt($("input[name=point_charge_select]").val());
    if (isNaN(point_charge_select)) {
        point_charge_select = parseInt(window.lastValidPointCharge || "0", 10);
        if (isNaN(point_charge_select)) {
            point_charge_select = 0;
        }
    }
    $("input[name=point_charge_select]").val(point_charge_select);
    window.lastValidPointCharge = String(point_charge_select);
    $("input[name=od_price]").val(point_charge_select);
    $("input[name=org_od_price]").val(point_charge_select);
    var sell_price = parseInt($("input[name=od_price]").val());
    var send_cost = parseInt($("input[name=od_send_cost]").val());
    var send_cost2 = parseInt($("input[name=od_send_cost2]").val());
    var send_coupon = parseInt($("input[name=od_send_coupon]").val());
    var tot_price = sell_price + send_cost + send_cost2 - send_coupon;
    $("input[name=good_mny]").val(tot_price);

    switch(selectedValue){
        case 'KRW':
            $("#tot_sell_price").html(number_format(tot_price)); // 포인트구매란 표시
            $("#od_tot_price .print_price").html(exchangeRateHead + number_format(String(tot_price), 0)+" "+selectedValue);
            $('#od_fx_type').val("KRWKRW");
            $('#od_fx_rate').val(KRWKRW);
            $('#od_fx_rate_disp').html("1 Point = "+ KRWKRW + " " + selectedValue);
            $('#od_fx_amount').val((tot_price).toFixed(0));
            break;
        case 'USD':
            $("#tot_sell_price").html(number_format(tot_price)); // 포인트구매란 표시
            $("#od_tot_price .print_price").html(exchangeRateHead + number_format(String(tot_price * KRWUSD), 2)+" "+selectedValue);
            $('#od_fx_type').val("KRWUSD");
            $('#od_fx_rate').val(KRWUSD);
            $('#od_fx_rate_disp').html("1 Point = "+ KRWUSD + " " + selectedValue);
            $('#od_fx_amount').val((tot_price * KRWUSD).toFixed(2));
            break;
        case 'EUR':
            $("#tot_sell_price").html(number_format(tot_price)); // 포인트구매란 표시
            $("#od_tot_price .print_price").html(exchangeRateHead + number_format(String(tot_price * KRWEUR), 2)+" "+selectedValue);
            $('#od_fx_type').val("KRWEUR");
            $('#od_fx_rate').val(KRWEUR);
            $('#od_fx_rate_disp').html("1 Point = "+ KRWEUR + " " + selectedValue);
            $('#od_fx_amount').val((tot_price * KRWEUR).toFixed(2));
            break;
        case 'CNY':
            $("#tot_sell_price").html(number_format(tot_price)); // 포인트구매란 표시
            $("#od_tot_price .print_price").html(exchangeRateHead + number_format(String(tot_price * KRWCNY), 2)+" "+selectedValue);
            $('#od_fx_type').val("KRWCNY");
            $('#od_fx_rate').val(KRWCNY);
            $('#od_fx_rate_disp').html("1 Point = "+ KRWCNY + " " + selectedValue);
            $('#od_fx_amount').val((tot_price * KRWCNY).toFixed(2));
            break;
        case 'JPY':
            $("#tot_sell_price").html(number_format(tot_price)); // 포인트구매란 표시
            $("#od_tot_price .print_price").html(exchangeRateHead + number_format(String(tot_price  * KRWJPY), 0)+" "+selectedValue);
            $('#od_fx_type').val("KRWJPY");
            $('#od_fx_rate').val(KRWJPY);
            $('#od_fx_rate_disp').html("1 Point = "+ KRWJPY + " " + selectedValue);
            $('#od_fx_amount').val((tot_price * KRWJPY).toFixed(0));
            break;
        case 'VND':
            $("#tot_sell_price").html(number_format(tot_price)); // 포인트구매란 표시
            $("#od_tot_price .print_price").html(exchangeRateHead + number_format(String(tot_price * KRWVND), 0, ',', '.')+" "+selectedValue);
            //$("#od_tot_price .print_price").text(number_format(String(tot_price * KRWVND), 0)+" VND");
            $('#od_fx_type').val("KRWVND");
            $('#od_fx_rate').val(KRWVND);
            $('#od_fx_rate_disp').html("1 Point = "+ KRWVND + " " + selectedValue);
            $('#od_fx_amount').val((tot_price * KRWVND).toFixed(0));
            break;
    }

    <?php if($temp_point > 0 && $is_member) { ?>
    calculate_temp_point();
    <?php } ?>
}

function calculate_temp_point()
{
    var sell_price = parseInt($("input[name=od_price]").val());
    var mb_point = parseInt(<?php echo $member['mb_point']; ?>);
    var max_point = parseInt(<?php echo $default['de_settle_max_point']; ?>);
    var point_unit = parseInt(<?php echo $default['de_settle_point_unit']; ?>);
    var temp_point = max_point;

    if(temp_point > sell_price)
        temp_point = sell_price;

    if(temp_point > mb_point)
        temp_point = mb_point;

    temp_point = parseInt(temp_point / point_unit) * point_unit;

    $("#use_max_point").text(number_format(String(temp_point))+" Point");
    $("input[name=max_temp_point]").val(temp_point);
}

function calculate_sendcost(code)
{
    $.post(
        "./ordersendcost.php",
        { zipcode: code },
        function(data) {
            $("input[name=od_send_cost2]").val(data);
            $("#od_send_cost2").text(number_format(String(data)));

            zipcode = code;

            calculate_order_price();
        }
    );
}

function calculate_tax()
{
    var $it_prc = $("input[name^=it_price]");
    var $cp_prc = $("input[name^=cp_price]");
    var sell_price = tot_cp_price = 0;
    var it_price, cp_price, it_notax;
    var tot_mny = comm_free_mny = tax_mny = vat_mny = 0;
    var send_cost = parseInt($("input[name=od_send_cost]").val());
    var send_cost2 = parseInt($("input[name=od_send_cost2]").val());
    var od_coupon = parseInt($("input[name=od_coupon]").val());
    var send_coupon = parseInt($("input[name=od_send_coupon]").val());
    var temp_point = 0;

    $it_prc.each(function(index) {
        it_price = parseInt($(this).val());
        cp_price = parseInt($cp_prc.eq(index).val());
        sell_price += it_price;
        tot_cp_price += cp_price;
        it_notax = $("input[name^=it_notax]").eq(index).val();
        if(it_notax == "1") {
            comm_free_mny += (it_price - cp_price);
        } else {
            tot_mny += (it_price - cp_price);
        }
    });

    if($("input[name=od_temp_point]").size())
        temp_point = parseInt($("input[name=od_temp_point]").val());

    tot_mny += (send_cost + send_cost2 - od_coupon - send_coupon - temp_point);
    if(tot_mny < 0) {
        comm_free_mny = comm_free_mny + tot_mny;
        tot_mny = 0;
    }

    tax_mny = Math.round(tot_mny / 1.1);
    vat_mny = tot_mny - tax_mny;
    $("input[name=comm_tax_mny]").val(tax_mny);
    $("input[name=comm_vat_mny]").val(vat_mny);
    $("input[name=comm_free_mny]").val(comm_free_mny);
}

function forderform_check(f)
{
    errmsg = "";
    errfld = "";
    var deffld = "";

    check_field(f.od_name, "포인트 충전 하시는 분 이름을 입력하십시오.");
    if (typeof(f.od_pwd) != 'undefined')
    {
        clear_field(f.od_pwd);
        if( (f.od_pwd.value.length<3) || (f.od_pwd.value.search(/([^A-Za-z0-9]+)/)!=-1) )
            error_field(f.od_pwd, "회원이 아니신 경우 주문서 조회시 필요한 비밀번호를 3자리 이상 입력해 주십시오.");
    }
    //check_field(f.od_tel, "포인트 충전 하시는 분 전화번호를 입력하십시오.");
    //check_field(f.od_addr1, "주소검색을 이용하여 포인트 충전 하시는 분 주소를 입력하십시오.");
    //check_field(f.od_addr2, " 포인트 충전 하시는 분의 상세주소를 입력하십시오.");
    //check_field(f.od_zip, "");

    clear_field(f.od_email);
    if(f.od_email.value=='' || f.od_email.value.search(/(\S+)@(\S+)\.(\S+)/) == -1)
        error_field(f.od_email, "E-mail을 바르게 입력해 주십시오.");

    if (typeof(f.od_hope_date) != "undefined")
    {
        clear_field(f.od_hope_date);
        if (!f.od_hope_date.value)
            error_field(f.od_hope_date, "희망배송일을 선택하여 주십시오.");
    }

    //check_field(f.od_b_name, "받으시는 분 이름을 입력하십시오.");
    //check_field(f.od_b_tel, "받으시는 분 전화번호를 입력하십시오.");
    //check_field(f.od_b_addr1, "주소검색을 이용하여 받으시는 분 주소를 입력하십시오.");
    //check_field(f.od_b_addr2, "받으시는 분의 상세주소를 입력하십시오.");
    //check_field(f.od_b_zip, "");

    var od_settle_bank = document.getElementById("od_settle_bank");
    if (od_settle_bank) {
        if (od_settle_bank.checked) {
            check_field(f.od_bank_account, "계좌번호를 선택하세요.");
            check_field(f.od_deposit_name, "입금자명을 입력하세요.");
        }
    }

    // 배송비를 받지 않거나 더 받는 경우 아래식에 + 또는 - 로 대입
    f.od_send_cost.value = parseInt(f.od_send_cost.value);

    if (errmsg)
    {
        alert(errmsg);
        errfld.focus();
        return false;
    }

    var settle_case = document.getElementsByName("od_settle_case");
    var settle_check = false;
    var settle_method = "";
    for (i=0; i<settle_case.length; i++)
    {
        if (settle_case[i].checked)
        {
            settle_check = true;
            settle_method = settle_case[i].value;
            break;
        }
    }
    if (!settle_check)
    {
        // alert("결제방식을 선택하십시오.");
        alert("충전하실 포인트를 입력하신 후 충전하기 버튼을 누르십시오.");
        return false;
    }

    var od_price = parseInt(f.od_price.value);
    var send_cost = parseInt(f.od_send_cost.value);
    var send_cost2 = parseInt(f.od_send_cost2.value);
    var send_coupon = parseInt(f.od_send_coupon.value);

    var max_point = 0;
    if (typeof(f.max_temp_point) != "undefined")
        max_point  = parseInt(f.max_temp_point.value);

    var temp_point = 0;
    if (typeof(f.od_temp_point) != "undefined") {
        if (f.od_temp_point.value)
        {
            var point_unit = parseInt(<?php echo $default['de_settle_point_unit']; ?>);
            temp_point = parseInt(f.od_temp_point.value);

            if (temp_point < 0) {
                alert("포인트를 0 이상 입력하세요.");
                f.od_temp_point.select();
                return false;
            }

            if (temp_point > od_price) {
                alert("상품 주문금액(배송비 제외) 보다 많이 포인트결제할 수 없습니다.");
                f.od_temp_point.select();
                return false;
            }

            if (temp_point > <?php echo (int)$member['mb_point']; ?>) {
                alert("회원님의 포인트보다 많이 결제할 수 없습니다.");
                f.od_temp_point.select();
                return false;
            }

            if (temp_point > max_point) {
                alert(max_point + " Point 이상 결제할 수 없습니다.");
                f.od_temp_point.select();
                return false;
            }

            if (parseInt(parseInt(temp_point / point_unit) * point_unit) != temp_point) {
                alert("포인트를 "+String(point_unit)+" Point 단위로 입력하세요.");
                f.od_temp_point.select();
                return false;
            }

            // pg 결제 금액에서 포인트 금액 차감
            if(settle_method != "무통장") {
                f.good_mny.value = od_price + send_cost + send_cost2 - send_coupon - temp_point;
            }
        }
    }

    var tot_price = od_price + send_cost + send_cost2 - send_coupon - temp_point;

    if (document.getElementById("od_settle_iche")) {
        if (document.getElementById("od_settle_iche").checked) {
            if (tot_price < 150) {
                alert("계좌이체는 150원 이상 결제가 가능합니다.");
                return false;
            }
        }
    }

    if (document.getElementById("od_settle_card")) {
        if (document.getElementById("od_settle_card").checked) {
            if (tot_price < 1000) {
                alert("신용카드는 1000원 이상 결제가 가능합니다.");
                return false;
            }
        }
    }

    if (document.getElementById("od_settle_hp")) {
        if (document.getElementById("od_settle_hp").checked) {
            if (tot_price < 350) {
                alert("휴대폰은 350원 이상 결제가 가능합니다.");
                return false;
            }
        }
    }

    <?php if($default['de_tax_flag_use']) { ?>
    calculate_tax();
    <?php } ?>

    <?php if($default['de_pg_service'] == 'inicis') { ?>
    if( f.action != form_action_url ){
        f.action = form_action_url;
        f.removeAttribute("target");
        f.removeAttribute("accept-charset");
    }
    <?php } ?>

    // 카카오페이 지불
    if(settle_method == "KAKAOPAY") {
        <?php if($default['de_tax_flag_use']) { ?>
        f.SupplyAmt.value = parseInt(f.comm_tax_mny.value) + parseInt(f.comm_free_mny.value);
        f.GoodsVat.value  = parseInt(f.comm_vat_mny.value);
        <?php } ?>
        getTxnId(f);
        return false;
    }

    var form_order_method = '';

    if( settle_method == "lpay" ){      //이니시스 L.pay 이면 ( 이니시스의 삼성페이는 모바일에서만 단독실행 가능함 )
        form_order_method = 'samsungpay';
    }

    if( jQuery(f).triggerHandler("form_sumbit_order_"+form_order_method) !== false ) {

        // pay_method 설정
        <?php if($default['de_pg_service'] == 'kcp') { ?>
        f.site_cd.value = f.def_site_cd.value;
        f.payco_direct.value = "";
        switch(settle_method)
        {
            case "계좌이체":
                f.pay_method.value   = "010000000000";
                break;
            case "가상계좌":
                f.pay_method.value   = "001000000000";
                break;
            case "휴대폰":
                f.pay_method.value   = "000010000000";
                break;
            case "신용카드":
                f.pay_method.value   = "100000000000";
                break;
            case "간편결제":
                <?php if($default['de_card_test']) { ?>
                f.site_cd.value      = "S6729";
                <?php } ?>
                f.pay_method.value   = "100000000000";
                f.payco_direct.value = "Y";
                break;
            default:
                f.pay_method.value   = "무통장";
                break;
        }
        <?php } else if($default['de_pg_service'] == 'lg') { ?>
        f.LGD_EASYPAY_ONLY.value = "";
        if(typeof f.LGD_CUSTOM_USABLEPAY === "undefined") {
            var input = document.createElement("input");
            input.setAttribute("type", "hidden");
            input.setAttribute("name", "LGD_CUSTOM_USABLEPAY");
            input.setAttribute("value", "");
            f.LGD_EASYPAY_ONLY.parentNode.insertBefore(input, f.LGD_EASYPAY_ONLY);
        }

        switch(settle_method)
        {
            case "계좌이체":
                f.LGD_CUSTOM_FIRSTPAY.value = "SC0030";
                f.LGD_CUSTOM_USABLEPAY.value = "SC0030";
                break;
            case "가상계좌":
                f.LGD_CUSTOM_FIRSTPAY.value = "SC0040";
                f.LGD_CUSTOM_USABLEPAY.value = "SC0040";
                break;
            case "휴대폰":
                f.LGD_CUSTOM_FIRSTPAY.value = "SC0060";
                f.LGD_CUSTOM_USABLEPAY.value = "SC0060";
                break;
            case "신용카드":
                f.LGD_CUSTOM_FIRSTPAY.value = "SC0010";
                f.LGD_CUSTOM_USABLEPAY.value = "SC0010";
                break;
            case "간편결제":
                var elm = f.LGD_CUSTOM_USABLEPAY;
                if(elm.parentNode)
                    elm.parentNode.removeChild(elm);
                f.LGD_EASYPAY_ONLY.value = "PAYNOW";
                break;
            default:
                f.LGD_CUSTOM_FIRSTPAY.value = "무통장";
                break;
        }
        <?php }  else if($default['de_pg_service'] == 'inicis') { ?>
        switch(settle_method)
        {
            case "계좌이체":
                f.gopaymethod.value = "DirectBank";
                break;
            case "가상계좌":
                f.gopaymethod.value = "VBank";
                break;
            case "휴대폰":
                f.gopaymethod.value = "HPP";
                break;
            case "신용카드":
                f.gopaymethod.value = "Card";
                f.acceptmethod.value = f.acceptmethod.value.replace(":useescrow", "");
                break;
            case "간편결제":
                f.gopaymethod.value = "Kpay";
                break;
            case "lpay":
                f.gopaymethod.value = "onlylpay";
                f.acceptmethod.value = f.acceptmethod.value+":cardonly";
                break;
            default:
                f.gopaymethod.value = "무통장";
                break;
        }
        <?php } ?>

        // 결제정보설정
        <?php if($default['de_pg_service'] == 'kcp') { ?>
        f.buyr_name.value = f.od_name.value;
        f.buyr_mail.value = f.od_email.value;
        f.buyr_tel1.value = f.od_tel.value;
        f.buyr_tel2.value = f.od_hp.value;
        f.rcvr_name.value = f.od_b_name.value;
        f.rcvr_tel1.value = f.od_b_tel.value;
        f.rcvr_tel2.value = f.od_b_hp.value;
        f.rcvr_mail.value = f.od_email.value;
        f.rcvr_zipx.value = f.od_b_zip.value;
        f.rcvr_add1.value = f.od_b_addr1.value;
        f.rcvr_add2.value = f.od_b_addr2.value;

        if(f.pay_method.value != "무통장") {
            jsf__pay( f );
        } else {
            f.submit();
        }
        <?php } ?>
        <?php if($default['de_pg_service'] == 'lg') { ?>
        f.LGD_BUYER.value = f.od_name.value;
        f.LGD_BUYEREMAIL.value = f.od_email.value;
        f.LGD_BUYERPHONE.value = f.od_hp.value;
        f.LGD_AMOUNT.value = f.good_mny.value;
        f.LGD_RECEIVER.value = f.od_b_name.value;
        f.LGD_RECEIVERPHONE.value = f.od_b_hp.value;
        <?php if($default['de_escrow_use']) { ?>
        f.LGD_ESCROW_ZIPCODE.value = f.od_b_zip.value;
        f.LGD_ESCROW_ADDRESS1.value = f.od_b_addr1.value;
        f.LGD_ESCROW_ADDRESS2.value = f.od_b_addr2.value;
        f.LGD_ESCROW_BUYERPHONE.value = f.od_hp.value;
        <?php } ?>
        <?php if($default['de_tax_flag_use']) { ?>
        f.LGD_TAXFREEAMOUNT.value = f.comm_free_mny.value;
        <?php } ?>

        if(f.LGD_CUSTOM_FIRSTPAY.value != "무통장") {
            launchCrossPlatform(f);
        } else {
            f.submit();
        }
        <?php } ?>
        <?php if($default['de_pg_service'] == 'inicis') { ?>
        f.price.value       = f.good_mny.value;
        <?php if($default['de_tax_flag_use']) { ?>
        f.tax.value         = f.comm_vat_mny.value;
        f.taxfree.value     = f.comm_free_mny.value;
        <?php } ?>
        f.buyername.value   = f.od_name.value;
        f.buyeremail.value  = f.od_email.value;
        f.buyertel.value    = f.od_hp.value ? f.od_hp.value : f.od_tel.value;
        f.recvname.value    = f.od_b_name.value;
        f.recvtel.value     = f.od_b_hp.value ? f.od_b_hp.value : f.od_b_tel.value;
        f.recvpostnum.value = f.od_b_zip.value;
        f.recvaddr.value    = f.od_b_addr1.value + " " +f.od_b_addr2.value;

        if(f.gopaymethod.value != "무통장") {
            // 주문정보 임시저장
            var order_data = $(f).serialize();
            var save_result = "";
            $.ajax({
                type: "POST",
                data: order_data,
                url: g5_url+"/shoppoint/ajax.orderdatasave.php",
                cache: false,
                async: false,
                success: function(data) {
                    save_result = data;
                }
            });

            if(save_result) {
                alert(save_result);
                return false;
            }

            if(!make_signature(f))
                return false;

            paybtn(f);
        } else {
            f.submit();
        }
        <?php } ?>
    }

}

// 구매자 정보와 동일합니다.
function gumae2baesong() {
    var f = document.forderform;

    f.od_b_name.value = f.od_name.value;
    f.od_b_tel.value  = f.od_tel.value;
    f.od_b_hp.value   = f.od_hp.value;
    f.od_b_zip.value  = f.od_zip.value;
    f.od_b_addr1.value = f.od_addr1.value;
    f.od_b_addr2.value = f.od_addr2.value;
    f.od_b_addr3.value = f.od_addr3.value;
    f.od_b_addr_jibeon.value = f.od_addr_jibeon.value;

    calculate_sendcost(String(f.od_b_zip.value));
}

<?php if ($default['de_hope_date_use']) { ?>
$(function(){
    $("#od_hope_date").datepicker({ changeMonth: true, changeYear: true, dateFormat: "yy-mm-dd", showButtonPanel: true, yearRange: "c-99:c+99", minDate: "+<?php echo (int)$default['de_hope_date_after']; ?>d;", maxDate: "+<?php echo (int)$default['de_hope_date_after'] + 6; ?>d;" });
});
<?php } ?>
</script>

<script>
// 페이지가 열릴때 자동으로 od_price input value를 0으로 지정
document.addEventListener('DOMContentLoaded', function() {
    var odPriceInput = document.querySelector('input[name="od_price"]');
    if(odPriceInput) { odPriceInput.value = '0'; } // 주문금액 기본값
    var org_odPriceInput = document.querySelector('input[name="org_od_price"]');
    if(org_odPriceInput) { org_odPriceInput.value = '0'; } // 주문금액 기본값
    $("#tot_sell_price").html(number_format(odPriceInput.value)); // 주문란 화면표시금액 기본값
    $(".print_price").html(number_format(odPriceInput.value) + " KRW");
    $("#ct_tot_price").html(number_format(odPriceInput.value));
});
</script>

<style>
/* ── 포인트 충전 다크모드 ── */
[data-site-theme="dark"] body { background:#1a1b1e !important; color:#e2e8f0 !important; }

/* 입금 통화 선택 (sod_frm 외부) */
[data-site-theme="dark"] .nationpay-container {
    background:#1e1e2e !important; border-color:#2d2d42 !important;
    box-shadow: 0 2px 6px rgba(0,0,0,.4) !important;
}
[data-site-theme="dark"] .nationpay-item_title { color:#e2e8f0 !important; }
[data-site-theme="dark"] .nationpay-item label {
    background:#252535 !important; color:#e2e8f0 !important; border-color:#3a3a52 !important;
}
[data-site-theme="dark"] .nationpay-item input[type="radio"]:checked + label {
    background:#162040 !important; color:#93c5fd !important;
    border-color:#3b82f6 !important; border-width:2px !important;
}
[data-site-theme="dark"] .nationpay-item.disabled label,
[data-site-theme="dark"] .nationpay-item label.disabled { background:#1a1a2e !important; color:#4b5563 !important; }

/* 충전 금액 입력 셀 */
[data-site-theme="dark"] .point-charge-input-cell { background:#1e1e2e !important; color:#e2e8f0 !important; }
[data-site-theme="dark"] #point_charge_select { background:#252535 !important; color:#e2e8f0 !important; border-color:#374151 !important; }

/* 패널 */
[data-site-theme="dark"] .sod_left,
[data-site-theme="dark"] .sod_right { background:#252535 !important; border-color:#2d2d42 !important; }

/* 결제 카드 항목 */
[data-site-theme="dark"] #sod_bsk_tot li { background:#1e1e2e !important; border-color:#2d2d42 !important; }
[data-site-theme="dark"] #sod_bsk_tot li span { color:#94a3b8 !important; }
[data-site-theme="dark"] #od_tot_price { background:#1e1e2e !important; border-color:#2d2d42 !important; }
[data-site-theme="dark"] #od_tot_price strong { color:#93c5fd !important; }
[data-site-theme="dark"] .print_price, [data-site-theme="dark"] .print_fx_rate { color:#93c5fd !important; }

/* 폼 테이블 */
[data-site-theme="dark"] table[style*="border-top:2px solid #333"] { border-top-color:#2d2d42 !important; }
[data-site-theme="dark"] table[style*="border-top:2px solid #333"] th { color:#94a3b8 !important; }
[data-site-theme="dark"] .sod_left th,
[data-site-theme="dark"] .sod_left td { color:#e2e8f0 !important; border-color:#2d2d42 !important; }

/* 입력 필드 */
[data-site-theme="dark"] input[type=text],
[data-site-theme="dark"] input[type=password],
[data-site-theme="dark"] select,
[data-site-theme="dark"] textarea { background:#1a1a2e !important; color:#e2e8f0 !important; border-color:#374151 !important; }
[data-site-theme="dark"] input[type=text]:focus,
[data-site-theme="dark"] input[type=password]:focus,
[data-site-theme="dark"] select:focus,
[data-site-theme="dark"] textarea:focus { border-color:#60a5fa !important; box-shadow:0 0 0 2px rgba(96,165,250,.18) !important; }
[data-site-theme="dark"] input[readonly],
[data-site-theme="dark"] input[disabled] { background:#252535 !important; color:#6b7280 !important; }
[data-site-theme="dark"] input::placeholder,
[data-site-theme="dark"] textarea::placeholder { color:#4b5563 !important; }

/* 결제 테이블 */
[data-site-theme="dark"] .pay_tbl th,
[data-site-theme="dark"] .pay_tbl td { background:#1e1e2e !important; color:#e2e8f0 !important; border-color:#2d2d42 !important; }

/* 충전/취소 버튼 */
[data-site-theme="dark"] .btn01 { background:#252535 !important; color:#e2e8f0 !important; border-color:#374151 !important; }
[data-site-theme="dark"] .btn01:hover { background:#2d2d42 !important; }

/* 한도 테이블 — style.css 규칙을 인라인으로 보강 (캐시 우회용) */
[data-site-theme="dark"] .limit_table,
[data-site-theme="dark"] #sod_frm .limit_table { background:#252535 !important; border-color:#2d2d42 !important; }
[data-site-theme="dark"] .limit_table th,
[data-site-theme="dark"] #sod_frm .limit_table th { background:#1e1e2e !important; color:#94a3b8 !important; }
[data-site-theme="dark"] .limit_table td,
[data-site-theme="dark"] #sod_frm .limit_table td { background:#252535 !important; color:#e2e8f0 !important; }
[data-site-theme="dark"] .limit_table tr,
[data-site-theme="dark"] .limit_table th,
[data-site-theme="dark"] .limit_table td { border-color:#2d2d42 !important; }
[data-site-theme="dark"] .limit_table::before { border-color:#2d2d42 !important; }

/* 안내 텍스트 */
[data-site-theme="dark"] #sod_frm_pt_alert { color:#4ade80 !important; }
[data-site-theme="dark"] .point-charge-rate-ticker .newsticker1 ul li,
[data-site-theme="dark"] .point-charge-rate-ticker .newsticker2 ul li { color:#94a3b8 !important; }
[data-site-theme="dark"] .point-charge-rate-ticker .newsticker1 ul li strong,
[data-site-theme="dark"] .point-charge-rate-ticker .newsticker2 ul li strong { color:#e2e8f0 !important; }
[data-site-theme="dark"] .point-charge-rate-update { color:#64748b !important; background:#1a1b1e !important; }

/* 주문상품 확인 테이블 (보유포인트 헤더) */
[data-site-theme="dark"] .tbl_head03 table { border-bottom-color:#2d2d42 !important; }
[data-site-theme="dark"] .tbl_head03 thead th {
    background:#1e1e2e !important; color:#94a3b8 !important;
    border-top-color:#2d2d42 !important; border-bottom-color:#2d2d42 !important;
}
[data-site-theme="dark"] .tbl_head03 thead td { background:#1e1e2e !important; }

/* 무통장입금 계좌 안내 영역 */
[data-site-theme="dark"] #settle_bank { background:#1e1e2e !important; }
[data-site-theme="dark"] #settle_bank select { background:#252535 !important; color:#e2e8f0 !important; border-color:#374151 !important; }
</style>