<?php get_header(); ?>
<?php if (get_option('flex_feat_display') == "no") { ?>
<?php } else { ?>
<?php if ((is_front_page() && get_option('flex_feat_pages')=="home plus IDs") || (get_option('flex_feat_pages')!="just by ID" && !is_search()) )  { ?>

<div id="feature">
  <div class="topshadow">
  
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Top Feature') ) : else : ?>
    <?php get_template_part( 'feature'); ?>
    <?php endif; ?>
    <div class="clear"></div>
  </div>
</div>
<?php } else { ?>
<?php } ?>
<?php } ?>
<?php if (get_option('flex_nav_show') == "yes" && (get_option('flex_nav_position') == "below feature")) {
	get_template_part( 'includes/nav.inc'); } 
	?>
<?php if (get_option('flex_nav_show') == "yes" && (get_option('flex_nav_position2') == "below feature")) {
	get_template_part( 'includes/secondary-nav.inc'); } 
	?>
<div id="content">
  <?php if (get_option('flex_adsense_loc1') == "yes" && !get_option('flex_adsense_loc1banner')) { ?>
  <div class="adsenseleaderboard">
    <?php 
	$adsize = get_option('flex_adsense_loc1size');
	$adtype = get_option('flex_adsense_loc1type');
	$adchannel = get_option('flex_adsense_loc1channel');
	include('adsense.php'); 
	?>
  </div>
  <?php } else if (get_option('flex_adsense_loc1') == "yes" && get_option('flex_adsense_loc1banner')) { ?>
  <div class="adsenseleaderboard"><?php echo stripslashes(get_option('flex_adsense_loc1banner'));  ?></div>
  <?php } ?>
  <?php if (get_option('flex_lsb_show') == "yes" && get_option('flex_lsb_pos') == "left of post") { get_sidebar('left'); } ?>
  <div class="postwrap">
  
  	<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Top of Post/Page') ) : else : ?>
    <?php endif; ?>
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?> style="padding-bottom: 20px;">
      <div class="posthead">
        <h2><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
        
        <div class="postMeta">
        <?php if (get_option('flex_metadata_show') == "yes") { ?>
          <div class="postdate">
            <?php the_time('l, F jS, Y') ?>
            at
            <?php the_time() ?>
            &nbsp;
            <?php edit_post_link('Edit'); ?>
          </div>
          <?php } ?>
          <?php if (get_option('flex_metadata_comoff') != "no") { ?>
          <div class="commentcount">
            <?php comments_popup_link('Leave your comment', 'Comments (1)', 'Comments (%)'); ?>
          </div>
           <?php } ?>
          <div class="clear"></div>
        </div>
       
      </div>
      <div class="postcontent">
        <?php the_post_thumbnail('thumbnail'); ?>
      <?php if (((get_option('flex_posttext_contex') == "content") || !get_option('flex_posttext_contex')) || (get_option('flex_posttext_contex') == "excerpt" && get_option('flex_posttext_sticky') == "yes" && is_sticky())) { the_content('' . get_option('flex_posttext_rm') . ''); } else { the_excerpt(); } ?>
        <?php if (get_option('flex_show_where') == "both") { ?>
        <?php if (get_option('flex_show_tags') == "yes") { ?>
        <p>
          <?php the_tags('<strong>Tagged with:</strong> ',' &bull; ',''); ?>
        </p>
        <?php } else { ?>
        <?php } ?>
        <?php if (get_option('flex_show_cats') == "yes") { ?>
        <p><strong>Filed under:</strong>
          <?php the_category(' &bull; '); ?>
        </p>
        <?php } else { ?>
        <?php } ?>
        <?php } ?>
        <div class="clear"></div>
      </div>
      <div class="clearer"></div>
    </div>
    <!--<?php trackback_rdf(); ?>-->
    <div class="clearer"></div>
    <?php endwhile; ?>
    <?php else : ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
      <div class="postcontent">
        <h2><?php _e('Oops, That wasn\'t found'); ?></h2>
        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
        <p>Perhaps you can find what you're looking for below.</p>
        <h2>Recent Blog Posts</h2>
        <ul style="margin-bottom:40px;">
          <?php wp_get_archives('type=postbypost&limit=15'); ?>
        </ul>
      </div>
    </div>
    <?php endif; ?>
      <?php
		  if (function_exists('wp_pagenavi')) {
			echo '<div id="nextprevious">'; 
			wp_pagenavi();
			echo '</div>';
		  } else { 
		  	echo '<div id="nextprevious">'; 
		  	include('wp-pagenavi.php'); 
		  	wp_pagenavi();
		  	echo '</div>';
		  }
?>
    
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Bottom of Post/Page') ) : else : ?>
    <?php endif; ?>
    
  </div>
  <?php if (get_option('flex_lsb_show') == "yes" && get_option('flex_lsb_pos') == "right of post") { get_sidebar('left'); } ?>
  <?php if (get_option('flex_rsb_show') == "yes" || !get_option('flex_rsb_show')) { get_sidebar(); } ?>
</div>
<?php get_footer(); ?>
