<?php get_header(); ?>
<?php $projectLayout = rwmb_meta( 'kk_project_layout', 'type=select', $post->ID );
	  $el_pos = 'left';
	  
	switch( $projectLayout ) {
		case "sidebar_on":	
			$el_pos = 'left';
		break;
		case "sidebar_off":	
			$el_pos = 'none';
		break;
		case "halfs":	
			$el_pos = 'none';
		break;		
	}
	
$kk_parallax = kk_parallax();
$title_type = $kk_parallax[0];
$bg_title_img = $kk_parallax[1];

?>

<?php if ( post_password_required( $post ) ) { 

		get_template_part( 'password-form' );
		
	} else { ?>
	
	<?php if (have_posts()) { ?>
		<?php while (have_posts()) : the_post(); ?>		
			<!-- start content wrapper -->	
			<div <?php post_class('content'); ?> id="post-<?php the_ID() ?>">
				<?php if( $title_type == 'parallax' ) { ?>
	
				<div id="kk-parallax-wrapper" class="kk-parallax-wrapper">
					
					<div id="kk-parallax-bg" class="kk-parallax-bg kk-hidden">
						<img id="kk-img-check" src="<?php echo esc_url( $bg_title_img ) ?>" alt="<?php echo esc_attr( $kk_parallax[2] ) ?>" />
					</div>

					<div id="kk-parallax-title-wrapper" class="kk-parallax-title-wrapper">
						<div id="kk-parallax-title" class="page-title">
							<?php the_title ('<h1>', '</h1>'); ?>
						</div>	
					</div>	
					
					<a id="kk-down" class="kk-down is-loading" href="#kk-to-me"></a>
				
				</div>	

				<?php } ?>
				
				<div class="content-inner-wrapper clearfix">
					<span id="kk-to-me"></span>	
				<?php if( $title_type == 'default' ) { ?>
				
					<div class="post-title">
						<?php the_title ('<h1>', '</h1>'); ?>
					</div>	

					<div class="divider clear"></div>	
					
				<?php } ?>
				
					<div id="<?php echo esc_attr($el_pos) ?>" class="inner-content">				
								
						<?php	$mediaType = rwmb_meta( 'kk_project_type', 'type=select',  $post->ID );
						
							switch( $mediaType ) {
								case "image":														
									
								$attachments = rwmb_meta( 'kk_projimg', 'type=image_advanced' ); ?>
								
								<div class="portfolio-images">	

									<?php foreach ($attachments as $attachment) { 
									
										echo wp_get_attachment_image( $attachment['ID'], 'large', '', array( 'title' => $attachment['caption'], 'data-lazy-load' => 0 ) );
										
									} ?>
								
								</div>
								
								<?php
								break;

								case "slideshow": ?>
								
									<!-- start slider -->		
									<div class="slider-wrapper">	
										
										<div id="kk_post_slider_<?php the_ID(); ?>" class="royalSlider rsDefault kk-slider-ef">
											<?php $attachments = rwmb_meta( 'kk_projimg', 'type=image_advanced' );
												
											foreach ($attachments as $attachment) { 
								
												echo wp_get_attachment_image( $attachment['ID'], 'large', '', array( 'class' => 'rsImg', 'title' => $attachment['caption'], 'data-lazy-load' => 0 ) );
												
											} ?>
										</div>
										
									</div>
									<!-- end slider -->
								<?php break;

								case "video":
									$projectVideo = rwmb_meta( 'kk_projvid', 'type=textarea', $post->ID );
																
									echo '<div class="portfolio-thumb"><div class="embed-container">'. $projectVideo .'</div></div>';									
								
									break;
									
							}
						?>			
					
					<div class="portfolio-content">	
						<div class="portfolio-entry">
							<?php the_content(); ?>
						</div>	
					
					</div>
					
					<!-- start projects nav -->
					<div class="proj-nav">					
						<div class="proj-prev">
							<?php previous_post_link( '%link', '<i class="kk-icon-left-open-big"></i><div class="proj-nav-title"><span class="proj-title">%title</span><span class="proj-label">'. esc_html__( 'Prev Project', 'toppic' ) .'</span></div>', TRUE, '', 'portfolio-type' ); ?>
						</div>
						<div class="proj-next">
							<?php next_post_link( '%link', '<div class="proj-nav-title"><span class="proj-title">%title</span><span class="proj-label">'. esc_html__( 'Next Project', 'toppic' ) .'</span></div><i class="kk-icon-right-open-big"></i>', TRUE, '', 'portfolio-type' ); ?>
						</div>
					</div>
					<!-- end projects nav -->
					
					<?php comments_template(); ?>	
				
				</div>
				
				<!-- start widgets -->
				<?php if ($el_pos == 'left') {
						if(is_active_sidebar("kk-portfolio-sidebar")) { ?> 
							<div class="sidebar">
								<?php dynamic_sidebar("kk-portfolio-sidebar")?>		
							</div>
				<?php } }?>
				<!-- end widgets -->
							
				</div>
				
				<?php get_template_part('extends/footer-area') ?>
				
			</div>
			<!-- end content wrapper -->
		<?php endwhile; ?>
	
	<?php } ?>
<?php } ?>
	
<?php get_footer(); ?>