<?php
/**
 *
 * @package Luzuk Premium
 */

if(get_theme_mod('blog_section_disable') != 'on' ){ ?>
	<?php 
 	if( get_theme_mod('blog_areaTpadding',true) ) {
 		$blog_areaTpadding = 'padding-top:'.esc_attr(get_theme_mod('blog_areaTpadding')).';';
 	}
 	if( get_theme_mod('blog_areaBpadding',true) ) {
 		$blog_areaBpadding = 'padding-bottom:'.esc_attr(get_theme_mod('blog_areaBpadding')).';';
 	}
 	?>
<div  class="blog-area" id="blog" >
		
	<?php			
		$blog_title = get_theme_mod('blog_title', 'Latest Event');
      	$blog_subtitle = get_theme_mod('blog_subtitle', 'It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.');
	?>

	<div class="" data-wow-duration="1s">
		<div class="container">
			<div class="row justify-content-center">
					<div class="col-xl-6 col-lg-6 col-sm-11 col-xs-12">	
							<div class="section-title-area">
								<?php if($blog_title){ ?>
									<?php if($blog_title){ ?>
									<div class="section-title">
										<h2><?php echo ($blog_title);  ?></h2>
											<div class="title-icon1">
						 					 	<img src="<?php echo esc_html(get_template_directory_uri()); ?>/images/sectitle.png" />
						 					</div>
				 					</div>
			 					<?php }?>
			 					<div class="clearfix"></div>	
								<?php }?>
									<div class="section-subtitle">
										<p><?php echo ($blog_subtitle);  ?></p>
									</div>
							</div>
					</div>
			</div>
		</div>
    <div class="clearfix"></div>

    	<div class="container">
			<div class="row">
				<div class="blog-area-wrap">
					<div class="blog-posts">

						<?php 
						$blog_post_count = get_theme_mod('blog_post_count', 3);
						$blog_cat_exclude = get_theme_mod('blog_cat_exclude');
						$blog_cat_exclude = explode(',', $blog_cat_exclude);
						$args = array(
							'posts_per_page' => absint($blog_post_count),
							'category__not_in' => $blog_cat_exclude
						);
						$query = new WP_Query($args);
						if($query -> have_posts()):
							while($query -> have_posts()) : $query -> the_post();
								$luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id() , 'total-blog-thumb');
								?>
								<?php 
								if(has_post_thumbnail()){
									$img = esc_url($luzuk_image[0]);
								}
								if(empty($luzuk_image)){
									$img = get_template_directory_uri().'/images/blog.jpg';
								}

								
								?>
								<div class="blog-post col-md-4 col-sm-6 col-xs-12">
									<div class="box-area-S">
											<div class="blog-imgbox">
												<div class="blog-date">
														<ul>
																<li><?php echo get_the_date( 'j' ); ?></li>
										            <li class="month"><?php echo get_the_date( 'M' ); ?></li>
												        <li><?php echo get_the_date( 'Y' ); ?></li>
											      </ul>
												</div>
												<div class="blog-img">
													<a href="<?php the_permalink(); ?>" class="blog-thumbnail">
														
														<img  src="<?php echo $img; ?>" alt="<?php the_title(); ?>">
														<div class="border-overlay"></div> 
														
													</a>
												<div class="clearfix"></div>
											</div>
										</div>
										<div class="blog-single">
												<div class="row blog-a-d">
														<div class="col-md-6 col-sm-6 col-xs-12 adbrd">
								                 <i class="fa fa-user" aria-hidden="true"></i> <span> <?php echo get_the_author(); ?></span>    
								            </div>
														<div class="col-md-6 col-sm-6 col-xs-12 ">
		                            <i class="fa fa-commenting-o" aria-hidden="true"></i><?php echo $my_var = get_comments_number(); ?> comment
		                        </div>						                       
						            </div>
						            <div class="clearfix"></div>
												<a href="<?php the_permalink(); ?>"><h4 class="inner-area-title"><?php the_title(); ?></h4></a>
												<div class="section-area-text">
												<?php 
														if(has_excerpt()){
															echo get_the_excerpt();
														}else{
															echo luzuk_excerpt( get_the_content() , 110 );
														}
													?>
												</div>
												<?php
                            $homepageblogbutton1 = get_theme_mod('homepageblog_txt1', 'Read More'); 
                          ?>
                             
                          <?php if($homepageblogbutton1){ ?>
                              <div class="readmore1">
                                  <a href="<?php echo esc_url(get_permalink()); ?>" class="more-button"><?php echo ($homepageblogbutton1 );  ?>
                                  	<div class="btnborder"></div>
                                  </a>
                              </div>
                          <?php }?>
												
											<div class="clearfix"></div>
										</div>
									</div>
								</div>
								<?php
							endwhile;
						endif;
						wp_reset_postdata();
						?>
					</div>
						<div class="clearfix"></div>
					</div>	
  
					<div class="clearfix"></div>
				</div>
			</div>

			</div>
		<div class="clearfix"></div>
</div>

<script>
(function ($) {
  var equalHeight = function (column) {
    // Set variables.
    var currentTallest = 0;
    var currentRowStart = 0;
    var currentColumn = 0;
    var topPosition = 0;
    var arrColumns = [];

    $(column).each(function () {
      var $column = $(this);

      // Reset height.
      $column.height('auto'); 

      // Get top position of this column
      // relative to the document.
      topPosition = $column.offset().top; 

      if (currentRowStart != topPosition) {
        for (currentColumn = 0 ; currentColumn < arrColumns.length; currentColumn++) {
          arrColumns[currentColumn].height(currentTallest);
        }

        arrColumns.length = 0; // Empty the array.
        currentRowStart = topPosition; // Set next row start based on top position.
        currentTallest = $column.height();
        arrColumns.push($column);
      } else {
        arrColumns.push($column);
        currentTallest = (currentTallest < $column.height()) ? ($column.height()) : (currentTallest);
      }

      for (currentColumn = 0 ; currentColumn < arrColumns.length; currentColumn++) {
         arrColumns[currentColumn].height(currentTallest);
      }
    });

  }

  $(window).on('load resize', function() {
    equalHeight('.blog-posts .blog-post');
  });

      $('.blog-post').each(function () {
    	 var hue = 'rgb(' + (Math.floor((256-199)*Math.random()) + 200) + ',' + (Math.floor((256-199)*Math.random()) + 200) + ',' + (Math.floor((256-199)*Math.random()) + 200) + ')';
    	$(this).css("background", hue);
    });
  
}(jQuery));

</script>
<?php }