<?php if (get_theme_mod( 'charsoogh_featured_ad_show') != 'no') : ?>
<section class="block featured-block">
  <div class="ad-loading-featured"><div class="ad-loader-show"></div></div>
<?php if (get_theme_mod( 'charsoogh_featured_ad_show_style') != 'full') : ?>
    <div class="container">
<?php endif; ?>
        <div class="<?php if (get_theme_mod( 'charsoogh_featured_ad_style' )) : echo get_theme_mod( 'charsoogh_featured_ad_style'); else: echo 'section-title'; endif; ?> clearfix">
        <h2><?php if (get_theme_mod( 'charsoogh_featured_ad_title' )) : echo get_theme_mod( 'charsoogh_featured_ad_title'); else: echo __('Featured' , 'charsoogh'); endif; ?></h2>
        </div>
        <div class="show_featured">
        <?php
        if (empty(get_theme_mod( 'charsoogh_featured_ad_show_style')) || get_theme_mod( 'charsoogh_featured_ad_show_style') != 'noneslider') :
        echo '<div class="row items featured-carousel owl-carousel">';
        else:
        echo '<div class="row items">';
        endif;
         ?>
        </div>
<?php if (get_theme_mod( 'charsoogh_featured_ad_show_style') != 'full') : ?>
    </div>
<?php endif; ?>
        </div>
</section>

<script>
var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
jQuery(function($) {
      jQuery(".ad-loading-featured").css("display", "block");
      <?php
      if (get_theme_mod('charsoogh_featured_ad_index_show')) : $ad_show = get_theme_mod('charsoogh_featured_ad_index_show');
      else: $ad_show = 12;
      endif;
      if (empty(get_theme_mod( 'charsoogh_featured_ad_show_style')) || get_theme_mod( 'charsoogh_featured_ad_show_style') == 'default' || get_theme_mod( 'charsoogh_featured_ad_show_style') == 'full') :
      if (get_theme_mod( 'charsoogh_featured_ad_layout' )) : $featured = 'item ' . get_theme_mod( 'charsoogh_featured_ad_layout'); else: $featured = 'item featured-4row'; endif;
      else:
      if (get_theme_mod( 'charsoogh_featured_ad_layout' ) == 'featured-4row') : $featured = 'item col-lg-3 col-md-3 col-sm-12'; else: $featured = 'item col-lg-4 col-md-4 col-sm-12'; endif;
      endif;
      ?>
        var data = {
            'action': 'load_featured_by_ajax',
            'ad_show': '<?php echo $ad_show; ?>',
            'ad_style': '<?php echo $featured; ?>',
            'security': '<?php echo wp_create_nonce("load_more_featured"); ?>'
        };

        $.post(ajaxurl, data, function(response) {
            $('.show_featured .items').append(response);
            $('[data-toggle="tooltip"]').tooltip();
            $(".ribbon-featured").each(function() {
                var thisText = $(this).text();
                $(this).html("");
                $(this).append(
                    "<div class='ribbon-start'></div>" +
                    "<div class='ribbon-content'>" + thisText + "</div>" +
                    "<div class='ribbon-end'>" +
                        "<figure class='ribbon-shadow'></figure>" +
                    "</div>"
                );
            });
            jQuery(".ad-loading-featured").css("display", "none");
            <?php if (get_theme_mod( 'charsoogh_featured_ad_layout' )) : $featured_item = get_theme_mod( 'charsoogh_featured_ad_layout'); else: $featured_item = 4; endif;
            if($featured_item == 'featured'){$featured_item = 3;}else{$featured_item = 4;}
             ?>
             <?php if (get_theme_mod( 'charsoogh_visit_ad_show') == 'no') : ?>
             jQuery('.ad_visit').hide();
   					<?php endif; ?>
            <?php if (get_theme_mod( 'charsoogh_featured_ad_show_style') != 'noneslider') : ?>
            <?php if (get_theme_mod( 'charsoogh_featured_ad_show_style') != 'full') : ?>
            jQuery(".featured-carousel").owlCarousel({loop:!1,margin:0,nav:!0,<?php if(is_rtl()): echo 'rtl:!0'; else: echo 'ltr:!0'; endif; ?>,dots:!1,items:<?php echo $featured_item; ?>,navText:["<i class='fa fa-chevron-left'></i>","<i class='fa fa-chevron-right'></i>"],URLhashListener:!0,responsive:{768:{items:<?php echo $featured_item; ?>},0:{items:1,dots:1,nav:false,center:!1,margin:0,autoWidth:!1}}});
            <?php else: ?>
            jQuery(".featured-carousel").owlCarousel({loop:!1,margin:0,nav:!1,<?php if(is_rtl()): echo 'rtl:!0'; else: echo 'ltr:!0'; endif; ?>,dots:1,items:6,navText:["<i class='fa fa-chevron-left'></i>","<i class='fa fa-chevron-right'></i>"],URLhashListener:!0,responsive:{768:{items:6},0:{items:1,dots:1,nav:false,center:!1,margin:0,autoWidth:!1}}});
            <?php endif; ?>
            <?php endif; ?>
        });
});
</script>
<?php endif; ?>
