<?php
$phone = get_field('phone', '8');
$whatsapp = get_field('whatsapp', '8');
$address = get_field('address', '8');
$social_media_choose = get_field('social_media_choose', '8');
?>

<footer>
   <div class="container">
      <div class="row d-flex align-items-center justify-content-center h-100">
         <div class="col-lg-9 mx-auto form">
            <?php echo do_shortcode('[contact-form-7 id="5cb5489" title="Contato Footer"]') ?>
         </div>

         <div class="col-lg-4 px-3">
            <img src="<?php echo get_field('logo_f', '8'); ?>" width="100%" alt="<?php echo get_bloginfo('name') ?>">
         </div>
         <div class="col-lg-5">
            <?php echo $address; ?>
         </div>
         <div class="col-lg-3">
            <div class="col-md-12">
               <div class="social">
                  <ul class="styled-icons">
                     <?php if ($social_media_choose && in_array('Facebook', $social_media_choose)) { ?>
                        <li><a href="<?php the_field('link_facebook'); ?>" target="_blank"><i class="fa fa-facebook"></i></a></li>
                     <?php } ?>
                     <?php if ($social_media_choose && in_array('Instagram', $social_media_choose)) { ?>
                        <li><a href="<?php the_field('link_instagram'); ?>" target="_blank"><i class="fa fa-instagram"></i></a></li>
                     <?php } ?>
                     <?php if ($social_media_choose && in_array('Youtube', $social_media_choose)) { ?>
                        <li><a href="<?php the_field('link_youtube'); ?>" target="_blank"><i class="fa fa-youtube"></i></a></li>
                     <?php } ?>
                     <?php if ($social_media_choose && in_array('Twitter', $social_media_choose)) { ?>
                        <li><a href="<?php the_field('link_twitter'); ?>" target="_blank"><i class="fa fa-twitter"></i></a></li>
                     <?php } ?>
                     <?php if ($social_media_choose && in_array('Linkedin', $social_media_choose)) { ?>
                        <li><a href="<?php the_field('link_linkedin'); ?>" target="_blank"><i class="fa fa-linkedin"></i></a></li>

                     <?php } ?>
                  </ul>
               </div>
            </div>
         </div>

      </div>
   </div>
</footer>

<script src="https://code.jquery.com/jquery-3.6.0.js"></script>

<?php wp_footer(); ?>

<script>
   // Preloader
   <?php $preloader = get_field('show_preloader', 'option');
   if ($preloader == true) { ?>
      $(document).ready(function() {
         $(window).on('load', function() {
            $('html').css('overflow-y', 'hidden');
            $('.preloader').delay(500).fadeOut('slow', function() {
               $('html').css('overflow-y', 'auto');
            });
         });
      });
   <?php } else { ?>
      $(document).ready(function() {
         $('html').css('overflow-y', 'auto');
      });
   <?php } ?>

   // Phone button
   function VerTelefone() {
      $("#VerTelefone").text('<?php
                              if ($phone == "") {
                                 $whatsapp = "(" . substr($whatsapp, 0, 2) . ") " . substr($whatsapp, 2, -4) . "-" . substr($whatsapp, -4);
                                 echo $whatsapp;
                              } else {
                                 $phone = "(" . substr($phone, 0, 2) . ") " . substr($phone, 2, -4) . "-" . substr($phone, -4);
                                 echo $phone;
                              }
                              ?>');
   }

   // Email button
   function VerEmail() {
      $("#VerEmail").text('<?php echo get_field('email', 'option'); ?>');
   }
</script>
<script type="text/javascript" async src="https://d335luupugsy2.cloudfront.net/js/loader-scripts/062f06dc-569d-4167-99a0-0a4d3116b39b-loader.js"></script>
</body>

</html>