<?php if ( ! have_posts() ) :
?>
<div class="title">
	<h1><?php _e('Not Found', 'mt-dark');?></h1>
	<p>
		<?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'mt-dark');?>
	</p>
</div>
<?php endif; wp_reset_query();?>

<?php  while (have_posts()) : the_post();
?>

<?php /* GALLERY */ if ( 'gallery' == get_post_format( $post->ID) ) :
?>
<div <?php post_class();?>>
	<div class="postmeta">
		<?php if ( post_password_required() ) :
		?>
		<h2><a href="<?php the_permalink();?>" title="<?php echo esc_attr(sprintf(__('Permanent Link to %s', 'mt-dark'), the_title_attribute('echo=0')));?>" rel="bookmark"><?php the_title();?></a></h2>
		<?php the_content();?>
		<?php else :?>
		<?php $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
if ( $images ) :
$total_images = count( $images );
$image = array_shift( $images );
$image_img_tag = wp_get_attachment_image( $image->ID, 'medium' );
		?>

		<?php endif;?>
		<h2><a href="<?php the_permalink();?>" title="<?php echo esc_attr(sprintf(__('Permanent Link to %s', 'mt-dark'), the_title_attribute('echo=0')));?>" rel="bookmark"><?php the_title();?></a></h2>
		<?php if ($image_img_tag) :
		?><a class="alignleft" href="<?php the_permalink();?>"><?php echo $image_img_tag;?></a><?php endif;?>
		<?php printf(__('<p>This gallery contains <a %1$s>%2$s photo</a>.</p>', 'mt-dark'), 'href="' . get_permalink() . '" title="' . sprintf(esc_attr__('Permalink to %s', 'mt-dark'), the_title_attribute('echo=0')) . '" rel="bookmark"', number_format_i18n($total_images));?>
		<?php the_excerpt();?>
		<div class="clear"></div>
		<?php endif;?>
		<ul>
			<?php if ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) :
			?><li>
			<a href="<?php echo get_post_format_link('gallery');?>" title="<?php esc_attr_e('More Galleries', 'mt-dark');?>"><img src="<?php echo get_template_directory_uri()?>/images/image2.png" /></a>
			</li><?php endif;?>
			<li>
				<?php
				if(function_exists('dark_posted_on'))
					dark_posted_on();
				?>,
				<?php edit_post_link(__('Edit This', 'mt-dark'));?>
			</li>
			<li>
				<?php _e('Author', 'mt-dark');?>:
				<?php the_author_posts_link();?>,
			</li>
			<li>
				<?php comments_popup_link(__('Leave a comment', 'mt-dark'), __('1 Comment', 'mt-dark'), __('% Comments', 'mt-dark'));?>
			</li>
		</ul>
	</div>
</div>
<?php /* IMAGE */ elseif ( 'image' == get_post_format( $post->ID ) ) :?>
<div <?php post_class();?>>
	<div class="postmeta">
		<?php if ( post_password_required() ) :
		?>
		<?php the_content();?>
		<?php else :?>
		<?php    $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
if ( $images ) {
$total_images = count( $images );
$image = array_shift( $images );
$image_img_tag = wp_get_attachment_image( $image->ID, 'large' );
		?>
		<a class="wp-post-image" href="<?php the_permalink();?>"><?php echo $image_img_tag;?></a>
		<?php } else {?>
		<a href="<?php echo the_permalink();?>" title="<?php printf(esc_attr__('Permalink to %s', 'mt-dark'), the_title_attribute('echo=0'));?>" rel="bookmark"> <?php
			if((function_exists('add_theme_support')) && ( has_post_thumbnail())) {
				the_post_thumbnail('large');
			}
		?></a>
		<?php }?>
		<?php endif;?>
		<ul>
			<?php if ( function_exists( 'get_post_format' ) && 'image' == get_post_format( $post->ID ) ) :
			?>
			<li>
				<a href="<?php echo get_post_format_link('image');?>" title="<?php esc_attr_e('View Images', 'mt-dark');?>"><img src="<?php echo get_template_directory_uri()?>/images/kpaint.png" /></a>
			</li><?php endif;?>
			<li>
				<?php
				if(function_exists('dark_posted_on'))
					dark_posted_on();
				?>,
				<?php edit_post_link(__('Edit This', 'mt-dark'));?>
			</li>
			<li>
				<?php comments_popup_link(__('Leave a comment', 'mt-dark'), __('1 Comment', 'mt-dark'), __('% Comments', 'mt-dark'));?>
				<br />
			</li>
		</ul>
	</div>
