function showAddBlogPostForm () {
	currentPopupId = '#popup_add_blog_post';
	showPopup('blog_post_window', {type: 'GET', dataType: 'html', url: '/blog/index/form/', success: processFormResponse}, currentPopupId, 'Добавление записи');
	return false;
}

function showEditBlogPostForm (post, gotoPost) {
	if (! gotoPost) {
		gotoPost = 0;
	}
	currentPopupId = '#popup_edit_blog_post';
	if (parent) {
		currentPopupId = currentPopupId + '_' + post.id;
	}
	showPopup('blog_post_window', {type: 'GET', data: {id: post.id, gotoPost: gotoPost}, dataType: 'html', url: '/blog/index/form/', success: processFormResponse}, currentPopupId, 'Редактирование записи');
	return false;
}

function deleteBlogPost(topic, deleteAllowed) {
	if (deleteAllowed) {
		return window.confirm('Ты точно хочешь удалить тему "' + topic.title + '"?');
	} else {
		alert('Тему может удалить только модератор');
	}
	return false;
}

function deletePreview (id) {
	if(window.confirm('Удалить картинку?')) {
		var invoker = $(this);
		$.ajax({type: "GET", data: {id: id}, url: '/blog/index/delete-preview', dataType: 'json', success: function (response) {
			if (response.status == 'invalid') {
				showMessages(response.currentMessages);
			} else {
				$('.picture_box').html('<p class="no_images">Нет&nbsp;картинок</p>');
			}
		}
		});
	}
	return false;
}
