<?
error_reporting(E_ERROR | E_PARSE);
@ini_set('display_errors','0');
$start_time=microtime(true);
require_once(__DIR__.'/_nomadlist_functions.php');

//echo json_encode($_SERVER); die;

if(!isset($_SERVER['GEOIP_LATITUDE']) && !isset($_SERVER['GEOIP_LONGITUDE'])) {
	$user['city']='London';
	$user['country']='United Kingdom';
	$user['countryCode']='GB';
	$user['nationalityCode']='GB';
	$user['latitude']=51.5072;
	$user['longitude']=0.1275;
} else {
	$user['city']=$_SERVER['GEOIP_CITY'];
	$user['country']=$_SERVER['GEOIP_CITY_COUNTRY_NAME'];
	$user['countryCode']=$_SERVER['GEOIP_CITY_COUNTRY_CODE'];
	$user['latitude']=$_SERVER['GEOIP_LATITUDE'];
	$user['longitude']=$_SERVER['GEOIP_LONGITUDE'];
}
$user['current_latitude']=$user['latitude'];
$user['current_longitude']=$user['longitude'];

ob_start("sanitizeOutput");
$config['googleAnalyticsTrackingId']='UA-40780399-14';
$config['nomadListApi']['tokens']['taylorbot']='klzeujltpxtqquxv';
$config['car_speed']=100;
$config['airplane_speed']=750;
$config['airplane_cost_per_km']=0.08932271785/2;
$config['airplane_cost_per_km_in_usd_variable']=0.09/2;
$config['airplane_cost_per_km_in_usd_diff']=-100/2;
$config['airplane_cost_per_km_in_usd_constant']=150/2;

$citiesCacheFile=__DIR__.'/../cache/cities.api.json';
if(!file_exists($citiesCacheFile) || time()-filemtime($citiesCacheFile) > 3600) {
	$apiBody=@file_get_contents('https://nomads.com/api/cities?key=qd4h368siut9lwsi');
	if($apiBody!==false) { file_put_contents($citiesCacheFile,$apiBody); }
}
$apiReply=json_decode(file_get_contents($citiesCacheFile),true);
$cities=array();
foreach($apiReply['cities'] as $c) {
	$slug=isset($c['long_slug'])?$c['long_slug']:$c['short_slug'];
	$cities[$slug]=$c;
}
$collections=array();
$lastModCache=date('c',filemtime($citiesCacheFile));
$cities=calculateDistanceForItemsFromUser($cities);
$sortedCities=sortItems($cities,'distance','asc','max',1000);
$nearestCity=$sortedCities[0];

// loadDbs(array('places'));
// $placesWork=getPlacesInCity($nearestCity,array('coworking','coffee'));
// sortBySubkey($placesWork,'nomad_score',false);
// $placesWork=array_slice($placesWork,0,5);
// $placesWork=array_reverse($placesWork);
// $placesWork=calculateDistanceForItemsFromUser($placesWork);

// $placesSleep=getPlacesInCity($nearestCity,array('hotel','hostel','airbnb'));
// sortBySubkey($placesSleep,'nomad_score',false);
// $placesSleep=array_slice($placesSleep,0,5);
// $placesSleep=array_reverse($placesSleep);
// $placesSleep=calculateDistanceForItemsFromUser($placesSleep);


$placesSleep=array();
$placesWork=array();


$userPlaceDetected=$nearestCity['name'];
// if(!empty($_SERVER['GEOIP_CITY'])) {
// 	$userPlaceDetected = $_SERVER['GEOIP_CITY'];
// }
// else if(!empty($_SERVER['GEOIP_CITY_COUNTRY_NAME'])) {
// 	$userPlaceDetected = $_SERVER['GEOIP_CITY_COUNTRY_NAME'];
// 	if(substr($userPlaceDetected,0,3)!='the') {
// 		if(substr($userPlaceDetected,-1)=='s') {
// 			$userPlaceDetected='the '.$userPlaceDetected;
// 		}
// 	}
// }

