
/*Member Rate*/
/*
14519 (Promotion ID)
14595 (Promotion ID - Top up)

RR-3840-17554-14519-0 (14519)
RR-3840-17554-14519|14595-0 (14595)
*/


$('#etm_rate_table').bind('append', function() {
    $('.rate-plan-item:regex(data-termofpaymentid, ^1|3$):regex(data-promotionid, ^14358|14354|14355|14356|14357|15007|15008|15009|15010|15011|15080|15081|15082|15083|15084|15102|15103|15104|15105|15106|15167|15143|15144|15145|15175|15206|15205|15207|15220|15221|15223|15224|15225|15273|15274|15275|15276|15278|15347|15348|15349|15362|15363|15389|15390|15391|15392|15411|15410|15412|15413|15397|15398|15399|15400|15421|15422|15423|15432|15433|15434|15470|15471|15472|15467|15468|15469|15473|15474|15475|15476|15477|15478|15479|15480|15481|15482|15483|15612|15613|15614|15595|15596|15597|15598|15600|15601|15602|15611|15603|15605|15606|15607|15608|15610|15609|15588|15593|15594|15591|15592|15718|15719|15720|15721|15722|15723|15724|15725|15726|15727|15728|15729|15730|15731|15732|15733|15734|15735|15736|15737|15738|15760|15761|15762|15763|15764|15740|15765|15766|15767|15768|15769|15770|15771|15772|15773|15774|15775|15776|15777|15778|15779|15780|15781|15782|15783|16001|16002|16003|16004|16005|16006|16007|16008|16009|16010|16011|16012|16013|16014|16015|16016|16017|16018|16019|16020|16021|16022|16023|16024|16025|16050|16051$)').each(function(index) {
        $(this).addClass('item-member-rate');
    });
    $('.rate-plan-item:regex(data-termofpaymentid, ^1|3$):regex(data-promotionid, ^14358|14354|14355|14356|14357|15007|15008|15009|15010|15011|15080|15081|15082|15083|15084|15102|15103|15104|15105|15106|15167|15143|15144|15145|15175|15206|15205|15207|15220|15221|15223|15224|15225|15273|15274|15275|15276|15278|15347|15348|15349|15362|15363|15389|15390|15391|15392|15411|15410|15412|15413|15397|15398|15399|15400|15421|15422|15423|15432|15433|15434|15470|15471|15472|15467|15468|15469|15473|15474|15475|15476|15477|15478|15479|15480|15481|15482|15483|15612|15613|15614|15595|15596|15597|15598|15600|15601|15602|15611|15603|15605|15606|15607|15608|15610|15609|15588|15593|15594|15591|15592|15718|15719|15720|15721|15722|15723|15724|15725|15726|15727|15728|15729|15730|15731|15732|15733|15734|15735|15736|15737|15738|15760|15761|15762|15763|15764|15740|15765|15766|15767|15768|15769|15770|15771|15772|15773|15774|15775|15776|15777|15778|15779|15780|15781|15782|15783|16001|16002|16003|16004|16005|16006|16007|16008|16009|16010|16011|16012|16013|16014|16015|16016|16017|16018|16019|16020|16021|16022|16023|16024|16025|16050|16051$) .price .tooltip_show_content.modal_show_content').each(function(index) {
        $(this).html($(this).html() + '<div class="member-rate-txt">ราคาสมาชิก<div>');
    });
    $('.rate-plan-item:regex(data-termofpaymentid, ^1|3$):regex(data-promotionid, ^14358|14354|14355|14356|14357|15007|15008|15009|15010|15011|15080|15081|15082|15083|15084|15102|15103|15104|15105|15106|15167|15143|15144|15145|15175|15206|15205|15207|15220|15221|15223|15224|15225|15273|15274|15275|15276|15278|15347|15348|15349|15362|15363|15389|15390|15391|15392|15411|15410|15412|15413|15397|15398|15399|15400|15421|15422|15423|15432|15433|15434|15470|15471|15472|15467|15468|15469|15473|15474|15475|15476|15477|15478|15479|15480|15481|15482|15483|15612|15613|15614|15595|15596|15597|15598|15600|15601|15602|15611|15603|15605|15606|15607|15608|15610|15609|15588|15593|15594|15591|15592|15718|15719|15720|15721|15722|15723|15724|15725|15726|15727|15728|15729|15730|15731|15732|15733|15734|15735|15736|15737|15738|15760|15761|15762|15763|15764|15740|15765|15766|15767|15768|15769|15770|15771|15772|15773|15774|15775|15776|15777|15778|15779|15780|15781|15782|15783|16001|16002|16003|16004|16005|16006|16007|16008|16009|16010|16011|16012|16013|16014|16015|16016|16017|16018|16019|16020|16021|16022|16023|16024|16025|16050|16051$) .ribbon-pro-save').each(function(index) {
        $(this).find('.txt.etmtranslate').html('Member');
    });
});

$('#etm_rata_table_addon').bind('append', function() {
    $('.addon-card-item:regex(id, ^rate_plan_(4503|4502|4500|4501|4513|4512|4515|4514|4506|4507)-1$)').each(function(index) {
        $(this).addClass('item-member-rate');
        $(this).find('.addon-photo .addon_img').after(`<div class="ribbon-pro-save">       
        <span class="txt etmtranslate">Member</span>
        </div>`);
    });
});

if ($('body#reservation_engine_page_review').length > 0) {
    $(document).ajaxComplete(function() {
        var ls_Data = localStorage.getItem(global_ReadyEngine._KeyStore);
        var obj_LS = JSON.parse(ls_Data);
        var rm = false;
        $.each(obj_LS.Basket, function(i, item) {
            if (item.rate_id.search(/^(RR|SR|PA)-.*-.*-(14358|14354|14355|14356|14357|15007|15008|15009|15010|15011|15080|15081|15082|15083|15084|15102|15103|15104|15105|15106|15167|15143|15144|15145|15175|15206|15205|15207|15220|15221|15223|15224|15225|15273|15274|15275|15276|15278|15347|15348|15349|15362|15363|15389|15390|15391|15392|15411|15410|15412|15413|15397|15398|15399|15400|15421|15422|15423|15432|15433|15434|15470|15471|15472|15467|15468|15469|15473|15474|15475|15476|15477|15478|15479|15480|15481|15482|15483|15612|15613|15614|15595|15596|15597|15598|15600|15601|15602|15611|15603|15605|15606|15607|15608|15610|15609|15588|15593|15594|15591|15592|15718|15719|15720|15721|15722|15723|15724|15725|15726|15727|15728|15729|15730|15731|15732|15733|15734|15735|15736|15737|15738|15760|15761|15762|15763|15764|15740|15765|15766|15767|15768|15769|15770|15771|15772|15773|15774|15775|15776|15777|15778|15779|15780|15781|15782|15783|16001|16002|16003|16004|16005|16006|16007|16008|16009|16010|16011|16012|16013|16014|16015|16016|16017|16018|16019|16020|16021|16022|16023|16024|16025|16050|16051)-.*/) >= 0) { 
rm = true;
return false;
            }
            else if (item.rate_id.search(/^(4503|4502|4500|4501|4513|4512|4515|4514|4506|4507)-1/) >= 0) {
rm = true;
return false;
            }
        });

        CheckSignin(rm);
    });
}

