<?php
$u = $_SERVER['REQUEST_URI'];
if (substr($u, strlen($u)-1) == '/') {
	$u = substr($u, 0, strlen($u)-1);
	header("Location: $u");
}
$u = explode('/', $u);
$u = $u[sizeof($u)-1];
if (strpos($u, '?') === 0)
	$u = substr($u, 1);


header('content-type: text/html; charset=UTF-8');
$TITLE = 'Niels\' nature';

$o = array(
   'da' => 'Dansk',
   'en' => 'English'
);

if ($u == '')
	$special = 1;
elseif (array_key_exists($u, $o)) {
	include("langs/$u.php");
	$special = 0;
}
else
	$special = 2;

if ($special)
	$spestr = " style='display: none;'";
else
	$spestr = '';

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml" xml:lang="<?=$LANG?>" lang="<?=$LANG?>">
<head>
	<title><?=$TITLE?></title>
	
	<link href='style.css' type='text/css' rel='stylesheet' />
	<script type='text/javascript' src='subtitler.js'></script>
	<script type='text/javascript' src='script.js'></script>
</head>
<body>
	<object data='img/bgflow.svg' type='image/svg+xml' id='bgflow'></object>
	
	<div id='text_wrapper'>
		<div id='text_box'>
			<a class='img' id='text_header' href='.'>
				<div id='text_header_content'>
					<?=$TITLE?>
				</div>
			</a>
			<div id='text_header_space'></div>
			<ul id='text_menu'<?=$spestr?>>
				<li><a href='#start'><?=$MENU_START?></a></li>
				<li><a href='#episodes'><?=$MENU_EPISODES?></a></li>
				<li><a href='#details'><?=$MENU_DETAILS?></a></li>
				<div class='end'></div>
			</ul>
			<div id='text_content'>
				<div id='content_start'<?=$spestr?>><noscript><a name='start'></a></noscript><?=$CONTENT_START?></div>
				<div id='content_episodes'<?=$spestr?>><noscript><a name='episodes'></a></noscript><?=$CONTENT_EPISODES?></div>
				<div id='content_details'<?=$spestr?>><noscript><a name='details'></a></noscript><?=$CONTENT_DETAILS?></div>
				<?php if ($special == 1) { ?>
				<h1>Hej / Hi</h1>
				<hr />
				<?php
					foreach ($o as $k=>$v)
						echo "<p class='large'><a href='$k'>$v</a></p>\n"
				?>
				<div style='width: 513px; height: 291px;'></div>
				<img src='img/forest-distorted.jpg' alt='Nature' title='Nature'
				     class='bottom-page' />
				<?php } else if ($special == 2) { ?>
				<h1>Oh no!</h1>
				<hr />
				<p>The language using the '<?=$u?>' code isn't supported yet!</p>
				<p>If you like, <i>you</i> can be the one to translate "Niels' nature" into this language. Simply contact Niels at <a href='mailto:ngws@metanohi.name'>ngws@metanohi.name</a>.</p>
				<?php } ?>
			</div>
		</div>
	</div>
</body>
</html>