<?php get_header(); ?>
<div id="wrapper">
<div id="main">
	<div id="featureline">
		<?php  popularPosts(); ?>
	</div>
	<div id="posts">
		<?php 
			
			$post_character_limit = 100; // limit the length of post
			$post_title_limit     = 75;  // limit the length of title
			$mycontent = null;

			query_posts($query_string); 

			if (have_posts()) : while (have_posts()) : the_post();

				$img		= null;
				$title      = substr($post->post_title,0,$post_title_limit); 
				$mycontent  = substr($post->post_content,0,$post_character_limit);
				
				$img = get_my_image($mycontent);
				?>
				<div <?php if (function_exists("post_class")) post_class(); else print 'class="post"'; ?> id="post-<?php the_ID(); ?>">
				<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php echo $img;?></a><p>
				<h2><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php echo $title;?></a></h2>
				<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(array( 200,200 ), array( 'class' => 'alignleft' )); } ?>
				<?php echo $mycontent; ?>
				<?php echo get_the_tag_list('<div class="tags">',', ','</div>');?>
				<h2 class="themore"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark">More&gt;</a></h2>
				<br />
				<div class="tags"><?php if(function_exists('the_tags')) : the_tags(); endif;?></div>
				</div>
				<?php comments_template(); ?>
				</p>	
		<?php endwhile;endif;?>
		<div id="nav">
			<?php
			if ( !function_exists('wp_pagenavi') ):
			?>
				<div class="newer_older">
				<span class="newer">&nbsp;<?php previous_posts_link(__('&laquo; Newer Entries','thischristmas')) ?></span>
				<span class="older">&nbsp;<?php next_posts_link(__('Older Entries &raquo;','thischristmas')) ?></span>
				</div>
			<?php
			else:
			wp_pagenavi();
			endif;
			?>
		</div>
	</div>
	<?php get_sidebar('1'); ?>	
</div>
<?php get_sidebar('2'); ?>
</div>
<?php get_footer();?>