<?php get_header(); ?>
	<?php
	$container_class = '';
	$post_class = '';
    $content_class = '';
	$sidebar_exists = true;

	if($smof_data['blog_archive_sidebar'] == 'None') {
		$content_css = 'width:100%';
		$sidebar_css = 'display:none';
		$content_class = 'full-width';
		$sidebar_exists = false;
	} elseif($smof_data['blog_sidebar_position'] == 'Left') {
		$content_css = 'float:right;';
		$sidebar_css = 'float:left;';
	} elseif($smof_data['blog_sidebar_position'] == 'Right') {
		$content_css = 'float:left;';
		$sidebar_css = 'float:right;';
	}


	if($smof_data['blog_archive_layout'] == 'Large Alternate') {
		$post_class = 'large-alternate';
	} elseif($smof_data['blog_archive_layout'] == 'Medium Alternate') {
		$post_class = 'medium-alternate';
	} elseif($smof_data['blog_archive_layout'] == 'Grid') {
		$post_class = 'grid-post';
		$container_class = sprintf( 'grid-layout grid-layout-%s', $smof_data['blog_grid_columns'] );
	} elseif($smof_data['blog_archive_layout'] == 'Timeline') {
		$post_class = 'timeline-post';
		$container_class = 'timeline-layout';
		if($smof_data['blog_archive_sidebar'] != 'None') {
			$container_class = 'timeline-layout timeline-sidebar-layout';
		}
	}

	$author = get_user_by( 'id', get_query_var( 'author' ) );
	$author_id = $author->ID;
	$name         = get_the_author_meta('display_name', $author_id);
	$avatar       = get_avatar( get_the_author_meta('email', $author_id), '82' );
	$description  = get_the_author_meta('description', $author_id);

	if(empty($description)) {
		$description  = __('This author has not yet filled in any details.','alora');
		$description .= '<br />'.sprintf( __( 'So far %s has created %s blog entries.', 'alora' ), $name, count_user_posts( $author_id ) );
	}
	?>
	<div id="content" class="<?php echo $content_class; ?>" style="<?php echo $content_css; ?>">
		<div class="about-author">
			<div class="avatar">
			<?php echo $avatar ?>
			</div>
			<div class="author_description">
      <div class="title">
      <h3 class="title-heading-left author_title vcard"><?php echo __( 'About' , 'alora' ); ?> <span class="fn"><?php echo $name; ?></span></h3>
      <div class="title-sep-container"><div class="title-sep"></div></div></div>
			<?php echo $description; ?>
			</div>
			<div style="clear:both;"></div>
			<div class="author_social clearfix">
			<div class="custom_msg">
			<?php if(get_the_author_meta('author_custom')): ?>
			<?php echo get_the_author_meta('author_custom'); ?>
			<?php endif; ?>
			</div>
			<?php
			$author_social_icon_options = array (
				'authorpage'		=> 'yes',
				'author_id'			=> $author_id,
				'icon_colors' 		=> $smof_data['social_links_icon_color'],
				'box_colors' 		=> $smof_data['social_links_box_color'],
				'icon_boxed' 		=> $smof_data['social_links_boxed'],
				'icon_boxed_radius' => $smof_data['social_links_boxed_radius'],
				'tooltip_placement'	=> $smof_data['social_links_tooltip_placement'],
				'linktarget'		=> '_blank',
			);

			echo $social_icons->render_social_icons( $author_social_icon_options );
			?>
			</div>
		</div>

		<div id="posts-container" class="<?php echo $container_class; ?> clearfix">
			<?php
			$post_count = 1;

			$prev_post_timestamp = null;
			$prev_post_month = null;
			$prev_post_year = null;
			$first_timeline_loop = false;

			while(have_posts()): the_post();
				$post_timestamp = strtotime($post->post_date);
				$post_month = date('n', $post_timestamp);
				$post_year = get_the_date('o');
				$current_date = get_the_date('o-n');
			?>
			
		  <?php if($smof_data['blog_archive_layout'] == 'Timeline'): ?>
				<?php if($prev_post_month != $post_month || $prev_post_year != $post_year): ?>
					<div class="timeline-date"><h3 class="timeline-title"><?php echo get_the_date($smof_data['timeline_date_format']); ?><div class="timeline-arrow-date"></div></h3></div>
	      <?php endif; ?>
  			<?php endif; ?> 
        <div id="post-<?php the_ID(); ?>" <?php post_class($post_class.getClassAlign($post_count).' clearfix'); ?>>
				<?php if($smof_data['blog_archive_layout'] == 'Medium Alternate'): ?>
				<div class="date-and-formats">
					<div class="format-box">
						<?php
						switch(get_post_format()) {
							case 'gallery':
								$format_class = 'camera-retro';
								break;
							case 'link':
								$format_class = 'link';
								break;
							case 'image':
								$format_class = 'picture-o';
								break;
							case 'quote':
								$format_class = 'quote-left';
								break;
							case 'video':
								$format_class = 'youtube-play';
								break;
							case 'audio':
								$format_class = 'headphones';
								break;
							case 'chat':
								$format_class = 'comments-o';
								break;
							default:
								$format_class = 'pencil';
								break;
						}
						?>
						<i class="t4p-icon-<?php echo $format_class; ?>"></i>
					</div>
				</div>
				<?php endif; ?>
				<?php
				if($smof_data['featured_images']):
				if($smof_data['legacy_posts_slideshow']) {
					get_template_part('legacy-slideshow');
				} else {
					get_template_part('new-slideshow');
				}
				endif;
				?>
				<div class="post-content-container">
					<?php if($smof_data['blog_archive_layout'] == 'Timeline'): ?>
					<div class="timeline-circle"></div>
					<div class="timeline-arrow"></div>
					<?php endif; ?>
					<?php if($smof_data['blog_archive_layout'] != 'Large' && $smof_data['blog_archive_layout'] != 'Large Alternate' && $smof_data['blog_archive_layout'] != 'Grid'  && $smof_data['blog_archive_layout'] != 'Timeline'): ?>
					<h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
					<?php endif; ?>
					<?php if($smof_data['blog_archive_layout'] == 'Large Alternate'): ?>
					<div class="date-and-formats">
						<div class="format-box">
							<?php
							switch(get_post_format()) {
								case 'gallery':
									$format_class = 'camera-retro';
									break;
								case 'link':
									$format_class = 'link';
									break;
								case 'image':
									$format_class = 'picture-o';
									break;
								case 'quote':
									$format_class = 'quote-left';
									break;
								case 'video':
									$format_class = 'youtube-play';
									break;
								case 'audio':
									$format_class = 'headphones';
									break;
								case 'chat':
									$format_class = 'comments-o';
									break;
								default:
									$format_class = 'pencil';
									break;
							}
							?>
							<i class="t4p-icon-<?php echo $format_class; ?>"></i>
						</div>
					</div>
					<?php endif; ?>
					<div class="post-content">
						<?php if($smof_data['blog_archive_layout'] == 'Large' ||$smof_data['blog_archive_layout'] == 'Large Alternate' || $smof_data['blog_archive_layout'] == 'Grid' || $smof_data['blog_archive_layout'] == 'Timeline'): ?>
						<h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
						<?php if($smof_data['post_meta']): ?>
						<?php if($smof_data['blog_archive_layout'] == 'Grid' || $smof_data['blog_archive_layout'] == 'Timeline'): ?>
					 	<div class="meta-info">
            			<div class="alignleft">
								<p class="single-line-meta"><?php if(!$smof_data['post_meta_author']): ?><?php echo __('By', 'alora'); ?> <span class="vcard author"><span class="fn"><?php the_author_posts_link(); ?></span></span><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_date']): ?><time class="updated"><?php the_time($smof_data['date_format']); ?></time><?php endif; ?></p>
			            </div>
            			</div>
						<?php else: ?>
						<div class="meta-info">
       			<div class="alignleft">
            <p class="single-line-meta"><?php if(!$smof_data['post_meta_author']): ?><?php echo __('By', 'alora'); ?> <span class="vcard author"><span class="fn"><?php the_author_posts_link(); ?></span></span><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_date']): ?><span class="updated"><?php the_time($smof_data['date_format']); ?></span><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_cats']): ?><?php if(!$smof_data['post_meta_tags']){ echo __('Categories:', 'alora') . ' '; } ?><?php the_category(', '); ?><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_tags']): ?><span class="meta-tags bottom"><?php the_tags( ); ?></span><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_comments']): ?><?php comments_popup_link(__('0 Comments', 'alora'), __('1 Comment', 'alora'), '% '.__('Comments', 'alora')); ?><?php endif; ?></p>
            			</div>
            			</div>
						<?php endif; ?>
						<?php endif; ?>
						<?php endif; ?>            
						<?php if( ( ! $smof_data['post_meta'] && $smof_data['excerpt_length_blog'] == '0' ) || ( $smof_data['post_meta_author'] && $smof_data['post_meta_date'] && $smof_data['post_meta_cats'] && $smof_data['post_meta_tags'] && $smof_data['post_meta_comments'] && $smof_data['post_meta_read'] && $smof_data['excerpt_length_blog'] == '0' ) ): ?>
						<?php if( ! $smof_data['post_meta'] ): ?> 
						<div class="no-content-sep"></div>            
						<?php endif; ?>
						<?php else: ?>            
						<div class="content-sep"></div>
						<?php endif; ?>            
						<?php
						if($smof_data['content_length'] == 'Excerpt') {
							$stripped_content = t4p_content( $smof_data['excerpt_length_blog'], $smof_data['strip_html_excerpt'] );
							echo $stripped_content;
						} else {
							the_content('');
						}
						?>
					<?php if($smof_data['post_meta']): ?>
					<div class="meta-info">
						<?php if($smof_data['blog_archive_layout'] == 'Grid' || $smof_data['blog_archive_layout'] == 'Timeline'): ?>
						<?php if($smof_data['blog_archive_layout'] != 'Large' && $smof_data['blog_archive_layout'] != 'Large Alternate'): ?>
						<div class="alignleft">
							<?php if(!$smof_data['post_meta_read']): ?><a href="<?php the_permalink(); ?>" class="read-more"><?php echo __('Read More', 'alora'); ?></a><?php endif; ?>
						</div>
						<?php endif; ?>
						<div class="alignright">
							<?php if(!$smof_data['post_meta_comments']): ?><span class="comment-number"><?php comments_popup_link('<i class="t4p-icon-comment"></i>&nbsp;'.__('0', 'alora'), '<i class="t4p-icon-comment"></i>&nbsp;'.__('1', 'alora'), '<i class="t4p-icon-comment"></i>&nbsp;'.'%'); ?></span><?php endif; ?>
						</div>
						<?php else: ?>
						<?php if($smof_data['blog_archive_layout'] != 'Large' && $smof_data['blog_archive_layout'] != 'Large Alternate'): ?>
						<p class="alignleft vcard">
              <?php if(!$smof_data['post_meta_author']): ?><?php echo __('By', 'alora'); ?> <span class="vcard author"><span class="fn"><?php the_author_posts_link(); ?></span></span><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_date']): ?><span class="updated"><?php the_time($smof_data['date_format']); ?></span><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_cats']): ?><?php if(!$smof_data['post_meta_tags']){ echo __('Categories:', 'alora') . ' '; } ?><?php the_category(', '); ?><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_tags']): ?><span class="meta-tags"><?php the_tags( ); ?></span><span class="sep">|</span><?php endif; ?><?php if(!$smof_data['post_meta_comments']): ?><?php comments_popup_link(__('0 Comments', 'alora'), __('1 Comment', 'alora'), '% '.__('Comments', 'alora')); ?><?php endif; ?>
						</p>
						<?php endif; ?>
						<div class="t4p-clearfix"></div>
						<p class="entry-read-more">
							<?php if(!$smof_data['post_meta_read']): ?><a href="<?php the_permalink(); ?>" class="read-more"><?php echo __('Read More', 'alora'); ?></a><?php endif; ?>
						</p>
						<?php endif; ?>
						</div>
						<?php endif; ?>
					</div>
         <div class="t4p-clearfix"></div>					
				</div>
       <div class="t4p-clearfix"></div>
			</div>
			<?php
			$prev_post_timestamp = $post_timestamp;
			$prev_post_month = $post_month;
			$prev_post_year = $post_year;
			$post_count++;
			endwhile;
			?>
		</div>
		<?php t4p_pagination($pages = '', $range = 2); ?>
	</div>
	<?php if( $sidebar_exists == true ): ?>  
	<?php wp_reset_query(); ?>
	<div id="sidebar" style="<?php echo $sidebar_css; ?>">
	<?php
	if ($smof_data['blog_archive_sidebar'] != 'None' && function_exists('dynamic_sidebar')) {
		generated_dynamic_sidebar($smof_data['blog_archive_sidebar']);
	}
	?>
	</div>
	<?php endif; ?>  
<?php get_footer(); ?>