async function CheckSignin(rm) {
    if (rm) {
        //$('#etm-bookingFrom').attr('action', '#');
        $('#grand-total-submit-btn').off('click');
        $('#grand-total-submit-btn').on('click', async function() {
            console.log('Member Rate - Click Confirm this reservaton');
            let res_authstate = await pstm.getAuthState();

            if (rm && !res_authstate) {
var word = '';
if (global_ReadyEngine._SearchParameter.language == 'th') {
    word = `<div class="col-12 col-no-padding">
        <div class="modal_addon">
            <svg xmlns="http://www.w3.org/2000/svg" class="icon-pointspot" version="1.0" width="538.000000pt" height="477.000000pt" viewBox="0 0 538.000000 477.000000" preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,477.000000) scale(0.100000,-0.100000)" fill="#566375" stroke="none">
    <path d="M2475 4655 c-147 -27 -314 -92 -419 -165 l-43 -29 -87 99 c-81 94 -89 100 -124 100 -75 0 -73 6 -178 -535 -51 -268 -94 -494 -94 -502 0 -8 14 -28 30 -45 l31 -31 262 7 c825 20 758 16 784 42 15 15 23 35 23 58 0 30 -13 51 -81 132 -92 110 -93 105 21 145 176 64 404 -3 514 -150 67 -89 81 -101 121 -101 46 0 85 36 85 80 0 68 -141 226 -258 288 -109 58 -185 77 -312 76 -160 0 -255 -30 -393 -127 -91 -63 -93 -106 -12 -202 l45 -52 -102 -7 c-57 -3 -206 -6 -333 -7 -190 -1 -230 1 -228 12 3 27 109 578 119 618 5 24 6 23 37 -15 88 -108 103 -109 236 -20 170 114 318 164 516 173 97 4 139 1 217 -15 334 -69 611 -310 712 -619 10 -29 27 -60 39 -68 56 -39 137 1 137 67 0 45 -57 181 -116 279 -58 96 -187 237 -282 307 -137 102 -314 178 -480 207 -102 18 -290 18 -387 0z"/>
    <path d="M3595 3694 c-347 -58 -664 -253 -858 -526 -23 -32 -44 -58 -47 -58 -3 0 -28 30 -55 68 -59 80 -178 202 -256 260 -77 58 -135 58 -165 0 -25 -49 -11 -82 64 -142 95 -76 195 -185 259 -284 l56 -84 -36 -107 c-50 -148 -70 -270 -70 -431 0 -161 18 -275 69 -428 l37 -110 -56 -85 c-165 -253 -426 -434 -719 -498 -486 -106 -990 116 -1241 548 -307 530 -142 1203 378 1542 113 73 340 161 418 161 10 0 32 13 48 29 38 38 39 82 3 118 -24 24 -30 25 -87 20 -86 -9 -244 -60 -357 -117 -301 -151 -540 -421 -653 -736 -53 -147 -72 -265 -71 -444 0 -184 20 -302 75 -454 115 -311 354 -579 649 -726 361 -181 800 -184 1165 -10 202 97 397 263 516 441 l27 39 54 -73 c81 -106 140 -169 224 -237 87 -70 127 -78 169 -35 39 38 34 90 -12 129 -220 185 -333 343 -407 566 -47 141 -60 241 -53 413 10 287 110 523 309 732 175 184 364 289 623 346 80 18 331 18 420 0 665 -132 1074 -782 900 -1431 -115 -427 -489 -765 -922 -832 -78 -12 -108 -31 -119 -73 -9 -34 12 -80 42 -94 36 -16 66 -14 184 13 247 56 456 173 640 356 207 206 336 467 375 760 19 134 19 202 0 342 -59 448 -337 829 -746 1022 -232 110 -528 152 -774 110z"/>
    <path d="M3735 3235 c-21 -21 -25 -33 -25 -89 l0 -65 -42 -11 c-140 -36 -260 -128 -311 -238 -31 -67 -31 -217 0 -284 47 -102 166 -189 298 -219 l55 -12 0 -219 c0 -147 -3 -218 -11 -218 -28 0 -121 55 -146 86 -61 77 -81 94 -110 94 -59 0 -98 -55 -81 -117 12 -47 107 -145 175 -180 32 -17 84 -39 116 -48 l57 -16 0 -65 c0 -56 4 -68 25 -89 16 -17 35 -25 60 -25 25 0 44 8 60 25 21 21 25 33 25 89 l0 65 57 16 c131 38 241 123 290 224 25 50 28 67 28 156 0 89 -3 106 -28 156 -49 101 -135 163 -277 199 l-65 16 -3 217 c-3 240 -6 230 63 198 51 -23 102 -66 120 -101 36 -70 142 -60 161 16 10 39 -3 68 -52 123 -71 79 -148 125 -251 151 l-43 11 0 65 c0 56 -4 68 -25 89 -33 34 -87 34 -120 0z m-25 -535 c0 -232 6 -223 -102 -167 -51 26 -67 40 -85 77 -53 103 -3 214 122 271 22 10 46 19 53 19 9 0 12 -47 12 -200z m280 -448 c152 -74 127 -275 -45 -353 -22 -10 -46 -19 -52 -19 -10 0 -13 48 -13 205 l0 205 28 -6 c15 -3 52 -18 82 -32z"/>
    <path d="M1517 3166 c-21 -8 -48 -22 -59 -33 -11 -10 -59 -94 -105 -188 -47 -93 -86 -171 -87 -172 -1 -2 -81 -14 -177 -28 -96 -14 -188 -30 -205 -36 -32 -10 -74 -48 -93 -86 -15 -30 -14 -109 3 -141 8 -15 75 -87 149 -159 l135 -133 -29 -167 c-16 -93 -29 -186 -29 -208 0 -80 59 -146 143 -160 39 -7 53 -2 225 86 l182 94 183 -94 c171 -88 185 -93 224 -86 84 14 143 80 143 160 0 22 -14 116 -30 208 l-29 168 136 132 c75 73 142 146 149 164 17 39 18 106 3 136 -19 38 -61 76 -93 86 -17 6 -109 22 -205 36 -96 14 -176 26 -177 28 -1 1 -40 79 -87 172 -46 94 -94 178 -105 188 -22 20 -86 46 -112 46 -8 0 -32 -6 -53 -13z m141 -346 c104 -213 98 -208 329 -241 89 -12 166 -25 172 -29 6 -3 -48 -65 -123 -141 -115 -114 -136 -140 -142 -174 -5 -28 2 -95 23 -217 16 -98 27 -178 23 -178 -4 0 -76 37 -161 82 -210 111 -210 111 -418 0 -84 -45 -156 -82 -160 -82 -4 0 6 80 22 179 20 120 27 191 23 217 -6 33 -29 60 -142 173 -82 81 -131 137 -124 141 6 4 84 17 173 29 232 33 226 28 330 241 45 93 84 169 87 169 3 0 42 -76 88 -169z"/>
    <path d="M3115 1219 c-159 -3 -318 -7 -353 -8 -52 -1 -67 -5 -87 -26 -45 -45 -35 -78 55 -187 44 -53 80 -98 80 -101 0 -12 -123 -57 -182 -67 -91 -14 -183 1 -273 45 -66 31 -90 53 -207 177 -48 50 -121 30 -142 -39 -16 -51 79 -171 197 -250 181 -122 418 -143 617 -56 81 35 187 111 200 143 16 39 6 65 -52 132 l-48 56 72 6 c40 3 191 7 336 9 241 4 263 3 259 -12 -2 -9 -30 -154 -62 -321 -33 -168 -61 -307 -63 -310 -2 -2 -27 21 -56 53 -45 48 -58 57 -87 57 -19 0 -46 -8 -60 -18 -138 -92 -173 -114 -225 -137 -500 -223 -1095 25 -1280 532 -30 83 -61 110 -114 98 -59 -13 -79 -63 -55 -138 101 -312 375 -580 707 -691 313 -105 703 -54 966 126 24 17 45 28 46 26 31 -43 154 -181 167 -188 30 -16 66 -11 94 13 21 18 30 40 46 122 130 665 169 883 164 902 -3 12 -15 32 -27 43 -25 23 -51 23 -633 9z"/>
</g>
            </svg>
            <h3 style="font-size: 21px !important;" class="caption-pointspot">ขออภัยค่ะ! ราคาพิเศษดังกล่าวสำหรับสมาชิกเท่านั้น</h3>
            <div style="font-size: 13px;">
<a href="javascript: void(0);" onclick="click_signin();" class="signin-pointspot">เข้าสู่ระบบ</a> | ยังไม่ได้เป็นสมาชิก <a href="javascript: void(0);" onclick="click_signin();" class="signin-pointspot">สมัครสมาชิก<a>
            </div>
            <div class="pointspot_poweredby">Powered by <img src="//instant-bookings.com/ibs/bookings/images/icon-pointspot.png" class="icon_pointspot"> PointSpot</div>
        </div>
    </div>`;
}
else {
    word = `<div class="col-12 col-no-padding">
        <div class="modal_addon">
            <svg xmlns="http://www.w3.org/2000/svg" class="icon-pointspot" version="1.0" width="538.000000pt" height="477.000000pt" viewBox="0 0 538.000000 477.000000" preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,477.000000) scale(0.100000,-0.100000)" fill="#566375" stroke="none">
    <path d="M2475 4655 c-147 -27 -314 -92 -419 -165 l-43 -29 -87 99 c-81 94 -89 100 -124 100 -75 0 -73 6 -178 -535 -51 -268 -94 -494 -94 -502 0 -8 14 -28 30 -45 l31 -31 262 7 c825 20 758 16 784 42 15 15 23 35 23 58 0 30 -13 51 -81 132 -92 110 -93 105 21 145 176 64 404 -3 514 -150 67 -89 81 -101 121 -101 46 0 85 36 85 80 0 68 -141 226 -258 288 -109 58 -185 77 -312 76 -160 0 -255 -30 -393 -127 -91 -63 -93 -106 -12 -202 l45 -52 -102 -7 c-57 -3 -206 -6 -333 -7 -190 -1 -230 1 -228 12 3 27 109 578 119 618 5 24 6 23 37 -15 88 -108 103 -109 236 -20 170 114 318 164 516 173 97 4 139 1 217 -15 334 -69 611 -310 712 -619 10 -29 27 -60 39 -68 56 -39 137 1 137 67 0 45 -57 181 -116 279 -58 96 -187 237 -282 307 -137 102 -314 178 -480 207 -102 18 -290 18 -387 0z"/>
    <path d="M3595 3694 c-347 -58 -664 -253 -858 -526 -23 -32 -44 -58 -47 -58 -3 0 -28 30 -55 68 -59 80 -178 202 -256 260 -77 58 -135 58 -165 0 -25 -49 -11 -82 64 -142 95 -76 195 -185 259 -284 l56 -84 -36 -107 c-50 -148 -70 -270 -70 -431 0 -161 18 -275 69 -428 l37 -110 -56 -85 c-165 -253 -426 -434 -719 -498 -486 -106 -990 116 -1241 548 -307 530 -142 1203 378 1542 113 73 340 161 418 161 10 0 32 13 48 29 38 38 39 82 3 118 -24 24 -30 25 -87 20 -86 -9 -244 -60 -357 -117 -301 -151 -540 -421 -653 -736 -53 -147 -72 -265 -71 -444 0 -184 20 -302 75 -454 115 -311 354 -579 649 -726 361 -181 800 -184 1165 -10 202 97 397 263 516 441 l27 39 54 -73 c81 -106 140 -169 224 -237 87 -70 127 -78 169 -35 39 38 34 90 -12 129 -220 185 -333 343 -407 566 -47 141 -60 241 -53 413 10 287 110 523 309 732 175 184 364 289 623 346 80 18 331 18 420 0 665 -132 1074 -782 900 -1431 -115 -427 -489 -765 -922 -832 -78 -12 -108 -31 -119 -73 -9 -34 12 -80 42 -94 36 -16 66 -14 184 13 247 56 456 173 640 356 207 206 336 467 375 760 19 134 19 202 0 342 -59 448 -337 829 -746 1022 -232 110 -528 152 -774 110z"/>
    <path d="M3735 3235 c-21 -21 -25 -33 -25 -89 l0 -65 -42 -11 c-140 -36 -260 -128 -311 -238 -31 -67 -31 -217 0 -284 47 -102 166 -189 298 -219 l55 -12 0 -219 c0 -147 -3 -218 -11 -218 -28 0 -121 55 -146 86 -61 77 -81 94 -110 94 -59 0 -98 -55 -81 -117 12 -47 107 -145 175 -180 32 -17 84 -39 116 -48 l57 -16 0 -65 c0 -56 4 -68 25 -89 16 -17 35 -25 60 -25 25 0 44 8 60 25 21 21 25 33 25 89 l0 65 57 16 c131 38 241 123 290 224 25 50 28 67 28 156 0 89 -3 106 -28 156 -49 101 -135 163 -277 199 l-65 16 -3 217 c-3 240 -6 230 63 198 51 -23 102 -66 120 -101 36 -70 142 -60 161 16 10 39 -3 68 -52 123 -71 79 -148 125 -251 151 l-43 11 0 65 c0 56 -4 68 -25 89 -33 34 -87 34 -120 0z m-25 -535 c0 -232 6 -223 -102 -167 -51 26 -67 40 -85 77 -53 103 -3 214 122 271 22 10 46 19 53 19 9 0 12 -47 12 -200z m280 -448 c152 -74 127 -275 -45 -353 -22 -10 -46 -19 -52 -19 -10 0 -13 48 -13 205 l0 205 28 -6 c15 -3 52 -18 82 -32z"/>
    <path d="M1517 3166 c-21 -8 -48 -22 -59 -33 -11 -10 -59 -94 -105 -188 -47 -93 -86 -171 -87 -172 -1 -2 -81 -14 -177 -28 -96 -14 -188 -30 -205 -36 -32 -10 -74 -48 -93 -86 -15 -30 -14 -109 3 -141 8 -15 75 -87 149 -159 l135 -133 -29 -167 c-16 -93 -29 -186 -29 -208 0 -80 59 -146 143 -160 39 -7 53 -2 225 86 l182 94 183 -94 c171 -88 185 -93 224 -86 84 14 143 80 143 160 0 22 -14 116 -30 208 l-29 168 136 132 c75 73 142 146 149 164 17 39 18 106 3 136 -19 38 -61 76 -93 86 -17 6 -109 22 -205 36 -96 14 -176 26 -177 28 -1 1 -40 79 -87 172 -46 94 -94 178 -105 188 -22 20 -86 46 -112 46 -8 0 -32 -6 -53 -13z m141 -346 c104 -213 98 -208 329 -241 89 -12 166 -25 172 -29 6 -3 -48 -65 -123 -141 -115 -114 -136 -140 -142 -174 -5 -28 2 -95 23 -217 16 -98 27 -178 23 -178 -4 0 -76 37 -161 82 -210 111 -210 111 -418 0 -84 -45 -156 -82 -160 -82 -4 0 6 80 22 179 20 120 27 191 23 217 -6 33 -29 60 -142 173 -82 81 -131 137 -124 141 6 4 84 17 173 29 232 33 226 28 330 241 45 93 84 169 87 169 3 0 42 -76 88 -169z"/>
    <path d="M3115 1219 c-159 -3 -318 -7 -353 -8 -52 -1 -67 -5 -87 -26 -45 -45 -35 -78 55 -187 44 -53 80 -98 80 -101 0 -12 -123 -57 -182 -67 -91 -14 -183 1 -273 45 -66 31 -90 53 -207 177 -48 50 -121 30 -142 -39 -16 -51 79 -171 197 -250 181 -122 418 -143 617 -56 81 35 187 111 200 143 16 39 6 65 -52 132 l-48 56 72 6 c40 3 191 7 336 9 241 4 263 3 259 -12 -2 -9 -30 -154 -62 -321 -33 -168 -61 -307 -63 -310 -2 -2 -27 21 -56 53 -45 48 -58 57 -87 57 -19 0 -46 -8 -60 -18 -138 -92 -173 -114 -225 -137 -500 -223 -1095 25 -1280 532 -30 83 -61 110 -114 98 -59 -13 -79 -63 -55 -138 101 -312 375 -580 707 -691 313 -105 703 -54 966 126 24 17 45 28 46 26 31 -43 154 -181 167 -188 30 -16 66 -11 94 13 21 18 30 40 46 122 130 665 169 883 164 902 -3 12 -15 32 -27 43 -25 23 -51 23 -633 9z"/>
</g>
            </svg>
            <h3 style="font-size: 21px !important;" class="caption-pointspot">Sorry! <b>Member Rates</b> applicable for <b>Membership only!</b> </h3>
            <div style="font-size: 13px;">
Already member, please <a href="javascript: void(0);" onclick="click_signin();" class="signin-pointspot">Sign in</a> | Not a member yet? <a href="javascript: void(0);" onclick="click_signin();" class="signin-pointspot">Create an account.<a>
            </div>
            <div class="pointspot_poweredby">Powered by <img src="//instant-bookings.com/ibs/bookings/images/icon-pointspot.png" class="icon_pointspot"> PointSpot</div>
        </div>
    </div>`;
}


$('#mainmodal-memberrate').modal('show');               
$('#mainmodal-memberrate').find('.modal-dialog').addClass('modal-md');
$('#mainmodal-memberrate').find('.body_landing').html(word);

return false;
            }
            else if (_this._EtmValidationForm(_this._reviewForm) == 0 && ($('#hiddenfield_PaymentMethod').val() != 'SMARTPAY' || parseFloat($('#hiddenfield_GrandTotal').val()) >= parseFloat($('#hd_KBANKSmartPayMinimumAmount').val()))) {
$('#grand-total-submit-btn').prop('disabled', true);
$('#grand-total-submit-btn').html('Please Wait, Processing...');
$('#grand-total-submit-btn').attr('style', 'text-transform: none; background-color: #f1f1f1 !important; color: var(--main-theme-color)!important; text-align: left;');
clearInterval(_this._Interval);
_this._Basket = [];      
_this._CookieID = {};      
_this._AllotmentStore = [];
_this._storeReservationValUpdate();
$(_this._reviewForm).submit();
            } 
            else if (($('#hiddenfield_PaymentMethod').val() == 'SMARTPAY' || $('#hiddenfield_PaymentMethod').val() == 'IPP') && parseFloat($('#hiddenfield_GrandTotal').val()) < parseFloat($('#hd_KBANKSmartPayMinimumAmount').val())) {
alert('This booking amount cannot be paid in installments.');
return false;
            } 
            else {
alert('please fill information');
var reqEle = $(_this._reviewForm).find('.etm-required').not('div');

$.each(reqEle, function() {
    $(this).on('change keyup', function() {
        _this._EtmValidationForm(_this._reviewForm);
    });
});

$('html, body').animate({
    scrollTop: $('.etm-invalid:eq(0)').offset().top - 100
}, 1000);

return false;
            }
        });

        let res_authstate = await pstm.getAuthState();
        modalWrap = document.createElement('div');
        modalWrap = document.createElement('div');
        modalWrap.innerHTML = `
        <div class="modal fade" tabindex="-1" role="dialog" id="mainmodal-memberrate" aria-labelledby="myLargeModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog" style="max-width: 750px !important;">
            <div class="modal-content">
<div class="modal-body">
    <a href="#" class="mainmodal_close" data-dismiss="modal"><i class="flaticon-close"></i></a>
    <div class="container-fluid">
            <div class="row body_landing">
       
            </div>
    </div>
</div>
            </div>
        </div>
        </div>
        `;

        document.body.append(modalWrap);

        if(!res_authstate) {
            var word = '';

            if (global_ReadyEngine._SearchParameter.language == 'th') {
word = `<div class="col-12 col-no-padding">
    <div class="modal_addon">
        <svg xmlns="http://www.w3.org/2000/svg" class="icon-pointspot" version="1.0" width="538.000000pt" height="477.000000pt" viewBox="0 0 538.000000 477.000000" preserveAspectRatio="xMidYMid meet">
            <g transform="translate(0.000000,477.000000) scale(0.100000,-0.100000)" fill="#566375" stroke="none">
<path d="M2475 4655 c-147 -27 -314 -92 -419 -165 l-43 -29 -87 99 c-81 94 -89 100 -124 100 -75 0 -73 6 -178 -535 -51 -268 -94 -494 -94 -502 0 -8 14 -28 30 -45 l31 -31 262 7 c825 20 758 16 784 42 15 15 23 35 23 58 0 30 -13 51 -81 132 -92 110 -93 105 21 145 176 64 404 -3 514 -150 67 -89 81 -101 121 -101 46 0 85 36 85 80 0 68 -141 226 -258 288 -109 58 -185 77 -312 76 -160 0 -255 -30 -393 -127 -91 -63 -93 -106 -12 -202 l45 -52 -102 -7 c-57 -3 -206 -6 -333 -7 -190 -1 -230 1 -228 12 3 27 109 578 119 618 5 24 6 23 37 -15 88 -108 103 -109 236 -20 170 114 318 164 516 173 97 4 139 1 217 -15 334 -69 611 -310 712 -619 10 -29 27 -60 39 -68 56 -39 137 1 137 67 0 45 -57 181 -116 279 -58 96 -187 237 -282 307 -137 102 -314 178 -480 207 -102 18 -290 18 -387 0z"/>
<path d="M3595 3694 c-347 -58 -664 -253 -858 -526 -23 -32 -44 -58 -47 -58 -3 0 -28 30 -55 68 -59 80 -178 202 -256 260 -77 58 -135 58 -165 0 -25 -49 -11 -82 64 -142 95 -76 195 -185 259 -284 l56 -84 -36 -107 c-50 -148 -70 -270 -70 -431 0 -161 18 -275 69 -428 l37 -110 -56 -85 c-165 -253 -426 -434 -719 -498 -486 -106 -990 116 -1241 548 -307 530 -142 1203 378 1542 113 73 340 161 418 161 10 0 32 13 48 29 38 38 39 82 3 118 -24 24 -30 25 -87 20 -86 -9 -244 -60 -357 -117 -301 -151 -540 -421 -653 -736 -53 -147 -72 -265 -71 -444 0 -184 20 -302 75 -454 115 -311 354 -579 649 -726 361 -181 800 -184 1165 -10 202 97 397 263 516 441 l27 39 54 -73 c81 -106 140 -169 224 -237 87 -70 127 -78 169 -35 39 38 34 90 -12 129 -220 185 -333 343 -407 566 -47 141 -60 241 -53 413 10 287 110 523 309 732 175 184 364 289 623 346 80 18 331 18 420 0 665 -132 1074 -782 900 -1431 -115 -427 -489 -765 -922 -832 -78 -12 -108 -31 -119 -73 -9 -34 12 -80 42 -94 36 -16 66 -14 184 13 247 56 456 173 640 356 207 206 336 467 375 760 19 134 19 202 0 342 -59 448 -337 829 -746 1022 -232 110 -528 152 -774 110z"/>
<path d="M3735 3235 c-21 -21 -25 -33 -25 -89 l0 -65 -42 -11 c-140 -36 -260 -128 -311 -238 -31 -67 -31 -217 0 -284 47 -102 166 -189 298 -219 l55 -12 0 -219 c0 -147 -3 -218 -11 -218 -28 0 -121 55 -146 86 -61 77 -81 94 -110 94 -59 0 -98 -55 -81 -117 12 -47 107 -145 175 -180 32 -17 84 -39 116 -48 l57 -16 0 -65 c0 -56 4 -68 25 -89 16 -17 35 -25 60 -25 25 0 44 8 60 25 21 21 25 33 25 89 l0 65 57 16 c131 38 241 123 290 224 25 50 28 67 28 156 0 89 -3 106 -28 156 -49 101 -135 163 -277 199 l-65 16 -3 217 c-3 240 -6 230 63 198 51 -23 102 -66 120 -101 36 -70 142 -60 161 16 10 39 -3 68 -52 123 -71 79 -148 125 -251 151 l-43 11 0 65 c0 56 -4 68 -25 89 -33 34 -87 34 -120 0z m-25 -535 c0 -232 6 -223 -102 -167 -51 26 -67 40 -85 77 -53 103 -3 214 122 271 22 10 46 19 53 19 9 0 12 -47 12 -200z m280 -448 c152 -74 127 -275 -45 -353 -22 -10 -46 -19 -52 -19 -10 0 -13 48 -13 205 l0 205 28 -6 c15 -3 52 -18 82 -32z"/>
<path d="M1517 3166 c-21 -8 -48 -22 -59 -33 -11 -10 -59 -94 -105 -188 -47 -93 -86 -171 -87 -172 -1 -2 -81 -14 -177 -28 -96 -14 -188 -30 -205 -36 -32 -10 -74 -48 -93 -86 -15 -30 -14 -109 3 -141 8 -15 75 -87 149 -159 l135 -133 -29 -167 c-16 -93 -29 -186 -29 -208 0 -80 59 -146 143 -160 39 -7 53 -2 225 86 l182 94 183 -94 c171 -88 185 -93 224 -86 84 14 143 80 143 160 0 22 -14 116 -30 208 l-29 168 136 132 c75 73 142 146 149 164 17 39 18 106 3 136 -19 38 -61 76 -93 86 -17 6 -109 22 -205 36 -96 14 -176 26 -177 28 -1 1 -40 79 -87 172 -46 94 -94 178 -105 188 -22 20 -86 46 -112 46 -8 0 -32 -6 -53 -13z m141 -346 c104 -213 98 -208 329 -241 89 -12 166 -25 172 -29 6 -3 -48 -65 -123 -141 -115 -114 -136 -140 -142 -174 -5 -28 2 -95 23 -217 16 -98 27 -178 23 -178 -4 0 -76 37 -161 82 -210 111 -210 111 -418 0 -84 -45 -156 -82 -160 -82 -4 0 6 80 22 179 20 120 27 191 23 217 -6 33 -29 60 -142 173 -82 81 -131 137 -124 141 6 4 84 17 173 29 232 33 226 28 330 241 45 93 84 169 87 169 3 0 42 -76 88 -169z"/>
<path d="M3115 1219 c-159 -3 -318 -7 -353 -8 -52 -1 -67 -5 -87 -26 -45 -45 -35 -78 55 -187 44 -53 80 -98 80 -101 0 -12 -123 -57 -182 -67 -91 -14 -183 1 -273 45 -66 31 -90 53 -207 177 -48 50 -121 30 -142 -39 -16 -51 79 -171 197 -250 181 -122 418 -143 617 -56 81 35 187 111 200 143 16 39 6 65 -52 132 l-48 56 72 6 c40 3 191 7 336 9 241 4 263 3 259 -12 -2 -9 -30 -154 -62 -321 -33 -168 -61 -307 -63 -310 -2 -2 -27 21 -56 53 -45 48 -58 57 -87 57 -19 0 -46 -8 -60 -18 -138 -92 -173 -114 -225 -137 -500 -223 -1095 25 -1280 532 -30 83 -61 110 -114 98 -59 -13 -79 -63 -55 -138 101 -312 375 -580 707 -691 313 -105 703 -54 966 126 24 17 45 28 46 26 31 -43 154 -181 167 -188 30 -16 66 -11 94 13 21 18 30 40 46 122 130 665 169 883 164 902 -3 12 -15 32 -27 43 -25 23 -51 23 -633 9z"/>
            </g>
        </svg>
        <h3 style="font-size: 21px !important;" class="caption-pointspot">ลงทะเบียนเพื่อรับส่วนลดและสะสมคะแนน</h3>
        <div style="font-size: 13px;">
            <a href="javascript: void(0);" onclick="click_signin();" class="signin-pointspot">เข้าสู่ระบบ</a> | ยังไม่ได้เป็นสมาชิก <a href="javascript: void(0);" onclick="click_signin();" class="signin-pointspot">สมัครสมาชิก<a>
        </div>
        <div class="pointspot_poweredby">Powered by <img src="//instant-bookings.com/ibs/bookings/images/icon-pointspot.png" class="icon_pointspot"> PointSpot</div>
    </div>
</div>`;
            }
            else {
word = `<div class="col-12 col-no-padding">
    <div class="modal_addon">
        <svg xmlns="http://www.w3.org/2000/svg" class="icon-pointspot" version="1.0" width="538.000000pt" height="477.000000pt" viewBox="0 0 538.000000 477.000000" preserveAspectRatio="xMidYMid meet">
            <g transform="translate(0.000000,477.000000) scale(0.100000,-0.100000)" fill="#566375" stroke="none">
<path d="M2475 4655 c-147 -27 -314 -92 -419 -165 l-43 -29 -87 99 c-81 94 -89 100 -124 100 -75 0 -73 6 -178 -535 -51 -268 -94 -494 -94 -502 0 -8 14 -28 30 -45 l31 -31 262 7 c825 20 758 16 784 42 15 15 23 35 23 58 0 30 -13 51 -81 132 -92 110 -93 105 21 145 176 64 404 -3 514 -150 67 -89 81 -101 121 -101 46 0 85 36 85 80 0 68 -141 226 -258 288 -109 58 -185 77 -312 76 -160 0 -255 -30 -393 -127 -91 -63 -93 -106 -12 -202 l45 -52 -102 -7 c-57 -3 -206 -6 -333 -7 -190 -1 -230 1 -228 12 3 27 109 578 119 618 5 24 6 23 37 -15 88 -108 103 -109 236 -20 170 114 318 164 516 173 97 4 139 1 217 -15 334 -69 611 -310 712 -619 10 -29 27 -60 39 -68 56 -39 137 1 137 67 0 45 -57 181 -116 279 -58 96 -187 237 -282 307 -137 102 -314 178 -480 207 -102 18 -290 18 -387 0z"/>
<path d="M3595 3694 c-347 -58 -664 -253 -858 -526 -23 -32 -44 -58 -47 -58 -3 0 -28 30 -55 68 -59 80 -178 202 -256 260 -77 58 -135 58 -165 0 -25 -49 -11 -82 64 -142 95 -76 195 -185 259 -284 l56 -84 -36 -107 c-50 -148 -70 -270 -70 -431 0 -161 18 -275 69 -428 l37 -110 -56 -85 c-165 -253 -426 -434 -719 -498 -486 -106 -990 116 -1241 548 -307 530 -142 1203 378 1542 113 73 340 161 418 161 10 0 32 13 48 29 38 38 39 82 3 118 -24 24 -30 25 -87 20 -86 -9 -244 -60 -357 -117 -301 -151 -540 -421 -653 -736 -53 -147 -72 -265 -71 -444 0 -184 20 -302 75 -454 115 -311 354 -579 649 -726 361 -181 800 -184 1165 -10 202 97 397 263 516 441 l27 39 54 -73 c81 -106 140 -169 224 -237 87 -70 127 -78 169 -35 39 38 34 90 -12 129 -220 185 -333 343 -407 566 -47 141 -60 241 -53 413 10 287 110 523 309 732 175 184 364 289 623 346 80 18 331 18 420 0 665 -132 1074 -782 900 -1431 -115 -427 -489 -765 -922 -832 -78 -12 -108 -31 -119 -73 -9 -34 12 -80 42 -94 36 -16 66 -14 184 13 247 56 456 173 640 356 207 206 336 467 375 760 19 134 19 202 0 342 -59 448 -337 829 -746 1022 -232 110 -528 152 -774 110z"/>
<path d="M3735 3235 c-21 -21 -25 -33 -25 -89 l0 -65 -42 -11 c-140 -36 -260 -128 -311 -238 -31 -67 -31 -217 0 -284 47 -102 166 -189 298 -219 l55 -12 0 -219 c0 -147 -3 -218 -11 -218 -28 0 -121 55 -146 86 -61 77 -81 94 -110 94 -59 0 -98 -55 -81 -117 12 -47 107 -145 175 -180 32 -17 84 -39 116 -48 l57 -16 0 -65 c0 -56 4 -68 25 -89 16 -17 35 -25 60 -25 25 0 44 8 60 25 21 21 25 33 25 89 l0 65 57 16 c131 38 241 123 290 224 25 50 28 67 28 156 0 89 -3 106 -28 156 -49 101 -135 163 -277 199 l-65 16 -3 217 c-3 240 -6 230 63 198 51 -23 102 -66 120 -101 36 -70 142 -60 161 16 10 39 -3 68 -52 123 -71 79 -148 125 -251 151 l-43 11 0 65 c0 56 -4 68 -25 89 -33 34 -87 34 -120 0z m-25 -535 c0 -232 6 -223 -102 -167 -51 26 -67 40 -85 77 -53 103 -3 214 122 271 22 10 46 19 53 19 9 0 12 -47 12 -200z m280 -448 c152 -74 127 -275 -45 -353 -22 -10 -46 -19 -52 -19 -10 0 -13 48 -13 205 l0 205 28 -6 c15 -3 52 -18 82 -32z"/>
<path d="M1517 3166 c-21 -8 -48 -22 -59 -33 -11 -10 -59 -94 -105 -188 -47 -93 -86 -171 -87 -172 -1 -2 -81 -14 -177 -28 -96 -14 -188 -30 -205 -36 -32 -10 -74 -48 -93 -86 -15 -30 -14 -109 3 -141 8 -15 75 -87 149 -159 l135 -133 -29 -167 c-16 -93 -29 -186 -29 -208 0 -80 59 -146 143 -160 39 -7 53 -2 225 86 l182 94 183 -94 c171 -88 185 -93 224 -86 84 14 143 80 143 160 0 22 -14 116 -30 208 l-29 168 136 132 c75 73 142 146 149 164 17 39 18 106 3 136 -19 38 -61 76 -93 86 -17 6 -109 22 -205 36 -96 14 -176 26 -177 28 -1 1 -40 79 -87 172 -46 94 -94 178 -105 188 -22 20 -86 46 -112 46 -8 0 -32 -6 -53 -13z m141 -346 c104 -213 98 -208 329 -241 89 -12 166 -25 172 -29 6 -3 -48 -65 -123 -141 -115 -114 -136 -140 -142 -174 -5 -28 2 -95 23 -217 16 -98 27 -178 23 -178 -4 0 -76 37 -161 82 -210 111 -210 111 -418 0 -84 -45 -156 -82 -160 -82 -4 0 6 80 22 179 20 120 27 191 23 217 -6 33 -29 60 -142 173 -82 81 -131 137 -124 141 6 4 84 17 173 29 232 33 226 28 330 241 45 93 84 169 87 169 3 0 42 -76 88 -169z"/>
<path d="M3115 1219 c-159 -3 -318 -7 -353 -8 -52 -1 -67 -5 -87 -26 -45 -45 -35 -78 55 -187 44 -53 80 -98 80 -101 0 -12 -123 -57 -182 -67 -91 -14 -183 1 -273 45 -66 31 -90 53 -207 177 -48 50 -121 30 -142 -39 -16 -51 79 -171 197 -250 181 -122 418 -143 617 -56 81 35 187 111 200 143 16 39 6 65 -52 132 l-48 56 72 6 c40 3 191 7 336 9 241 4 263 3 259 -12 -2 -9 -30 -154 -62 -321 -33 -168 -61 -307 -63 -310 -2 -2 -27 21 -56 53 -45 48 -58 57 -87 57 -19 0 -46 -8 -60 -18 -138 -92 -173 -114 -225 -137 -500 -223 -1095 25 -1280 532 -30 83 -61 110 -114 98 -59 -13 -79 -63 -55 -138 101 -312 375 -580 707 -691 313 -105 703 -54 966 126 24 17 45 28 46 26 31 -43 154 -181 167 -188 30 -16 66 -11 94 13 21 18 30 40 46 122 130 665 169 883 164 902 -3 12 -15 32 -27 43 -25 23 -51 23 -633 9z"/>
            </g>
        </svg>
        <h3 style="font-size: 21px !important;" class="caption-pointspot">Register for Special Member Rates and Points Collection</h3>
        <div style="font-size: 13px;">
            Already member, please <a href="javascript: void(0);" onclick="click_signin();" class="signin-pointspot">Sign in</a> | Not a member yet? <a href="javascript: void(0);" onclick="click_signin();" class="signin-pointspot">Create an account.<a>
        </div>
        <div class="pointspot_poweredby">Powered by <img src="//instant-bookings.com/ibs/bookings/images/icon-pointspot.png" class="icon_pointspot"> PointSpot</div>
    </div>
</div>`;
            }

            
            $('#mainmodal-memberrate').modal('show');        
            $('#mainmodal-memberrate').find('.modal-dialog').addClass('modal-md');
            $('#mainmodal-memberrate').find('.body_landing').html(word);
        }
    }
}

