{include file="left.tpl"}

<div class="content float-right">
	<div class="block">
		<div class="header">{name}</div>
		{if('{page}' == '1')}
			<div class="topic" id="answer_0">
				<table>
					<tbody>
						<tr>
							<td align="center">
								<a href="../profile?id={author_id}" class="fs-17">
					            	{author_login}
					            </a>
							</td>
							<td align="right">
								{if((is_worthy("e")) or (isset($sessionid) and $sessionid != null and '{author_id}' == '{my_id}'))}
									<a href="edit_topic?id={id}"><span class="float-left c-p-d">[редактировать]</span></a>
								{/if}
								{if(is_worthy("e"))}
									<a href="#"><span onclick="dell_topic('{id}' , '{id2}');" class="float-left c-p-d">[удалить]</span></a>
								{/if}
								{date}
							</td>
						</tr>
						<tr>
							<td align="center">
								<img src="../{author_avatar}" alt="{author_login}">

								<div class="space"></div>

								<div class="info">
									<p style="color: {group_color}">{group_name}</p>
									<p>Рейтинг: {reit}</p>
									<p>Сообщений: {answers}</p>
									<p>Спасибок: {thanks}</p>
								</div>
							</td>
							<td>
								<div class="content" id="text_0">{text}</div>

								{if('{edited_by_id}' != '')}
									<div class="edit">Отредактировал: <a href="../profile?id={edited_by_id}" title="{edited_by_login}">{edited_by_login}</a>, {edited_time}</div>
								{/if}
								{if('{signature}' != '')}
									<div class="signature">{signature}</div>
									
									<div class="clear"></div>
								{/if}
							</td>
						</tr>
						<tr>
							{if(isset($sessionid) and $sessionid != null and '{author_id}' != '{my_id}')}
								<td>
									<div class="btn c-p" onclick="thank({id}, 1)">Спасибо</div>
									<div class="btn c-p" onclick="answer(0,'{author_login}','{link}')">Ответить</div>
								</td>
								<td>{thanks_str}</td>
							{else}
								<td colspan="2">{thanks_str}</td>
							{/if}
						</tr>
					</tbody>
				</table>
			</div>
		{/if}

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

		<div class="space"></div>

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

	{if(is_auth())}
		<div class="space"></div>

		{if('{status}' == '1' or '{status}' == '3')}
			<link href="{site_host}templates/SquareLine/css/_small.css" rel="stylesheet">

			<script src="../modules/editors/tinymce/tinymce.min.js"></script>
            <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-content");
            			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';
            	}
            
            	$(document).ready(function() {
            		h1 = $('#answer_0 tr:nth-child(2) > .col-xs-2').height();
            		h2 = $('#answer_0 tr:nth-child(2) > .col-xs-10').height();
            
            		if(h2 > h1) {
            			$('#answer_0 tr:nth-child(2) > .col-xs-2').height(h2+20);
            		}
            	});
            </script>

			<div class="block">
				<div class="header">Оставить ответ</div>
				<div class="block-content">
				    <div id="send_answer">
					    <textarea id="text" maxlenght="2000"></textarea>
					    
					    <div class="message-send">
					    	<i class="fa fa-smile-o" id="smile_btn" data-container="body" data-toggle="popover" data-placement="top" data-content="empty"></i>
					    	<div id="send_btn" class="btn float-right" type="button" onclick="send_answer('{id}');">Отправить</div>
					    </div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
		{else}
			<div class="bs-callout bs-callout-error bs-mini"><p>Тема закрыта</p></div>
		{/if}
	{/if}
</div>