<?php echo $header; ?>
<section class="main-container col2-right-layout">
    <div class="breadcrumbs">
        <ul>
            <?php foreach ($breadcrumbs as $breadcrumb) { ?>
            <li class="category11"><span><?php echo $breadcrumb['separator']; ?></span><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a> </li>
            <?php } ?>
        </ul>
    </div>
    <article class="col-main">
        <div id="content">
            <?php echo $content_top; ?>
            <div class="page-title">
                <h2><?php echo $heading_title; ?></h2>
             
            </div>
                 <b><?php echo $text_critea; ?></b>
               <p><?php echo $entry_search; ?>
      <?php if ($search) { ?>
      <input type="text"  class="input-text" name="search" value="<?php echo $search; ?>" />
      <?php } else { ?>
      <input type="text" class="input-text" name="search" value="<?php echo $search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '000000'" style="color: #999;" />
      <?php } ?>
      <select name="category_id">
        <option value="0"><?php echo $text_category; ?></option>
        <?php foreach ($categories as $category_1) { ?>
        <?php if ($category_1['category_id'] == $category_id) { ?>
        <option value="<?php echo $category_1['category_id']; ?>" selected="selected"><?php echo $category_1['name']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $category_1['category_id']; ?>"><?php echo $category_1['name']; ?></option>
        <?php } ?>
        <?php foreach ($category_1['children'] as $category_2) { ?>
        <?php if ($category_2['category_id'] == $category_id) { ?>
        <option value="<?php echo $category_2['category_id']; ?>" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_2['name']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $category_2['category_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_2['name']; ?></option>
        <?php } ?>
        <?php foreach ($category_2['children'] as $category_3) { ?>
        <?php if ($category_3['category_id'] == $category_id) { ?>
        <option value="<?php echo $category_3['category_id']; ?>" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_3['name']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $category_3['category_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category_3['name']; ?></option>
        <?php } ?>
        <?php } ?>
        <?php } ?>
        <?php } ?>
      </select>
      <?php if ($sub_category) { ?>
      <input type="checkbox" name="sub_category" value="1" id="sub_category" checked="checked" />
      <?php } else { ?>
      <input type="checkbox" name="sub_category" value="1" id="sub_category" />
      <?php } ?>
      <label for="sub_category"><?php echo $text_sub_category; ?></label>
    </p>
    <?php if ($description) { ?>
    <input type="checkbox" name="description" value="1" id="description" checked="checked" />
    <?php } else { ?>
    <input type="checkbox" name="description" value="1" id="description" />
    <?php } ?>
    <label for="description"><?php echo $entry_description; ?></label>
  </div>
  <div class="buttons">
    <div class="right"><input type="button" value="<?php echo $button_search; ?>" id="button-search" class="button" /></div>
  </div>
  <h2><?php echo $text_search; ?></h2>
            
            

            <?php if ($products) { ?>
            <div class="product-compare"><a href="<?php echo $compare; ?>" id="compare-total"><?php echo $text_compare; ?></a></div>
            <div class="toolbar">
                <div class="sorter">
                    <div class="sort-by">
                        <label class="left"><?php echo $text_sort; ?></label>
                        <div class="dropdown left dropdown-select"> 
                            <select onchange="location = this.value;">
                                <?php foreach ($sorts as $sorts) { ?>
                                <?php if ($sorts['value'] == $sort . '-' . $order) { ?>
                                <option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
                                <?php } else { ?>
                                <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
                                <?php } ?>
                                <?php } ?>
                            </select>
                        </div>
                    </div>  

                    <div class="view-mode"> <label><?php echo $text_display; ?></label>
                        <span class="button button-active button-grid first" title="Grid"></span>
                        <a class="button button-list last" title="List" href="#"></a> 
                    </div>
                </div>
                <div class="pager">
                    <div class="pages">
                        <?php echo $pagination; ?>
                    </div>
                    <div class="limiter">
                        <label><?php echo $text_limit; ?> </label>
                        <div class="dropdown left dropdown-select"> 
                            <select onchange="location = this.value;">
                                <?php foreach ($limits as $limits) { ?>
                                <?php if ($limits['value'] == $limit) { ?>
                                <option value="<?php echo $limits['href']; ?>" selected="selected"><?php echo $limits['text']; ?></option>
                                <?php } else { ?>
                                <option value="<?php echo $limits['href']; ?>"><?php echo $limits['text']; ?></option>
                                <?php } ?>
                                <?php } ?>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="category-products">

                <ul class="products-grid first odd">
                    <?php $i=1; foreach ($products as $product) { ?>   
                  
                    
                    
                    <li class="item   <?php if($i%3==0) echo 'last';  ?>  "> 
                                <?php if ($product['thumb']) { ?>
              <a href="<?php echo $product['href']; ?>" title="<?php echo $product['name']; ?>" class="product-image">
               
                    <?php if ($product['price'] && $product['special']) { ?>
                         <div class="sale-label sale-top-right"><?php echo $this->language->get('lang_sale'); ?> </div>
                  <?php } ?>
                <img class="small-image" src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>"> 
                 <?php 
                 if(isset($image)){   ?>
                   <?php $show_24wg=1; foreach ($image as $hover) {
                       if($product['product_id']==$hover['hover_id'])
                       { ?>
                <img class="thumbnail" src="<?php echo $hover['mousehover'] ?>" alt="<?php echo $product['name']; ?>"> 
                <?php 
                  }
                  else{ if($show_24wg==1){ ?>
                 <img class="thumbnail" src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>"> 
                <?php }
                }
                $show_24wg=$show_24wg+1;
                }
                
                } else{ ?>
                 <img class="thumbnail" src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>"> 
                <?php  }
                 ?>  
             </a> 
              <?php } ?>
                        <a class="product-detail-bnt" rel="category-gallery" title="" href="<?php echo $product['href']; ?>">&nbsp;</a>
                        <div class="prod_image_detail">
                            <div class="inner">
                                <a class="product-name" href="<?php echo $product['href']; ?>" title="<?php echo html_entity_decode(substr($product['name'],0,22));?>"><?php echo html_entity_decode(substr($product['name'],0,22))."..";?></a>
                                <div class="rating">
                                    <div class="ratings">
                                        <div class="rating-box">
                                            <?php if ($product['rating']) { ?>
                                            <div class="rating"><img src="catalog/view/theme/vista/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
                                            <?php } ?>
                                        </div>
                                    </div>
                                </div>

                                <div class="price-box">
                                    <?php if ($product['price']) { ?>
                                    <?php if (!$product['special']) { ?>
                                    <span class="regular-price">
                                        <span class="price"> <?php echo $product['price']; ?></span>
                                    </span>

                                    <?php } else { ?>
                                    <span class="old-price">
                                        <span class="price"><?php echo $product['price']; ?></span>
                                    </span>

                                    <span class="regular-price">
                                        <span class="price"><?php echo $product['special']; ?></span>
                                    </span>
                                    <?php } ?>

                                    <?php } ?>


                                </div>

                            </div>
                            <div class="actions">
                                <button type="button" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button btn-cart" title="<?php echo $button_cart; ?>">
                                    <span><?php echo $button_cart; ?></span>
                                </button>
                                <span class="add-to-links">                           
                                    <a title="<?php echo $button_wishlist; ?>" class="button link-wishlist" onclick="addToWishList('<?php echo $product['product_id']; ?>');"><spen><?php echo $button_wishlist; ?></spen></a> 
                                    <a title="<?php echo $button_compare; ?>" class="button link-compare" onclick="addToCompare('<?php echo $product['product_id']; ?>');"><spen><?php echo $button_compare; ?></spen></a> 
                                </span>
                            </div>
                        </div>
                    </li>
                    <?php $i=$i+1;} ?>
                </ul>

                <ol style="display: none;" class="products-list" id="products-list"   >

                    <?php foreach ($products as $product) { ?>    
                    <li class="ajax_block_product first item">
                        <div class="product-image">
                                    <?php if ($product['thumb']) { ?>
              <a href="<?php echo $product['href']; ?>" title="<?php echo $product['name']; ?>" class="product-image">
               
                    <?php if ($product['price'] && $product['special']) { ?>
                         <div class="sale-label sale-top-right"><?php echo $this->language->get('lang_sale'); ?> </div>
                  <?php } ?>
                <img class="small-image" src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>"> 
                 <?php 
                 if(isset($image)){   ?>
                   <?php $show_24wg=1; foreach ($image as $hover) {
                       if($product['product_id']==$hover['hover_id'])
                       { ?>
                <img class="thumbnail" src="<?php echo $hover['mousehover'] ?>" alt="<?php echo $product['name']; ?>"> 
                <?php 
                  }
                  else{ if($show_24wg==1){ ?>
                 <img class="thumbnail" src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>"> 
                <?php }
                }
                $show_24wg=$show_24wg+1;
                }
                
                } else{ ?>
                 <img class="thumbnail" src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>"> 
                <?php  }
                 ?>  
             </a> 
              <?php } ?>
                            <a class="product-detail-bnt" rel="category-gallery" title="" href="<?php echo $product['href']; ?>">&nbsp;</a>
                        </div>
                        <div class="product-shop">
                            <h2 class="product-name">
                                <a class="product-name" href="<?php echo $product['href']; ?>" title="<<?php echo html_entity_decode(substr($product['name'],0,30));?>"><?php echo html_entity_decode(substr($product['name'],0,30))."..";?></a>
                            </h2>
                            <div class="rating">
                                <div class="ratings">
                                    <div class="rating-box">
                                        <?php if ($product['rating']) { ?>
                                        <div class="rating"><img src="catalog/view/theme/vista/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                            <div class="desc std">
                                <p itemprop="description" class="product-desc">
                                    <?php echo $product['description']; ?>
                                    <a class="link-learn" title="" href="<?php echo $product['href']; ?>"><?php echo $this->language->get('lang_learn_more_icon'); ?></a> 
                                </p> 
                            </div>
                            <div class="content_price item-price  " itemtype="http://schema.org/Offer" itemscope="" itemprop="offers">
                                <div class="price-box">
                                    <?php if ($product['price']) { ?>
                                    <?php if (!$product['special']) { ?>
                                    <span class="regular-price">
                                        <span class="price"> <?php echo $product['price']; ?></span>
                                    </span>
                                    <?php } else { ?>
                                    <span class="old-price">
                                        <span class="price"><?php echo $product['price']; ?></span>
                                    </span>
                                    <span class="regular-price">
                                        <span class="price"><?php echo $product['special']; ?></span>
                                    </span>
                                    <?php } ?>
                                    <?php } ?>
                                </div>
                            </div>
                            <div class="actions">
                                <button type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button btn-cart" title="<?php echo $button_cart; ?>">
                                    <span><?php echo $button_cart; ?></span>
                                </button>
                                <span class="add-to-links">                           
                                    <a title="<?php echo $button_wishlist; ?>" class="button link-wishlist" onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a> 
                                    <a title="<?php echo $button_compare; ?>" class="button link-compare" onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a> 
                                </span>
                            </div>
                        </div>
                    </li>
                    <?php } ?>
                </ol>  

            </div>
            <div class="bottom toolbar">
                <div class="toolbar">
                <div class="sorter">
                    <div class="sort-by">
                        <label class="left"></label>
                        <div class="dropdown left dropdown-select"> 
                            
                        </div>
                    </div>  

                    <div class="view-mode"> <label><?php echo $text_display; ?></label>
                        <span class="button button-active button-grid first" title="Grid"></span>
                        <a class="button button-list last" title="List" href="#"></a> 
                    </div>
                </div>
                <div class="pager">
                    <div class="pages">
                        <?php echo $pagination; ?>
                    </div>
                    <div class="limiter">
                     
                    </div>
                </div>
                </div>
            </div>
            <?php } ?>
          
       </div> 
    </article>
    <!--	///*///======    End Col Main  ========= //*/// -->
    <aside class="col-left sidebar">
        <?php echo $column_left; ?>

    </aside>
    <!--	///*///======    End Main Container  ========= //*/// -->
</section>







<script type="text/javascript"><!--
$('#content input[name=\'search\']').keydown(function(e) {
	if (e.keyCode == 13) {
		$('#button-search').trigger('click');
	}
});

$('select[name=\'category_id\']').bind('change', function() {
	if (this.value == '0') {
		$('input[name=\'sub_category\']').attr('disabled', 'disabled');
		$('input[name=\'sub_category\']').removeAttr('checked');
	} else {
		$('input[name=\'sub_category\']').removeAttr('disabled');
	}
});

$('select[name=\'category_id\']').trigger('change');

$('#button-search').bind('click', function() {
	url = 'index.php?route=product/search';
	
	var search = $('#content input[name=\'search\']').attr('value');
	
	if (search) {
		url += '&search=' + encodeURIComponent(search);
	}

	var category_id = $('#content select[name=\'category_id\']').attr('value');
	
	if (category_id > 0) {
		url += '&category_id=' + encodeURIComponent(category_id);
	}
	
	var sub_category = $('#content input[name=\'sub_category\']:checked').attr('value');
	
	if (sub_category) {
		url += '&sub_category=true';
	}
		
	var filter_description = $('#content input[name=\'description\']:checked').attr('value');
	
	if (filter_description) {
		url += '&description=true';
	}

	location = url;
});

function display(view) {
	if (view == 'list') {
		$('.product-grid').attr('class', 'product-list');
		
		$('.product-list > div').each(function(index, element) {
			html  = '<div class="right">';
			html += '  <div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '  <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '  <div class="compare">' + $(element).find('.compare').html() + '</div>';
			html += '</div>';			
			
			html += '<div class="left">';
			
			var image = $(element).find('.image').html();
			
			if (image != null) { 
				html += '<div class="image">' + image + '</div>';
			}
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
						
			html += '  <div class="name">' + $(element).find('.name').html() + '</div>';
			html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
				
			html += '</div>';
						
			$(element).html(html);
		});		
		
		$('.display').html('<b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display(\'grid\');"><?php echo $text_grid; ?></a>');
		
		$.totalStorage('display', 'list'); 
	} else {
		$('.product-list').attr('class', 'product-grid');
		
		$('.product-grid > div').each(function(index, element) {
			html = '';
			
			var image = $(element).find('.image').html();
			
			if (image != null) {
				html += '<div class="image">' + image + '</div>';
			}
			
			html += '<div class="name">' + $(element).find('.name').html() + '</div>';
			html += '<div class="description">' + $(element).find('.description').html() + '</div>';
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}	
					
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
						
			html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
			
			$(element).html(html);
		});	
					
		$('.display').html('<b><?php echo $text_display; ?></b> <a onclick="display(\'list\');"><?php echo $text_list; ?></a> <b>/</b> <?php echo $text_grid; ?>');
		
		$.totalStorage('display', 'grid');
	}
}

view = $.totalStorage('display');

if (view) {
	display(view);
} else {
	display('list');
}
//--></script> 
<?php echo $footer; ?>