<?php get_header();

global $wp_query;
$postid = $wp_query->post->ID;
$postlayout = get_post_meta($postid, 'gabfire_post_template', true);

$media_name = 'qs-postbody';
$postcontainer_class = 'pull-left';
$sidebar_class = 'pull-right';
$media_width = 538;
$media_height = 320;

if ($postlayout == 'leftsidebar') {
	$postcontainer_class = 'pull-right';
	$sidebar_class = 'pull-left';
	
} elseif ($postlayout == 'fullwidth') {
	$postcontainer_class = 'fullwidth';
	$media_name = 'qs-postbody-full';
	$media_width = 898;
	$media_height = 450;	
} 
 elseif ($postlayout == 'bigpicture') {
	$media_name = 'qs-postbody-full';
} 
?>

	<div id="body">	
	
		<h3 class="bcrumb">
			<?php gabfire_breadcrumb(); ?>
		</h3>

		<?php 
		if ($postlayout == 'bigpicture') {
			get_template_part( 'inc/theme-gallery-bigpicture', '' );
		} else {
			gabfire_innerslider(); 
		}
		?>	
		
		
		
		<div id="main_content" class="<?php echo $postcontainer_class; ?>">
		

			<?php if (have_posts()) : while (have_posts()) : the_post(); ?>				
				
				<article id="post-<?php the_ID(); ?>" <?php post_class('post'); ?>>
						
						<div class="head">
							<h1 class="entry-title">
									<?php the_title(); ?>
							</h1>
							
							<p class="metadata-top">
								<i class="fa fa-calendar"></i> <?php echo get_the_date('') ?> 
								<?php _e('by','gabfire'); ?> 
								<?php the_author_posts_link(); ?>
								<span class="postcomment"><i class="fa fa-comment-o"></i> <?php comments_popup_link(__('No Comment','gabfire'), __('1 Comment','gabfire'), __('% Comments','gabfire'));?></span>
							</p>
						</div><!-- /post head -->
				
						
						<div class="entry">
							<?php				
							
							$disable_feaimage = get_post_meta($post->ID, 'post_feaimage', true);
							if (of_get_option('of_autoimage') == 1) { 
								if ($disable_feaimage == 'true') { 
									$enableimage = 0;
									$enablevideo = 0;
								} else { 
									$enableimage = 1;
								}
							} else {
								$enableimage = 0;
							}     							
							
							gabfire_media(array(
							'name' => $media_name, 
							'imgtag' => 1,
							'link' => 0,
							'enable_video' => 1, 
							'video_id' => 'mediabar', 
							'enable_thumb' => $enableimage, 
							'catch_image' => 1,
							'resize_type' => 'c', /* c to crop, h to resize only height, w to resize only width */
							'media_width' => $media_width, 
							'media_height' => $media_height, 
							'thumb_align' => 'aligncenter', 
							'enable_default' => 0
							)); 

							the_content(); 
							
							// make sure any floated content gets cleared
							echo '<div class="clear"></div>';
							
							// Display pagination
							gabfire_postpagination();
							
							// Tags
							the_tags('<p class="posttags"><i class="fa fa-tags"></i> ',', ', '</p>');							
							
							// If there is a widget, display it
							dynamic_sidebar('PostWidget');
							?>
							<div class="clear"></div>
						</div><!-- /entry -->
																		
				</article><!-- /post -->
				
			<?php endwhile; endif; ?>
			
			<div class="post commentswrapper">
				<?php comments_template(); ?>
			</div>

		</div><!-- /main_content -->

		<?php if ($postlayout !== 'fullwidth') { ?>
		<aside id="sidebar" class="<?php echo $sidebar_class; ?>">
			<?php get_sidebar(); ?> 
		</aside>
		<?php } ?>	

	</div><!-- /body -->

<?php get_footer(); ?>