<?php

// include WordPress
require_once('../../../wp-load.php');
$results = $_SERVER['QUERY_STRING'];

if ($_GET['n_more'] && is_numeric($_GET['n_more'])) {
	for ($c = 1; $c <= $_GET['n_more']; $c++) {
		$postsnum = $_GET['posts_per_page'] += $news['num_per_more'];
		$results = preg_replace('/(?:&|(\?))' . 'posts_per_page' . '=[^&]*(?(1)&|)?/i', "$1", $results);
		$results .= '&posts_per_page=' . $postsnum;
	}
}

/* uncomment the following line for debugging only */
//echo $results;

?>

	<!--
	#
	#	set the query
	#
	// -->
	<?php query_posts($results); if (have_posts()) { ?>
	<!--
	#
	#	loop thru posts
	#
	// -->
	<?php $i = 0; while (have_posts()) : the_post(); $i++; ?>
	
	<?php /* lets load different templates */ ?>
	<?php if ($_GET['n_view'] == 'headers') { ?>
	
	<div id="post-<?php echo $i; ?>" class="posti<?php if ($_GET['n_style'] == 'grid') { echo '-grid'; } ?>">
	<div class="entry">
		<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php dt_posttype(); ?><?php the_title(); ?></a></h2>
	</div><div class="clear"></div>
	</div><?php if (($_GET['n_style'] == 'grid' && $i % 2 == 0) || ($_GET['n_style'] == 'grid' && $i == $wp_query->post_count) || ($_GET['n_style'] == 'grid' && $i == $news['num_per_page'])) { echo '<div class="clear"></div><div class="sep"></div>'; } ?>
	
	<?php } elseif ($_GET['n_view'] == 'textonly') { ?>
	
	<div id="post-<?php echo $i; ?>" class="posti<?php if ($_GET['n_style'] == 'grid') { echo '-grid'; } ?>">
	<div class="entry">
		<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php dt_posttype(); ?><?php the_title(); ?></a></h2>
		<div class="shortpost"><?php dt_excerpt('type=chars&limit=500&after= '); ?><p><a href="<?php the_permalink(); ?>"><?php _e('Read full story &raquo;','news'); ?></a></p></div>
	</div><div class="clear"></div>
	</div><?php if (($_GET['n_style'] == 'grid' && $i % 2 == 0) || ($_GET['n_style'] == 'grid' && $i == $wp_query->post_count) || ($_GET['n_style'] == 'grid' && $i == $news['num_per_page'])) { echo '<div class="clear"></div><div class="sep"></div>'; } ?>
	
	<?php } else { ?>
	
	<div id="post-<?php echo $i; ?>" class="posti<?php if ($_GET['n_style'] == 'grid') { echo '-grid'; } ?>">
	<?php if ($_GET['n_style'] != 'grid') { ?><div class="thumb"><?php dt_thumb('width=200&height=180'); ?></div><?php } ?>
	<div class="entry">
		<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php dt_posttype(); ?><?php the_title(); ?></a></h2>
		<div class="postmeta">
			<?php if ($_GET['orderby'] == 'modified') { ?>
			<?php the_modified_date('d M Y g:ia', 'Last modified: ', '', true); ?> <?php printf(__('by <a href="%1$s" class="author-link">%2$s</a>','news'), get_author_link(false, get_the_author_meta('ID')), get_the_author_meta('display_name')); ?>
			<?php } else { ?>
			<?php printf(__('By <a href="%1$s" class="author-link">%2$s</a> on %3$s','news'), get_author_link(false, get_the_author_meta('ID')), get_the_author_meta('display_name'), get_the_time('d M Y g:ia')); ?>
			<?php } ?> - <?php dt_archive_meta(); ?>
		 </div>
		<?php if ($_GET['n_style'] == 'grid') { ?><div class="thumb"><?php dt_thumb('width=140&height=90'); ?></div><?php } ?>
		<div class="shortpost"><?php dt_excerpt('type=chars&limit=500&after= '); ?><p><a href="<?php the_permalink(); ?>"><?php _e('Read full story &raquo;','news'); ?></a></p></div>
	</div><div class="clear"></div>
	<?php the_tags('<ul class="taglist"><li>'.dt_get_category().'</li><li>','</li><li>','</li></ul><div class="clear"></div>'); ?>
	</div><?php if (($_GET['n_style'] == 'grid' && $i % 2 == 0) || ($_GET['n_style'] == 'grid' && $i == $wp_query->post_count) || ($_GET['n_style'] == 'grid' && $i == $news['num_per_page'])) { echo '<div class="clear"></div><div class="sep"></div>'; } ?>
	
	<?php } ?>

	<?php dt_paged_ads(); ?>
	<?php endwhile; ?>	
	<!--
	#
	#	end the query
	#
	// -->
	<?php } ?>
	
<script type="text/javascript">
$(function() {

	// rounded corners calculations
	$(".posti .taglist li a, .posti-grid .taglist li a").corner("10px");

});
</script>