<?php global $post;

$kk_parallax = kk_parallax();
$title_type = $kk_parallax[0];
$bg_title_img = $kk_parallax[1];
$grid_p = 'is_inner';

?>

<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

		<?php if( $title_type == 'parallax' ) { ?>
		<!-- start parallax container -->	
		<div class="content clearfix">
			
		<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>	
		</div>	
		<?php $grid_p = 'not_is_inner'; ?>
		<?php } ?>
			
	<!-- start gallery container -->	
	<div class="fullmasonry grid-gal <?php echo esc_attr( $grid_p ) ?>">
	
		<span id="kk-to-me"></span>
		
		<!-- start gallery -->		
		<div class="gallery-full-masonry">

			<ul class="masonry-container">
			<?php 
				$attachments = rwmb_meta( 'kk_imgadv', 'type=image_advanced' );						
				
				foreach ($attachments as $attachment) { 
		
					$koto_gridType = get_post_meta( get_the_ID(), '_grid_type_value', true );
					$kktfwp_ratio = '';
					
					if ( $koto_gridType === 'Random' ) {
						$kktfwp_ratio = wp_get_attachment_image_src( $attachment['ID'], 'full' );
						$kktfwp_ratio = $kktfwp_ratio[2]/$kktfwp_ratio[1] * 100 .'%';
					}
					
					?>
					
					<li id="<?php echo esc_attr($attachment['ID']) ?>" <?php post_class( array( 'masonry-box', esc_attr( strtolower($koto_gridType )) ) ); ?> >
						<div class="portfolio-thumb">		
							<a class="kk-lightbox img-loading" data-group="kk-lightbox[<?php the_ID();?>]" href="<?php echo esc_url($attachment['full_url']) ?>" data-title="<?php echo esc_attr($attachment['title']) ?>" style="padding-bottom:<?php echo esc_attr( $kktfwp_ratio ); ?>">
								
								<?php echo wp_get_attachment_image( $attachment['ID'], 'kktfwp-s', '', array( 'class' => 'responsively-lazy-img', 'title' => $attachment['title'], 'data-lazy-load' => 1 ) ); ?>
								
								<span class="kk-n"><?php _e('View','toppic'); ?></span>	
							</a>
							
							<?php if ( rwmb_meta( 'kk_proof' ) === 'proofing' ) :
								
									$kk_proofing = wp_get_attachment_metadata( $attachment['ID'] );

									if ( isset($kk_proofing['image_meta']['proof_status']) && $kk_proofing['image_meta']['proof_status'] === 'checked') {
										$kk_photo_class = 'photo-details photo-approved';
									} else {
										$kk_photo_class = 'photo-details';
									}
								?>							
									<div class="<?php echo esc_attr($kk_photo_class) ?>">
										<h5><?php echo sprintf( '#%s', esc_html($attachment['ID']) ); ?></h5>
										<span class="proof-btn" data-photo-id="<?php echo esc_attr($attachment['ID']) ?>"></span>
									</div>											
								<?php endif; ?>
								
						</div>
					</li>
				<?php } ?>
			</ul>
		</div>
		<!-- end gallery -->
		
	</div>
	<!-- end gallery container -->	
	
	<?php $content = get_the_content();
			if(!empty($content)) { ?>
			
		<div class="info-fs-form kk-active-button">
			<!-- start info close icon -->
			<div class="kk-info-close">
					<span></span>
			</div>
			<!-- end info close icon -->
			<div class="content-inner-wrapper">
				<div class="content-child">
					<?php the_content(); ?>
				</div>
			</div>
		</div>
		
	<?php } ?>
	
<?php endwhile; ?>
<?php endif; ?>		