
<?php \Laravel\Section::start('content'); ?>

<div class="wrapper pageType pageCategorie">

	<div class="left title">
		<div class="chemin">
			<a href="<?php echo  URL::to('/'); ; ?>" title="<?php echo  __('site.accueil') ; ?>"><?php echo  __('site.accueil') ; ?></a> <i class="icon-angle-right"></i> <a href="<?php echo  URL::to_action('home@categorie', array($categorie->id, GeneralFunctions::cleanstring($categorie->descLocale()->name))) ; ?>" title="<?php echo  ucwords(strtolower($categorie->descLocale()->name)) ; ?>"><?php echo  ucwords(strtolower($categorie->descLocale()->name)) ; ?></a>
		</div>
		
		<h1><?php echo $categorie->descLocale()->name; ?></h1>
	</div>
	
	<?php if($produits && count($produits)>=1): ?>
	<div class="right filter">
		<div class="filter-container">
			<div class="right barre1"></div>
			<div class="right barre2"></div>
			<div class="clear"></div>
			<div class="types right">
				<?php echo __('site.filtre1'); ?><br/>
				<a href="#" class="filterChoice tooltipType left typeH sprite" data-filter="homme" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="<?php echo __('site.filtre2'); ?>"></a>
				<a href="#" class="filterChoice tooltipType left typeF sprite" data-filter="femme" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="<?php echo __('site.filtre3'); ?>"></a>
			</div>
			<div class="tailles right">
				<?php echo __('site.filtre4'); ?><br/>
				<?php foreach($tailles as $t): ?>
				<a href="#" class="filterChoice left circle" data-filter="<?php echo $t->name; ?>"><?php echo $t->name; ?></a>
				<?php endforeach; ?>
			</div>
		</div>
	</div>
	<?php endif; ?>
	<div class="clear"></div>
		
	<div class="row-fluid">
	<?php if($produits && count($produits)>=1): ?>
		<div class="resultatsFilter">
			<?php $i = 0; ?>
			<?php foreach($produits as $p): ?>
			<?php $i++; ?>
			<div class="produit_min span3<?php echo ($i%5==0) ? ' productFirst' : '' ?><?php echo ($p->homme=='y') ? ' homme' : '' ?><?php echo ($p->femme=='y') ? ' femme' : '' ?><?php foreach($p->tailles as $t){ echo ' '.$t->taille->name; } ?>">
				<a href="<?php echo  URL::to_action('produits@index', array($p->id, GeneralFunctions::cleanstring($p->nom))) ; ?>" title="Produit" class="photo">
					<?php if($p->miniature): ?>
						<img src="<?php echo  URL::to_action('photoproduit',array('235','200',$p->miniature)); ; ?>" alt="" />
					<?php else: ?>
						<img src="http://placehold.it/235x200&text=Parking+Clothes">
					<?php endif; ?>
				</a>
				<div class="left titleP">
					<a href="<?php echo  URL::to_action('produits@index', array($p->id, GeneralFunctions::cleanstring($p->nom))) ; ?>" class="name"><strong><?php echo $p->nom; ?></strong></a>
					<a href="<?php echo  URL::to_action('home@categorie', array($p->category->id, GeneralFunctions::cleanstring($p->category->descLocale()->name))) ; ?>" class="type"><?php echo $p->category->descLocale()->name; ?></a>
				</div>
				<div class="right price">
					<div class="cursor"></div>
					<strong><?php echo  str_replace('.',',',$p->prix_ttc) ; ?>&euro;</strong>
				</div>
			</div>
			<?php if($i==5) $i=1; ?>
            <?php endforeach; ?>
		</div>
		<div id="destination"></div>
		
		<script type="text/javascript">
			// Action lors d'un filtre
			$('.filterChoice').each(function(){
				$(this).on('click',function(e){
					e.preventDefault();
					
					if($(this).hasClass('active'))
					{
						$(this).removeClass('active');
						$('#destination div.produit_min').show().appendTo('.resultatsFilter');
						$('.resultatsFilter div.produit_min:nth-child(4n+1)').addClass('productFirst');
					}
					else
					{
						// On gère la couleur sur le filtre sélectionné
						$('.filterChoice').removeClass('active');
						$(this).addClass('active');
						
						// On récupère tout les produits cachés (dans #destination) pour les afficher à nouveau
						$('#destination div.produit_min').appendTo('.resultatsFilter');
						
						// On cache tous les produits et ré-affiche les bons
						$('.resultatsFilter div.produit_min').removeClass('productFirst').hide();
						$('.'+$(this).attr('data-filter')).show();
						
						// On déplace dans #destination les produits cachés (pour la gêne occasionnée)
						$('.resultatsFilter div.produit_min').each(function(){
							if($(this).is(':hidden'))
							{
								$(this).appendTo('#destination');
							}
						});
						
						// On restructure les produits
						$('.resultatsFilter div.produit_min:nth-child(4n+1)').addClass('productFirst');
					}
				});
			});
		</script>
	<?php else: ?>
		<p><?php echo  __('site.error_categ') ; ?><br/><br/><br/><br/></p>
	<?php endif; ?>
	</div>
	<div class="clear"></div>

</div>
<div class="clear"></div>
		
<?php \Laravel\Section::stop(); ?>
<?php echo view('template')->with(get_defined_vars())->render(); ?>