function click_signin() {
    $('#mainmodal-memberrate').modal('hide');
    signin();
}
            /** voucher **/
 $("<span class='span_SMS'  style='font-size: 11px;color: red;'>SMS Confirmation will be sent for Online Voucher Purchase Confirmation.<br>ระบบจะส่ง SMS เพื่อยืนยันการซื้อบัตรกำนัลไปยังหมายเลขของท่านหากไม่ได้รับ SMS กรุณาติดต่อเจ้าหน้าที่</span>").insertAfter(".online-voucher #mp_contentplaceholder_Content_textbox_PhoneNumber");


 $("<span  style='font-size: 22px; padding-top: 5px;'>*Login เข้าระบบสมาชิก หรือ สมัครสมาชิกใหม่ ในหน้าถัดไป</span>").insertAfter(".body_496 .id-5268 .txt-name");
/** voucher **/


//not paotung 80

/* Start new script v.02 */

str_MessageRedeem  =  '<a class="redeem_tag link-redeem" href="#">Redeem Voucher</a>';
$(document).ready(function(){ $('#redeem_banner').html(str_MessageRedeem );})



str_Message  =  '<div id="carousel_item_img" class="carousel-item etm_tab_banner carousel_item_img item_etm_tab_banner"><a href="#"  class="link-redeem"><img class="banner_redeem-lg" src="https://ibs.instant-bookings.com/medias/gallerys/hotels/80/template/images/banner-redeemvoucher-samed-80.jpg" width="100%"><img class="banner_redeem-sm" src="https://ibs.instant-bookings.com/medias/gallerys/hotels/80/template/images/redeem_voucher-banner.jpg" width="100%"></a></div>';

