$(document).ready(function()
{
	// tell friends window showup
	$(".ww_abuse").bind("click", function(e)
		{
			e.preventDefault();
			cast_blanket($("#ww_abuse"), 0);
			if ($.browser.msie && $.browser.version <= 6)
			{
				$("#ww_abuse").css({top: 10});
				var ww_abuse_t = $("#ww_abuse").css("top");
				var ww_abuse_l = $("#ww_abuse").css("left");
				doc_h = $(document).height() - $(window).height();
				$(window).bind("scroll", function()
					{
						$("#ww_abuse").css({top: $(window).scrollTop() + 10});
						if ($(window).scrollTop() > doc_h)
						{
							$(window).scrollTop(doc_h);
						}
					}
				);
			}
		}
	);
	$("#ww_abuse .close").bind("click", function(e)
		{
			e.preventDefault();
			remove_blanket($("#ww_abuse"), 0);
		}
	);

	$("#send_abuse").bind("click", function(e)
    {
                e.preventDefault();
                $('#ww_abuse').mask('Отправляем...');

                $.post("/utils/send_abuse", $('#abuse_form').serializeArray(),
                        function(data)
                        {
                            $('#ww_abuse').unmask();
                            if (data == '1')
                            {
                                $.gritter.add({
                                       title: 'Отлично!',
                                       text: 'Твое сообщение отправлено',
                                       image: '/images/accept.png',
                                       sticky: false,
                                       time: ''
                                });
                                window.location.reload();
                            } else
                            {
                                $.gritter.add({
                                       title: 'Ошибка!',
                                       text: data,
                                       image: '/images/warning.png',
                                       sticky: false,
                                       time: ''
                                });
                            }
                        });



    });


	// checking input max length - #ww_abuse
	var txt_0_lngth = 200;
	// init
	$("#ww_abuse .textarea_0").each(function()
		{
			check_str_lngth($(this), txt_0_lngth, "li");
		}
	);
	$("#ww_abuse .textarea_0").bind("keyup click change", function(e)
		{
			check_str_lngth($(this), txt_0_lngth, "li");
		}
	);
	// checking input max length - #ww_abuse
	var input_0_lngth = 40;
	// init
	$("#ww_abuse .input_0").each(function()
		{
			check_str_lngth($(this), input_0_lngth, "li");
		}
	);
	$("#ww_abuse .input_0").bind("keyup click change", function(e)
		{
			check_str_lngth($(this), input_0_lngth, "li");
		}
	);
});