// <people near>
	$userLocationsFile=__DIR__.'/../cache/bot-locations.json';
	$userLocations=json_decode(file_get_contents($userLocationsFile),true);
	$nearestUsers=array();
	foreach($userLocations as $username => $otherUser) {
		$distance=round(getDistanceBetweenTwoGPSCoords($otherUser['latitude'],$otherUser['longitude'],$user['latitude'],$user['longitude']));
		$nearestUsers[$username]=$distance;
	}

	asort($nearestUsers);
	$nearestUsers=array_slice($nearestUsers,0,5);

	$newNearestUsers=array();
	foreach($nearestUsers as $username => $distance) {
		$nearestCities=array();
		foreach($cities as $city) {
			$distanceToCity=round(getDistanceBetweenTwoGPSCoords($userLocations[$username]['latitude'],$userLocations[$username]['longitude'],$city['latitude'],$city['longitude']));
			$nearestCities[$city['name']]=$distanceToCity;
		}
		asort($nearestCities);
		array_slice($nearestCities,0,1);
		reset($nearestCities);
		$key=key($nearestCities);
		$nearUser['nearestCityName']=$key;
		if($distance<1) {
			$nearUser['transport_text']='<i class="em em-runner"></i>'.round($distance*1000)."m";
		}
		else if($distance<100) {
			$nearUser['transport_text']='<i class="em em-runner"></i>'.round($distance)."km";
		}
		else if($distance<500) {
			$nearUser['transport_text']='<i class="em em-car"></i>'.floor($distance/$config['car_speed'])."h drive";
		}
		else {
			$nearUser['transport_text']='<i class="em em-airplane"></i> '.round($distance/$config['airplane_speed'])."h flight";
		}
		$nearUser['username']=$username;
		array_push($newNearestUsers,$nearUser);
	}
	$nearestUsers=$newNearestUsers;
// </people>


if(!empty($_GET['n'])) {
	setcookie('n', $_GET['n'], time()+365*24*60*60,"/");
	header("Location:/");
	exit;
}
$botPerson=rand(1,3);
$botUsernames=array(
	1 => 'nomadscom',
	2 => 'nomadscom',
	3 => 'nomadscom'
);

?>

