<?php get_header(); ?>
<div class="container-fluid posts-wrapper">
<?php 
if(imwb_zonpress_get_option('hideptthumbs') == 'N') {

   if(imwb_zonpress_get_option('fplistorder') == '0') {
   $args = Array('meta_key' => '_imwb_zonpress_post_ctr',
                 'orderby' => 'meta_value_num',
                 'order' => 'DESC',
                 'showposts' => imwb_zonpress_get_option('ptthumbsshown'));                      
   }
   else {
   $args = Array('showposts' => imwb_zonpress_get_option('ptthumbsshown'),
                 'orderby' => 'date',
                 'order' => 'DESC');
   }
   $fpexcludecats = imwb_zonpress_get_option('fpexcludecats');
   if(!empty($fpexcludecats)) {
    $cats = explode(",", htmlspecialchars(imwb_zonpress_get_option('fpexcludecats')) );
    foreach ($cats as $key => $value) {
       $cats[$key] = "-".$value;
    }      
    $args = array_merge($args, Array('cat' => implode(',', $cats)));
   }
   $thumbnails = '';
   $carousel_query = new WP_Query($args); 
    
   if ($carousel_query->have_posts()) {
   
      while ($carousel_query->have_posts()) { 
         $carousel_query->the_post(); 
         
         $thumbnails .= '<a href="'.get_permalink().'">'.imwb_zonpress_get_post_thumbnail (get_the_ID(), "153", "128" ).'</a>';
      } 
    }
    ?>
   <div class="row-fluid"> 
    <div class="span12 thumbnails"><?php echo $thumbnails;?></div>
   </div>
<?php } ?> 
<div class="row-fluid">
<?php if(imwb_zonpress_get_option('postsidebar') == '1' && is_active_sidebar("sidebar-post-widget")) { ?>
   <div id="post-sidebar" class="span4 content_sidebar left">
	   <?php dynamic_sidebar("sidebar-post-widget"); ?>
   </div>
<?php } ?>
<?php if(imwb_zonpress_get_option('postsidebar') == '0' || !is_active_sidebar("sidebar-post-widget")) { ?>
<div id="post-sidebar" class="span2"></div>
<?php } ?>
<div class="span8 the-post"> 
<?php while(have_posts()): the_post(); 

   $postImage = imwb_zonpress_get_post_thumbnail(get_the_ID(), "300","250", true);
   preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', $postImage, $matches );
   $postImageSrc = $matches[1][0];
?>
<div class="thumb">
 <a href="<?php echo imwb_zonpress_get_product_href(); ?>" title="<?php the_title_attribute(); ?>" <?php echo imwb_zonpress_get_post_link_target();?>>
 <?php echo $postImage; ?></a>
</div>

<div class="content">
<?php if(imwb_zonpress_get_option('hidepttitle') == 'N') { ?>
	<h1 class="title"><?php the_title(); ?></h1>
<?php } ?>
<?php if(imwb_zonpress_get_option('hideptdetails') == 'N') { ?>
	<div class="stats"><?php echo get_the_date('F j, Y'); ?> - <a href="<?php comments_link(); ?>"><?php _e("Comment", "imwb_zonpress");?></a></div>
<?php } ?> 
<div class="description"><?php  echo do_shortcode(the_excerpt()); ?></div>
<?php if(imwb_zonpress_is_product()) { ?>
   <div class="actions clearfix">
     <a class="btn btn-success pull-right" href="<?php echo imwb_zonpress_get_product_href(); ?>" <?php echo imwb_zonpress_get_post_link_target();?>><?php echo imwb_zonpress_get_option('ptprdbtntxt');?></a>
     <?php if(imwb_zonpress_get_option('hideptprice') != "Y") imwb_zonpress_post_price();?>
     <?php if(imwb_zonpress_post_onwishlist($user_ID, get_the_ID())) { ?>
       <span class="wishlistlink"><?php echo imwb_zonpress_get_option('onwishlisttext');?></span>
     <?php } else { 
        if (is_user_logged_in()) { ?>
          <a class="wishlistlink" href="" data-post-item='<?php echo get_the_ID(); ?>'><?php echo imwb_zonpress_get_option('addwishlisttext');?></a>
        <?php } else { ?>
          <a class="smcf-login wishlistlink" href="<?php bloginfo( 'url' );?>/wp-login.php"><?php echo imwb_zonpress_get_option('addwishlisttext');?></a>
     <?php } } ?>         
   </div>
 <?php } ?>
 </div>