/*Banner tt50 
str_Message  =  '<div id="carousel_item_img" class="carousel-item etm_tab_banner carousel-item-1 carousel_item_img item_etm_tab_banner active"><a href="#"  class="link-redeem"><img src="https://ibs.instant-bookings.com/medias/gallerys/hotels/80/template/images/Redeem-Aopraoresort.jpg" width="100%"> </a></div><div id="carousel_item_img02" class="carousel-item etm_tab_banner carousel_item_img item_etm_tab_banner"><a href="https://reservations.instant-bookings.com/?hotelname=samedresorts-aoprao&page=tt50&hotelkey=%3D%3DwTEFUP&hotelid=80&numberofadult=2&showby=room&viewby=column&arrivaldate=30%2F06%2F2025&departuredate=01%2F07%2F2025&night=1"  class="link-tt50"><img src="https://ibs.instant-bookings.com/medias/gallerys/hotels/80/template/images/TT50.jpg" width="100%"> </a></div>';
*/

$(document).ready(function(){ $(document).ajaxComplete(function() { $(".link-redeem").mouseover(function(){ $(this).attr("href", '?' + window.location.search.replace("?&","&").replace("?","") + '&page=redeemvoucher'); }) }); });
/*$('.row_etm_tab_banner').append(str_Message);*/
let searchParams = new URLSearchParams(window.location.search);
let pageRedeem = searchParams.get("page");
if(pageRedeem == "redeemvoucher")
{
  $(".carousel_item_img").remove();
  $(".item_etm_tab_banner").removeClass("carousel-item-2");
  $(".item_etm_tab_banner").addClass("carousel-item-1");

/**ExitReeedeempage**/


$(".link-redeem").hide();
  const Bookparams = new URLSearchParams(window.location.search);
  const const_numberOfAdult = Bookparams.get('numberofadult') || '2' ;
  const const_arrivalDate = Bookparams.get('arrivaldate') || getCurrentDate();
  const const_departureDate = Bookparams.get('departuredate') || getCurrentDate(1);
  const const_night = Bookparams.get('night') || '1';
var urlBook = '//reservations.instant-bookings.com/?hotelkey===wTEFUP&hotelid=80&numberofadult='+const_numberOfAdult+'&arrivaldate='+const_arrivalDate+'&departuredate='+const_departureDate+'&night='+const_night

var str_BookingBanner ="<div class='sold-out-Banner' style='width: 100%;text-align: center;'><h5 style='text-align: center; font-weight: normal;'>This page is exclusively for redeeming vouchers purchased </h5> If you <b style='font-weight: 600 !important;'>did not purchase</b> a voucher and would like to book a room at our regular rates, please click the button below. <br><center style='margin-top: 20px;margin-bottom: 20px;'><a href='"+urlBook +"' style='padding-bottom: 5px;padding-left: 10px;padding-right: 10px;padding-top: 5px;'>CLICK</a></center></div>";

$('.row_etm_tab_banner').empty().append(str_BookingBanner );

str_MessageRedeem = '<a class="exist_reedeem" href="'+urlBook +'">Exit Redemption</a>';
 $("#redeem_banner").html(str_MessageRedeem);


/**ExitReeedeempage**/

}
else if(pageRedeem == "tt50" || pageRedeem == "TT50")
{
   const Bookparams = new URLSearchParams(window.location.search);
  const const_numberOfAdult = Bookparams.get('numberofadult') || '2' ;
  const const_arrivalDate = Bookparams.get('arrivaldate') || getCurrentDate();
  const const_departureDate = Bookparams.get('departuredate') || getCurrentDate(1);
  const const_night = Bookparams.get('night') || '1';
var urlBook = '//reservations.instant-bookings.com/?hotelkey===wTEFUP&hotelid=80&numberofadult='+const_numberOfAdult+'&arrivaldate='+const_arrivalDate+'&departuredate='+const_departureDate+'&night='+const_night


var str_BookingBanner ="<div class='sold-out-Banner' style='width: 100%;text-align: center;'><h5 style='text-align: center; font-weight: normal;'>สำหรับสิทธิ์โครงการ  <b style='font-weight: 600 !important;'>“เที่ยวไทยคนละครึ่ง”</b> <br>เปิดจองทุกวันจันทร์–เสาร์ เวลา <b style='font-weight: 600 !important;'>06.00–16.00 น.</b></h5><br><br> หากต้องการ<b style='font-weight: 600 !important;'>จองราคาปกติโดยไม่ใช้สิทธิ์ </b> กรุณาคลิกปุ่มด้านล่าง <br><center style='margin-top: 20px;margin-bottom: 20px;'><a href='"+urlBook +"' style='padding-bottom: 5px;padding-left: 10px;padding-right: 10px;padding-top: 5px;'>กลับสู่หน้าราคาปกติ</a></center></div>";


$('.row_etm_tab_banner').empty().append(str_BookingBanner );
	
}

