<?php
$index = 0;

if ($pointsAirport && $usersAirport && $pointsAirport->id != $usersAirport->id){
	App::log('airportsAndHotels', array(
		$usersAirport->iata,
		$pointsAirport->iata,
		App::$userGeo,
		App::$userIp,
		$point->id,
		$point->name,
		$pointsAirport->countryRu,
	));
}
?>
<div id="pageSmoothBackground" style="background-image: url(<?= $point->getImg('middle') ?>);"></div>
<div class="container" style="background-color: rgba(255,255,255, 0.8);margin-top: -10px;">
	<div class="row">
		<div class="col-md-12">
			<?php if ($point->status != Point::statusPublished): ?>
				<h1 style="text-align: right; color: red;">Точка скрыта</h1>
			<?php endif; ?>
			<h1 style="text-align: right;"><?= $point->name ?></h1>
			<div class="coords-container">
				Координаты:&nbsp;
				<nobr>
					<?= $point->lat > 0 ? 'N' : 'S' ?><?= number_format(abs($point->lat), 5, '.', '') ?>°
					<?= $point->lng > 0 ? 'E' : 'W' ?><?= number_format(abs($point->lng), 5, '.', '') ?>°
				</nobr>
				&nbsp;&nbsp;/&nbsp;&nbsp;
				<nobr>
					<?= $point->lat > 0 ? 'N' : 'S' ?><?= Coord::dergeeToMinute($point->lat) ?>
					<?= $point->lng > 0 ? 'E' : 'W' ?><?= Coord::dergeeToMinute($point->lng) ?>
				</nobr>
				<span class="hideOnPrint">
				&nbsp;&nbsp;/&nbsp;&nbsp;
				</span>
				<a href="/?point=<?= $point->id ?>" class="hideOnPrint" title="<?= $point->name ?> на карте">На карте</a>
				<?php if ($user && $user->isAdmin): ?>
					&nbsp;&nbsp;/&nbsp;&nbsp;
					<a href="/?point=<?= $point->id ?>&edit=true">Редактировать</a>
					&nbsp;&nbsp;/&nbsp;&nbsp;
					<a href="/page/vkpoint/id/<?= $point->id ?>">4VK</a>
					&nbsp;&nbsp;/&nbsp;&nbsp;
					<a href="/page/instapoint/id/<?= $point->id ?>">4IG</a>
				<?php endif; ?>
			</div>

			<div class="mainTextBlock">
				<?php
				if (count($text) > 4) {
					for ($index = 0; $index < 4; $index++) {
						print $text[$index];
					}
				} else {
					print $point->descriptionHtml;
				}
				?>

				<?php if ($photos || $point->img): ?>
					<br/><br/>
					<div style="text-align: center;">
						<div class="dfotorama"  data-loop="true" data-allowfullscreen="native" data-nav="thumbs" data-thumbwidth="100" data-keyboard="true" data-autoplay="true" data-stopautoplayontouch="true">
							<?php if ($point->img): ?>
								<img data-thumb="<?= $point->img ?>" src="<?= $point->img ?>">
							<?php endif; ?>
							<?php if ($photos): ?>
								<?php foreach ($photos as $photo): ?>
									<img data-thumb="/photos/small/<?= $photo->name ?>" src="/photos/middle/<?= $photo->name ?>" data-full="/photos/big/<?= $photo->name ?>" data-caption="<?= $photo->getOriginalLink() ?>" alt="<?= $point->name ?> на wikipoints.ru">
								<?php endforeach; ?>
							<?php endif; ?>
							<span data-thumb="/img/mapThumb.png">
								<div id="map" style="width: 100%; height: 100%; position: static; display: block;"></div>
							</span>
						</div>
					</div>
					<br/><br/>
				<?php endif; ?>

				<?php
				if (count($text) > 4) {
					for ($index = $index; $index < count($text); $index++) {
						print $text[$index] . ' ';
					}

					print "<br/><br/>";
				}
				?>

				<?php if ($extraParams): ?>
					<div style="width: 100%; text-align: center;">
						<table class="table table-bordered table-hover" style="background-color: #fff; display: inline-table; width: 100%; max-width: 700px; text-align: left;">
							<thead>
								<tr>
									<th colspan="2">Дополнительная информация:</th>
								</tr>
							</thead>
							<?php
							foreach ($extraParams as $extraParam) {
								print '<tr>';
								print '<td>' . $extraParam->name . '</td>';
								if (false && $point->isPaid()) {
									print '<td>';
									print '<span id="extraHolder' . $extraParam->id . '" class="extraHolder" onclick="showExtraParam(' . $extraParam->id . ')" style="display: block;">' . mb_substr($extraParam->value, 0, 5, 'UTF-8') . '… <span class="glyphicon glyphicon-chevron-right"></span></span>';
									print '<span style="display: none;" id="extraData' . $extraParam->id . '"  class="extraData">' . Helper::replaceUrls($extraParam->value) . '</span>';
									print '</td>';
								} else {
									print '<td>' . Helper::replaceUrls($extraParam->value, TRUE) . '</td>';
								}
								print '</tr>';
							}
							?>
						</table>
					</div>
				<?php endif;
				?>

				<?php if ($photoLinks): ?>
					Использованы фотоматериалы с сайтов: <?= $photoLinks ?>
