<div class="col-lg-9 order-is-first">
	<div class="block transparent">
		<div class="block_head">
			{name}
		</div>
		<div id="answers" class="topic-answers">
			{if('{page}' == '1')}
			<div id="answer_0">
				<div class="center-area">
					<div class="left-side">
						<img src="../{author_avatar}" alt="{author_login}">
						
						<a href="../profile?id={author_id}" style="color: {group_color}">
							{author_login}
						</a>
						<a href="../messages?create_id={author_id}">
							<i class="fas fa-envelope" tooltip="yes" title="Написать {author_login}"></i>
						</a>
						<p>{group_name}</p>

						<p>Рейтинг <span>{reit}</span></p>
						<p>Сообщений <span>{answers}</span></p>
						<p>Спасибок <span>{thanks}</span></p>
					</div>
					<div class="right-side">
						<div class="top-area">
							<a href="#answer_0">
								<i class="far fa-clock"></i> {date}
							</a>
						</div>
						<div id="text_0" class="with_code">
							{text}
						</div>
						{if('{edited_by_id}' != '')}
							<div class="edited">Отредактировал: <a href="../profile?id={edited_by_id}" title="{edited_by_login}">{edited_by_login}</a>, {edited_time}</div>
						{/if}
						{if('{signature}' != '')}
							<div class="with_code signature">
								{signature}
							</div>
						{/if}
					</div>
					<div class="clearfix"></div>
				</div>

				<div class="bottom-area">
					{if(is_auth())}
					<div class="left-side">
						<div class="btn-group">
							{if('{author_id}' == '{my_id}')}
							<button class="btn btn-outline-primary btn-sm w-100" tooltip="yes" title="Ответить" onclick="answer(0, '{author_login}', '{link}');">
								<i class="fas fa-comment"></i>
							</button>
							{else}
							<button class="btn btn-outline-primary btn-sm" tooltip="yes" title="Ответить" onclick="answer(0, '{author_login}', '{link}');">
								<i class="fas fa-comment"></i>
							</button>
							<button class="btn btn-outline-primary btn-sm" tooltip="yes" title="Спасибо" onclick="thank({id}, 1);">
								<i class="fas fa-thumbs-up"></i>
							</button>
							{/if}
						</div>
					</div>
					{else}
					<div class="left-side">
						<div class="btn-group">
							<button class="btn btn-outline-primary btn-sm" tooltip="yes" title="Ответить" onclick="show_stub();">
								<i class="fas fa-comment"></i>
							</button>
							<button class="btn btn-outline-primary btn-sm" tooltip="yes" title="Спасибо" onclick="show_stub();">
								<i class="fas fa-thumbs-up"></i>
							</button>
						</div>
					</div>
					{/if}

					<div class="right-side">
						{thanks_str}
					</div>
					<div class="clearfix"></div>
				</div>
			</div>
			{/if}

			{func Forum:get_answers("{id}", "{start}", "{limit}", "{script}", "{link}")}
		</div>
	</div>

	<div id="pagination2">{pagination}</div>

	{if(is_auth())}
		{if('{status}' == '1' or '{status}' == '3')}
		<div class="block mt-4">
			<div class="block_head">
				Оставить ответ
			</div>
			<div id="send_answer">
				<textarea id="text" maxlenght="2000"></textarea>
				<div class="smile_input_forum mt-3">
					<input id="send_btn" class="btn btn-primary" type="button" onclick="send_answer('{id}');" value="Отправить"></input>
					<div id="smile_btn" class="smile_btn visible-lg-inline-block" data-container="body" data-toggle="popover" data-placement="top" data-content="empty"></div>
				</div>
			</div>
		</div>
		{else}
			<div class="noty-block info mb-5">Тема закрыта</div>
		{/if}
	{/if}
</div>

<script>
	$(document).ready(function() {
		init_tinymce("text", "forum", "{file_manager_theme}", "{file_manager}", "{{md5($conf->code)}}");
		get_smiles('#smile_btn', 1);
	});

	$('#smile_btn').popover({ html: true, animation: true, trigger: "click" });
	$('#smile_btn').on('show.bs.popover', function () {
		$(document).mouseup(function (e) {
			var container = $(".popover-body");
			if (container.has(e.target).length === 0){
				$('#smile_btn').popover('hide');
				selected = 'gcms_smiles';
			}
		});
	});

	function set_smile(elem){
		var smile =  "<img src=\""+$(elem).attr("src")+"\" class=\"g_smile\" height=\"20px\" width=\"20px\">";
		tinymce.activeEditor.insertContent(smile);
		$('#smile_btn').popover('hide');
		selected = 'gcms_smiles';
	}
</script>

<div class="col-lg-3 order-is-last">
	{if((is_worthy("e")) || (is_auth() && '{author_id}' == '{my_id}'))}
	<div class="block">
		{if(is_worthy("e"))}
			<a href="#" onclick="dell_topic('{id}' , '{id2}');" class="btn btn-outline-primary btn-xl mb-2">Удалить</a>
		{/if}
		{if((is_worthy("e")) || (is_auth() && '{author_id}' == '{my_id}'))}
			<a href="../forum/edit_topic?id={id}" class="btn btn-outline-primary btn-xl">Редактировать</a>
		{/if}
	</div>
	{/if}

	{if(is_auth())}
		{include file="/home/navigation.tpl"}
		{include file="/forum/sidebar.tpl"}
	{else}
		{include file="/index/authorization.tpl"}
		{include file="/forum/sidebar.tpl"}
	{/if}
</div>