/************************************************************************/
/*						FONCTIONS JAVASCRIPT GLOBALES					*/
/************************************************************************/
var Global = {
	makeTableCSS : function(){
		$('table.table').each( function(){
			var i = 0;
			$(this).find('thead tr').each(function(){
				$(this).addClass('thead');
				$(this).find('td').each(function(){
					$(this).addClass('p5 souligne');
				});
			});
			$(this).find('tbody tr').each(function(){
				$(this).addClass('hover');
				i%2==0 ? $(this).addClass('color1') : $(this).addClass('color2');
				i++;
			})
		});
	}
}

var Products = {
	showCategory : function(IdCategory){
		var Elt = $('#category_'+IdCategory);
		$(Elt).is(':visible') ? $(Elt).slideUp('fast') : $(Elt).slideDown();
		return false;
	},
	addCartProduct : function(IdProduct, Quantity){
		$.ajax({
			type: 'post',
			url: 'vad/products.php',
			data: {
				action: 'addCartProduct',
				id_product: IdProduct,
				quantity: Quantity
			},
			success: function(xhr){
				var xhr = xhr.split('xhr=>')[1];
				Products.reloadCart();
			}
		})
	},
	reloadCart : function(){
		$.ajax({
			type: 'post',
			url: 'vad/products.php',
			data: {
				action: 'reloadCart'
			},
			success: function(xhr){
				var xhr = xhr.split('xhr=>')[1];
				$('#cart').html(xhr);
			}
		})
	}
}

$(window).load( function(){ $('#workspace').css('minHeight',($(window).height()-148)+'px') });
$(window).resize( function(){ $('#workspace').css('minHeight',($(window).height()-148)+'px') });
