<?php get_header(); 
/*
Template Name: Home Page Template
*/
?>
<!-- ==== HOME HEADERWRAP ==== -->
	

<?php
global $kp_current_page_id;
$kp_current_page_id = get_option('page_on_front');
 if(has_nav_menu('main_nav')) {
if ( ( $kp_locations = get_nav_menu_locations() ) && $kp_locations['main_nav'] ) {
    $kp_menu = wp_get_nav_menu_object( $kp_locations['main_nav'] );
    $kp_menu_items = wp_get_nav_menu_items($kp_menu->term_id);
    $kp_check_item_in = array();
    foreach($kp_menu_items as $kp_item) {

        if($kp_item->object == 'page')
        $kp_check_item_in[] = $kp_item->object_id;
    }
	
	$kp_args = array( 'post_type' => 'page', 'post__in' => $kp_check_item_in, 'posts_per_page' => count($kp_check_item_in), 'orderby' => 'post__in',  'suppress_filters'=> true );
	$kp_home_query = new WP_Query($kp_args);
}
}
else{
    $kp_args=array(
    'post_type' => 'page',
    'order' => 'ASC',
    'orderby' => 'menu_order',
    'posts_per_page' => '-1',
	'suppress_filters'=> true
  );
    $kp_home_query = new WP_Query($kp_args); 
}

	$i=0;
	$kp_data_type = ' data-animate-up="ha-header-hide" data-animate-down="ha-header-small"';
    while ($kp_home_query->have_posts()) : $kp_home_query->the_post();
	
	global $post;

    $post_name = $post->post_name;
	$post_id = $post->ID;
    
    global $post_id;
	$post_id = get_the_ID();
	
	$kp_page_check = rwmb_meta( 'slant_check_page' );
    if (($kp_page_check!= 'separate' )&& ($post_id != $kp_current_page_id ))
    { 
	
	$kp_bg_type = rwmb_meta( 'slant_section_bg' );
	$kp_disable_title = rwmb_meta( 'slant_disable_title' );
	$kp_disable_container = rwmb_meta( 'slant_disable_container' );
	$kp_parallax = rwmb_meta( 'slant_enable_parallax' );
	$kp_overlay = rwmb_meta( 'slant_overlay_effect' );
	$kp_triangle = rwmb_meta( 'slant_triangle_effect' );
	$kp_video_id = rwmb_meta( 'slant_bg_video_id' );
	
	$kp_text_color = rwmb_meta( 'slant_text_color' );
	$kp_bg_color = rwmb_meta( 'slant_bg_color' );

	$kp_style = 'style="';
	
	if(($kp_bg_type == 'image') && (has_post_thumbnail()))
	{
	$kp_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' ); 
	$kp_style .= 'background: url('. $kp_image[0] .');';
	}
	if($kp_bg_color){
	$kp_style .= ' background-color: '. $kp_bg_color .';';
	}
	$kp_style .='"';
	
	if(($kp_bg_type == 'video') && ($kp_video_id))
	{
	wp_enqueue_script( 'youtube-player' );
	?>

	<a class="player" id="bgndVideo" data-property="{
		videoURL: 'https://www.youtube.com/watch?v=<?php echo $kp_video_id; ?>',
		containment:'.video-bg-<?php echo $kp_video_id; ?>',
		 autoPlay:true,
		 mute:true,
		 startAt:0, 
		 autoPlay: true,
		 showControls: false,
		 opacity: 1,
		 ratio: '16/9', 
		 addRaster: false }">
	</a>
	
	<?php } 
	
	$kp_section_clases = 'class="';
	$kp_section_clases .= "page". $post_id ." section ";
	if($kp_text_color=='light'){$kp_section_clases .= "white-text ";}
	if($kp_text_color=='dark'){$kp_section_clases .= "dark-text ";}
	if(($kp_bg_type == 'video') && ($kp_video_id)){$kp_section_clases .= " video-section video-bg-". $kp_video_id." ";}
	if($kp_parallax){$kp_section_clases .= "parallax-background fixed "; wp_enqueue_script( 'parallax' );}
	$kp_section_clases .='"';
	
	
	
	if($i==1){ $kp_second_section = $post_id; }
	$kp_disable_menu = slant_check_menu_item_disable($post_id);
	?>
	
	<section <?php if($kp_disable_menu != true ){ echo 'data-scroll-index="'. $i.'"'; } ?> id="<?php echo $post_name; ?>" <?php echo $kp_section_clases; ?> <?php echo $kp_style;  if($i==1){echo $kp_data_type;} ?> >
	

	<?php
	if($kp_parallax){ echo '<div class="parallax">';}
	
	if($kp_triangle){
	if($kp_triangle =="top"){echo '<div class="triangle-down"></div>';}
	if($kp_triangle =="left"){echo '<div class="triangle-right"></div>';}
	}
	
	
	if($kp_overlay){
	if($kp_overlay =="color"){echo '<div class="color-overlay"></div>';}
	if($kp_overlay =="pattern"){echo '<div class="pattern-overlay"></div>';}
	}
	
	if(!$kp_disable_container){ ?>
	<div class="container">	
	<?php } ?>
	
    <div class="row">
	<?php 
	if(!$kp_disable_title){?>
	<div class="title"><h3><?php the_title(); ?><span class="divider"></span></h3></div>
	<?php } ?>
	<?php the_content(); ?>	   
		   
		 </div><!--row-->
		<?php if(!$kp_disable_container){ ?>	
		</div><!--container-->  
		<?php } 
		
		if($kp_parallax){echo '</div>';}
		?> 

	</section>
	<?php
	}
	
	$kp_disable_menu = slant_check_menu_item_disable($post_id);
	if($kp_disable_menu != true ) { 
	if($kp_page_check != 'separate' ) { $i++; } 
	}
	
	endwhile;
	wp_reset_postdata();
?>

<?php get_footer(); ?>