function goodsCalc(obj, igoods, isize, icolor)
{
	var goods_id = "#goods-" + igoods;

	var price_all = $(goods_id + " .price-all").text();
	var price_xxl = $(goods_id + " .price-xxl").text();

	var quantity = 0;

	var subtotal = 0;
	$(goods_id + " input.c" + icolor).each(function() {
		quantity = Number(this.value.replace(/\D/g, ''));
		if(quantity < 0 || isNaN(quantity))
			quantity = 0;

		subtotal = subtotal + quantity * (!$(this).hasClass("xxl") ? price_all : price_xxl);
	});

	$(goods_id + " .sum-c" + icolor).text((subtotal > 0 ? subtotal : ""));

	subtotal = 0;
	$(goods_id + " input.s" + isize).each(function() {
		quantity = Number(this.value.replace(/\D/g, ''));
		if(quantity < 0 || isNaN(quantity))
			quantity = 0;

		subtotal = subtotal + quantity * (!$(this).hasClass("xxl") ? price_all : price_xxl);
	});


	$(goods_id + " .sum-s" + isize).text((subtotal > 0 ? subtotal : ""));

	subtotal = 0;
	$(goods_id + " input").each(function() {
		quantity = Number(this.value.replace(/\D/g, ''));
		if(quantity < 0 || isNaN(quantity))
			quantity = 0;

		subtotal = subtotal + quantity * (!$(this).hasClass("xxl") ? price_all : price_xxl);
	});

	$(goods_id + " .total").text(subtotal);


	// общий итог
	subtotal = 0;
	var total = 0;
	$(".order .total").each(function() {
		subtotal = Number($(this).text());
		if(subtotal < 0 || isNaN(subtotal))
			subtotal = 0;

		total = total + subtotal;
	});

	$("#total").text(total);

	if ($("#discount"))
	{
		$("#subtotal").text(total);

		var discount = Number($("#discount").text().replace(/\D/g, ''));
		$("#total").text(total * (100 - discount) / 100);
	}
}
