<?php

get_header();

extract(etheme_get_blog_sidebar());
$postspage_id = get_option('page_for_posts');

$posts_count = 0;
$total_posts = count($posts);

$sidebarname = $position = null;

$blog_page = get_page_by_title('blog');
if ( $blog_page ) {
	$ot_page_options = get_post_meta($blog_page->ID);

	if ( isset($ot_page_options['widget_area']) && $ot_page_options['widget_area'][0] ) {
		$sidebarname = $ot_page_options['widget_area'][0];

		if ( isset($ot_page_options['sidebar_state']) ) {
			$position = is_array($ot_page_options['sidebar_state']) ? $ot_page_options['sidebar_state'][0] : $ot_page_options['sidebar_state'];
		}
	} elseif ( is_active_sidebar( 'blog-sidebar' ) ) {
		$sidebarname = 'blog-sidebar';
		$position = etheme_get_option('blog_sidebar');
	}

}
if( !$position || $position == 'no_sidebar' ) {
	$content_span = 'span12';
} else {
	$content_span = 'span9';
}

$tags = get_the_tag_list('<div class="tagcloud">', '', '</div>');

?>


	<section id="content">
		<div class="container top">

			<div class="row">

				<?php if ( $responsive == 'top' && $position && $position != 'no_sidebar' ) { ?>
					<div class="<?php echo $sidebar_span; ?> sidebar sidebar-<?php echo $position; ?>">
						<?php dynamic_sidebar($sidebarname); ?>
					</div>
				<?php } //endif; ?>

				<div class="post-single <?php echo $content_span; ?>">

					<?php if(have_posts()): while(have_posts()) : the_post(); ?>

						<?php

						get_template_part('content', 'default');

						if ( $tags ) {
							echo $tags;
						}
						?>

					<?php endwhile; ?>

					<?php else: ?>

						<h1><?php _e('No posts were found!', WFT_DOMAIN) ?></h1>

					<?php endif; ?>

					<?php

					$prev_link = get_previous_post_link( '%link', __('Previous Post', WFT_DOMAIN) );
					$next_link = get_next_post_link( '%link', __('Next Post', WFT_DOMAIN) );
					?>

					<div class="post-navigation">

						<div class="pull-left"><?php if ( $prev_link ) { echo '<i class="icon-left-open"></i>&nbsp;' . $prev_link; } ?></div>
						<div class="pull-right"><?php if ( $next_link ) { echo $next_link . '&nbsp;<i class="icon-right-open"></i>'; } ?></div>

					</div>

					<?php comments_template('', true); ?>

				</div>

				<?php if ( $responsive == 'bottom' && $position && $position != 'no_sidebar' ) { ?>
					<div class="<?php echo $sidebar_span; ?> sidebar sidebar-<?php echo $position; ?>">
						<?php dynamic_sidebar($sidebarname); ?>
					</div>
				<?php } //endif; ?>

			</div>

		</div><!-- #content .container -->
	</section><!-- #content -->

<?php get_footer(); ?>