function ManipulationCommentForm() {
	if ($("div#formCommentBlock").is(":hidden")) {
		$("div#formCommentBlock").slideDown("slow");
		$("img.RightImage").attr('src', '/images/button_up.gif');
		$("div#comments h2").text('Оставьте сообщение, ваше мнение очень важно!');
	} else {
		$("div#formCommentBlock").slideUp();
		$("img.RightImage").attr('src', '/images/button_down.gif');
		$("div#comments h2").text('Добавить комментарий');
	}
}
function ManipulationComment() {
	$("div#blogBlock").slideUp();
	if ($("div#formCommentBlock").is(":hidden")) {
		$("div#formCommentBlock").slideDown("slow");
	} else {
		$("div#formCommentBlock").slideUp();
	}
}
function ManipulationQuestions() {
	if ($("div#formQuestionsBlock").is(":hidden")) {
		$("div#formQuestionsBlock").slideDown("slow");
	} else {
		$("div#formQuestionsBlock").slideUp();
	}
}
function ManipulationAnswers() {
	if ($("div#formAnswersBlock").is(":hidden")) {
		$("div#formAnswersBlock").slideDown("slow");
	} else {
		$("div#formAnswersBlock").slideUp();
	}
}


function ManipulationBlog() {
	$("div#formCommentBlock").slideUp();
	if ($("div#blogBlock").is(":hidden")) {
		$("div#blogBlock").slideDown("slow");
	} else {
		$("div#blogBlock").slideUp();
	}
}
function PageNavigate() {
	if($(this).attr('title')){
		var iPage = $(this).attr('title');
	} else {
		var iPage = 1;
	}
	var iModuleId = $("#iModuleId").val();
	var iElementId = $("#iElementId").val();
	var iCount = $("div.commentCountNavigation select option:selected").val();
	$.ajax({
		type: "POST",
		url: "/ajax.php",
		data: "pager=true&iPage="+iPage+"&iModuleId="+iModuleId+"&iElementId="+iElementId+"&iCount="+iCount,
		cache: false,
		success: function(html){
			$("#commentsBlock").html(html);
			$("div.Page a").click(PageNavigate);
		}
	});
}
$(document).ready(function(){
	$("div.Page a").click(PageNavigate);
	$("div.commentCountNavigation select").change(PageNavigate);
	$("a#commentManipulator").click(ManipulationComment);
	$("a#blogManipulator").click(ManipulationBlog);
	$("img.RightImage").click(ManipulationCommentForm);
	$("div#comments h2").click(ManipulationCommentForm);

	$("a#questions").click(ManipulationQuestions);
	$("a#answers").click(ManipulationAnswers);
});
