<?php
/*
Template Name: 4 Column Portfolio Home Full Width
*/
?>

<?php get_header(); 

?>
<div id="mainwrap">

	<div id="main" class="clearfix mainport">

	<div class="portfolio full">		
				<div class="loading"></div>
				<div id="portitems4">
				
					<?php 

						$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
						$showposts = $data['home_recent_number']; 
			
						$args = array(
										'showposts' => $showposts ,
										'post_type' => 'portfolioentry'
									  );
			
						$my_query = new WP_Query($args);
						$wp_query = $my_query;
			
						query_posts("showposts=$showposts&post_type=portfolioentry&paged=$paged");
			
						$limit_text = 100;
						$currentindex = '';
						$counter = 0;
						$count = 0;
						$temp = '';
						while ( have_posts() ) : the_post();
							$do_not_duplicate = $post->ID; 
							$full_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', false);
						    $entrycategory = get_the_term_list( $post->ID, 'portfoliocategory', '', '_', '' );
							$catstring = $entrycategory;
							$catstring = strip_tags($catstring);
							$catstring = str_replace('_', ', ', $catstring);
							$categoryname = $catstring;							
							$entrycategory = strip_tags($entrycategory);
							$entrycategory = str_replace(' ', '-', $entrycategory);
							$entrycategory = str_replace('_', ' ', $entrycategory);
							
							$catidlist = explode(" ", $entrycategory);
							for($i = 0; $i < sizeof($catidlist); ++$i){
								$catidlist[$i].=$currentindex;
							}
							$catlist = implode(" ", $catidlist);

							
							$category = get_the_term_list( $post->ID, 'portfoliocategory', '', ', ', '' );	

							if(isset($full_image[0]))
								$img = get_template_directory_uri() .'/js/timthumb.php?src='.$full_image[0] .'&';
							else
								$img = get_template_directory_uri() .'/js/timthumb.php?src='.get_template_directory_uri() .'/images/placeholder-port.png&';
								
							?>
								<div class="item4">

						

							<a href="<?php the_permalink(); ?>">
								<div class="overdefult">
								
									<div class="viewIcon"><?php echo getPostViews(get_the_ID()); ?></div>
									<div class="likeIcon"><?php echo GetWtiLikeCount($post->ID) ?></div>
		
								</div>
							</a>
							<div class = "detailsoverdefault">
								<h3><a href="<?php the_permalink(); ?>"><?php $title = substr(the_title('','',FALSE),0,30); echo $title  ?></a></h3>
								<a href="<?php the_permalink(); ?>"><div class = "moreButton">+</div></a>
							</div>
							<div class="image">
								
								<img class="newimage <?php echo $newheight ?>" src="<?php echo  $img ?>" alt="<?php the_title(); ?>">
							</div>	
				
							</div>	
						<?php 
							
						
							
						
						endwhile; 
						?>
					
		</div>
					
	
	</div>
	
</div>	
</div>

<script>
	   jQuery(function(){
  
  
		var $container = jQuery('#portitems4');
		var number;
		// initialize Isotope
			if($container.width() > 1680){
				number=6;
			}
			
			if($container.width() > 1280 && $container.width() < 1680){
				number=6;
			}	
			

			if($container.width() < 1280 && $container.width()>900){
				number=4;
			}	
			if($container.width() > 460 && $container.width() < 900){
				number=2;
			}				
			if($container.width() < 460){
				number=1;
			}		
		$container.isotope({
		  // options...
		  resizable: false, // disable normal resizing
		  // set columnWidth to a percentage of container width
		  masonry: { columnWidth: $container.width() / number }
		});


		

    });

</script>
	
<?php get_footer(); ?>