<?php
/*
 *
 Template Name: Blog
 *
 * This is the custom Blog page template.
 *
 */ 
 get_header(); ?>

<?php if ( has_post_thumbnail()) { ?>
	<div class="row">
		<div id="banner"><?php the_post_thumbnail( 'banner' ); ?></div>
	</div>
<?php } else { } ?>

<!-- #content -->
<div id="content">
	
	<!-- .row -->
	<div class="row blog-page">

		<!-- BEGIN .eight columns -->
		<div class="eight columns">
									
			<?php $wp_query = new WP_Query(array('cat'=>of_get_option('categories_blog'), 'showposts'=>of_get_option('postnumber_blog'), 'paged'=>$paged)); ?>
			<?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
			<?php $meta_box = get_post_custom($post->ID); $video = $meta_box['custom_meta_video'][0]; ?>
	        <?php global $more; $more = 0; ?>
	        
	        <!-- BEGIN .hentry -->
			<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
			
				<div class="datebox">
				    <div class="month"><?php the_time(__("M", 'organicthemes')); ?></div>
				    <div class="day"><?php the_time(__("j", 'organicthemes')); ?></div>
				</div>
	
				<!-- BEGIN .article -->
				<div class="article">
		            
		            <h1 class="headline alt"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
		            
		            <?php if(of_get_option('display_feature_blog') == '1') { ?>
			            <?php if ( $video ) : ?>
			                <div class="feature_vid"><?php echo $video; ?></div>
			            <?php else: ?>
			            	<?php if ( has_post_thumbnail()) { ?>
			                	<div class="feature_img"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'archive-thumb' ); ?></a></div>
			                <?php } else { ?>
			                <?php } ?>
			            <?php endif; ?>
		            <?php } else { ?>
		            <?php } ?>
		            
		            <?php the_content(__("Read More", 'organicthemes')); ?>
		            				
					<?php if(of_get_option('display_social_blog') == '1') { ?>
					<div class="postmeta">
					    <div class="social full">
					    	<div class="like-btn">
					    	  	<div class="fb-like" href="<?php the_permalink(); ?>" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false"></div>
					    	</div>
					    	<div class="pin-btn">
					    		<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo $feat_image; ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="horizontal" target="_blank"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
					    	</div>
					    	<div class="tweet-btn">
					    		<a href="http://twitter.com/share" class="twitter-share-button"
					    		data-url="<?php the_permalink(); ?>"
					    		data-via="<?php echo of_get_option('twitter_user'); ?>"
					    		data-text="<?php the_title(); ?>"
					    		data-related=""
					    		data-count="horizontal"><?php _e("Tweet", 'organicthemes'); ?></a>
					    	</div>
					    	<div class="plus-btn">
					    		<div class="g-plusone" data-size="medium" href="<?php the_permalink(); ?>"></div>
					    	</div>
					    </div>
					</div>
					<?php } else { ?>
					<?php } ?>
					
				<!-- END .article -->
				</div>
			
			<!-- END .hentry -->
			</div>
									
			<?php endwhile; ?>
			
			<div class="pagination">
				<?php if (function_exists("number_paginate")) { number_paginate(); } ?>
			</div>
	        
	        <?php else : // do not delete ?>
	
	        <h1 class="headline"><?php _e("Page not Found", 'organicthemes'); ?></h1>
	        <p><?php _e("We're sorry, but the page you're looking for isn't here.", 'organicthemes'); ?></p>
	        <p><?php _e("Try searching for the page you are looking for or using the navigation in the header or sidebar", 'organicthemes'); ?></p>
	
			<?php endif; // do not delete ?>
	
		<!-- END .eight columns -->
		</div>
		
	    <div class="four columns">
	    	<?php get_sidebar('blog'); ?>
	    </div><!-- .four columns -->	

	<!-- END .row -->
    </div>

<!-- END #content -->
</div>

<?php get_footer(); ?>