{include file="left.tpl"}

<script>
	jQuery(document).ready(function($)
	{
		<? if('{vk}' != '---'){ ?>
			$.getJSON('https://api.vk.com/method/users.get?user_id={vk_api}&v=5.73&fields=photo_50&callback=?', function(resp)
			{
				$('#vk_user_link').html(resp.response[0].first_name+' '+resp.response[0].last_name);
			});
		<? } ?>

		profile_admins();

		<? if('{dell}' != '1' && '{checker}' != '1'){ ?>
			tinymce.init({
				selector: '#text',
				language: 'ru',
				plugins: [
					'advlist autolink lists link image charmap  preview hr anchor pagebreak',
					'searchreplace',
					'insertdatetime media nonbreaking contextmenu directionality',
					'paste textpattern codesample spoiler'
				],
				toolbar1: 'undo redo removeformat | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist | blockquote | link image media codesample | hr  | subscript superscript | charmap ',
				image_advtab: true,
				menubar: false,
				toolbar_items_size: 'small'
			});

			$('#msgsmile').popover({html: true, animation: true, trigger: 'click'});
			$('#msgsmile').on('show.bs.popover', function()
			{
				$(document).mouseup(function(e)
				{
					var container = $('.popover-content');

					if(container.has(e.target).length === 0)
					{
						$('#msgsmile').popover('hide');

						selected = 'gcms_smiles';
					}
				});
			});

			get_smiles('#msgsmile');
		<? } ?>
	});

	function profile_admins()
	{
		$.ajax({
			type: 'POST',
			url: home+'templates/SquareLine/php/profile_privileges.php',
			data: 'token='+$('#token').val()+'&id={profile_id}',
			success: function(data)
			{
				if(data.indexOf('<td>') != -1)
					$('#admins > thead').show();

				$('#admins > tbody').html(data);

				if(data.indexOf('<td>') == -1)
					$('#admins > tbody > div').addClass('m-l-5 m-b-5 m-r-5 m-t-5');
			}
		});

		return null;
	}

	function profile_admin_info(id)
	{
		$.ajax({
			type: 'POST',
			url: home+'templates/SquareLine/php/profile_privileges_info.php',
			data: 'token='+$('#token').val()+'&id='+id,
			success: function(data)
			{
				if(data.indexOf('<td>') != -1)
					$('#admin_info thead').show();

				$('#admin_info').show();
				$('#admin_info tbody').html(data);

				if(data.indexOf('<td>') == -1)
					$('#admin_info > tbody > div').addClass('m-l-5 m-b-5 m-r-5 m-t-5');
			}
		});

		return null;
	}

	function set_sticker(elem)
	{
		send_user_comment('{profile_id}', encodeURIComponent('sticker'+$(elem).attr('src')));

		$('#msgsmile').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);

		selected = 'gcms_smiles';
	}
</script>