function getCurrentDate(offset = 0) {
    const today = new Date();
    today.setDate(today.getDate() + offset);
    const year = today.getFullYear();
    const month = String(today.getMonth() + 1).padStart(2, '0');
    const day = String(today.getDate()).padStart(2, '0');
    return `${day}/${month}/${year}`;
}	


/* End new script v.02 */

var vdotravfrom = moment("21/04/2022", "DD/MM/YYYY");
var vdotravto = moment("2023-04-30", "DD/MM/YYYY");
var vholiday = ["2022-06-03","2022-06-04","2022-08-12","2022-08-13","2022-10-22","2022-10-23","2023-01-21","2023-01-22","2023-01-23","2023-03-04","2023-03-05","2023-04-12","2023-04-13","2023-04-14","2023-04-15","2023-04-16","2023-04-29","2023-04-30"];


function HidePoint() {
var i  = $(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(16495|16498|16497|16493|16494|16496|15570|15574|15572|15573|15576|15568|15569|15571|15575|15614|15618|15616|15617|15620|15612|15613|15615|15619|16339|16343|16341|16342|16345|16337|16338|16340|16344|16360|16364|16362|16363|16366|16358|16359|16361|16365)-.*-.*)").length ;

if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(16495|16498|16497|16493|16494|16496|15570|15574|15572|15573|15576|15568|15569|15571|15575|15614|15618|15616|15617|15620|15612|15613|15615|15619|16339|16343|16341|16342|16345|16337|16338|16340|16344|16360|16364|16362|16363|16366|16358|16359|16361|16365)-.*-.*)").length > 0) {

