<?php

global $news; // Do not delete these lines 

// Trying to load comments.php directly!
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
	die ('Please do not load this page directly. Thanks!');

// Password protected post
if ( post_password_required() ) {
	echo '<p class="nocomments">'.__('This post is password protected. Enter the password to view comments.','news').'</p>';
	return;
}

// Comment list framework
function mytheme_comment($comment, $args, $depth) {
	global $news;
	$GLOBALS['comment'] = $comment; ?>
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>"><?php deluxe_comment(); ?>
	<div id="comment-<?php comment_ID(); ?>">

		<div class="comment-author vcard"><?php echo get_avatar($comment,$size='48'); ?></div>

		<div class="comment-meta commentmetadata">
		<cite class="fn"><?php print get_comment_author_link(); ?></cite><?php printf(__('%1$s at %2$s','news'), get_comment_date('D M d'), get_comment_time('g:i a')); ?>
		</div>

		<?php comment_text() ?>

		<?php if ($comment->comment_approved == '0') : ?><div class="waiting"><?php _e('This comment is pending approval by a site moderator.','news'); ?></div><?php endif; ?>

		<div class="reply">
		<?php comment_reply_link(array_merge( $args, array('reply_text' => __('Reply','news'), 'login_text' => __('Login to reply','news'), 'add_below' => 'comment', 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
		</div>

	</div><div class="clear"></div>
<?php
}
?>

<div class="comments-wrap">

<?php
/*
#
#	Display comments/pings, navigation, etc.
#
*/
if (have_comments()) {
?>

<h3 id="comments"><?php comments_number(__('0 Comments','news'), __('1 Comment','news'), __('% Comments','news')); ?></h3>

<div class="commentdata">
	<?php if ('open' == $post->comment_status) { ?>
	<div class="alignleft"><a href="#respond" class="postcomment"><?php _e('Post a Comment','news'); ?></a></div>
	<?php } else { ?>
	<div class="alignleft"><?php _e('Comments are closed on this post.','news'); ?></div>
	<?php } ?>
	<div class="alignright"><?php dt_comment_ajaxpagination(); ?></div>
	<div class="clear"></div>
</div>

<?php if (!empty($comments_by_type['comment'])) : // Seperate comments ?>
<ol class="commentlist"><?php wp_list_comments('max_depth=2&style=ol&callback=mytheme_comment&type=comment'); ?></ol><div class="clear"></div>
<?php endif; ?>

<div class="commentdata">
	<div class="alignright"><?php dt_comment_ajaxpagination(); ?></div>
	<div class="clear"></div>
</div>

<?php
}

/*
#
#	comments are open. display reply form
#
*/
if ('open' == $post->comment_status) {
?>

<div id="respond">

<h3><?php comment_form_title(__('Leave a Reply','news'), __('Reply to %s','news')); ?></h3>

<?php if ( get_option('comment_registration') && !$user_ID ) { ?>

<p><?php printf(__('You must <a href="%1$s">sign in</a> to post a comment. %2$s','news'), wp_login_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']), dt_register_link()); ?></p>

<?php } else { ?>

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

<?php if ( $user_ID ) { ?>

<p><?php printf(__('You are logged in as <a href="%1$s/wp-admin/profile.php">%2$s</a>. <a href="%3$s" title="Logout">Logout &raquo;</a>','news'), get_option('siteurl'), $user_identity, wp_logout_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])); ?></p>

<?php } else { ?>

<p>
<input class="text" type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
<label for="author"><?php _e('Your name','news'); ?> <?php if ($req) _e('(Required)','news'); ?></label>
</p>
<p>
<input class="text" type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
<label for="email"><?php _e('Your e-mail','news'); ?> (<?php _e('Your email won\'t be published','news'); ?>) <?php if ($req) _e('(Required)','news'); ?></label>
</p>
<p>
<input class="text" type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><?php _e('Your website','news'); ?></label>
</p>

<?php } ?>

<p>
<textarea name="comment" id="comment" tabindex="4"></textarea>
</p>

<?php if (function_exists(show_subscription_checkbox)) { show_subscription_checkbox(); } ?>
<p><input class="submit" name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('Submit Comment','news'); ?>" />
<p class="cancel-comment-reply"><?php cancel_comment_reply_link(__('Click here to cancel reply','news')); ?></p>
<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>

</form>

<?php } // If registration required and not logged in ?>

</div>

<?php } else { // comments are closed? ?>

<div id="respond">
<h3><?php comment_form_title(__('Leave a Reply','news'), __('Reply to %s','news')); ?></h3>
<p><?php _e('Comments are closed on this post.','news'); ?></p>
</div>

<?php } ?>

</div><!-- comments-wrap -->