<?php get_header(); ?>
<?php if (get_option('flex_feat_postid')) { // if showing feature by ID 
global $post;
$thePostID = $post->ID;
$postidlist = get_option('flex_feat_postid');
$postids = explode (",", $postidlist);
if (in_array($thePostID, $postids)) { ?>
<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 { // if showing feature by generic page type
if (get_option('flex_feat_display') == "no" OR get_option('flex_feat_pages') == "home only") { ?>
<?php } else { ?>
<?php if (get_option('flex_header_trans') == "yes" && get_option('flex_feat_trans') == "yes" && get_option('flex_nav_position') == "below") { ?>
	<script type="text/javascript">
	jQuery("#nav").css("border-bottom","solid <?php echo get_option('flex_blog_borderwidth'); ?>px #<?php echo get_option('flex_blog_bordercolor'); ?>");
	</script>
<?php } ?>
<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 } ?>
<?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(); ?>>
			<div class="posthead">
				<h1><?php the_title(); ?></h1>
				<?php if (get_option('flex_metadata_show') == "yes") { ?>
				<div class="postMeta">
					<div class="postdate">
						<?php the_time('l, F jS, Y') ?>
						at
						<?php the_time() ?>
						&nbsp;
						<?php edit_post_link('Edit'); ?>
					</div>
					<div class="clear"></div>
				</div>
				<?php } ?>
			</div>
			<div class="postcontent">
				<?php if (get_option('flex_adsense_loc4') == "yes" && !get_option('flex_adsense_loc4banner')) { ?>
				<div class="adsenseposttop">
					<?php 
					$adsize = get_option('flex_adsense_loc4size');
					$adtype = get_option('flex_adsense_loc4type');	
					$adchannel = get_option('flex_adsense_loc4channel');
					include('adsense.php'); ?>
				</div>
				<?php } else if (get_option('flex_adsense_loc4') == "yes" && get_option('flex_adsense_loc4banner')) { ?>
   <div class="adsenseposttop">
   <?php echo stripslashes(get_option('flex_adsense_loc4banner'));  ?>
   </div>
   <?php } ?>
				<?php the_content('Read the rest of this entry'); ?>
				<?php wp_link_pages('before=<div id="page-links"><p style="text-align:right"><strong>Pages:</strong>&after=</p></div>'); ?>
				<?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 if (get_option('flex_show_like') == "yes") { ?>
				<p><strong>Like this post?</strong> <a href="<?php if (get_option('flex_email_address')) { echo get_option('flex_email_address'); } else { bloginfo_rss('rss2_url');} ?>">Subscribe to my RSS feed</a> and get loads more! </p>
				<?php } ?>
                
                <?php if (get_option('flex_adsense_loc5') == "yes" && !get_option('flex_adsense_loc5banner')) { ?>
				<div style="display:block; margin:10px 0 15px 0;">
					<?php 
					$adsize = get_option('flex_adsense_loc5size');
					$adtype = get_option('flex_adsense_loc5type');	
					$adchannel = get_option('flex_adsense_loc5channel');
					include('adsense.php'); ?>
				</div>
				<?php } else if (get_option('flex_adsense_loc5') == "yes" && get_option('flex_adsense_loc5banner')) { ?>
   <div style="display:block; margin:10px 0 15px 0; text-align:center;">
   <?php echo stripslashes(get_option('flex_adsense_loc5banner'));  ?>
   </div>
   <?php } ?>
   		<div class="clear"></div>
		</div>
		<div class="clear"></div>
			</div>
            
        <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Bottom of Post/Page') ) : else : ?>
    	<?php endif; ?>
    
			
		<?php if (get_option('flex_metadata_comoff') == "yes" || get_option('flex_metadata_comoff') == "posts only") { ?>
		<ul class="Note">
			<?php if ( comments_open() ) : ?>
			<li class="NoteRss">
				<?php post_comments_feed_link( $link_text = 'Comments RSS Feed') ?>
			</li>
			<?php endif; ?>
			<?php if ( pings_open() ) : ?>
			<li class="NoteTrackBack"><a href="<?php trackback_url() ?>" rel="trackback">
				<?php _e('TrackBack <abbr title="Uniform Resource Identifier">URI</abbr>'); ?>
				</a></li>
			<?php endif; ?>
		</ul>
		<?php comments_template('', true); ?>
		<?php } ?>
		<?php endwhile; else : ?>
		<h2>
			<?php _e('Not Found'); ?>
		</h2>
		<p>
			<?php _e('Sorry, but the page you requested cannot be found.'); ?>
		</p>
		<?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(); ?>