
$(document).ready(function(){

	
	//Fonctions
	function catalogBorder(){
		var parent = '.productsList';
		var el = '.short_product';
		var size = $(parent).find(el).size();
		var horizontale = 3;
		var verticale = size / horizontale;
		if(parseInt(verticale) != verticale)
			verticale = parseInt(verticale) + 1;
		var ligne = '<div class="catalog_ligne"></div>';
		
		var i = 1;
		$(parent).find(el).each(function(){
			if((i / horizontale) == 1)
			{
				ligne = '<div class="catalog_ligne">'+ '<div class="short_product">' + $(this).html() + '</div><div class="short_product">' + $(this).prev().html() + '</div><div class="short_product">' + $(this).prev().prev().html() +'</div></div>';
				$(this).parent().append(ligne);
				i = 0;
			}
			
			i++;
		});
		if($('.catalogue_ligne').size() < verticale)
		{
			var sh_1 = $(parent + ' > ' + el).eq((horizontale * (verticale - 1))).html();
			var sh_2 = $(parent + ' > ' + el).eq((horizontale * (verticale - 1)) + 1).html();
			var sh_3 = $(parent + ' > ' + el).eq((horizontale * (verticale - 1)) + 2).html();
			if(sh_1 == null)
				sh_1 = '';
			if(sh_2 == null)
				sh_2 = '';
			if(sh_3 == null)
				sh_3 = '';
				
			ligne = '<div class="catalog_ligne">'+ '<div class="short_product">' + sh_1 + '</div><div class="short_product">' + sh_2 + '</div><div class="short_product">' + sh_3 +'</div></div>';
			$(parent).append(ligne);
		}
		
		$(parent + ' > ' + el).each(function(){$(this).remove();});
	}
	
	$('.js_update_cart').each(function(){
		var value = $(this).find('.js_update_value').html();
		if( value == ''){
			value = 0;
			$(this).find('.js_update_value').html('0');
		}
		if(value > 1)
			$(this).html($('.js_update_cart').html() + 's');
	});
});

