<?php
$layout = get_post_meta($post->ID, '_page_layout', true);
if(empty($layout) || $layout == 'default'){
	$layout=theme_get_option('portfolio','layout');
}
if(empty($layout) || $layout == 'default'){
	$layout=theme_get_option('general','layout');
}
?>
<?php  get_header(); ?>
<?php theme_generator('introduce',$post->ID);?>
<div id="content-area">
	<div class="wrap-center <?php if($layout=='right'):?>right_sidebar<?php endif;?><?php if($layout=='left'):?>left_sidebar<?php endif;?><?php if($layout=='full'):?>full_width<?php endif;?>">
	<div id="content" class="main">
<?php echo theme_generator('breadcrumbs',$post->ID);?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
			<article id="post-<?php the_ID(); ?>" class="post">
<?php if(theme_get_option('portfolio','featured_image')):?>
				<header>
					<?php echo theme_generator('portfolio_featured_image',$layout); ?>
				</header>
<?php endif; ?>
				<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', THEME_FRONT_DOMAIN ), 'after' => '</div>' ) ); ?>
				<footer>
<?php 
$order = theme_get_option('portfolio','single_navigation_order');
if(theme_get_option('portfolio','single_navigation')):
?>
		<div class="pagenavi">
<?php add_filter('the_title','title_length');?>
			<div class='post-prev'>
<?php previous_post_link('%link','<img src="'.THEME_IMAGES.'/post-prev.png"/>%title',false);?>
			</div>
			<div class='post-next'>
<?php next_post_link('%link','%title<img src="'.THEME_IMAGES.'/post-next.png">',false);?>
			</div>
		</div>
<?php endif; ?>
				</footer>
				<div class="clear"></div>
<?php if(theme_get_option('blog','author')){
	theme_generator('author_box');		
}
?>
<?php if(theme_get_option('portfolio','related_recent')):?>
				<div class="related_popular_wrap">
					<div class="one_half">
						<?php theme_generator('portfolio_recent_posts');?>
					</div>
					<div class="one_half last">
						<?php theme_generator('portfolio_related_posts');?>
					</div>
					<div class="clear"></div>
				</div>
<?php endif;?>
			</article>
<?php endwhile; // end of the loop.?>
<?php if(theme_get_option('portfolio','enable_comment')) comments_template( '', true ); ?>

		</div>
		<?php if($layout != 'full') get_sidebar(); ?>
		<div class="clear"></div>
	</div>
</div>
<?php get_footer(); ?>
