<?php echo $header; ?>
<div class="display_block">

    <div class="sixteen columns breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
        <?php } ?>
    </div>
</div>

<?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <h1><?php echo $heading_title; ?></h1>
  <b><?php echo $text_critea; ?></b>
  <div class="content">
    <p>
	   <div class="search_criteria">
          <div class="title_search">
            <?php echo $entry_search; ?>
          </div>
          <div class="input_search">
            <?php if ($search) { ?>
      <input type="text" name="search" value="<?php echo $search; ?>" />
      <?php } else { ?>
      <input type="text" name="search" value="<?php echo $search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '000000'" style="color: #999;" />
      <?php } ?>
          </div>

          <div class="dropdown_search">
            <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>
          </div>

          <div class="checkbox_search">
              <?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>
          </div>
          <div class="clear"></div>
      </div>
	  
	  
    </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) { ?>

    <!--Inicio inclusão pager.php--> 
            <div class="product-filter">
				<div class="sort">
					<?php echo $text_sort; ?>
					<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 class="limit">
					<?php echo $text_limit; ?>
					<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 class="product-compare"><a href="<?php echo $compare; ?>" id="compare-total"><?php echo $text_compare; ?></a></div>
				<div class="display">
					<div class="f_left"><?php echo $text_display; ?></div>
					<span class="display-list">&nbsp;</span>
					<a class="display-grid" onclick="display('grid');"></a>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
            <!--fim inclusão page.php-->


    <div class="product-grid hide">
        <!--Inicio require list view grid. php-->
				<?php
					$col3 = 1;
					$col2 = 1;
                    foreach ($products as $k => $product) { ?>
						<div class="four columns product_wrapper count_3cols_col_<?php echo $col3; ?> count_2cols_col_<?php echo $col2; ?>">
							<div class="product">
								<?php if ($product['thumb'] == '') { ?>
									<div class="image product-image-wrapper">
										<?php if ( $sale !== 'disable') : ?>
											<span class="product_sticker sticker_sale sticker_onsale_<?php echo $saleposition; ?> <?php echo ($sale ? ($product['special'] ? 'sticker_display' : 'sticker_display_none') : 'sticker_display_none'); ?>"></span>
										<?php endif; ?>
										<?php if ( $video !== 'disable') : ?>
											<span class="product_sticker sticker_video sticker_video_<?php echo $videoposition; ?> <?php echo ($video ? (($product['youtube_video'][0] !== '') ? 'sticker_display' : 'sticker_display_none') : 'sticker_display_none'); ?>"></span>
										<?php endif; ?>
										<a style="display: block;" class="img_conteiner" href="<?php echo $product['href']; ?>">
											<img class="scale-with-grid image-<?php echo $product['product_id']; ?>" src="image/data/sem-imagem.png" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" />
											<?php if ($product['popup']) { ?>
												<div class="roll_over_img">
													<img class="scale-with-grid" src="<?php echo $product['popup']; ?>" alt="<?php echo $product['name']; ?>" />
												</div>
											<?php } ?>
											<div class="product-image-wrapper-hover"></div>
										</a>
									</div>
								<?php } else { ?>
									<div class="image product-image-wrapper">
										<?php if ( $sale !== 'disable') : ?>
											<span class="product_sticker sticker_sale sticker_onsale_<?php echo $saleposition; ?> <?php echo ($sale ? ($product['special'] ? 'sticker_display' : 'sticker_display_none') : 'sticker_display_none'); ?>"></span>
										<?php endif; ?>
										<?php if ( $video !== 'disable') : ?>
											<span class="product_sticker sticker_video sticker_video_<?php echo $videoposition; ?> <?php echo ($video ? (($product['youtube_video'][0] !== '') ? 'sticker_display' : 'sticker_display_none') : 'sticker_display_none'); ?>"></span>
										<?php endif; ?>
										<a style="display: block;" class="img_conteiner" href="<?php echo $product['href']; ?>">
											<img class="scale-with-grid image-<?php echo $product['product_id']; ?>" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" />
											<?php if ($product['popup']) { ?>
												<div class="roll_over_img">
													<img class="scale-with-grid" src="<?php echo $product['popup']; ?>" alt="<?php echo $product['name']; ?>" />
												</div>
											<?php } ?>
											<div class="product-image-wrapper-hover"></div>
										</a>
									</div>
								<?php } ?>
								<div class="wrapper-hover">
									<div class="description"><?php echo $product['description']; ?></div>
									<?php if ($product['price']) { ?>
										<div class="product-price">
											<div class="price">
												<?php if (!$product['special']) { ?>
												<span><?php echo $product['price']; ?></span>
												<?php } else { ?>
												<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
												<?php } ?>
												<?php if ($product['tax']) { ?>
												<br />
												<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
												<?php } ?>
											</div>
										</div>
									<?php } ?>
									<div class="product-name">
										<div class="name">
											<a href="<?php echo $product['href']; ?>"><?php echo $product['name-main']; ?></a>
										</div>
										<div class="cart">
											<a onclick="addToCartFly('<?php echo $ajaxcart; ?>', '<?php echo $product['product_id']; ?>');"></a>
										</div>
									</div>
								</div>
                            </div>
					    </div>
						<?php
							$col3 ++;
							$col2 ++;
							if ($col3 == 4 ) {$col3 = 1;}
							if ($col2 == 3 ) {$col2 = 1;}
					}
				        ?>
				<!--Fim require list view grid.php-->		
    </div>
    <div class="product-list hide">
        <!--Inicio require list view list.php-->
				<?php foreach ($products as $product) { ?>
					<div class="product">
						<?php if ($product['thumb'] == '') { ?>
                            <div class="image product-image-wrapper">
								<span class="product_sticker sticker_onsale_top_left <?php echo ($product['special']) ? 'sticker_onsale_display' : 'sticker_onsale_display_none'; ?>"></span>

								<a style="display: block;" class="img_conteiner" href="<?php echo $product['href']; ?>">
									<img class="scale-with-grid" src="image/data/sem-imagem.png" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" />
									<div class="product-image-wrapper-hover"></div>
								</a>
							</div>
	
						<?php } else { ?>
							<div class="image product-image-wrapper">
								<span class="product_sticker sticker_onsale_top_left <?php echo ($product['special']) ? 'sticker_onsale_display' : 'sticker_onsale_display_none'; ?>"></span>
								<a style="display: block;" class="img_conteiner" href="<?php echo $product['href']; ?>">
									<img class="scale-with-grid" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" />
									<div class="product-image-wrapper-hover"></div>
								</a>
							</div>
						<?php } ?>
						<div class="right">
							<div class="name">
								<a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
							</div>
							<div class="description"><?php echo $product['description']; ?></div>
							<div class="overflow_hidden">
								<?php if ($product['price']) { ?>
									<div class="product-price">
										<div class="price">
											<?php if (!$product['special']) { ?>
												<span><?php echo $product['price']; ?></span>
											<?php } else { ?>
												<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
											<?php } ?>
											<?php if ($product['tax']) { ?>
												<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
											<?php } ?>
										</div>
									</div>
								<?php } ?>
								<?php if ($product['rating']) { ?>
									<div class="rating"><img src="catalog/view/theme/<?php echo $this->config->get('config_template'); ?>/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
								<?php } ?>
								<div class="listing_cart">
									<input class="listing_button" type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" />
								</div>
							</div>
							<div class="overflow_hidden">
                                <div class="wishlist"><a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a></div>
								<div class="compare"><a onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a></div>
							</div>
						</div>
                    </div>
				<?php } ?>
				<!--Fim require list view list.php-->	
    </div>

    <div class="pagination"><?php echo $pagination; ?></div>
  <?php } else { ?>
  <div class="content"><?php echo $text_empty; ?></div>
  <?php }?>
  <?php echo $content_bottom; ?></div>
<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').addClass('hide');
        $('.product-list').removeClass('hide');

        $('.display').html('<div class="f_left"><?php echo $text_display; ?><\/div> <span class="display-list">&nbsp;<\/span>  <a class="display-grid" onclick="display(\'grid\');">&nbsp;</a><div class="clear"><\/div>');

        $.totalStorage('display', 'list'); 
    } else {
        $('.product-list').addClass('hide');
        $('.product-grid').removeClass('hide');
        $('.display').html('<div class="f_left"><?php echo $text_display; ?><\/div> <a class="display-list" onclick="display(\'list\');">&nbsp;</a>  <span class="display-grid"><\/span><div class="clear"><\/div>');

        $.cookie('display', 'grid');

        var colH = 0;
        $('.product-grid .grid_row').each(function(){
            colH = 0;
            $('.grid_item', $(this)).each(function(){
                if(parseInt($(this).height()) > colH){
                    colH = $(this).height();
                }
            });
            $('.grid_item', $(this)).height(colH);
        });
    }
}

view = $.totalStorage('display');

if (view) {
    display(view);
} else {
    display('grid');
}

//--></script> 
<?php echo $footer; ?>