<?php 
get_header();
global $page, $paged;
?>
<div class="container-fluid posts-wrapper">
 <div class="row-fluid">
 
<?php if(imwb_zonpress_get_option('catsidebar') == '1' && is_active_sidebar("sidebar-catpage-widget")) { ?>
   <div id="post-sidebar" class="span4 content_sidebar left">
	   <?php dynamic_sidebar("sidebar-catpage-widget"); ?>
   </div>
<?php } ?>

<div class="<?php echo (imwb_zonpress_get_option('catsidebar') == '0' || !is_active_sidebar("sidebar-catpage-widget")) ? 'span12' : 'span8';?>"> 

	<?php if ( have_posts() ) { ?>
		<header class="search-header">
			<h1 class="search-title"><?php printf( __( 'Search Results for: "%s"', 'imwb_zonpress' ), get_search_query() ); ?></h1>
		</header>

		<?php 
		$current_post = 0;  
		while ( have_posts() ) : the_post(); 
		   $zp_is_product = false;
		   $ctr_track_attr = "";
		   if(imwb_zonpress_is_product()) {
   		   $zp_is_product = true;
		      $ctr_track_attr = " class='zp-ctr-track' data-post-item='".get_the_ID()."'";  
		   }
         if($current_post % 2 == 0) {
      ?>
      <div class="row-fluid">
      <?php } ?>
      <div class="span6 post <?php echo $zp_is_product ? "zp-product" : "";?>">
      <?php  if(imwb_zonpress_get_option('showtitle') == '1') { ?>
       <h1 class="title">
        <a <?php echo $ctr_track_attr;?> href="<?php echo imwb_zonpress_get_post_permalink('title'); ?>" title="<?php the_title_attribute(); ?>" <?php echo imwb_zonpress_get_post_link_target();?>><?php echo do_shortcode(the_title());?></a>
       </h1>
      <?php } ?>
       <div class="post_thumb">
          <a <?php echo $ctr_track_attr;?> href="<?php echo imwb_zonpress_get_post_permalink('image'); ?>" title="<?php the_title_attribute(); ?>" <?php echo imwb_zonpress_get_post_link_target();?>>
        <?php imwb_zonpress_the_post_thumbnail(get_the_ID(), "300", "250"); ?>
        </a>
       </div>
      <?php if(imwb_zonpress_get_option('postcontent') != 'N') { ?>
      	<div class="description">
      	<?php echo do_shortcode(the_excerpt()); ?>
      	</div>
         <?php if(imwb_zonpress_is_product()) { 
            imwb_zonpress_update_imp();
         ?>
         	<div class="actions clearfix">
         	  <a class="btn btn-success pull-right zp-ctr-track" data-post-item='<?php echo get_the_ID(); ?>' href="<?php echo imwb_zonpress_get_post_permalink('button'); ?>" title="<?php the_title_attribute(); ?>" <?php echo imwb_zonpress_get_post_link_target();?>><?php echo imwb_zonpress_get_option('postprdbtntxt');?></a>
         	  <?php if(imwb_zonpress_get_option('fphideprice') != "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 } ?>	
      <?php } ?> 
      </div>
      <?php  
         if($current_post % 2 == 1) { ?>
       </div>
      <?php }
      $current_post++;  
      endwhile; 
      
      if($current_post % 2 > 0) { ?>
       </div>
	<?php }
	 
	} else { ?>
		<header class="search-header">
			<h1 class="search-title"><?php printf( __( 'No Results Found For: "%s"', 'imwb_zonpress' ), get_search_query() ); ?></h1>
		</header>
   <?php } ?>

 </div>
 <?php if(imwb_zonpress_get_option('catsidebar') == '2' && is_active_sidebar("sidebar-catpage-widget")) { ?>
    <div id="post-sidebar" class="span4 content_sidebar right">
 	   <?php dynamic_sidebar("sidebar-catpage-widget"); ?>
    </div>
 <?php } ?>
 </div>
 
 <div class="row-fluid">
 <div class="span12">
 <?php imwb_zonpress_page_numbers(); ?>
 </div>
 </div>
</div>

<?php get_footer(); ?>