</div>
<?php /* ASIDE */ elseif ( 'aside' == get_post_format( $post->ID ) ) :?>
<div <?php post_class() ?> >
	<div class="postmeta">
		<?php if ( is_archive() || is_search() ) :
		?>
		<?php the_excerpt();?>
		<?php else :?>
		<?php the_content(__('(more...)', 'mt-dark'));?>
		<?php endif;?>
		<ul>
			<?php if ( function_exists( 'get_post_format' ) && 'aside' == get_post_format( $post->ID ) ) :
			?><li>
			<a href="<?php echo get_post_format_link('aside');?>" title="<?php esc_attr_e('More Asides', 'mt-dark');?>"><img src="<?php echo get_template_directory_uri()?>/images/edit.png" /></a>
			</li><?php endif;?>
			<li>
				<?php
				if(function_exists('dark_posted_on'))
					dark_posted_on();
				?>,
				<?php edit_post_link(__('Edit This', 'mt-dark'));?>
			</li>
			<li>
				<?php comments_popup_link(__('Leave a comment', 'mt-dark'), __('1 Comment', 'mt-dark'), __('% Comments', 'mt-dark'));?>
				<br />
			</li>
		</ul>
	</div>
</div>
<?php /* LINK */ elseif ( 'link' == get_post_format( $post->ID ) ) :?>

<div <?php post_class('post') ?> >
	<?php if ( post_password_required() ) :
	?>
	<div class="postmeta">
		<?php the_content();?>
	</div>
	<?php endif;?>
	<div class="postmeta">
		<?php if (function_exists( 'dark_link_format' )) {
		?>
		<h2 class="title"><a href="<?php echo dark_link_format();?>" title="<?php printf(esc_attr__('%s', 'mt-white'), the_title_attribute('echo=0'));?>" rel="bookmark"> <?php the_title();?></a></h2><?php }?>
		<?php the_excerpt();?>
		<ul>
			<?php if ( function_exists( 'get_post_format' ) && 'link' == get_post_format( $post->ID ) ) :
			?><li>
			<a href="<?php echo get_post_format_link('link');?>" title="<?php esc_attr_e('More Links', 'mt-dark');?>"><img src="<?php echo get_template_directory_uri()?>/images/reload.png" /></a>
			</li><?php endif;?>
			<li>
				<?php
				if(function_exists('dark_posted_on'))
					dark_posted_on();
				?>,
				<?php edit_post_link(__('Edit This', 'mt-dark'));?>
			</li>
			<li>
				<?php comments_popup_link(__('Leave a comment', 'mt-dark'), __('1 Comment', 'mt-dark'), __('% Comments', 'mt-dark'));?>
				<br />
			</li>
		</ul>
	</div>
</div>
<?php  else :?>

<div <?php post_class() ?> >
	<h2 class="title"><a href="<?php the_permalink();?>" title="<?php echo esc_attr(sprintf(__('Permanent Link to %s', 'mt-dark'), the_title_attribute('echo=0')));?>" rel="bookmark"><?php the_title();?></a></h2>
	<div class="entry">
		<?php
		if((function_exists('add_theme_support')) && ( has_post_thumbnail())) {
			the_post_thumbnail('single_post');
		}
		?>
		<?php if ( is_archive()) {
		?>
		<?php the_excerpt();?>
		<?php } else {?>
		<?php the_content(__('(more...)', 'mt-dark'));?>
		<div class="clear"></div>
		<?php }?>
	</div>
	<ul class="postmeta">
		<?php wp_link_pages(array('before' => '<li class="page-link">' . __('Pages:', 'mt-dark'), 'after' => '<br /></li>'));?>
		<li>
			<?php
			if(function_exists('dark_posted_on'))
				dark_posted_on();
			?>,
			<?php edit_post_link(__('Edit This', 'mt-dark'));?>
		</li>
		<li>
			<?php _e('Author', 'mt-dark');?>:
			<?php the_author_posts_link();?>,
		</li>
		<li>
			<?php comments_popup_link(__('Leave a comment', 'mt-dark'), __('1 Comment', 'mt-dark'), __('% Comments', 'mt-dark'));?>
			<br />
		</li>
		<li>
			<?php _e('Categories', 'mt-dark');?>:
			<?php the_category(' , ')
			?><br />
		</li>
		<li>
			<?php if (the_tags()) : ?><?php the_tags(' ' ,  ' ,  ' ,  ' ') ?><?php endif;?>&nbsp;
		</li>
	</ul>
</div>
<?php endif;?>
<?php endwhile;?>
<?php comments_template('', true);?>