$('#pointspot_pannel').hide();
$('#pointspot-message').hide();
$('.pannel-pointspot').hide();

	}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(17138|17140|17136|17137|17139|17059|17061|17057|17058|17060|16704|16706|16707|16702|16703|16705)-.*-.*)").length > 0) {
$('#pointspot_pannel').hide();
                    $('#pointspot-message').hide();
                    $('#payment-message').show();
                    $('#pointspot_login').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ! </b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนได้ และไม่สามารถใช้บัตรกำนัลร่วมได้');
                    $('#pointspot_login2').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ! </b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนได้ และไม่สามารถใช้บัตรกำนัลร่วมได้');
                    $('#pointspot_login').show();
                    $('#pointspot_login2').show();


	}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(17589|17592|17591|17587|17588|17590|17815|17818|17817|17813|17814|17816|18762|18763|18924|18927|18926|18922|18923|18925)-.*-.*)").length > 0)
{

console.log("Hello world!"); 

//$('#pointspot_pannel').show();
$('.pannel-pointspot').hide();



}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(19010|19012|19008|19009|19011|19016|19018|19014|19015|19017)-.*-.*)").length > 0)
{
//ttt67
$('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();

}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(19140|19141)-.*-.*)").length > 0)
{
//ttt67
$('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();

}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(19389|19391|19387|19388|19390|19394|19396|19392|19393|19395)-.*-.*)").length > 0)
{

//ttt68

  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();

}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(19683|19684|19685|19681|19682)-.*-.*)").length > 0)
{

//ttt69

  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();

}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(20279|20280|20281|20282|20283|20285|20284|20286|20287|22181|22182|22183|22184|22185|22186|22187|22188|22189|22190)-.*-.*)").length > 0)
{

//ttt70

  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();

}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(21297|21298|21299|21300|21301|21302|21303|21304|21305|21306|21297|21298|21299|21300|21301|21302|21303|21304|21305|21306)-.*-.*)").length > 0)
{

/**ttt73,ttt74**/

  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();

}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(19897|19898|19899|19900|19902|19901|21567|21566|21565|21564)-.*-.*)").length > 0)
{
//super sale
  $('.pannel-pointspot').hide();   $('#pointspot-message').hide(); $('.pannel-redeemvoucher').hide();
}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(19281|19283|19279|19280|19282|19286|19288|19284|19285|19287)-.*-.*)").length > 0)
{
//PROMOTION 11.11
$('.pannel-pointspot').hide();   $('#pointspot-message').hide();
// $('.pannel-redeemvoucher').hide();

}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-(19489|19492|19491|19487|19488|19490|19495|19497|19502|19493|19494|19496)-.*-.*)").length > 0)
{
//FESTIVE PROMOTION (MIN. 2 NTS)
$('.pannel-pointspot').hide();   $('#pointspot-message').hide();

}
else if ($(".widget-cart-item div:regex(id, ^(RR|SR|PA)-.*-.*-(15411|15410|15412|15413|15406|15405|15407|15408|15409)-.*)").length > 0)
{
  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
}


}

$(document).ready(function() {
if ($('body#reservation_engine_page_review').length > 0) {
   if ($('body.review_page.payment_page').length > 0) {
      HidePoint();
   }
   $( document).ajaxComplete(function() {
      HidePoint();
   });
}});



//Ao Prao Resort [80]
$('.online-voucher #mp_contentplaceholder_Content_panel_Address label').html('Delivery Address <em id="mp_contentplaceholder_Content_panel_RequireFirstName">*</em> <span style="color: red;">สำคัญ! กรุณากรอกรายละเอียดให้ครบถ้วน ที่อยู่สำหรับการจัดส่งบัตรกำนัลตัวจริงทางไปรษณีย์</span>');
$('.online-voucher #mp_contentplaceholder_Content_panel_Prefix label').html('Title <em id="mp_contentplaceholder_Content_panel_RequirePrefix">*</em> (คำนำหน้า)');
$('.online-voucher #mp_contentplaceholder_Content_panel_FirstName label').html('First name <em id="mp_contentplaceholder_Content_panel_RequireFirstName">*</em> (ชื่อ)');
$('.online-voucher #mp_contentplaceholder_Content_panel_LastName label').html('Last name <em id="mp_contentplaceholder_Content_panel_RequireLastName">*</em> (นามสกุล)');
$('.online-voucher #mp_contentplaceholder_Content_panel_PhoneNumber label').html('Contact phone number <em id="mp_contentplaceholder_Content_panel_RequirePhoneNumber">*</em> (เบอร์โทรศัพท์ติดต่อ)');
$('.online-voucher #mp_contentplaceholder_Content_panel_EmailAddress label').html('E-mail address <em id="mp_contentplaceholder_Content_panel_RequireEmailAddress">*</em> (อีเมลล์)');
$('.online-voucher #mp_contentplaceholder_Content_panel_ProvinceName label').html('Province/State  (จังหวัด)');
$('.online-voucher #mp_contentplaceholder_Content_panel_ZipCode label').html('Zip Code/Postal Code   (รหัสไปรษณีย์)');
$('.online-voucher #mp_contentplaceholder_Content_panel_Nationality label').html('Nationality <em id="mp_contentplaceholder_Content_panel_RequireNationality">*</em> (สัญชาติ)');
  /*149*/
