<?php
use \lithium\security\Auth;
?>
<!DOCTYPE html>
<html>
<head>
	<?= $this->html->charset(); ?>
	<title>OtakuHub<?php $title = $this->title(); if ($title) echo " > $title" ?></title>
	<?= $this->html->style(array('style', 'base')) ?>
	<?= $this->html->style('themes/light') ?>
	<?= $this->html->style('jquery.fancybox-1.3.4') ?>
	<?= $this->html->style('http://fonts.googleapis.com/css?family=Cantarell:regular,bold&amp;v1') ?>
	<?= $this->styles(); ?>
</head>
<header>
	<?php
	$links = array(
		'Home' => '/',
		'Anime' => '/anime',
		'Manga' => '/manga',
	);
	$user = Auth::check('default');
	if ($user)
	{
		$links['Feed'] = '/users/feed';
		$links['Profile'] = '/users/feed';
		$links['Logout'] = '/logout';
	}
	else
	{
		$links['Sign up'] = '/signup';
		$links['Login'] = '/login'; // overwritten with JS; see functions.js
		echo '
		<div style="display: none"><div id="login">
		<h2>Login</h2>
		';
		echo $this->form->create(null, array('url' => '/login'));
		echo $this->form->field('username',
				array('type' => 'text', 'id' => 'f_username'));
		echo $this->form->field('password',
				array('type' => 'password', 'id' => 'f_password'));
		echo $this->form->field('remember',
				array('type' => 'checkbox', 'id' => 'f_remember', 'label' => 'Remember me'));
		echo $this->form->submit('Login');
		echo $this->form->end();
		echo '</div></div>';
	}
	echo '
	<nav>
	<ul>
	';
	foreach ($links as $name => $path) {
		if ($path == '/')
			echo '<li class="current">';
		else
			echo '<li>';
		echo "<a href=\"$path\">$name</a></li>";
	}
	echo '
	</ul>
	</nav>
	';
	?>

	<?= $this->form->create(null, array('url' => '/search/index/anime', 'class' => 'search', 'method' => 'get')); ?>
	<?= $this->form->text('search', array('placeholder' => 'Search...')); ?>
	<input type="submit" value="Go">
	<?= $this->form->end(); ?>

	<br class="cl" />
</header>
<div id="page">
	<?php echo $this->content() ?>
</div>
<footer>
	<p>Copyright ©2011, <a href="http://www.melenion.org">Melenion Dev Studios</a></p>
	<br class="cl" />
</footer>

<?= $this->html->script("http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"); ?>
<?= $this->html->script("/js/jquery.anchor.js"); ?>
<?= $this->html->script("/js/jquery.tools.min.js"); ?>
<?= $this->html->script("/js/jquery.form.js"); ?>
<?= $this->html->script("/js/jquery.tipsy.js"); ?>
<?= $this->html->script("/js/jquery.fancybox-1.3.4.pack.js") ?>
<?= $this->html->script("/js/functions.js"); ?>
<?= $this->scripts(); ?>

</body>
</html>