<?php if(imwb_zonpress_get_option('hideptlikestats') == 'N') { 

$shareoptions = imwb_zonpress_get_option('shareoptions');
if(!empty($shareoptions)) $shareoptions = explode(",", imwb_zonpress_get_option('shareoptions'));
else $shareoptions = false;

if($shareoptions !== false) {
?>   
 <div class="social-actions">
      <ul class="social-buttons">
      <?php if(in_array("T", $shareoptions)) { ?>
      <li class="story-share-tweet"><a href="javascript:imwb_zonpress_window_open('<?php echo 'http://twitter.com/share?url={URL}&text='.esc_js(the_title('','',false)); ?>', '<?php echo urlencode(get_permalink());?>')"><?php _e("Tweet this", "imwb_zonpress");?></a></li>
      <?php } if(in_array("F", $shareoptions)) { ?>
      <li class="story-share-fb"><a href="javascript:imwb_zonpress_window_open('http://www.facebook.com/sharer.php?u={URL}', '<?php echo urlencode(get_permalink());?>')"><?php _e("Share to Facebook", "imwb_zonpress");?></a></li>
      <?php } if(in_array("P", $shareoptions)) { ?>
      <li class="story-share-pin"><a href="javascript:imwb_zonpress_window_open('<?php echo 'http://pinterest.com/pin/create/bookmarklet/?media='.imwb_zonpress_post_thumbnail_img_src().'&url={URL}&description='.esc_js(the_title('','',false)) ; ?>', '<?php echo urlencode(get_permalink());?>')"><?php _e("Pin It", "imwb_zonpress");?></a></li>
      <?php } if(in_array("L", $shareoptions)) { ?>
      <li class="story-share-linkin"><a href="javascript:imwb_zonpress_window_open('<?php echo 'http://www.linkedin.com/shareArticle?mini=true&url={URL}&source='.esc_js(the_title('','',false)).'&token=&isFramed=false'; ?>', '<?php echo urlencode(get_permalink());?>')"><?php _e("LinkedIn", "imwb_zonpress");?></a></li>
      <?php } if(in_array("G", $shareoptions)) { ?>
      <li class="story-share-gplus"><a href="javascript:imwb_zonpress_window_open('http://plus.google.com/share?url={URL}&authuser=0', '<?php echo urlencode(get_permalink());?>')"><?php _e("Google+", "imwb_zonpress");?></a></li>
      <?php } ?>      
      </ul>
 </div>
<?php } 

} ?>
<div class="description">
<?php 
      $content = get_the_content();
      if(!empty($postImageSrc))
         $content = apply_filters('imwb_zonpress_filter_content', $content, $postImageSrc );
      $content = apply_filters('the_content', $content);
      $content = str_replace(']]>', ']]&gt;', $content);
      echo $content;
?>
</div>
<?php if(imwb_zonpress_get_option('commenttype') != '3') { 

   if(imwb_zonpress_get_option('commenttype') == '0') { 
?>	
	<?php comments_template("", true); ?>
<?php } else if(imwb_zonpress_get_option('commenttype') == '1') {?>	
   <a name="comments"></a>
   <div class="fb-comments" data-href="<?php echo get_permalink();?>" data-width="630" data-num-posts="15"></div>
<?php } else if(imwb_zonpress_get_option('commenttype') == '2') {?>
   <div class="fb-comments" data-href="<?php echo get_permalink();?>" data-width="630" data-num-posts="15"></div>
	<?php comments_template("", true); ?>
<?php }
}
endwhile;
?>
</div>
<?php if(imwb_zonpress_get_option('postsidebar') == '2' && is_active_sidebar("sidebar-post-widget")) { ?>
   <div id="post-sidebar" class="span4 content_sidebar right">
	   <?php dynamic_sidebar("sidebar-post-widget"); ?>
   </div>
<?php } ?>
</div>
</div>

<?php get_footer(); ?>