 const header = document.querySelector('header.header');
      
      document.addEventListener('scroll', () => {
        if (header) {
          header.classList.toggle('shadow-sm', document.documentElement.scrollTop > 0);
        }
      });
      $(document).ready(function() {
        $("form").submit(function(event) {
          var email = $("input[name='email']").val();
          var emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

          if (!emailPattern.test(email)) {
            alert("Please enter a valid email address.");
            event.preventDefault(); // Prevent form submission
          }
        });
      });
      $(document).ready(function(){
          $('input[name="email"]').on('blur',function(event){
            const email = $(this).val().trim();
            var emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
            if (!emailPattern.test(email)) {
              //alert("Please enter a valid email address.");
              $(this).focus();
              return false;
            }
            $.ajax({
                        url: 'getusercountry',
                        method: 'get',
                        data:{email:this.value},
                        dataType: 'json',
                        beforeSend : function(){
                            $('.countrysection').hide();
                            $('#loader').show();
                        },
                        success: function(data) {
                          
                          var html = ``;
                          if(data.length > 0){
                            $('.countrysection').removeClass('hidden').show();
                            data.map(function(val){
                              html += `<option value="${val.iso}">India - ${val.country_name} Partnership</option>`;
                            });
                          }
                          $('.country').html(html);
                        },
                        complete: function() {
                            // Hide the loader after request completes
                            $('#loader').hide();
                        },
                        error: function(xhr, status, error) {
                          $('.countrysection').hide();
                            $('#loader').hide();
                            console.error('Error Status:', status);
                            console.error('Error Thrown:', error);
                            console.error('Response Text:', xhr.responseText);
                        }
                  });
          });
      });