<!doctype html>
	<head>
		<title>
			Taylor is your travel assistant powered by artifical intelligence
		</title>
		<meta property="og:title" content="Taylor is your travel assistant powered by artifical intelligence"/>
		<meta name="twitter:title" content="Taylor is your travel assistant powered by artifical intelligence">
		<meta property="og:url" content="<?=$_SERVER['HTTPS'] ? 'https://' : 'http://';?>taylorbot.com"/>
		<meta property="og:description" content="Your travel assistant over chat powered by artifical intelligence, who can help you find out where to go, what to do and who to meet in cities all over the world."/>
		<meta name="twitter:description" content="Your travel assistant over chat powered by artifical intelligence, who can help you find out where to go, what to do and who to meet in cities all over the world.">
		<meta property="og:image" content="http://taylorbot.com/assets/media.png"/>
		<meta name="twitter:image:src" content="http://taylorbot.com/assets/media.png">
		<meta property="og:type" content="website"/>
		<meta name="twitter:card" content="summary_large_image">
		<meta name="twitter:site" content="@levelsio">
		<meta name="twitter:creator" content="@levelsio">
		<meta name="twitter:url" content="<?=($_SERVER['HTTPS'] ? 'https://' : 'http://')?>taylorbot.com">
		<link rel="icon" href="/assets/favicon.ico" type="image/x-icon"/>
		<link rel="shortcut icon" href="/assets/favicon.ico" type="image/x-icon"/>
					
		<meta charset="UTF-8" />
		<meta http-equiv="Content-Language" content="en-us" />
		<meta name="google" value="notranslate" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<meta http-equiv="cleartype" content="on" />
		<meta name="HandheldFriendly" content="true"  />
		
		<link href="/assets/emoji.css" rel="stylesheet">

		<style>
			html {
				font-family:"proxima-nova","Proxima Nova","Helvetica Neue","Helvetica";
			}
			* {
				margin:0;
				padding:0;
				box-sizing:border-box;
			}
			body {
				text-align:center;
			}
			.bg {
				background-color:rgb(248,244,240);
				background-image:url('/assets/bot-bg-<?=$botPerson?>.jpg');
				background-repeat:no-repeat;
				background-height:100%;
				background-size:cover;
				background-position:center;
				width:100%;
				height:100%;
				z-index:-1;
				position:fixed;
				opacity:1;
			}
			.try {
				color:#fff;
				font-size:0.75em;
				margin-top:0.25em;
			}
			.try a {
				color:#fff;
				border-bottom-color:#fff;
				font-weight:600;
			}
			h1 {
				font-size:1em;
				margin:0;
			}
			@media (min-width:1000px) {
				.line {
					width:2px;
					background-color:rgb(50,50,50);
					/*border:1px dashed rgb(255,255,255);*/
					height:100%;
					position:absolute;
					left:50%;
					top:0;
					z-index:0;
				}
			}
			section {
				font-size:1.25em;
				display:block;
				z-index:1;
			}
			section.top {
				color:#fff;
				width:100%;
				height:auto;
				display:block;
			}

			.contents {
				position:relative;
				padding:0.5em;
				padding-top:4em;
				padding-bottom:4em;
				text-align:center;
			}
			.max-width {
				max-width:44em;
				display:block;
				margin:0 auto;
				z-index:1;
				position:relative;
			}
			.contents:first-child {
				height:100vh;
			}
			.contents:nth-child(2) {
				max-width:none;
				background-color:rgba(0,0,0,0.85);
			}
			.contents:last-child {
				max-height:100vh;
				height:100vh;
				background-image:url('/assets/bot-bg2-<?=$botPerson?>.jpg');
				padding-bottom:40vh;
				background-position:center;
				background-size:cover;
				max-width:none;
			}
			.contents:first-child .max-width,
			.contents:last-child .max-width {
				position:absolute;
				top:50%;
				width:100%;
				left:50%;
				transform: translateY(-50%) translateX(-50%);
				-webkit-transform: translateY(-50%) translateX(-50%);
				-ms-transform: translateY(-50%) translateX(-50%);
				-moz-transform: translateY(-50%) translateX(-50%);
			}
			.balloon {
				background-color:#fff;
				border-radius:0.5em;
				display:inline-block;
				text-align:left;
				padding:0.75em;
				min-width:20em;
				max-width:20em;
			}
			.top .balloon {
				background-color:rgba(255,255,255,0.85);
			}
			.message {
				display:inline-block;
				vertical-align:bottom;
				margin-bottom:1em;
				z-index:1;
				padding:0.25em;
				position:relative;
			}
			@media (min-width:600px) {
				.message.first {
					width:100%;
				}
				.balloon.first {
					max-width:27em;
					width:100%;
				}
			}
			.message.right .photo {
			}
			.message.right {
				float:right;
			}
			.message.left {
				float:left;
			}
			.action-switch-person {
				position:absolute;
				top:0;
				right:0;
				margin:0.5em;
				color:#fff;
				font-size:1.5em;
				cursor:pointer;
				filter: grayscale(100%);
				-webkit-filter: grayscale(100%);
				-moz-filter: grayscale(100%);
				-ie-filter: grayscale(100%);
			}
			.action-switch-person.person-1 {
				right:0em;
			}
			.action-switch-person.person-2 {
				right:1.75em;
			}
			.action-switch-person.person-3 {
				right:3.5em;
			}
			.action-switch-person:hover {
				color:#ff4742;
				opacity:1;
			}
			.action-switch-person:hover,
			.action-switch-person.active {
				filter: none;
				-webkit-filter: none;
				-moz-filter: none;
				-ie-filter: none;
				opacity:1;
			}
			@media (max-width:600px) {
				.section {
					font-size:0.1em;
				}
				.balloon {
					width:75%;
					width:calc(100% - 4em);
					max-width:none;
					min-width:0;
				}
				.message {
					margin:0;
					width:100%;
					margin-bottom:1em;
				}
				.contents:first-child {
					padding:0;
				}
				.message:first-child {
					margin-top:25vh;
				}
				.cta.first {
					margin-bottom:25vh;
				}
				.contents:last-child {
					padding-bottom:30vh;
				}
			}
			.photo {
				background-color:#fff;
				width:3em;
				height:3em;
				border-radius:100%;
				display:inline-block;
				vertical-align:bottom;
				margin-left:0.25em;
				margin-right:0.25em;
			}
			.contents:nth-child(2) .photo {
				/*border:1px solid rgb(25,25,25);*/
			}
			.pieter .photo {
				background-image:url('/assets/levelsio-big.jpg');
				background-size:cover;
				background-position:center;
			}
			.taylor .photo {
				background-image:url('/assets/bot-<?=$botPerson?>.png');
				background-size:cover;
				background-position:center;
			}
			.name {
				color:#ff4742;
				font-weight:700;
			}
			.text {
				color:#000;
				line-height:1.5;
			}
			.text img {
				max-width:250px;
				width:100%;
				border-radius:5px;
				display:block;
				margin-top:1em;
				margin-bottom:0.5em;
			}
			.clear {
				clear:both;
			}
			.cta {
				border-radius:0.5em;
				background-color:#40afe7;
				color:#fff;
				font-weight:600;
				width:auto;
				display:inline-block;
				padding:0.35em;
				padding-right:0.6em;
				padding-left:0.5em;
				cursor:pointer;
				border-bottom:3px solid #1891CF;
			}
			.cta:hover {
				color:#2993c9;
				background-color:#fff;
			}
			.cta:active {
				border-bottom:none;
				margin-top:2px;
			}
			.cta p {
				display:inline-block;
				margin:0;
			}
			.telegram-icon {
				border:2px solid #fff;
				display:inline-block;
				vertical-align:middle;
				margin-right:0.25em;
				border-radius:100%;
				width:2em;
				height:2em;
				background: #40afe7; /* Old browsers */
				background: -moz-linear-gradient(top,  #40afe7 0%, #2993c9 100%); /* FF3.6+ */
				background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#40afe7), color-stop(100%,#2993c9)); /* Chrome,Safari4+ */
				background: -webkit-linear-gradient(top,  #40afe7 0%,#2993c9 100%); /* Chrome10+,Safari5.1+ */
				background: -o-linear-gradient(top,  #40afe7 0%,#2993c9 100%); /* Opera 11.10+ */
				background: -ms-linear-gradient(top,  #40afe7 0%,#2993c9 100%); /* IE10+ */
				background: linear-gradient(to bottom,  #40afe7 0%,#2993c9 100%); /* W3C */
				filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#40afe7', endColorstr='#2993c9',GradientType=0 ); /* IE6-9 */
				text-align:center;
				position:relative;
			}
			.cta:hover .telegram-icon {
				background:#fff;
				border:2px solid #40afe7;
			}
			.telegram-icon i {
				position:absolute;
				font-size:1em;
				color:#fff;
				margin-left:-0.05em;
				top: 50%;
				transform: translateY(-50%) translateX(-50%);
				-webkit-transform: translateY(-50%) translateX(-50%);
				-ms-transform: translateY(-50%) translateX(-50%);
				-moz-transform: translateY(-50%) translateX(-50%);
			}
			.cta:hover .telegram-icon i {
				color:#40afe7;
			}
			a {
				cursor:pointer;
				color:#40afe7;
				text-decoration:none;
				border-bottom:2px solid #40afe7;
			}
			.logo {
				font-size:2.5em;
				display:none;
				color:#fff;
				position:absolute;
				top:0.5em;
				left:0.5em;
				text-transform:lowercase;
				line-height:1;
				border-bottom:3px solid #fff;
			}
			.by {
				right:0;
				bottom:0;
				background-color:#ff4742;
				color:#fff;
				position:fixed;
				font-weight:500;
				z-index:4;
				border-top-left-radius: 0.2em;
				padding: 0.5em;
			}
			.by:hover {
				background-color:#fff;
				color:rgb(255, 71, 66);
			}
			.by img {
				border-radius:2em;
				width:1.5em;
				vertical-align:middle;
			}
			.by p {
				margin:0;
				vertical-align:middle;
				display:inline;
				margin-left:0.5em;
				font-weight:600;
			}
			h2 {
				color:#fff;
				font-weight:400;
				line-height:1.5;
				max-width:15em;
				padding:0.5em;
				margin:0 auto;
				margin-bottom:1em;
			}
			h2 a {
				color:#fff;
				font-weight:700;
				border-bottom:4px solid #fff;
			}
			.social-bar {
				display:none;
			}
			.twitter-follow-floating-container {
				position:fixed;
				display:none;
				bottom:0;
				left:0;
			}
			.dimmer-dark {
				background-color:rgba(0,0,0,0.35);
				background-color:#ff4742;
				opacity:0.85;
				position:absolute;
				top:0;
				left:0;
				width:100%;
				height:100%;
				z-index:0;
			}
			@media (max-height:500px) {
				.featured {
					display:none;
				}
			}
			@media (max-width:600px) {
				.featured {
					display:none;
				}
			}
			.featured a {
				border:none;
			}
			.featured { 
				width:100%;
				padding:0.5em;
				/*background-color:rgba(0,0,0,0.85);*/
				background-color:#fff;
				position:absolute;
				bottom:0;
				left:0;
			}
			.featured img {
				/*-webkit-filter:grayscale(1) invert(1) brightness(1.5) contrast(1.75);*/
				-webkit-filter:grayscale(1) invert(0) brightness(0.5) contrast(1.5);
				filter:grayscale(1) invert(0) brightness(0.5) contrast(1.5);;
				margin:0.5em;
				height:50px;
			}
			.featured img:hover {
				-webkit-filter:none;
				filter:none;
			}
		</style>
	</head>
	<body>

		<div class="bg">
		</div>

		<div class="logo">
			Taylor
		</div>

		<section class="top">
			<div class="contents">
				<div class="max-width">
					<div class="message first right taylor">
						<div class="photo bot"></div>
						<div class="balloon first">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								<h1>
									Hi! I'm Taylor, your travel assistant powered by A.I.
								</h1>
								While you travel, I give you advice on where to go, what to do and who to meet near you (did I tell you I <i class="em em-heart"></i> <?=$userPlaceDetected?>?)
							</div>
						</div>
					</div>
					<div class="clear"></div>

					<?/*<h1>
						Offline for 24 hours while we fix Taylor
					</h1>*/?>
					<a class="cta first" href="https://nomads.com" onclick="alert('Sorry, TaylorBot was launched but then discontinued in 2016 as it didn\'t get traction and back then AI chat bots were just not good enough like AI is now. Check out my site Nomads.com for travel recommendations - @levelsio');">
						<div class="telegram-icon"><i class="fa fa-paper-plane"></i></div>
						<p>
							chat with me
						</p>
					</a>
					<?/*<div class="clear"></div>
					<div class="try">
						or <a href="https://t.me/<?=$botUsernames[$botPerson]?>">try it on the web</a>
					</div>*/?>

				</div>

				<div class="featured">
					<a href="https://news.ycombinator.com/item?id=9830765">
						<img src="/assets/hackernews.png" />
					</a>
					<a href="http://www.producthunt.com/tech/taylor">
						<img src="/assets/producthunt.png" />
					</a>
					<a href="http://thenextweb.com/apps/2015/07/06/this-chatbot-tells-you-where-to-live-and-work-next/">
						<img src="/assets/thenextweb.png" />
					</a>
					<a href="http://techcrunch.com/2015/11/11/no-ui-is-the-new-ui/">
						<img src="/assets/techcrunch.png" />
					</a>
					<a href="https://medium.com/swlh/no-ui-is-the-new-ui-ab3f7ecec6b3#6eff">
						<img src="/assets/medium.png" />
					</a>
					<a href="https://zapier.com/blog/prototype-app-zapier/#taylor">
						<img src="/assets/zapier.png" />
					</a>
				</div>

			</div>



			<div class="contents">
				<div class="line"></div>

				<div class="max-width">

					<?if(!empty($userPlaceDetected)) {?>
						<div class="message right taylor">
							<div class="photo bot"></div>
							<div class="balloon">
								<div class="name">
									Taylor
								</div>
								<div class="text">
									I see you just arrived in <a><?=$userPlaceDetected?></a>, I love the food there!
								</div>
							</div>
						</div>
						<div class="clear"></div>
					<?}?>

					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								You say that to everyone, Taylor <i class="em em-angry"></i>
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>

				<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								Yes, yes, I do... <i class="em em-dissapointed_relieved"></i>
							</div>
						</div>
					</div>
					<div class="clear"></div>

					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								Anyhow, what can I help you with?<br/>
								<i class="em em-earth_asia"></i> Where to go<br/>
								<i class="em em-running"></i> People nearby<br/>
								<i class="em em-city_sunrise"></i> Cities nearby<br/>
								<i class="em em-hotel"></i> Places to sleep<br/>
								<i class="em em-computer"></i> Places to work<br/>
							</div>
						</div>
					</div>
					<div class="clear"></div>


					<?if(empty($placesWork)){?>

						<div class="message left pieter">
							<div class="balloon">
								<div class="name">
									Pieter
								</div>
								<div class="text">
									Me and my friend are visiting NYC next month, do you know any good places to work at?
								</div>
							</div>
							<div class="photo bot"></div>
						</div>
						<div class="clear"></div>


						<div class="message right taylor">
							<div class="photo bot"></div>
							<div class="balloon">
								<div class="name">
									Taylor
								</div>
								<div class="text">
									Here's some places near you with great WiFi you can work:</br>
									#5 <a>Absolute Coffee</a> (<i class="em em-earth_asia"></i>4km)</br>
									#4 <a>Irving Farm Coffee</a> (<i class="em em-earth_asia"></i>3km)</br>
									#3 <a>Ninth Street Espresso</a> (<i class="em em-earth_asia"></i>3km)</br>
									#2 <a>Everyman Espresso</a> (<i class="em em-earth_asia"></i>3km)</br>
									#1 <a>Berkli Parc</a> (<i class="em em-earth_asia"></i>1km)</br>
								</div>
							</div>
						</div>
						<div class="clear"></div>
					<?}
					else {?>

						<div class="message left pieter">
							<div class="balloon">
								<div class="name">
									Pieter
								</div>
								<div class="text">
									Do you know a place where I can work nearby here?
								</div>
							</div>
							<div class="photo bot"></div>
						</div>
						<div class="clear"></div>


						<div class="message right taylor">
							<div class="photo bot"></div>
							<div class="balloon">
								<div class="name">
									Taylor
								</div>
								<div class="text">
									Here's some places near you with great WiFi you can work:</br>
									<?
									$i=count($placesWork);
									foreach($placesWork as $place){
										?>
										<?if(!empty($place['img'])){?><img src="<?=str_replace('http:','https:',$place['img'])?>" /><?}?>
										#<?=$i?> <a><?=$place['name']?></a> (<i class="em em-earth_asia"></i><?=round($place['distance'])?>km) <?if(!empty($place['price']['USD'])){?>($<?=$place['price']['USD']?>/d)<?}?></br>
										<?
										$i=$i-1;
									}
									?>
								</div>
							</div>
						</div>
						<div class="clear"></div>

					<?}?>

					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								Ah that helps! <i class="em em-blush"></i><br/> Are some travelers around me I can meet up with for <i class="em em-beers"></i>?
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>

					<?if(empty($nearestUsers)){?>

						<div class="message right taylor">
							<div class="photo bot"></div>
							<div class="balloon">
								<div class="name">
									Taylor
								</div>
								<div class="text">
									Yes, there are! <i class="em em-balloon"></i> Lucky you! <br/>

									<a>@reustle</a> (<i class="em em-earth_asia"></i> New York City) (<i class="em em-runner"></i>0.2km)</br>
									<a>@lily8xo</a> (<i class="em em-earth_asia"></i> New York City) (<i class="em em-runner"></i>8km)</br>
									<a>@ddmirolli</a> (<i class="em em-earth_asia"></i> New York City) (<i class="em em-runner"></i>22km)</br>
									<a>@jnmandal</a> (<i class="em em-earth_asia"></i> New York City) (<i class="em em-runner"></i>35km)</br>
									<a>@duelist</a>  (<i class="em em-earth_asia"></i> Toronto) (<i class="em em-airplane"></i> 1h flight)</br>
								</div>
							</div>
						</div>
						<div class="clear"></div>

					<?}
					else {?>

						<div class="message right taylor">
							<div class="photo bot"></div>
							<div class="balloon">
								<div class="name">
									Taylor
								</div>
								<div class="text">
									Yes, there are! <i class="em em-balloon"></i> Lucky you! <br/>

									<?foreach($nearestUsers as $nearUser) {?>
										<a>@<?=$nearUser['username']?></a> (<i class="em em-earth_asia"></i> <?=$nearUser['nearestCityName']?>) (<?=$nearUser['transport_text']?>)</br>
									<?}?>
								</div>
							</div>
						</div>
						<div class="clear"></div>

					<?}?>



					<?if(empty($placesSleep)){?>


						<div class="message left pieter">
							<div class="balloon">
								<div class="name">
									Pieter
								</div>
								<div class="text">
									Also, do you know any places in NYC I can sleep at?
								</div>
							</div>
							<div class="photo bot"></div>
						</div>
						<div class="clear"></div>

						<div class="message right taylor">
							<div class="photo bot"></div>
							<div class="balloon">
								<div class="name">
									Taylor
								</div>
								<div class="text">
									YES! Here's some places with good ratings near you<br/>
									#3 <a>Encore Express Hotel</a> <i class="em em-star"></i><i class="em em-star"></i><i class="em em-star"></i><i class="em em-star"></i> ($95/d) (<i class="em em-earth_asia"></i>2km)<br/>
									#2 <a>USA Hotels</a> <i class="em em-star"></i><i class="em em-star"></i><i class="em em-star"></i><i class="em em-star"></i><i class="em em-star"></i> ($134/d) (<i class="em em-earth_asia"></i>2km)<br/>
									#1 <a>HI NYC</a> <i class="em em-star"></i><i class="em em-star"></i><i class="em em-star"></i><i class="em em-star"></i> ($124/d) (<i class="em em-earth_asia"></i>1km)<br/>
								</div>
							</div>
						</div>
						<div class="clear"></div>
					<?}
					else {?>

						<div class="message left pieter">
							<div class="balloon">
								<div class="name">
									Pieter
								</div>
								<div class="text">
									And where will I sleep tonight?
								</div>
							</div>
							<div class="photo bot"></div>
						</div>
						<div class="clear"></div>


						<div class="message right taylor">
							<div class="photo bot"></div>
							<div class="balloon">
								<div class="name">
									Taylor
								</div>
								<div class="text">
									Up to you 🙈 But here's some places with good ratings near you<br/>
									<?
									$i=count($placesSleep);
									foreach($placesSleep as $place){
										?>
										<?if(!empty($place['img'])){?><img src="<?=str_replace('http:','https:',$place['img'])?>" /><?}?>
										#<?=$i?> <a><?=$place['name']?></a> (<i class="em em-earth_asia"></i><?=round($place['distance'])?>km) <?if(!empty($place['price']['USD'])){?>($<?=$place['price']['USD']?>/d)<?}?></br>
										<?
										$i=$i-1;
									}
									?>
								</div>
							</div>
						</div>
						<div class="clear"></div>

					<?}?>



					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								After <a><?=$userPlaceDetected?></a>, where should I travel next?
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>


					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								Well, that depends...
							</div>
						</div>
					</div>
					<div class="clear"></div>


					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								What's your monthly budget?<br/>
								<i class="em em-moneybag"></i> $500<br/>
								<i class="em em-dollar"></i> $1,000<br/>
								<i class="em em-money_with_wings"></i> $2,000<br/>
								<i class="em em-credit_card"></i> $3,000<br/>
								<i class="em em-gem"></i> $4,000<br/>
							</div>
						</div>
					</div>
					<div class="clear"></div>


					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								I have about <i class="em em-money_with_wings"></i> $2,000 to spend
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>




					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								Cool, I think we can work with that!</br>
								What kind of <i class="em em-partly_sunny"></i> weather do you want?
							</div>
						</div>
					</div>
					<div class="clear"></div>



					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								Ah, it should be warm for sure! Don't wanna freeze <i class="em em-snowflake"></i>
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>





					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								Haha agree, can't stand the cold <i class="em em-smiley"></i><br/>
								Do you need fast internet?
							</div>
						</div>
					</div>
					<div class="clear"></div>



					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								Yes, please! <i class="em em-relaxed"></i> I'll need to work on my startups from there
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>





					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								No worries, I found 3 places PERFECT <i class="em em-ok_hand"></i> for you!</br/>
								#3 <a>Kaohsiung in Taiwan</a> is a <?=round($cities['kaohsiung-taiwan']['distance']/$config['airplane_speed'])?> hour flight from you, costs $1,326 per month to live for you and has 50mbps internet. It's currently 27°C / 80°F there and it's VERY safe.<br/>
								#2 <a>Timisoara in Romania</a> is a <?=round($cities['timisoara-romania']['distance']/$config['airplane_speed'])?> hour flight from you, costs $1,799 per month to live for you and has 90mbps internet. It's currently 23°C / 73°F there and  it's VERY safe<br/>
								#1 <a>Braga in Portugal</a> is a <?=round($cities['braga-portugal']['distance']/$config['airplane_speed'])?> hour flight from you, costs $1,408 per month to live for you and has 30mbps internet. It's currently 27°C / 80°F there and it's VERY safe<br/>
							</div>
						</div>
					</div>
					<div class="clear"></div>








					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								Nice! I'd love to visit Taiwan next!
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>



					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								Can you book me a flight with <a>Emirates</a> + a double room in a good hotel near the center for less than $50/night, somewhere around <?=date('jS F Y',strtotime("+7 days"))?>? <i class="em em-sunglasses"></i>
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>

 
					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								Sure! That's a paid request as I'll have to ask a human to complete it, I'll charge your <i class="em em-credit_card"></i> card $25 to complete it. Is that okay?
							</div>
						</div>
					</div>
					<div class="clear"></div>

					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								Sure! <i class="em em-santa"></i>
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>


					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								Great, I'll get back to you on here when I find some flights and hotels.
							</div>
						</div>
					</div>
					<div class="clear"></div>


					<div class="message left pieter">
						<div class="balloon">
							<div class="name">
								Pieter
							</div>
							<div class="text">
								Thanks, Taylor! <i class="em em-grin"></i>
							</div>
						</div>
						<div class="photo bot"></div>
					</div>
					<div class="clear"></div>



					<div class="message right taylor">
						<div class="photo bot"></div>
						<div class="balloon">
							<div class="name">
								Taylor
							</div>
							<div class="text">
								LOL, it's okay, that's what I do! <i class="em em---1"></i><br/>
							</div>
						</div>
					</div>
					<div class="clear"></div>



				</div>
			</div>

			<a href="/?n=1"><i data-person="1" class="em em-blush action-switch-person person-3 <?if($botPerson==1){?>active<?}?>"></i></a>
			<a href="/?n=2"><i data-person="2" class="em em-smiley action-switch-person person-2 <?if($botPerson==2){?>active<?}?>"></i></a>
			<a href="/?n=3"><i data-person="3" class="em em-sunglasses action-switch-person person-1 <?if($botPerson==3){?>active<?}?>"></i></a>

			<div class="contents">
				<div class="dimmer-dark"></div>
				<div class="max-width">

					<h2>
						I'm available 24/7 on Telegram to assist you in your travels
					</h2>		

					<a class="cta first" href="https://nomads.com" onclick="alert('Sorry, TaylorBot was launched but then discontinued in 2016 as it didn\'t get traction and back then AI chat bots were just not good enough like AI is now. Check out my site Nomads.com for travel recommendations - @levelsio');">
						<div class="telegram-icon"><i class="fa fa-paper-plane"></i></div>
						<p>
							chat with me
						</p>
					</a>

				</div>
			</div>

		</section>

		<a href="https://levels.io/">
			<div class="by">
				<img src="https://levels.io/levelsio.jpg" />
				<p>by levels.io</p>
			</div>
		</a>
		<link rel="stylesheet" href="/assets/font-awesome.css" />
		<link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'>
		<?require_once(__DIR__.'/foot.php');?>
	</body>
</html>
