<?php get_header(); ?>

<?php wp_reset_postdata(); ?>

<?php $featuredImageType = get_field('background_image_type'); ?>
<?php setBgImg();  ?>

<main class="content singlePage mainBgColor <?php echo $featuredImageType; ?>">

		<section class="pageImage">
			<?php if($featuredImageType == "bgImg"): ?>	
				<div class="fullBg"></div>
			<?php elseif($featuredImageType == "headerImg"): ?>
				<div class="um_parallax" data-velocity="-.1"></div>
			<?php endif; ?>
		</section>
	
	<div class="container">
		<div class="row">
			<section class="pageTitle text-center"></section>
			
			<section class="content">
				
				<?php 
				 	$col_md_pull = "";  
					$col_md_push = "";
					$container_class = "col-md-12"; 
				 ?>
				
				<?php if( is_active_sidebar( 'sidebar-main' ) ){
						
					$container_class = 'col-md-8';
					$position = get_field('sidebar_position','options');
						if($position == 'left'){
							$col_md_push = "col-md-push-4";
							$col_md_pull = "col-md-pull-8";
						}
				}?>
					
				
				<div class="<?php echo $container_class; ?> <?php echo $col_md_push; ?>">
					<section class="innerContent mainBgColor singleBlogContent">
							
							<header class="text-center">		
								<?php if(has_post_format() ){
									  get_template_part('content', get_post_format()); 
								}
								 ?>
							</header>
						<div class="itemContainer">
							
							<?php 
								$post_categories  = get_the_category();
								$post_categories_names = '';
								if($post_categories){
									foreach ($post_categories as $post_cat){
										$post_categories_names .= $post_cat->name.', ';
									}
									$post_categories_names = substr($post_categories_names, 0, -2);
								}
							 ?>
							
							<h5 class="category"><?php echo $post_categories_names; ?></h5>
							<h5 class="title titleUp"><?php the_title(); ?></h5>
							<div class="itemContent">
								<?php the_content(); ?>
								<?php wp_link_pages(); ?>
							</div>
								
						
							<?php $attributes = get_field('attributes'); ?>
							<?php if($attributes): ?>
									<table class="um_table">
										<tr>
											<th colspan="2" class="brandBgColor"><h5 class="title titleUp"><i class="fa <?php the_field('attribute_icon'); ?>"></i>	<?php the_field('attribute_title'); ?> </h5></th>
										</tr>
										
										<?php foreach($attributes as $attr): ?>
											<tr>
												<td><?php echo $attr['title']; ?></td>
												<td><?php echo $attr['description']; ?></td>
											</tr>
										<?php endforeach; ?>
									</table>
							<?php endif; ?>
							
						</div>
						
						<?php if(get_the_tags()): ?>
							<div class="tags">
									<span class="tagsTitle"><?php _e('Tags', 'um_lang'); ?></span>
									<?php the_tags('',' ',''); ?>
							</div>	
						<?php endif; ?>
						<?php if(get_field('share_networks','options')): ?>
						<div class="social">
									<span class="tagsTitle"><?php _e('Share it', 'um_lang'); ?></span>
									<ul class="list-unstyled list-inline">
										<?php addSocialShareButtons(get_field('share_networks','options')); ?>
									</ul>	
							</div>
						<?php endif; ?>
						
					</section>
					
							<?php if($post->comment_status == 'open'): ?>
								<section class="singleComments mainBgColor">
										<?php comments_template(); ?>
								</section>
							<?php endif; ?>
					
				</div>
				<?php if ( is_active_sidebar( 'sidebar-main' ) ):?>
					<div class="col-md-4 <?php echo $col_md_pull; ?>">
						<aside class="sidebar">
							<?php dynamic_sidebar( 'sidebar-main' );?>
						</aside>
					</div>
				<?php endif; ?>
			</section>
			
		</div>
	</div>

</main>

<?php get_footer(); ?>