function word(number)
{
	var left = number % 100;
	if (left >= 5 && left <= 20) return tovarov;
	if (left % 10 == 0) return tovarov;
	if (left % 10 == 1) return tovar;
	if (left % 10 >= 2 && left % 10 <= 4) return tovara;
	return tovarov;
}

$(document).ready(function()
{
	var count = $.cookie('count')
	if (count < 1) 
	{
		count = no;
		$('#makebuy a:first').replaceWith('<span class="buy">' + buy + '</span>');
		$('#clear').hide();
	}
	else
	{
		$('#makebuy span:first').replaceWith('<a href="buy.php" class="buy">' + buy + '</a>');
		$('#clear').show();
	}
	$('#count').html(count);
	$('#item').html(word(count));
});
function add(item_id)
{
	if ($.cookie('items') == null) $.cookie('items', item_id + ';');
	else $.cookie('items', $.cookie('items') + item_id + ';');
	var count = $.cookie('count');
	count++;
	$.cookie('count', count);
	if (count < 1) 
	{
		count = no;
		$('#makebuy a:first').replaceWith('<span class="buy">' + buy + '</span>');
		$('#clear').hide();
	}
	else
	{
		$('#makebuy span:first').replaceWith('<a href="buy.php" class="buy">' + buy + '</a>');
		$('#clear').show();
	}
	$('#cart').stop(true, true).animate({opacity: "0.1"}, 100).animate({opacity: "1.0"}, 100).animate({opacity: "0.1"}, 200).animate({opacity: "1.0"}, 200).animate({opacity: "0.1"}, 300).animate({opacity: "1.0"}, 300).animate({opacity: "0.1"}, 500).animate({opacity: "1.0"}, 1000);
	$('#count').html(count);
	$('#item').html(word(count));
}
function clear()
{
	$.cookie('items', null);
	$.cookie('count', null);
	$('#count').html(no);
	$('#makebuy a:first').replaceWith('<span class="buy">' + buy + '</span>');
	$('#clear').hide();
	$('#item').html(word(count));
}