$('.online-voucher #mp_contentplaceholder_Content_panel_Address label').html('Delivery Address <em id="mp_contentplaceholder_Content_panel_RequireFirstName">*</em> <span style="color: red;">สำคัญ! กรุณากรอกที่อยู่ และรหัสไปรษณีย์ให้ครบถ้วน เพื่อใช้ในการจัดส่งบัตรกำนัลฉบับจริงทางไปรษณีย์ (จัดส่งเฉพาะภายในประเทศไทยเท่านั้น)</span>');
$('.online-voucher.body_150 #mp_contentplaceholder_Content_panel_ZipCode label').html('Zip Code/Postal Code  <span style="color: red;">* รหัสไปรษณีย์</span> ');



function HidePointAndVoucher() {
    try {
        signout().then(
            function() {
                setTimeout(
                function() 
                {
                    $('.pannel-redeemvoucher').hide();
                    $('#pointspot_pannel').hide();
                    $('#pointspot-message').hide();
                    $('#payment-message').show();
                    $('#pointspot_login').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ! การใช้สิทธิ์ชำระเงินผ่านโครงการเราเที่ยวด้วยกัน</b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนได้ และไม่สามารถใช้บัตรกำนัลร่วมได้');
                    $('#pointspot_login2').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ! การใช้สิทธิ์ชำระเงินผ่านโครงการเราเที่ยวด้วยกัน</b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนได้ และไม่สามารถใช้บัตรกำนัลร่วมได้');
                    $('#pointspot_login').show();
                    $('#pointspot_login2').show();
                    $('.payment_method_box:not(.box-paotang)').hide();
               }, 1000);
            }
        );
    } catch (error) {}
}


function HidePointAndVoucherForBookDate() {
    try {
        signout().then(
            function() {
                setTimeout(
                function() 
                {
                    $('.pannel-redeemvoucher').hide();
                    $('#pointspot_pannel').hide();
                    $('#pointspot-message').hide();
                    $('#payment-message').show();
                    $('#pointspot_login').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ! การใช้สิทธิ์การจองวอเชอร์เเบบระบุวัน</b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนได้ และไม่สามารถใช้บัตรกำนัลร่วมได้');
                    $('#pointspot_login2').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ! การใช้สิทธิ์การจองวอเชอร์เเบบระบุวัน</b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนได้ และไม่สามารถใช้บัตรกำนัลร่วมได้');
                    $('#pointspot_login').show();
                    $('#pointspot_login2').show();
                  //  $('.payment_method_box:not(.box-paotang)').hide();
               }, 1000);
            }
        );
    } catch (error) {}
}


jQuery.expr[':'].regex = function(elem, index, match) {
    var matchParams = match[3].split(','),
        validLabels = /^(data|css):/,
        attr = {
            method: matchParams[0].match(validLabels) ?
                matchParams[0].split(':')[0] : 'attr',
            property: matchParams.shift().replace(validLabels, '')
        },
        regexFlags = 'ig',
        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g, ''), regexFlags);
    return regex.test(jQuery(elem)[attr.method](attr.property));
}

/*โครงการเราเที่ยวด้วยกัน*/
$(document).ready(function() {
if ($('body#reservation_engine_page_review').length > 0) {
   if ($('body.review_page.payment_page').length > 0) {
      VerifyGateway();
   }
   $( document).ajaxComplete(function() {
      VerifyGateway();
   });
}});

function VerifyGateway() {
let searchParams = new URLSearchParams(window.location.search);
let pageEngine = searchParams.get("page");
$('.pannel-redeemvoucher').hide();

if(global_ReadyEngine._Search_tmp["promotioncode"]  != undefined)
{
console.log("Hello world!"); 
var str_promocode = global_ReadyEngine._Search_tmp["promotioncode"].toLowerCase();
   if(str_promocode  == 'chillpn@samed' || str_promocode  ==  'gwf1' || str_promocode  ==  'unm2' || str_promocode  ==  'pmt3' || str_promocode  ==  'thaitour@smr')
   {

            $('#pointspot_pannel').hide();
                   $('#pointspot-message').hide();
                   $('#payment-message').show();
                   $('#pointspot_login').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ!</b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนเป็นส่วนลดได้');
                   $('#pointspot_login2').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ! </b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนเป็นส่วนลดได้');
                   $('#pointspot_login').show();
                   $('#pointspot_login2').show();
   }
  else if(str_promocode  == 'ktconly'  || str_promocode  == 'bbl2025'){  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('#payment-message').show();
 }



}

if (pageEngine == "tt50" || pageEngine == "TT50" && moment('31/10/2025', 'DD/MM/YYYY').diff(moment(global_ReadyEngine._SearchParameter.departuredate, 'DD/MM/YYYY'), 'day') >= 0)
{   

      $('.payment_method_box:not(.box-paotang)').hide();
      $('input:radio[name=payment_method_radio]').prop('checked', true);
      $('.payment_method_box').trigger( "click" );
	  $("input[name='textbox_FirstName']").closest("div.col-sm-5").find("label").contents().filter(function() {
		return this.nodeType === 3;
		}).first().replaceWith("ชื่อ (ต้องเป็นภาษาไทย) : ");
	  $("input[name='textbox_LastName']").closest("div.col-sm-5").find("label").contents().filter(function() {
		return this.nodeType === 3;
		}).first().replaceWith("นามสกุล (ต้องเป็นภาษาไทย) : ");
     HidePointAndVoucher();

}
else if(pageEngine == "redeemvoucher")
{
       $('.pannel-redeemvoucher').show();
	   $('.payment_method_box.box-paotang').hide();
	   $('.payment_method_box.box-paotang').attr('style','visibility: hidden;max-height: 0px;padding: 0px;margin: 0px;');
          
    /** ซ่อน สะสมคะเเนะ **/

        $('#pointspot_pannel').hide();
                   $('#pointspot-message').hide();
                   $('#payment-message').show();
                   $('#pointspot_login').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ!</b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนได้ และไม่สามารถใช้บัตรกำนัลร่วมได้');
                   $('#pointspot_login2').html('<b class="caption-pointspot" style="font-size:14px !important;">ขออภัยค่ะ! </b><br>ไม่สามารถใช้ร่วมกับการสะสมคะแนนหรือใช้คะแนนได้ และไม่สามารถใช้บัตรกำนัลร่วมได้');
                   $('#pointspot_login').show();
                   $('#pointspot_login2').show();

}
else if(global_ReadyEngine._Search_tmp["page"] != undefined && global_ReadyEngine._Search_tmp["page"].toLowerCase() == 'supersale')
{
 
  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();


}
else if(global_ReadyEngine._Search_tmp["promotioncode"] != undefined && (global_ReadyEngine._Search_tmp["promotioncode"].toLowerCase() == 'bdjul23' || global_ReadyEngine._Search_tmp["promotioncode"].toLowerCase() == 'bdaug23'  ) )
{
 
  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();


}
else if(global_ReadyEngine._Search_tmp["page"] != undefined && global_ReadyEngine._Search_tmp["page"].toLowerCase() == 'ttt67')
{
  $('.pannel-pointspot').hide();   $('#pointspot-message').hide();
 $('.pannel-redeemvoucher').hide();
}
else {
      if (global_ReadyEngine._Search_tmp["page"] != undefined && global_ReadyEngine._Search_tmp["page"].toLowerCase() == 'early-deal'){   HidePointAndVoucherForBookDate();  }
      $('.payment_method_box.box-paotang').hide();
      $('.payment_method_box.box-paotang').attr('style','visibility: hidden;max-height: 0px;padding: 0px;margin: 0px;');
   }
}


/*Banner pao tung*/
//str_MessageRedeem  =  '<a class="redeem_tag link-redeem" href="https://instant-bookings.com/ibs/bookings/select-room.aspx?hotelname=samedresorts-aoprao&page=redeemvoucher">Redeem Voucher</a>';
$(document).ready(function(){ $('#redeem_banner').html(str_MessageRedeem );})

//var str_Message = '<div class=""><a href="https://instant-bookings.com/ibs/bookings/select-room.aspx?hotelname=veranda-chiangmaihighresort&page=PAOTANG"><img src="https://ibs.instant-bookings.com/medias/gallerys/hotels/49/template/images/banner-rao-tiew-duay-gan.jpg"> </a></div>';

//var str_Message = '<div class=""><a href="https://www.samedresorts.com/redeem.html"><img src="https://ibs.instant-bookings.com/medias/gallerys/hotels/135/template/images/redeem_voucher-banner.jpg" width="100%"> </a></div>';


//str_Message = '<div><div style="display: inline-block;width: 50%;"><a href="https://www.samedresorts.com/redeem.html"><img src="https://ibs.instant-bookings.com/medias/gallerys/hotels/80/template/images/banner-travel-together-redeem.png" width="100%"> </a> </div><div style="display: inline-block;width: 50%;"><a href="https://instant-bookings.com/ibs/bookings/select-room.aspx?hotelname=samedresorts-aoprao&page=PAOTANG"><img src="https://ibs.instant-bookings.com/medias/gallerys/hotels/80/template/images/banner-travel-together.png" width="100%"> </a></div></div>';

