
// brand sign up code
$(document).ready(function () {
    /* Telephone Input Start */
    
    let flagInput = document.querySelectorAll('[name="quote[phone]"]');
    
    if (flagInput.length !== 0) {
    
      let ip;
      let ip_value;
    
      $('[name="quote[phone]"]').intlTelInput({
    
        geoIpLookup: function (callback) {
          $.get('https://ipinfo.io', function () { }, "jsonp").always(function (resp) {
            var countryCode = (resp && resp.country) ? resp.country : "";
            callback(countryCode);
            ip = "23.94.140.50";
          });
        },
    
        initialCountry: "us",
        nationalMode: true,
        separateDialCode: true,
    
      }).then(() => {
    
         let pc = $('.selected-dial-code').html();
         let ctry = $('.selected-flag').attr('title').split(':')[0];
    
        $('input[name="code"]').val(pc);
        $('input[name="cip"]').val(ip);
        $('input[name="ctry"]').val(ctry);
    
      });
    
    
    
      $(document).on('click', '.country', function () {
        
        
          let countryDetail = $(this).parent().parent().find('.selected-flag').attr('title');
          countryDetail =  countryDetail.split(':');


          $('input[name="code"]').val(countryDetail[0]);
          $('input[name="ctry"]').val(countryDetail[1]);
    
    
      });
    
    }
})