<!--<link rel="stylesheet" type="text/css" href="catalog/template/beststoreitems/css/page.css">-->
<style type="text/css">
.col-main{padding:0;}
</style>
<div class="main container">
	<div class="clearfix category-container row">          
    <?php if ($categories) { ?>
      <div class="col-main col-sm-24">
      <div class="category-products">
        <ul class="product_list" id="product_list_add">
            <?php foreach ($categories as $category) { ?>
            <li class="list_item">
                <div class="list_item_inner">
                    <div class="img_wrap">
                        <a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['thumb']; ?>" title="<?php echo $category['name']; ?>" alt="<?php echo $category['name']; ?>" /></a>
                    </div>
                  <div class="product-description">
                  <p class="item_title"><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></p>
                  </div>
                  </div>
              </li>
            <?php } ?>
      </ul></div>
      </div>
    <?php } ?>
    
    <?php if ($products) { ?>
    
    <?php if ($categories) { ?>    
    <div class="heading"><?php echo $text_product; ?></div>    
    <?php } ?>   
        <div class="page-title-wrap container">
            <h1 class="product-category"><?php echo $heading_title; ?></h1>
            <span class="items-count"><?php echo $text_results; ?> Item(s)</span>
        </div>
        <div class="category-products">
          <div class="toolbar clearfix">
              <div class="sorter">
              	<a class="sort_link selected" href="<?php echo $href_new_arrivals; ?>">New Arrivals</a><a class="sort_link" href="<?php echo $href_top_sellers; ?>">Top Sellers</a>
                      	
                      	<select name="sort_by" id="sort_by" onchange="sort_by()">
                          <option value="1"<?php if($sort==1) echo 'selected'?>>Newest</option>
                          <option value="2"<?php if($sort==2) echo 'selected'?>>Bestselling</option>
                          <option value="3"<?php if($sort==3) echo 'selected'?>>Price:lowest first</option>
                          <option value="4"<?php if($sort==4) echo 'selected'?>>Price:highest first</option>
                      	</select>
                        <label>Sort by:</label>
            	 
              </div>
          </div>
        </div>
        <div style="width:100;float:left;clear:both;"></div>
        
        <!-- product list start-->
        <div class="col-main col-sm-24">
          <div class="category-products">
          		<ul class="product_list">
                <?php foreach ($products as $product) { ?>
                    <li class="list_item">
                      <dl class="list_item_inner">
                      	<a href="<?php echo  $product['href_addtowishlist']; ?>" class="link-wishlist">
                          <span class="tip">Add to Wishlist</span>
				          <i class="icon-heart"></i>
                         </a>
                        <dt class="img_wrap"><a href="<?php echo $product['href']; ?>" class="list_item_img"><img  class="product-img" width="270"  alt="<?php echo $product['name']; ?>" src="<?php echo $product['thumb']; ?>"></a> </dt>
                        <dd class="product-description">
                        	<div class="item_title item_title_2"> <a title="<?php echo $product['name']; ?>" href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a> </div>
                            <div class="clearfix">
                                <div class="item_price">
                                	
                                    <!--<p><span class="old-price"><?php echo $product['market_price']; ?></span></p>-->
                                    <p><span class="old-price"><?php echo $product['market_price']; ?></span><span class="special-price"><?php echo $product['price']; ?></span></p>
                                    <!--<div class="item_review">
                                        <div class="rating rating_2">
                                            <span class="nostar nostar_category">
                                                <span style="width:90%;" class="nstar nstar_category"></span>
                                            </span>
                                        </div>
                                        (<?php echo $product['review_info']['count'];?>)<span class="line">|</span>Orders (<?php echo $product['sold'];?>) 
                                     </div>-->
                                </div>
							</div>
                        </dd>
						</dl>
                      </li>
                	<?php }?>
                </ul>
            </div>
          <div class="hei20"></div>
          <div class="toolbar clearfix">
          		<div class="sorter_bottom">
                	<div class="col-sm-8 left"><b><?php echo $text_results; ?></b> items in <strong><?php echo $heading_title; ?></strong> category</div>
                    <div class="col-sm-16 right">
                        <a href="<?php echo $action . '&page=' . (($page>1)?($page-1):$page); ?>"><?php echo 'Previous'?></a>                     
                        <?php foreach ($pages as $f_page) { ?>        
                        <?php if ( $f_page['value'] < ($page - 2) ) {continue; } ?>
                        <?php if ( $f_page['value'] > ($page + 4) ) {continue; } ?>                                               
                        <?php if ($f_page['value'] == $page) { ?>
                        <b class="selected"><?php $x = explode(" ",$f_page['text']);echo $x[0]; ?></b>
                        <?php } else { ?>
                          <a class="page_btn" href="<?php echo $action . '&page=' . $f_page['value']; ?>"><?php $x = explode(" ",$f_page['text']);echo $x[0]; ?></a></td>
                        <?php } ?>   
                        <?php } ?>                       
                        <a class="page_btn" href="<?php echo $action . '&page=' . (($page<count($pages))?($page+1):$page); ?>"><?php echo 'Next'?></a>                     
                        <label>Go to Page</label>
                        <select onchange="return SelectPage(this.value)" style="width:50px;">
                            <?php foreach ($pages as $f_page){?>
                            <option value="<?php echo $f_page['value']?>" <?php if ($f_page['value'] == $page){echo 'selected';}?>><?php echo $f_page['value']?></option>
                            <?php };?>
                        </select>
                        <script type="text/javascript">
							function SelectPage(page) {
								window.location.href="<?php echo $action; ?>&page=" + page;
							}
						</script>
                    </div>
                </div>
          </div>          
          <div class="hei10"></div>
        </div>
    <!-- product list start -->    
    <?php } ?>
	</div>
    <hr class="delimiter">
</div>
<script type="text/javascript">
 function sort_by(){
 	var sort=$("#sort_by").val();
		location='https://www.beststoreitems.com/index.php?controller=category&path=<?php echo $path?>&sort='+sort;
	 }
	 $(function(){
			$("#product_list_add li:nth-child(4n)").addClass("last");
		/*$("#breadcrumb i:last").remove();*/
	})
	var liList= $(".sorter a:not('.none')");
	var currentLink = document.location.href;
	var linkss= $(".sorter a:not('.one')");
	for(var i=0;i<liList.length;i++){
		if(currentLink.indexOf(linkss[i])!=-1) {
			$(liList[i]).siblings().removeClass("selected");
			$(liList[i]).addClass("selected");
		}
	}	
</script>