function searchTag(elem)
{
	document.getElementById('keyword').value = elem.getAttribute('full');
	document.forms['search'].submit();
}
$(document).ready(function()
{
	$(".the_item .icon_color").hover(
		function()
		{
			$(this).html('<div class="balloon iepng"><div class="wrap">У товара доступны цветовые вариации.</div></div>');
		},
		function()
		{
   $(".balloon", $(this)).remove();
		}
	);
	$(".the_item .icon_photo").hover(
		function()
		{
			$(this).html('<div class="balloon iepng"><div class="wrap">Как это выглядит вживую?</div></div>');
		},
		function()
		{
   $(".balloon", $(this)).remove();
		}
	);
	$(".the_item .icon_heart").hover(
		function()
		{
			$(this).append('<div class="balloon iepng"><div class="wrap">Добавить в избранное.</div></div>');
		},
		function()
		{
			$(".balloon", $(this)).remove();
		}
	);
    $(".icon_heart").click(function(e){
        e.preventDefault();
        if ($(e.target).hasClass("fav"))
        {
            $.post('/utils/fav_remove', {tov_id: e.target.getAttribute('tov_id')}, function(data){
                $(e.target).removeClass("fav");
                $('#favorites_total').html(data);
            });
        }
        else
        {
            $.post('/utils/fav_add', {tov_id: e.target.getAttribute('tov_id')}, function(data){
                $(e.target).addClass("fav");
                $('#favorites_total').html(data);
                var test = read_cookie('cat_fav');
                if (test != 'no')
                {
        			cast_blanket($("#ww_favadd"), 0);
                    create_cookie('cat_fav', 'no', 365);
                }
            });
        }
    });
    $('#add_to_favorites_link').click(function(e)
    {
        e.preventDefault();
        if ($(e.target).attr("fav") == '1')
        {
            $.post('/utils/fav_remove', {tov_id: e.target.getAttribute('tov_id')}, function(data){
                $('#favorites_total').html(data);
                $(e.target).html("Добавить в избранное").attr("fav", 0);
            })
        }
        else
        {
            $.post('/utils/fav_add', {tov_id: e.target.getAttribute('tov_id')}, function(data){
                $(e.target).html("Убрать из избранного").attr("fav", 1);
                $('#favorites_total').html(data);
                var test = read_cookie('cat_fav');
                if (test != 'no')
                {
                    cast_blanket($("#ww_favadd"), 0);
                }
            })
        }
    });
});