<div class="content float-right">
	<div class="block">
		<div class="header">Информация о пользователе</div>

		<div class="topic">
			<table>
				<tbody>
					<tr>
						<td align="center"><b>{login}</b></td>
						<td align="left">
							<span class="float-right">{last_activity}</span>
						</td>
					</tr>
					<tr>
						<td align="center">
							<img src="../{avatar}" alt="{login}">

							<? if($_SESSION['id']){?>
								<div class="block profile-menu m-t-5 m-b-5">
									<div class="header">Меню</div>

									<ul>{menu}</ul>
								</div>
							<? } ?>
						</td>
						<td>
							<? if('{dell}' != '1'){ ?>
								<div class="block m-b-5">
									<div class="header short">Общая информация</div>
									<div class="block-content">
										<p><b>Индентификатор</b>: {profile_id}</p>
										<p class="m-t-5"><b>Группа</b>: <span style="color: {group_color}">{group}</span></p>
										<p class="m-t-5"><b>Дата регистрации</b>: {regdate}</p>
										<p class="m-t-5"><b>Ник на сервере</b>: {nick}</p>
									</div>
								</div>
								<? if('{name}' != '---' || '{birth}' != '1 января 1900 г'){ ?>
									<div class="block m-b-5">
										<div class="header short">Личные данные</div>
										<div class="block-content">
											<p><b>Имя</b>: {name}</p>
											<p class="m-t-5"><b>Дата рождения</b>: {birth}</p>
										</div>
									</div>
								<? } ?>
								<? if('{skype}' != '---' || '{vk}' != '---' || '{telegram}' != '' || '{steam_api}' != '0'){ ?>
									<div class="block m-b-5">
										<div class="header short">Контактная информация</div>
										<div class="block-content">
											<? if('{skype}' != '---'){ ?>
												<p><b>Skype</b>: <a title="Добавить в скайп" href="skype:{skype}?add">{skype}</a></p>
											<? } ?>
											<? if('{vk}' != '---'){ ?>
												<p class="m-t-5"><b>Вконтакте</b>: <a href="http://vk.com/{vk}" id="vk_user_link" title="Перейти в профиль vk" target="_blank"></a></p>
											<? } ?>
											<? if('{telegram}' != ''){ ?>
												<p class="m-t-5"><b>Телеграм</b>: <a href="https://telegram.me/{telegram}" title="Написать в телеграм" target="_blank">@{telegram}</a></p>
											<? } ?>
											<? if('{steam_api}' != '0'){ ?>
												<p class="m-t-5"><b>Steam</b>: <a href="http://steamcommunity.com/profiles/{steam_api}/" title="Перейти в профиль steam" target="_blank">Загрузка...</a></p>
											<? } ?>
										</div>
									</div>
								<? } ?>
								<div class="block m-b-5">
									<div class="header short">Активность на форуме</div>
									<div class="block-content">
										<p><b>Рейтинг</b>: {reit}</p>
										<p class="m-t-5"><b>Сообщений</b>: {answers}</p>
										<p class="m-t-5"><b>Спасибок</b>: {thanks}</p>
										<p class="m-t-5"><b>Последняя тема</b>: <? if('{topic_id}' == '0'){ ?>Пользователь не просматривал форум<? } else { ?><a href="../forum/topic?id={topic_id}" title="Перейти в тему">{topic_name}</a><? } ?></p>
									</div>
								</div>
							<? } else { ?>
								<div class="bs-callout bs-callout-error bs-mini"><p>Пользователь удален</p></div>
							<? } ?>
						</td>
					</tr>
					<tr>
						<td colspan="2"></td>
					</tr>
				</tbody>
			</table>
		</div>

		<div class="clear"></div>
	</div>

	<div class="block">
		<div class="header">Привилегии</div>

		<table class="table-list" id="admins">
			<thead class="disp-n">
				<tr>
					<th align="left" width="45%">Сервер</th>
					<th align="left" width="25%">Идентификатор</th>
					<th align="left" width="25%">Тип</th>
					<th align="center" width="5%">Услуги</th>
				</tr>
			</thead>
			<tbody></tbody>
		</table>
	</div>

	<div class="block disp-n" id="admin_info">
		<div class="header">Информация об услугах</div>

		<table class="table-list">
			<thead class="disp-n">
				<tr>
					<th align="left" width="45%">Услуга</th>
					<th align="left" width="25%">Дата покупки</th>
					<th align="left" width="25%">Дата окончания</th>
					<th align="center" width="5%">Осталось</th>
				</tr>
			</thead>
			<tbody></tbody>
		</table>
	</div>

	<div class="block">
		<div class="header">Список друзей</div>

		<div class="profile-friends">{friends}</div>

		<div class="clear"></div>
	</div>

	<? if('{dell}' != '1'){ ?>
		<? if('{checker}' != '1'){ ?>
			<link href="{site_host}templates/SquareLine/css/_small.css" rel="stylesheet">

			<script src="../modules/editors/tinymce/tinymce.min.js"></script>

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

			<div class="block">
				<div class="header">Оставить комментарий</div>
				<div class="block-content">
					<textarea id="text" maxlenght="500"></textarea>

					<div class="message-send">
						<i class="fa fa-smile-o" data-container="body" data-content="empty" data-placement="top" data-toggle="popover" id="msgsmile"></i>

						<div class="btn float-right" onclick="send_user_comment({profile_id})">Отправить</div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
		<? } ?>

	<div class="block">
		<div class="header">Стена</div>

		<div id="comments"></div>

			<script>load_users_comments({profile_id},'first');</script>

		<div class="clear"></div>
	</div>
	<? } ?>
</div>