{{ header }}
{% if journal3.get('pageTitlePosition') == 'top' %}
  <h1 class="title page-title {{ journal3.get('title_color_scheme') }}"><span class="page-title-text">{{ heading_title }}</span></h1>
{% endif %}
<div class="breadcrumbs {{ journal3.get('breadcrumbs_color_scheme') }}">
  <ul class="breadcrumb">
    {% for breadcrumb in breadcrumbs %}
      <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
    {% endfor %}
  </ul>
</div>
{{ journal3_top }}
<div id="product-search" class="container">
  <div class="row">{{ column_left }}
    {% if column_left and column_right %}
    {% set class = 'col-sm-6' %}
    {% elseif column_left or column_right %}
    {% set class = 'col-sm-9' %}
    {% else %}
    {% set class = 'col-sm-12' %}
    {% endif %}
    <div id="content" class="{{ class }}">
      {% if journal3.get('pageTitlePosition') == 'default' %}
      <h1 class="title page-title {{ journal3.get('title_color_scheme') }}">{{ heading_title }}</h1>
      {% endif %}
      {{ content_top }}
      <h2 class="title search-criteria-title">{{ entry_search }}</h2>
      <div class="search-form">
        <div class="inputs">
          <input type="text" name="search" value="{{ search }}" placeholder="{{ text_keyword }}" id="input-search" class="form-control" aria-label="{{ text_keyword }}" />
          <select name="category_id" class="form-control">
            <option value="0">{{ text_category }}</option>
            {% for category_1 in categories %}
            {% if category_1.category_id == category_id %}
            <option value="{{ category_1.category_id }}" selected="selected">{{ category_1.name }}</option>
            {% else %}
            <option value="{{ category_1.category_id }}">{{ category_1.name }}</option>
            {% endif %}
            {% for category_2 in category_1.children %}
            {% if category_2.category_id == category_id %}
            <option value="{{ category_2.category_id }}" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ category_2.name }}</option>
            {% else %}
            <option value="{{ category_2.category_id }}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ category_2.name }}</option>
            {% endif %}
            {% for category_3 in category_2.children %}
            {% if category_3.category_id == category_id %}
            <option value="{{ category_3.category_id }}" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ category_3.name }}</option>
            {% else %}
            <option value="{{ category_3.category_id }}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ category_3.name }}</option>
            {% endif %}
            {% endfor %}
            {% endfor %}
            {% endfor %}
          </select>
        </div>
        <div class="checkbox search-category-checkbox">
          <label class="checkbox-inline">
            {% if sub_category %}
            <input type="checkbox" name="sub_category" value="1" checked="checked" />
            {% else %}
            <input type="checkbox" name="sub_category" value="1" />
            {% endif %}
            {{ text_sub_category }}</label>
        </div>
        <div class="checkbox search-description-checkbox">
          <label class="checkbox-inline">
            {% if description %}
              <input type="checkbox" name="description" value="1" id="description" checked="checked" />
            {% else %}
              <input type="checkbox" name="description" value="1" id="description" />
            {% endif %}
            {{ entry_description }}</label>
        </div>
      </div>
      <div class="buttons clearfix">
        <div class="pull-right"><button id="button-search" class="btn btn-primary"><span>{{ button_search }}</span></button></div>
      </div>
      <h2 class="title search-products-title">{{ text_search }}</h2>
      <div class="main-products-wrapper">
      {% if products %}
      {% if journal3.get('sortBarStatus') %}
      <div class="products-filter">
        <div class="grid-list">
          <button id="btn-grid-view" class="view-btn {% if journal3.get('globalProductView') == 'grid' %}active{% endif %}" {% if journal3.is_desktop %}data-toggle="tooltip-hover"{% endif%} title="{{ button_grid }}" data-view="grid" aria-label="{{ button_grid }}"></button>
          <button id="btn-list-view" class="view-btn {% if journal3.get('globalProductView') == 'list' %}active{% endif %}" {% if journal3.is_desktop %}data-toggle="tooltip-hover"{% endif%} title="{{ button_list }}" data-view="list" aria-label="{{ button_list }}"></button>
          <a href="{{ compare }}" id="compare-total" class="compare-btn" title="{{ text_compare }}">{{ journal3_text_compare }}</a>
        </div>
        <div class="select-group">
          <div class="input-group input-group-sm sort-by">
            <label class="input-group-addon" for="input-sort">{{ text_sort }}</label>
            <select id="input-sort" class="form-control" data-filter-sort="{{ journal3_filter_sort }}" data-filter-order="{{ journal3_filter_order }}">
              {% for sorts in sorts %}
              {% if sorts.value == '%s-%s'|format(sort, order) %}
              <option value="{{ sorts.href }}" selected="selected">{{ sorts.text }}</option>
              {% else %}
              <option value="{{ sorts.href }}">{{ sorts.text }}</option>
              {% endif %}
              {% endfor %}
            </select>
          </div>
          <div class="input-group input-group-sm per-page">
            <label class="input-group-addon" for="input-limit">{{ text_limit }}</label>
            <select id="input-limit" class="form-control" data-filter-limit="{{ journal3_filter_limit }}">
              {% for limits in limits %}
              {% if limits.value == limit %}
              <option value="{{ limits.href }}" selected="selected">{{ limits.text }}</option>
              {% else %}
              <option value="{{ limits.href }}">{{ limits.text }}</option>
              {% endif %}
              {% endfor %}
            </select>
          </div>
        </div>
      </div>
      {% endif %}
      <div class="main-products main-products-style product-{{ journal3.get('globalProductView') }} {{ journal3.get('globalProductGridType') }}-grid">
        {{ products }}
      </div>
      <div class="row pagination-results">
        <div class="col-sm-6 text-left">{{ pagination }}</div>
        <div class="col-sm-6 text-right">{{ results }}</div>
      </div>
      {% else %}
      <p>{{ journal3_is_oc4 ? text_no_results : text_empty }}</p>
      <div class="buttons">
        <div class="pull-right"><a href="{{ continue }}" class="btn btn-primary">{{ button_continue }}</a></div>
      </div>
      {% endif %}
      </div>
      {{ content_bottom }}</div>
    {{ column_right }}</div>
</div>
<script type="text/javascript"><!--
$('#button-search').bind('click', function() {
  {% if journal3_is_oc4 %}
  url = 'index.php?route=product/search&language={{ language }}';
  {% else %}
  url = 'index.php?route=product/search';
  {% endif %}

	var search = $('#content input[name=\'search\']').prop('value');

	if (search) {
		url += '&search=' + encodeURIComponent(search);
	}

	var category_id = $('#content select[name=\'category_id\']').prop('value');

	if (category_id > 0) {
		url += '&category_id=' + encodeURIComponent(category_id);
	}

	var sub_category = $('#content input[name=\'sub_category\']:checked').prop('value');

	if (sub_category) {
		url += '&sub_category=true';
	}

	var filter_description = $('#content input[name=\'description\']:checked').prop('value');

	if (filter_description) {
		url += '&description=true';
	}

	location = url;
});

$('#content input[name=\'search\']').bind('keydown', function(e) {
	if (e.keyCode == 13) {
		$('#button-search').trigger('click');
	}
});

$('select[name=\'category_id\']').on('change', function() {
	if (this.value == '0') {
		$('input[name=\'sub_category\']').prop('disabled', true);
	} else {
		$('input[name=\'sub_category\']').prop('disabled', false);
	}
});

$('select[name=\'category_id\']').trigger('change');
--></script>
{{ footer }}
