function addBlogComment(user_ids, entry_id)
{
	$('#error').hide();

	var current_parent_id = $('#parent_reply_id').val();
	var parameters = $('#fComment').formSerialize();

	$.post('ajax.php?page=blogs&action=addComment&entryId='+entry_id+'&pid='+current_parent_id+'&userIds='+user_ids, parameters, function(response) {

		eval( "var reply = "+response+";");
		if (reply.result) {

			$('#error').hide();
			$('#cthread'+current_parent_id).html($('#cthread'+current_parent_id).html() + reply.info);
			$('#comment'+reply.blogCommentId).fadeIn(400);
			$('textarea.jTagEditor-editor').val("");
			$('div.jTagEditor-preview').hide();
			$('#replyForm').hide();

		} else {
			$('#error').html(reply.info);
			$('#error').show();
		}
	});
};

function deleteBlogComment(userIds, blogCommentId)
{
	$('#del'+blogCommentId).hide();

	$.post('ajax.php?page=blogs&action=deleteComment&userIds='+userIds+'&blogCommentId='+blogCommentId, '', function(response) {

		eval( "var reply = "+response+";");
		if (reply.result) {
			$('#blogCommentItem'+blogCommentId).fadeOut(300);
		} else
		{
			$('#del'+blogCommentId).show();
		}
	});
};

function addPhotoComment(photoIds)
{
	$('#errorBlock').hide();

	var current_parent_id = $('#parent_reply_id').val();
	var parameters = $('#fComment').formSerialize();

	$.post('ajax.php?page=photos&action=addComment&photoIds='+photoIds+'&pid='+current_parent_id, parameters, function(response) {

		eval( "var reply = "+response+";");
		if (reply.result) {

			$('#error').hide();
			$('#cthread'+current_parent_id).html($('#cthread'+current_parent_id).html() + reply.info);
			$('#comment'+reply.photoCommentId).fadeIn(400);
			$('textarea.jTagEditor-editor').val("");
			$('#replyForm').hide();

		} else {
			$('#error').html(reply.info);
			$('#error').show();
		}
	});
};

function deletePhotoComment(photoIds, commentId)
{
	$('#del'+commentId).hide();

	$.post('ajax.php?page=photos&action=deleteComment&photoIds='+photoIds+'&commentId='+commentId, '', function(response) {

		eval( "var reply = "+response+";");
		if (reply.result) {
			$('#photoCommentItem'+commentId).fadeOut(300);
		} else
		{
			$('#del'+photoCommentId).show();
		}
	});
};

function addTargetPhotoComment(target, photoIds)
{
	$('#errorBlock').hide();

	var current_parent_id = $('#parent_reply_id').val();
	var parameters = $('#fComment').formSerialize();

	$.post('ajax.php?page=album&action=addPhotoComment&photoIds='+photoIds+'&target='+target+'&pid='+current_parent_id, parameters, function(response) {

		eval( "var reply = "+response+";");
		if (reply.result) {

			$('#error').hide();
			$('#cthread'+current_parent_id).html($('#cthread'+current_parent_id).html() + reply.info);
			$('#comment'+reply.photoCommentId).fadeIn(400);

			$('textarea.jTagEditor-editor').val("");
			$('#replyForm').hide();

		} else {
			$('#error').html(reply.info);
			$('#error').show();
		}
	});
};

function deleteTargetPhotoComment(target, photoIds, commentId, targetId)
{
	$('#del'+commentId).hide();

	$.post('ajax.php?page=album&action=deletePhotoComment&photoIds='+photoIds+'&commentId='+commentId+'&target='+target+'&target_id='+targetId, '', function(response) {

		eval( "var reply = "+response+";");
		if (reply.result) {
			$('#photoCommentItem'+commentId).fadeOut(300);

			$('#photoCommentCounter').html(s);

			if ($('#photoCommentCountAll').val() == 0)
			{
				$('#photoCommentFilled').hide();
				$('#photoCommentEmpty').show();
			}
		} else
		{
			$('#del'+photoCommentId).show();
		}
	});
};



function addFaqComment(questionId)
{
	$('#errorBlock').hide();

	var current_parent_id = $('#parent_reply_id').val();
	var parameters = $('#fComment').formSerialize();

	$.post('ajax.php?page=faq&action=addAnswer&questionId='+questionId+'&pid='+current_parent_id, parameters, function(response) {

		eval( "var reply = "+response+";");
		if (reply.result) {

			$('#error').hide();
			$('#cthread'+current_parent_id).html($('#cthread'+current_parent_id).html() + reply.info);
			$('#comment'+reply.answerId).fadeIn(400);

			$('textarea.jTagEditor-editor').val("");
			$('#replyForm').hide();

		} else {
			$('#error').html(reply.info);
			$('#error').show();
		}
	});
};

function deleteFaqComment(commentId)
{
	$('#del'+commentId).hide();

	$.post('ajax.php?page=faq&action=deleteAnswer&answerId='+commentId, '', function(response) {

		eval( "var reply = "+response+";");
		if (reply.result) {
			$('#photoCommentItem'+commentId).fadeOut(300);

			$('#photoCommentCounter').html(s);

			if ($('#photoCommentCountAll').val() == 0)
			{
				$('#photoCommentFilled').hide();
				$('#photoCommentEmpty').show();
			}
		} else
		{
			$('#del'+photoCommentId).show();
		}
	});
};
