
<?php
/**
 * @package Luzuk Premium
 */
if(get_theme_mod('newvideo_area_disable') != 'on' ){ 
	?>
	<?php 
	if( get_theme_mod('sec_newvideosectionTpadding',true) ) {
		$sec_newvideosectionTpadding = 'padding-top:'.esc_attr(get_theme_mod('sec_newvideosectionTpadding')).';';
	}
	if( get_theme_mod('sec_newvideosectionBpadding',true) ) {
		$sec_newvideosectionBpadding = 'padding-bottom:'.esc_attr(get_theme_mod('sec_newvideosectionBpadding')).';';
	}

	?>	
	<div class="newvideo-area wow zoomIn" id="newvideo" style="<?php echo esc_attr($sec_newvideosectionTpadding); ?>" "<?php echo esc_attr($sec_newvideosectionBpadding); ?>">
		<?php
			$newvideo_title = get_theme_mod('luzuk_newvideo_title', 'Newest Videos');			
			$newvideo_subtitle = get_theme_mod('newvideo_subtitle', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has industrys. Lorem Ipsum has industrys.');
		?>
		<div class="row">
			<div class="col-md-5 col-sm-12 col-xs-12 pd-0">
					<?php if($newvideo_title || $newvideo_subtitle) { ?>
							<div class="section-title">
								<div class="headbrer"></div>
								<h2 class="headtitle"><?php echo ($newvideo_title);  ?></h2>
								<p class="headtext"><?php echo ($newvideo_subtitle);  ?></p>
							</div>
					<?php }?>
				<div class="pro-recentpro-area">
							<?php
							$showStatic = true;
							for( $i = 1; $i < 4; $i++ ){
								$luzuk_featuredpro_page_id = get_theme_mod('luzuk_featuredpro_page'.$i); 
								if(!empty($luzuk_featuredpro_page_id)){
									$showStatic = false;
									break;
								}
							}
							
							?>
								<?php 
	        // if ($isCustomizer === true) {
	            	if(!empty($team_featured) && is_array($team_featured)){
	                $team_featured = get_theme_mod('team_featured' . $i);
	                
	            } else {
	                $team_featured = '';
	                
	            }

	            $post = get_post();
	            $teamfeatured = get_post_meta($post->ID, 'teamfeatured', false);
	            $team_featured = !empty($teamfeatured[0]) ? $teamfeatured[0] : '';
	        ?>     
					<div class="owl-carousel owl-theme">	
					    <?php
			    			$args = array( 'post_type' => 'our-video', 'stock' => 1, 'posts_per_page' => 5, 'orderby' =>'date','order' => 'ASC' );
			    		
			    			
			    			$args = array(
			    				'post_type'   =>  'our-video',
			    				'stock'       =>  1,
			    				'posts_per_page' => 5, 
			    				'orderby'     =>  'date',
			    				'order'       =>  'ASC',
			    			);
			    			$loop = new WP_Query( $args );
			    			if($loop->post_count > 0){
			    				while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
					    <div class="item"> 
	    					<div class="feaboxes">
	    						<div id="recent-porduct" class="wow zoomIn">
	    							<div class="total-product-title-wrap">	
	    								<div class="col-md-10 col-sm-10 col-xs-9 pd-0 play-icon">
		    								<div class="col-md-1 col-sm-1 col-xs-2 pd-0 play-icon">
		    									 <a class="video" href="#<?php the_ID(); ?>">
													<i class="fa fa-play" aria-hidden="true"></i>
		    									 </a>
		    								</div>
	    									<div class="col-md-11 col-sm-11 col-xs-10 title-content">
	    									 	<a class="video" href="#<?php the_ID(); ?>">
		    									<h6><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6></a>
		    									 <?php
			    									$taxonomyName = "video-category";
			    									$terms = wp_get_post_terms( get_the_id(), 'video-category' );
													 $term  = reset($terms);
													foreach ($terms as $term) {
														if( isset( $term->name ) ){
														$img_ll = get_term_link($term->name, $taxonomyName);
														if ( is_wp_error( $img_ll ) ) {
														continue;
														}

														echo '<a class="video-post-cat" href="' . $img_ll . '"> ' . $term->name . '</a>';
														}
													}
													?>	
	    									</div>
	    								</div>
	    								<div class="col-md-2 col-sm-2 col-xs-3 wish-icon">
	    									 <a class="video" href="#<?php the_ID(); ?>">
	    									 	<i class="fa fa-heart" aria-hidden="true"></i>
	    									 </a>
	    								</div>
	    								<div class="clearfix"></div>
						    		</div>
	    							<div class="pro-img text-center">
	    								 <a class="video" href="#<?php the_ID(); ?>">
	    									<div class="pro-img-b">
	    									<?php if (has_post_thumbnail( $loop->post->ID )) 
	    									echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog');
	    									else
	    										echo '<img src="'.get_template_directory_uri().'/images/default.png" alt="Placeholder" width="100%" height="200px" />'; ?>	
	    									</div>
	    								</a>
	    							</div>
	    						</div>
    							<div class="fea-popup-content">
				                    <div id="<?php the_ID(); ?>">
				                         <iframe width="850" height="500" src="<?php echo ($team_featured) ?>" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> 
				                    </div>
				                </div>        
	    					</div>
							<script>
						        var links = $('.feaboxes a.video');
						            links.colorbox({
						              inline: true,
						              rel: 'newvideo'
						            });

						            /* Colorbox resize function */
						            var resizeTimer;
						            function resizeColorBox()
						            {
						                if (resizeTimer) clearTimeout(resizeTimer);
						                resizeTimer = setTimeout(function() {
						                        if ($('#cboxOverlay').is(':visible')) {
						                                $.colorbox.load(true);
						                        }
						                }, 300)
						            }

						        // Resize Colorbox when resizing window or changing mobile device orientation
						        $(window).resize(resizeColorBox);
						        window.addEventListener("orientationchange", resizeColorBox, false);

						        $('.feaboxes a.video').colorbox({maxWidth:'95%', maxHeight:'95%'});
						    </script> 
			    	<div class="clearfix"></div>
			    	</div><!-- /span3 -->

	    				<?php
	    					endwhile; 
	    				}else{ ?>
	    					<div class="alert alert-warning text-center">
	    						<strong>Sorry, no recent videos to show.</strong>
	    					</div>
	    					<?php
	    				}
	    				?>
	    				<!-- </div>-->
	    				<!-- </div>-->
	    				<?php
	    				wp_reset_query(); 
	    			?>
				</div>
			</div>
		</div>
		<div class="col-md-7 col-sm-12 col-xs-12">
            <div class="row">			
                <?php
                $categories = get_theme_mod('post_videonew_categories');
                $args = array(
                    'number' => 4,
                    'orderby' => 'name',
                    'order' => 'asc',
                    'hide_empty' => false,
                    'include' => $categories
                );
                $product_categories = get_terms('video-category', $args);
                $i = 0;
                    foreach ($product_categories as $cat) {
                        if(!empty($cat)){
                            ?>
                            <?php
                            $i = 0;
                            $args = array( 'post_type' => 'our-video', 'posts_per_page' => 4,  'orderby' =>'date','order' => 'DESC' );
                            if(!empty($cat->slug)){
                                $args['video-category']= $cat->slug;
                            }
                            $product = new stdClass();
                            $loop = new WP_Query( $args );
                            while ( $loop->have_posts() ) : $loop->the_post();
                                global $product; ?>	
                               <?php $luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium_large'); ?>   
			  		<?php 
			        // if ($isCustomizer === true) {
			            	if(!empty($team_featured) && is_array($team_featured)){
			                $team_featured = get_theme_mod('team_featured' . $i);
			                
			            } else {
			                $team_featured = '';
			                
			            }

			            $post = get_post();
			            $teamfeatured = get_post_meta($post->ID, 'teamfeatured', false);
			            $team_featured = !empty($teamfeatured[0]) ? $teamfeatured[0] : '';
			        ?>            
		        <div class="col-md-6 col-sm-6 col-xs-12 wow zoomIn">
		            <div class="feaboxes">
		                <div class="newvideoboxes">                        
		                    <a class="video" href="#<?php the_ID(); ?>">
		                        <div class="newvbox">
		                            <div class="newest-video">
		                                 <?php
		                                     if (has_post_thumbnail()) {
		                                        $image_url = $luzuk_image[0];
		                                    } else {
		                                        $image_url = get_template_directory_uri() . '/images/movie1.jpg';
		                                    }
		                                    ?>
		                                <img alt="<?php the_title(); ?>" src="<?php echo esc_url($image_url); ?>" /> 
		                                <i class="fa fa-play-circle-o" aria-hidden="true"></i>
		                            </div>    
		                        </div>
		                    </a>
		                        <div class="clearfix"></div>
		                </div>
		                <div class="feagcontain text-center">
		                	<h5> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
		                </div>
		                <div class="fea-popup-content">
		                    <div id="<?php the_ID(); ?>">
		                         <iframe width="850" height="500" src="<?php echo ($team_featured) ?>" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> 
		                    </div>
		                </div>            
		            </div>
		        </div>
			    <script>
			        var links = $('.feaboxes a.video');
			            links.colorbox({
			              inline: true,
			              rel: 'newvideo'
			            });

			            /* Colorbox resize function */
			            var resizeTimer;
			            function resizeColorBox()
			            {
			                if (resizeTimer) clearTimeout(resizeTimer);
			                resizeTimer = setTimeout(function() {
			                        if ($('#cboxOverlay').is(':visible')) {
			                                $.colorbox.load(true);
			                        }
			                }, 300)
			            }

			        // Resize Colorbox when resizing window or changing mobile device orientation
			        $(window).resize(resizeColorBox);
			        window.addEventListener("orientationchange", resizeColorBox, false);

			        $('.feaboxes a.video').colorbox({maxWidth:'95%', maxHeight:'95%'});
			    </script> 
			       <div class="clearfix"></div>    
                        <?php endwhile; 
                        wp_reset_query(); 
                        ?><!-- 
	                        <div class="clearfix"></div>    
	                    </div> -->
	                    <?php
	                }
	            }
	            ?>  
           
        	</div>
		</div>
	</div>
     <div class="clearfix"></div>     
        <div class="videocatmain">
            <?php
                $newvideo_link = get_theme_mod('newvideo_link', '');
                $newvideo_button = get_theme_mod('newvideo_button1', 'Explore All');
            ?>
            <?php if( get_theme_mod('newvideo_button_display','show' ) == 'show') :
                ?>
            <div class="newvideobtn">
                <a class="main-btn btn-3" href="<?php echo $newvideo_link ?>"> <?php echo $newvideo_button ?> <i class="fa fa-angle-double-right"></i></a>
            </div>
            <?php endif ?>
        </div>
    <div class="clearfix"></div>  
</div>
	<script>
            $(document).ready(function() {
              $('#newvideo .owl-carousel').owlCarousel({
                loop: true,
                margin: 30,
                autoplay: true,
                responsiveClass: true,
                responsive: {
                  0: {
                    items: 1,
                    nav: true
                  },
                  600: {
                    items:1,
                    nav: true
                  },
                  1000: {
                    items:1,
                    nav: true,
                    loop: true,
                    margin: 30
                  }
                }
              })
            })
    </script>
<?php }



