<?php
/*
Template Name: Home
*/
?>

<?php get_header(); ?>
			
			<!--BEGIN #primary .hfeed-->
			<div id="primary" class="hfeed">
				
				<h1 class="page-title"><?php the_title(); ?></h1>
				
				<?php
				
				$caption = get_post_meta(get_the_ID(), 'tz_caption', TRUE);
				
				if($caption != '') : 
				
				?>
				<p class="page-caption"><?php echo stripslashes(htmlspecialchars_decode(nl2br($caption))); ?></p>
				<?php endif; ?>
				
				<ul class="grid clearfix">
				
					<?php 
					$count = 1;
					$paged = (get_query_var('paged')) ? get_query_var('paged') : (get_query_var('page') ? get_query_var('page') : 1 );
					query_posts(array(
							'paged' => $paged,
							'post_type' => 'portfolio',
							'posts_per_page' => get_option('tz_home_number')
						)
					);
					$post_count = $wp_query->post_count;
					if (have_posts()) : while (have_posts()) : the_post(); 
					$terms = get_the_terms( get_the_ID(), 'skill-type' );
					
					?>
					
					<!--BEGIN .hentry -->
					<li <?php post_class() ?> id="post-<?php the_ID(); ?>">
						
						<!--BEGIN .post-wrap -->
						<div class="post-wrap <?php if($count&1 && $post_count != $count) : echo "odd"; endif; ?>">
		                    <div class="post-thumb clearfix">
		                    	
	                            <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">
	                            	<span class="post-thumb-overlay"></span>
	                            	<?php the_post_thumbnail('thumbnail-home'); ?>
	                            </a>
                    
		                    </div>
		                    
		                    <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
		                    
		                    <?php if($terms) : ?>
		                    <!--BEGIN .entry-meta .entry-footer-->
							<div class="entry-meta entry-footer">
								<span class="entry-categories">
									<?php foreach ($terms as $term) :  ?>
				                    <a href="<?php echo get_term_link($term->slug, 'skill-type'); ?>"><?php echo $term->name; ?></a><span>, </span>
				                    <?php endforeach; ?>
								</span>
							<!--END .entry-meta .entry-footer-->
							</div>
							<?php endif; ?>

						<!--END .post-wrap -->
						</div>
						
							        
	                <!--END .hentry-->  
					</li>
					
					<?php $count++; endwhile; endif; ?>

				</ul>
				
				<!--BEGIN .navigation .page-navigation -->
				<div class="navigation page-navigation">
					<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
					<div class="nav-next"><?php next_posts_link(__('&larr; Older Entries', 'framework')) ?></div>
					<div class="nav-previous"><?php previous_posts_link(__('Newer Entries &rarr;', 'framework')) ?></div>
					<?php } ?>
				<!--END .navigation .page-navigation -->
				</div>
				
			<!--END #primary .hfeed-->
			</div>
				

<?php get_sidebar(); ?>

<?php get_footer(); ?>