<?php get_header(); ?>
	<?php 
	if (have_posts()) : ?>
	<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    <?php /* If this is a category archive */ if (is_category()) { ?>
        <h1 class="catheader"><?php single_cat_title(); ?></h1>
		<?php $catdesc = category_description(); if(stristr($catdesc,'<p>')) { echo '<div class="catdesc">'.$catdesc.'</div>'; } ?>   
    <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
        <h1 class="catheader"><?php printf(__("Posts Tagged &#8216; %s &#8217;", "moderno"), single_tag_title('',false)); ?></h1>
        <div id="tagcloud"><?php wp_tag_cloud('smallest=8&largest=16'); ?></div>
    <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
        <h1 class="catheader"><?php _e("Archive for ", "moderno").the_time('F jS, Y'); ?></h1>
    <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
        <h1 class="catheader"><?php _e("Archive for ", "moderno").the_time('F, Y'); ?></h1>
    <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
        <h1 class="catheader"><?php _e("Archive for ", "moderno").the_time('Y'); ?></h1>
    <?php /* If this is an author archive */ } elseif (is_author()) { ?>
        <h1 class="catheader"><?php _e("Author Archive", "moderno"); ?></h1>
    <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
        <h1 class="catheader"><?php _e("Blog Archives", "moderno"); ?></h1>
    <?php } ?>
    <?php while (have_posts()) : the_post(); ?>
		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <h2><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
			<?php if(function_exists('has_post_thumbnail') && has_post_thumbnail()) { ?>
                <div class="postimage">
                    <img src="<?php echo THEME_URL; ?>/images/imagebg2.png" alt="" class="imgbg" />
                    <?php the_post_thumbnail('main-thumb', array('class'=>'aligncenter')); ?>
                    <?php if(theme_option('dates_cats') == 'on') { echo '<div class="datecirc">'; the_time('M'); echo '<br />'; the_time('d'); echo '</div>'; } ?>
                    <div class="readmore"><a href="<?php the_permalink() ?>"><?php echo theme_option('more_link_text'); ?></a></div>
                </div>
            <?php } elseif(resize(1,1)) { ?>
                <div class="postimage">
                    <img src="<?php echo THEME_URL; ?>/images/imagebg2.png" alt="" class="imgbg" />
                    <?php echo resize((CONTENT_WIDTH-60), 210, 'aligncenter'); ?>
                    <?php if(theme_option('dates_cats') == 'on') { echo '<div class="datecirc">'; the_time('M'); echo '<br />'; the_time('d'); echo '</div>'; } ?>
                    <div class="readmore"><a href="<?php the_permalink() ?>"><?php echo theme_option('more_link_text'); ?></a></div>
                </div>
			<?php 
			} else { 
				if(theme_option('dates_cats') == 'on') { echo '<div class="datecirc nopic">'; the_time('M'); echo '<br />'; the_time('d'); echo '</div>'; } 
			}
			?> 
            <div class="storycontent">
				<?php 
				if(theme_option('frontpage_exorcon') == '2') { 
					theme_content(theme_option('more_link_text'));
				} else {
					the_excerpt();
				}	
				?>
			</div>                                 
   			<div class="meta">
                <?php if(theme_option('authors_cats') == 'on') { echo '<div class="author">'; _e("Posted by", "moderno"); echo " "; the_author_posts_link(); echo '&nbsp;</div>'; } ?> 
                <?php if(theme_option('comment_count') == 1 && comments_open()) { ?>
                    <?php comments_popup_link(__('0 Comments', "moderno"),__('1 Comment', "moderno"),__('% Comments', "moderno"),'ind-comments'); ?>
                <?php } ?>
            </div>
            <div class="bottomline"></div>
        </div>

    <?php endwhile; ?>

	<?php
    if(function_exists('pagination')) { pagination(); }
    ?>
	<?php else :
		echo '<div class="ind-post">';
		if ( is_category() ) { // If this is a category archive
			printf(__("<p class='center'>Sorry, but there aren't any posts in the %s category yet.</p>", "moderno"), single_cat_title('',false));
		} else if ( is_date() ) { // If this is a date archive
			_e("<p>Sorry, but there aren't any posts with this date.</p>", "moderno");
		} else if ( is_author() ) { // If this is a category archive
			$userdata = get_userdatabylogin(get_query_var('author_name'));
			printf(__("<p class='center'>Sorry, but there aren't any posts by %s yet.</p>", "moderno"), $userdata->display_name);
		} else {
			_e("<p class='center'>No posts found.</p>", "moderno");
		}
		echo '</div>';
	endif;
?>
</div>
<?php get_footer(); ?>
