function update_small_cart(q, a) {
	var small_cart = $("div.small_cart");
	var cart_no_pr = $("#small_cart_no_products");

	if (small_cart.is(":hidden") && q != 0) {
		small_cart.removeClass("hidden");
		cart_no_pr.addClass("hidden");
	}
	else if (q == 0 && cart_no_pr.is(":hidden")) {
		small_cart.addClass("hidden");
		cart_no_pr.removeClass("hidden");
		return;
	}
	var products_word = get_products_word(q);
	small_cart.find("#sc_quantity").html(q);
	small_cart.find("#sc_amount").html(a);
	small_cart.find("#sc_products_word").html(products_word);
}


function get_products_word(q) {
	var p_word1 = "товар";
	var p_word2 = "товара";
	var p_word3 = "товаров";
	
	var p_ar2 = [2, 3, 4];
	var p_ar3 = [11, 12, 13, 14];

	if (q == 1) return p_word1;
	if (in_array(q, p_ar2)) return p_word2;
	if (in_array(q, p_ar3)) return p_word3;
	if (in_array(q % 100, p_ar3)) return p_word3;
	if (in_array(q % 10, p_ar2)) return p_word2;
	if (q % 10 == 1) return p_word1;
	return p_word3;
}


function remove_cart() {
	var cart = $(".cart");
	cart.html("<b>Ваша корзина пуста</b>");
}


function in_array(v ,array) {
	for (i in array) {
		if (array[i] == v) {
			return true;
		}
	}
	return false;
}


function remove_cart_record(id) {
	$("#cart_record_"+id).remove();
}