<?php endif; ?>
			</div>
			<p style="margin-top: 5px; text-align: right;">
<?php if (App::$user && App::$user->id): ?>
				<nobr>[ <button type="button" class="btn btn-link" style="color: #333;" onclick="addRemoveFavorite(<?= $point->id ?>)"><span id="myFavoritesButton" class="glyphicon glyphicon-star<?= $point->inFavorites ? '' : '-empty' ?>"></span> Хочу посетить</button> ]</nobr>
				<nobr>[ <button type="button" class="btn btn-link" style="color: #333;" onclick="addRemoveLike(<?= $point->id ?>)"><span id="myLikesButton" class="glyphicon glyphicon-<?= $point->iLike ? 'ok' : 'thumbs-up' ?>"></span> Нравится</button> ]</nobr>
<?php else: ?>
				<nobr>[ <span class="glyphicon glyphicon-star"></span> <?= $countInFavs ?> - в закладках ]</nobr>
				<nobr>[ <span class="glyphicon glyphicon-thumbs-up"></span> <?= $countLikes ?> - нравится ]</nobr>
			<?php endif; ?>
			<nobr>[ <span class="glyphicon glyphicon-user"></span> <a href="/user/<?= $point->authorUser->id ?>"><?= $point->authorUser->nick ?></a> - <span class="glyphicon glyphicon-pencil" title="<?= date('d-m-Y H:i', $point->date) ?>"></span> <?= $point->authorUser->getPointsCount() ?> ]</nobr>
			<?php if (App::$user && App::$user->isAdmin == 1): ?>
				<nobr>[ <span class="glyphicon glyphicon-new-window"></span> <a href="<?= $point->source ?>" target="_blank">источник: <?= $point->source ?></a> ]</nobr>
<?php endif; ?>
			</p>
		</div>
	</div>
	<br/>
<?php if ($pointsAirport && $usersAirport && $pointsAirport->id != $usersAirport->id): ?>
		<div class="row hideOnPrint">
			<div class="col-md-12 text-center">
				<script charset="utf-8" type="text/javascript">
					window.TP_FORM_SETTINGS = window.TP_FORM_SETTINGS || {};
					window.TP_FORM_SETTINGS["394e02eacac3a5c9b000360787c2d5d2"] = {
						"handle": "394e02eacac3a5c9b000360787c2d5d2",
						"widget_name": "Поисковая форма — точка",
						"border_radius": "3",
						"additional_marker": null,
						"width": null,
						"show_logo": true,
						"show_hotels": false,
						"form_type": "avia_hotel",
						"locale": "ru",
						"currency": "rub",
						"sizes": "default",
						"search_target": "_blank",
						"active_tab": "hotel",
						"search_host": "hydra.aviasales.ru",
						"hotels_host": "hotellook.ru/search",
						"hotel": {
							"name": "<?= $pointsAirport->cityRu?>",
							"location": "<?= $pointsAirport->countryRu?>",
							"hotels_count": "",
							"search_id": "12104",
							"search_type": "city",
							"country_name": "<?= $pointsAirport->countryRu?>"
						},
						"hotel_alt": "Hotellook — Поиск дешёвых отелей!",
						"avia_alt": "Aviasales — Поиск дешёвых авиабилетов!",
						"retargeting": true,
						"trip_class": "economy",
						"depart_date": "<?= date('Y-m-d', strtotime('+7 days')) ?>",
						"return_date": "<?= date('Y-m-d', strtotime('+10 days')) ?>",
						"check_in_date": "<?= date('Y-m-d', strtotime('+7 days')) ?>",
						"check_out_date": "<?= date('Y-m-d', strtotime('+10 days')) ?>",
						"id": 70240,
						"marker": 52337,
						"origin": {
						"name": "<?= $usersAirport->cityRu?>",
						"iata": "<?= $usersAirport->iata?>"
						},
						"destination": {
						"name": "<?= $pointsAirport->cityRu?>",
						"iata": "<?= $pointsAirport->iata?>"
						},
						"color_scheme": {
							"name": "white_orange",
							"icons": "icons_orange",
							"background": "#ffffff",
							"color": "#000000",
							"border_color": "#cccccc",
							"button": "#feb20e",
							"button_text_color": "#ffffff",
							"input_border": "#cccccc"
						},
						"hotels_type": "hotellook_host",
						"best_offer": {
							"locale": "ru",
							"currency": "rub",
							"marker": 52337,
							"search_host": "hydra.aviasales.ru",
							"offers_switch": true,
							"api_url": "//www.travelpayouts.com/minimal_prices/offers.json",
							"routes": [
								{
									"one_way": true,
									"origin": {
										"name": "<?= $usersAirport->cityRu ?>",
										"iata": "<?= $usersAirport->iata ?>"
									},
									"destination": {
										"name": "<?= $pointsAirport->cityRu ?>",
										"iata": "<?= $pointsAirport->iata ?>"
									}
								}
							]
						},
						"hotel_logo_host": "hotellook.ru",
						"search_logo_host": "www.aviasales.ru",
						"hotel_marker_format": "marker=",
						"hotelscombined_marker": null,
						"responsive": true,
						"height": 245
					};
				</script>
				<script charset="utf-8" src="//www.travelpayouts.com/widgets/394e02eacac3a5c9b000360787c2d5d2.js?v=727" async></script>
			</div>
		</div>
