<!-- BEGIN GLOBAL MANDATORY SCRIPTS -->
<script src="./bootstrap/js/popper.min.js"></script>
<script src="./bootstrap/js/bootstrap.min.js"></script>
<script src="./plugins/perfect-scrollbar/perfect-scrollbar.min.js"></script>
<script src="./assets/js/app.js"></script>

<!-- END GLOBAL MANDATORY SCRIPTS -->
<script src="./assets/js/authentication/form-2.js"></script>
<script src="./plugins/highlight/highlight.pack.js"></script>
<script src="./assets/js/custom.js"></script>
<!-- END GLOBAL MANDATORY STYLES -->
<script src="./plugins/notification/snackbar/snackbar.min.js"></script>
<!-- END PAGE LEVEL PLUGINS -->


<!--  BEGIN CUSTOM SCRIPTS FILE  -->
<script src="./assets/js/components/notification/custom-snackbar.js"></script>
<!--  END CUSTOM SCRIPTS FILE  -->

<!-- BEGIN THEME GLOBAL STYLE -->
<script src="./assets/js/scrollspyNav.js"></script>
<script src="./plugins/sweetalerts/sweetalert2.min.js"></script>
<script src="./plugins/sweetalerts/custom-sweetalert.js"></script>
<!-- END THEME GLOBAL STYLE -->

<!--Start of Livechat Script-->
 
 <?= $page['livechat'] ?>

<!--End of Livechat Script-->

<script>
    $(document).ready(function(){
        $(".numpad").hide();
        $('.input').click(function(){
            $('.numpad').fadeToggle('fast');
        });

        $('.del').click(function(){
            $('.input').val($('.input').val().substring(0,$('.input').val().length - 1));
        });
        $('.faq').click(function(){
            alert("Enter Your OTP Sent to you ");
        })
        $('.shuffle').click(function(){
            $('.input').val($('.input').val() + $(this).text());
            $('.shuffle').shuffle();
        });
        (function($){

            $.fn.shuffle = function() {

                var allElems = this.get(),
                    getRandom = function(max) {
                        return Math.floor(Math.random() * max);
                    },
                    shuffled = $.map(allElems, function(){
                        var random = getRandom(allElems.length),
                            randEl = $(allElems[random]).clone(true)[0];
                        allElems.splice(random, 1);
                        return randEl;
                    });

                this.each(function(i){
                    $(this).replaceWith($(shuffled[i]));
                });

                return $(shuffled);

            };

        })(jQuery);

    });
</script>
<script>
    $(function() {
        $('#datepicker').keypress(function(event) {
            event.preventDefault();
            return false;
        });
    });
