<?php
/**
 *
 */
if(get_theme_mod('lz_featured_pages_disable') != 'on' ){?>
<section id="featured-pages-section" class="ht-section">
	<div class="lightbox">
		<div class="col-md-10 col-md-offset-1">
			<div class="row">
				<?php
				$showStatic = true;
				for( $i = 1; $i <= 8; $i++ ){
					$luzuk_featured_page_id = get_theme_mod('luzuk_featured_page_'.$i); 
					if(!empty($luzuk_featured_page_id)){
						$showStatic = false;
						break;
					}
				}
				$luzuk_featured_title = get_theme_mod('lz_featured_pages_title','Our Features');
				$luzuk_featured_sub_title = get_theme_mod('lz_featured_pages_sub_title','CHOOSE YOUR DESIRED COURSE');
				?>

				<div class="ht-section-title-tagline">
					<h2 class="ht-section-title lz-featured-Page-heading">
						<?php
						if(!empty($luzuk_featured_title))	{
							echo esc_html($luzuk_featured_title);
						} ?>
					</h2>
					<div class="ht-section-tagline lz-featured-Page-text feature-border">
						<?php if($luzuk_featured_sub_title){
							echo esc_html($luzuk_featured_sub_title);
						}?>
					</div
				</div>

				<div class="col-md-12 padding0">
					<div class="featured-post-wrap">
						<?php
						$cols = get_theme_mod('lz_featured_pages_npp_count', 2);
						$cols++;
						$col = 1;
						switch($cols){
							case 1:
								$colCls = 'col-md-12 col-sm-12';
							break;
							case 2:
								$col = 2;
								$colCls = 'col-md-6 col-sm-6';
								break;
							case 3:
							case 5:
							case 6:
							case 9:
							case 12:
								$col = 3;
								$colCls = 'col-md-4 col-sm-6';
								break;

							case 4:
							case 7:
							case 8:
							case 10:
							case 11:
							default: 
								$col = 4;
								$colCls = 'col-md-3 col-sm-6';
								break; 
						}
						$icons = array(1=>'heart', 2=>'star', 3=>'flash', 4=>'bell',5=>'heart', 6=>'star', 7=>'flash', 8=>'bell');
						?>
						<div class="row feature-post-boxes">
							<?php
							$luzuk_featured_page_icon = 'fa fa-bell';
							$j=1;
							for( $i = 1; $i <= $cols; $i++ ){
								if($showStatic === false){
									$luzuk_featured_page_id = get_theme_mod('luzuk_featured_page_'.$i); 
									$luzuk_featured_page_icon = get_theme_mod('luzuk_featured_page_icon_'.$i);
									if($luzuk_featured_page_id){
										$args = array( 
											'page_id' => absint($luzuk_featured_page_id) 
										);
										$query = new WP_Query($args);
										if( $query->have_posts() ):
											while($query->have_posts()) : $query->the_post();
												?>
												<div class="<?php echo $colCls;?> featured-sec">
													<div class="featured-post fpost wow fadeInUp text-center">
														<div class="col-md-12">
															<div class="featured-icon">
																<span class="<?php echo $luzuk_featured_page_icon; ?>"></span>
															</div>
														</div>
														<div class="col-md-12 text-center">
															<h5><a href="<?php echo esc_url(get_permalink()); ?>"><?php the_title(); ?></a></h5>
															<div class="featured-excerpt">
																<?php 
																if(has_excerpt()){
																	echo get_the_excerpt();
																}else{
																	echo luzuk_excerpt( get_the_content(), 120); 
																}?>
															</div>
														</div>
														<div class="col-md-12">
															<a class="btn " href="<?php echo esc_url(get_permalink()); ?>">Read More</a>
														</div>
														<div class="clearfix"></div>
													</div>
												</div>
												<?php
											endwhile;
										endif;	
										wp_reset_postdata();
									}
								}else{?>
									<div class="<?php echo $colCls;?> featured-sec">
										<div class="featured-post fpost wow fadeInUp text-center">
											<div class="col-md-12">
												<div class="featured-icon"><span class="<?php echo $luzuk_featured_page_icon; ?> fa-bell"></span></div>
											</div>
											<div class="col-md-12">
												<h5><a href="#">Sample Page</a></h5>
												<div class="featured-excerpt">
													Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a
												</div>
											</div>
											<div class="col-md-12 ">
												<a class="btn" href="#"> Read More</a>
											</div>
											<div class="clearfix"></div>
										</div>
									</div>
								<?php 
								}
								if(($j%$col) == 0){
									echo '
										<div class="clearfix"></div>
									</div>
									<div class="row feature-post-boxes">';
								}
								++$j;

							}?>
							<div class="clearfix"></div>
						</div>
					</div>
					<div class="clearfix"></div>
				</div>
			</div>
		</div>
		<div class="clearfix"></div>
		</div>
		<div class="clearfix"></div>
	</div>
</section>
<script>
	jQuery.noConflict();
	$(function(){
		function fpostHeight(){
			var ht = 0;
			$('#featured-pages-section .featured-post h5').each(function(i){
				var tHt = $(this).height();
				if(ht<tHt){
					ht=tHt;
				}
			});
			$('#featured-pages-section .featured-post h5').height(ht+'px');
		}
		fpostHeight();
	});
	$( window ).resize(function(){
		fpostHeight();
	});
</script>
<script>
	jQuery.noConflict();
	$(function(){
		function fpostHeight(){
			var ht = 0;
			$('#featured-pages-section .featured-excerpt').each(function(i){
				var tHt = $(this).height();
				if(ht<tHt){
					ht=tHt;
				}
			});
			$('#featured-pages-section .featured-excerpt').height(ht+'px');
		}
		fpostHeight();
	});
	$( window ).resize(function(){
		fpostHeight();
	});
</script>
<?php }