<?php else: ?>
		<div class="row hideOnPrint">
			<div class="col-md-12" style="text-align: center;">
				<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
				<!-- Point - DOWN -->
				<ins class="adsbygoogle"
					 style="display:block"
					 data-ad-client="ca-pub-0069680015252793"
					 data-ad-slot="4972494746"
					 data-ad-format="auto"></ins>
				<script>
					(adsbygoogle = window.adsbygoogle || []).push({});
				</script>
			</div>
		</div>
<?php endif; ?>

	<div class="row">
		<div class="col-md-12">
<?= self::renderPartial('comments/all.php', array('parentId' => $point->id, 'parentType' => 'point'), TRUE); ?>
		</div>
	</div>
	<hr class="hideOnPrint"/>

	<!--googleoff: all-->
	<!--noindex-->

<?php if ($articles): ?>
		<div class="row">
			<div class="col-md-12">
				<h3 style="margin-top: 0;">Эта точка в статьях:</h3>
				<?php foreach ($articles as $article): ?>
					<a href="/article/<?= $article->id ?>" class="pagePoinsNearCards"><img src="<?= $article->getImg('small') ?>" title="<?= $article->title ?>" class="pagePoinsNearCardsImg"/></a>
	<?php endforeach; ?>
			</div>
		</div>
		<hr class="hideOnPrint"/>
	<?php endif; ?>

<?php if (!empty($closestPoints)): ?>
		<div class="row hideOnPrint">
			<div class="col-md-12">
				<h3 style="margin-top: 0;">Поблизости расположены:</h3>
	<?php foreach ($closestPoints as $cPoint): ?><a href="/point/<?= $cPoint->id ?>" class="pagePoinsNearCards"><?php if($cPoint->categoryId == 26):?><div class="excursionMarker" title="<?= $cPoint->name ?>"><img src="/ico/flag-export.png"> ЭКСКУРСИЯ</div><?php endif;?><img src="<?= $cPoint->getImg() ?>" title="<?= $cPoint->name ?>" class="pagePoinsNearCardsImg"/></a><?php endforeach; ?>
			</div>
		</div>
		<hr class="hideOnPrint"/>
	<?php endif; ?>

<?php if (!$articles): ?>
		<div class="row hideOnPrint">
			<div class="col-md-12">
				<h3 style="margin-top: 0;">Похожие точки:</h3>
	<?php foreach ($similarPoints as $sPoint): ?><a href="/point/<?= $sPoint->id ?>" class="pagePoinsNearCards"><img src="<?= $sPoint->getImg() ?>" title="<?= $sPoint->name ?>" class="pagePoinsNearCardsImg"/></a><?php endforeach; ?>
			</div>
		</div>
		<hr class="hideOnPrint"/>
<?php endif; ?>
	<!--/noindex-->
	<!--googleon: all-->
<?= self::renderPartial('randomPoint.php', array('randomPoint' => $randomPoint), true) ?>
	<br/>
	<?= self::renderPartial('/page/darkFooter.php',array(), true)?>
</div>
<script>
	function showExtraParam(id) {
//		$('#extraHolder'+id).hide();
//		$('#extraData'+id).show();
		$('.extraHolder').hide();
		$('.extraData').show();
	}
</script>