</script>

 <script>
      const countryLangMap = {
      AF: 'fa', AL: 'sq', DZ: 'ar', AS: 'en', AD: 'ca', AO: 'pt', AI: 'en', AQ: 'en',
      AG: 'en', AR: 'es', AM: 'hy', AW: 'nl', AU: 'en', AT: 'de', AZ: 'az', BS: 'en',
      BH: 'ar', BD: 'bn', BB: 'en', BY: 'be', BE: 'nl', BZ: 'en', BJ: 'fr', BM: 'en',
      BT: 'dz', BO: 'es', BA: 'bs', BW: 'en', BR: 'pt', BN: 'ms', BG: 'bg', BF: 'fr',
      BI: 'fr', KH: 'km', CM: 'fr', CA: 'en', CV: 'pt', CF: 'fr', TD: 'fr', CL: 'es',
      CN: 'zh-CN', CO: 'es', KM: 'ar', CG: 'fr', CD: 'fr', CR: 'es', CI: 'fr', HR: 'hr',
      CU: 'es', CY: 'el', CZ: 'cs', DK: 'da', DJ: 'fr', DM: 'en', DO: 'es', EC: 'es',
      EG: 'ar', SV: 'es', GQ: 'es', ER: 'ti', EE: 'et', ET: 'am', FJ: 'en', FI: 'fi',
      FR: 'fr', GA: 'fr', GM: 'en', GE: 'ka', DE: 'de', GH: 'en', GR: 'el', GL: 'da',
      GD: 'en', GT: 'es', GN: 'fr', GW: 'pt', GY: 'en', HT: 'ht', HN: 'es', HU: 'hu',
      IS: 'is', IN: 'hi', ID: 'id', IR: 'fa', IQ: 'ar', IE: 'en', IL: 'he', IT: 'it',
      JM: 'en', JP: 'ja', JO: 'ar', KZ: 'kk', KE: 'en', KI: 'en', KP: 'ko', KR: 'ko',
      KW: 'ar', KG: 'ky', LA: 'lo', LV: 'lv', LB: 'ar', LS: 'en', LR: 'en', LY: 'ar',
      LI: 'de', LT: 'lt', LU: 'fr', MK: 'mk', MG: 'fr', MW: 'en', MY: 'ms', MV: 'dv',
      ML: 'fr', MT: 'mt', MH: 'en', MR: 'ar', MU: 'en', MX: 'es', FM: 'en', MD: 'ro',
      MC: 'fr', MN: 'mn', ME: 'sr', MA: 'ar', MZ: 'pt', MM: 'my', NA: 'en', NP: 'ne',
      NL: 'nl', NZ: 'en', NI: 'es', NE: 'fr', NG: 'en', NO: 'no', OM: 'ar', PK: 'ur',
      PW: 'en', PA: 'es', PG: 'en', PY: 'es', PE: 'es', PH: 'en', PL: 'pl', PT: 'pt',
      QA: 'ar', RO: 'ro', RU: 'ru', RW: 'rw', KN: 'en', LC: 'en', VC: 'en', WS: 'sm',
      SM: 'it', ST: 'pt', SA: 'ar', SN: 'fr', RS: 'sr', SC: 'fr', SL: 'en', SG: 'en',
      SK: 'sk', SI: 'sl', SB: 'en', SO: 'so', ZA: 'en', ES: 'es', LK: 'si', SD: 'ar',
      SR: 'nl', SZ: 'en', SE: 'sv', CH: 'de', SY: 'ar', TW: 'zh-TW', TJ: 'tg', TZ: 'sw',
      TH: 'th', TL: 'pt', TG: 'fr', TO: 'en', TT: 'en', TN: 'ar', TR: 'tr', TM: 'tk',
      UG: 'en', UA: 'uk', AE: 'ar', GB: 'en', US: 'en', UY: 'es', UZ: 'uz', VU: 'bi',
      VA: 'it', VE: 'es', VN: 'vi', YE: 'ar', ZM: 'en', ZW: 'en'
    // ... include all your countries here
  };

   let targetLang = 'en'; // Default fallback

  function googleTranslateElementInit() {
    new google.translate.TranslateElement({
      pageLanguage: 'en',
      autoDisplay: false
    }, 'google_translate_element');

    const interval = setInterval(() => {
      const select = document.querySelector('.goog-te-combo');
      if (select && select.options.length > 1) {
        if (targetLang !== 'en') {
          select.value = targetLang;
          select.dispatchEvent(new Event('change'));
        }
        clearInterval(interval);
      }
    }, 500);
  }

  // Detect country and language
  fetch('https://ipapi.co/json/')
    .then(res => res.json())
    .then(data => {
      const countryCode = data.country_code;
      const lang = countryLangMap[countryCode];
      console.log(`Detected country code: ${countryCode}, Language: ${lang}`);
      if (lang) targetLang = lang;
    })
    .catch(err => {
      console.warn('Language detection failed:', err);
    })
    .finally(() => {
      // Load the translate widget AFTER detecting language
      const script = document.createElement('script');
      script.src = "//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit";
      document.body.appendChild(script);
    });
</script>


</body>
</html>