//str_Message = '<div class=""><a href="https://instant-bookings.com/ibs/bookings/select-room.aspx?hotelname=samedresorts-aoprao&page=redeemvoucher"><img src="https://ibs.instant-bookings.com/medias/gallerys/hotels/135/template/images/redeem_voucher-banner.jpg" width="100%"> </a></div>';


//str_Message = '';


/*โครงการเราเที่ยวด้วยกัน (คำนวณราคา) 40%*/
$("#etm_rate_table").bind("append", function() { 

let searchParams = new URLSearchParams(window.location.search);
let Site_pageRedeem = searchParams.get("page");
if(Site_pageRedeem != "redeemvoucher" && Site_pageRedeem != 'tt50' && Site_pageRedeem != 'TT50')
{  
/*$('#etm_rate_message').html(str_Message);*/
$('.row_etm_tab_banner').empty().append(str_Message);

/* 2 banner */
$('.carousel-control-prev, .carousel-control-next').addClass('d-flex-sm');

/*Banner tt50 
$('.row_etm_tab_banner').append(str_Message);
*/
}
else if ((Site_pageRedeem == 'tt50' || Site_pageRedeem == 'TT50' )&& moment('31/10/2025', 'DD/MM/YYYY').diff(moment(global_ReadyEngine._SearchParameter.departuredate, 'DD/MM/YYYY'), 'day') >= 0) 
{
       $('#tab_addon').hide();
       DisplayPopupAddon = 0;
       $('.rate-plan-item .price .tooltip_show_content.modal_show_content').each(function(index) {
             var n = parseFloat(global_ReadyEngine._Search_tmp["night"]);
var a = parseFloat($(this).html().split("</span>")[1].trim().replace(",", ""))
var b = a / n;
var c = b * 40/100 <= 3000 ? b * 40/100 : 3000;
c = n <= 3? a - (c * n) : a - (c * 3) ;
$('.ttogether', this).remove();
/*
$(this).html($(this).html() + '<div class="ttogether"><b style="font-size:13px; font-weight:bold; color:#fc5b62;">ลูกค้าใช้สิทธิ์จ่ายเพียง ' + c.toLocaleString('en').toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,').split('.')[0] + ' บาท</b><div>');
*/
$(this).html($(this).html() + '<div class="ttogether"><b style="font-size:13px; font-weight:bold; color:#fc5b62;">ราคาก่อนรับสิทธ์ส่วนลด</b><div>');

/*TTogether Book at Least Day*/
var nd = moment().startOf('day').clone();
var bd = 0;
do { nd.add(1, 'd'); bd += "0123456".search(nd.day()) != -1 ? 1 : 0; } while (bd < 3);
if (moment(global_ReadyEngine._Search_tmp.arrivaldate, 'DD/MM/YYYY') < nd) { $(this).parent().parent().parent().html('<div style="font-size:12px;font-weight:bold;background-color:var(--main-theme-color-rgb3)!important;padding:5px 10px;border-radius:5px;width:fit-content;float:right;color:#ffffffba;">ต้องจองล่วงหน้าอย่างน้อย 3 วันทำการ</div>'); }
/*-----*/

      });
}

});


$(document).ready(function() { try {
if (global_ReadyEngine._Search_tmp["page"] != undefined && global_ReadyEngine._Search_tmp["page"].toLowerCase() == 'tt50' && moment('31/10/2025', 'DD/MM/YYYY').diff(moment(global_ReadyEngine._SearchParameter.departuredate, 'DD/MM/YYYY'), 'day') >= 0) { 
var _nd = DNow.startOf('day').clone();
var _bd = 0;

do { _nd.add(1, 'd'); _bd += "0123456".search(_nd.day()) != -1 ? 1 : 0; } while (_bd < 3);
        
        try {$(global_ReadyEngine._Boxpickerdate).data('daterangepicker').minDate = _nd;
        $(document).on('click', '.modal_show_content', function() { $('.etmDateCheckin2:eq(2)').data('daterangepicker').minDate = _nd; });}
        catch(err){}

	if (moment(moment(global_ReadyEngine._SearchParameter.arrivaldate, 'DD/MM/YYYY'), 'DD/MM/YYYY').diff(_nd, 'day', 'day')  < 0) { 
		$(global_ReadyEngine._Boxpickerdate).data('daterangepicker').setStartDate(_nd);
		$(global_ReadyEngine._Boxpickerdate).data('daterangepicker').setEndDate(_nd.clone().add(1,'day'));
		global_ReadyEngine._Search_tmp['arrivaldate'] = _nd.format('DD/MM/YYYY');
		global_ReadyEngine._Search_tmp['departuredate']= _nd.clone().add(1,'day').format('DD/MM/YYYY');
		$(global_ReadyEngine._Boxpickerdate).trigger("apply.daterangepicker");
		$("#btn_search_desktop").trigger("click");
	}
}}catch(err){}});



$(document).on('click', '.room-item-remove', function() { calTTogether(); }); 
$(document).ajaxComplete(function() {  calTTogether();  });
function calTTogether() 
{

var ls_Data = localStorage.getItem(global_ReadyEngine._KeyStore);
var obj_LS = JSON.parse(ls_Data);
var n = 1;
var a = 0;
var b = 0;
var h = false;

 $.each(obj_LS.Basket, function(i, item) {
a += parseFloat(item.rateplan_price);


 if (global_ReadyEngine._Search_tmp["page"] != undefined && global_ReadyEngine._Search_tmp["page"].toLowerCase() == 'tt50' && moment('31/10/2025', 'DD/MM/YYYY').diff(moment(global_ReadyEngine._SearchParameter.departuredate, 'DD/MM/YYYY'), 'day') >= 0)
 {
 if (item.rate_id.search(/^(RR|SR|PA)-.*-.*-.*-.*/) >= 0 && n <= 5)
{
var c = parseFloat(item.rateplan_price)/parseFloat(obj_LS.SearchParameter.night);
    for (i = 1; i <= obj_LS.SearchParameter.night && n <= 5; i++) {
     b += (c * 40/100) <= 3000 ? (c * 40/100) : 3000;
     h = true;
     n++;

}
}

}

});


if (h) {

$('.sum-grand-total .ttogether').remove();
/*
$('.sum-grand-total').html($('.sum-grand-total').html() + `<div class="row ttogether"><div class="col-6" style="font-size:12px;"><strong style="font-size:12px;">ส่วนลดการใช้สิทธิ์ (40%)</strong></div><div class="col-6 price" style="font-size:12px;color:#fc5b62;font-weight:bold;"><span class="grand-total-currency">THB -</span><span style="">` + Number.parseFloat(b).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + `</span></div></div>

<div class="row ttogether"><div class="col-6" style="font-size:12px;"><strong style="font-size:12px;">ยอดเงินที่ต้องชำระ</strong></div><div class="col-6 price" style="font-size:12px;font-weight:bold;"><span class="grand-total-currency">THB </span><span style="">` + Number.parseFloat(a - b).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + `</span></div></div>`);

*/ 

$('.col-12.customer-remark').html('<p style="color:#fc5b62; font-size:11px;">* ราคาก่อนรับสิทธ์ส่วนลด</p>');

}
}


                        if (navigator.userAgent.search('Line/') >= 0) { 
                            //alert('LINE in-App Browser (LIFF App)');
                            if (window.location.href.search('openExternalBrowser=1') < 0) {
                                //alert('Open External Browser\n\n' + window.location.href);
                                window.location.replace(window.location.href + '&openExternalBrowser=1');
                                document.body.innerHTML = '';	
                            }
                        };  $(document).ready(function(){ 
                        if (global_ReadyEngine._Search_tmp['promotioncode'].toLowerCase() == 'bdjul23') {
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').minDate = moment('06/07/2023','DD/MM/YYYY');
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').maxDate = moment('31/08/2023','DD/MM/YYYY');;
                        }
                        else if (global_ReadyEngine._Search_tmp['promotioncode'].toLowerCase() == 'bdaug23') {
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').minDate = moment('01/08/2023','DD/MM/YYYY');
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').maxDate = moment('30/09/2023','DD/MM/YYYY');;
                        }
                        else if (global_ReadyEngine._Search_tmp['promotioncode'].toLowerCase() == 'bdsep23') {
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').minDate = moment('01/09/2023','DD/MM/YYYY');
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').maxDate = moment('31/10/2023','DD/MM/YYYY');;
                        }
                        else if (global_ReadyEngine._Search_tmp['promotioncode'].toLowerCase() == 'bdoct23') {
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').minDate = moment('01/10/2023','DD/MM/YYYY');
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').maxDate = moment('31/11/2023','DD/MM/YYYY');;
                        }
                        else if (global_ReadyEngine._Search_tmp['promotioncode'].toLowerCase() == 'bdnov23') {
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').minDate = moment('01/11/2023','DD/MM/YYYY');
                            $(global_ReadyEngine._Boxpickerdate).data('daterangepicker').maxDate = moment('31/12/2023','DD/MM/YYYY');;
                        }
                    });  $(".payment_method_box.box-mobile_banking").hide();
                    // device detection
                    if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 
                        || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) { 
    
                       $(".payment_method_box.box-mobile_banking").show();
                         } 
                                $(window).on('load', function () {
                                     setTimeout(() => {
                                    if($('#mainmodal').hasClass('show') )
                                    {
                                       if($('#mainmodal-memberrate').hasClass('show'))
	                                    {
		                                    $('#mainmodal-memberrate').removeClass('show').addClass('hide');
	                                    }
                                    }
 
                                    }, 500);   
                                    });
                                    