function AB(area, aid, cid) {
	if(!confirm("Ваша просьба обратить внимание на данный пост (комментарий) будет направлена модератору. Помните, что Вы всегда можете воздействовать на поведение других пользователей с помощью повышения или понижения рейтинга.")) return false;
	$.post("/ajax/abuse/", {area:area, aid:aid, cid:cid}, function() {
		alert("Модератору отправлено сообщение.");
	});
	return false;
}

(function($) {
	$.postJSON = function(url, data, callback) {
			$.ajax({
				url: url,
				type: 'POST',
				data: data,
				dataType: "json",
				success: callback
			});
		}
	}
)(jQuery);


$(function() {
	$(".post .rb").each(function() {
		if(this.innerHTML == "+") this.title = "Мне нравится этот пост!";
		else this.title = "Мне НЕ нравится этот пост!";
	});

	$("img.Abuse").attr("title", "Обратить внимание модератора");

	var srch = $("form#Search #what");
	var srch_changed = 0;
	srch.focus(function() {
		if(srch_changed == 0) srch.val("");
	}).blur(function() {
		if(srch_changed == 0) srch.val("найти на сайте");
	}).keypress(function() {
		srch_changed = 1;
	});

	$(".FF_video").each(function() {
		var img_src = this.src;
		var flv_src = img_src.slice(0, -4) + ".flv";

		var s1 = new SWFObject("/i/player.swf", "ply", "320", "240", "9", "#FFFFFF");
		s1.addParam("allowfullscreen","true");
		s1.addParam("allowscriptaccess","always");
		s1.addParam("flashvars", "file=" + flv_src + "&image=" + img_src);
		s1.write(this.parentNode);

	});
	
	$(".post .poll form").ajaxForm({dataType: 'json', success: poll_submit_callback});
});

function poll_submit_callback(response) {
	if(response.error) return !!alert(response.error);

	$("#poll_" + response.poll_id).replaceWith(response.html);
}

function poll_show_results(id) {
	$.postJSON("/ajax/poll/", {poll_id: id}, function(response) {
		if(response.error) return !!alert(response.error);
		$("#poll_" + response.poll_id).replaceWith(response.html);
	});
	return false;
}

function poll_show_form(id) {
	$.postJSON("/ajax/poll/", {poll_id: id, show_form: 1}, function(response) {
		if(response.error) return !!alert(response.error);
		$("#poll_" + response.poll_id).replaceWith(response.html);
		$("#poll_" + response.poll_id + " form").ajaxForm({dataType: 'json', success: poll_submit_callback});
	});


	return false;
}