<?php @validInc() or die; ?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="image/x-icon" rel="shortcut icon" href="<?=getLink('assets/Creyz.ico')?>"/><title><?=$CONFIG['website-title']?></title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.8.1/build/cssreset/cssreset-min.css">
<link href="<?=getLink('css/bootstrap.min.css')?>" rel="stylesheet">
<link href="<?=getLink('css/main.css')?>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<?=getLink('nivo/nivo-slider.css')?>" type="text/css" media="screen" />
<script src="<?=getLink('js/jquery-1.11.0.min.js')?>" type="text/javascript"></script>
<script src="<?=getLink('js/jquery-ui-1.10.3.min.js')?>"></script>
<script src="<?=getLink('js/clock.js')?>"></script>
<script src="<?=getLink('js/dropdown.js')?>"></script>

  <style>
  label {
    display: inline-block;
    width: 5em;
  }
  </style>
  <script>
  $(function() {
    $( document ).tooltip({
      track: true
    });
  });
  </script>
</head>
<body>

<div class="nav-placeholder">
  <div class="navbar">
    <div class="navbar-inner">
      <a class="brand" href="<?=getLink()?>"></a>
      <ul class="nav">

	          <li><a href="#" onclick="GamesMenu(); return false;">Games<i class="icon-chevron-down games-icon icon-white"></i></a>
		<div id="games_menu" style="display:none; position:absolute; z-index:9999; margin-left:-7px;">
			<ul id="games_menu_ul">
				<li class="games_li"><a href="#">Rising</a></li>
				<li class="games_li"><a href="#">Eclipse</a></li>
				<li class="games_li"><a href="http://minecraft.mymmoplanet.net/">MineCraft</a></li>
			</ul>
		</div>
		</li>
		
        <li><a href="http://forum.mymmoplanet.net/">Forums</a></li>
        <li><a href="<?=getLink('Account')?>">Account</a></li>
        <li><a href="<?=getLink('Store')?>">Store</a></li>
        <li class="nav-last"><a href="#">Support</a></li>
      </ul>
      <div id="liveClock" title="Local Server Time">
        <i class="icon-time icon-white"></i>
        <span class="clock"></span>
      </div>

<script>
	var is_opn = false;
	function GamesMenu()
	{
		if( is_opn == true )
		{
			$("#games_menu").fadeOut();
			is_opn = false;
		}
		else
		{
			$("#games_menu").fadeIn();
			is_opn = true;
		}
	}
</script>
  
      <ul class="nav right">
		<?php if(loggedIn()) { ?>
		<div id="LoggedIn">
        <?=$USER['sUsername']?>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;$0&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="Logout">Logout</a>
		</div>
		<?php }else{ ?>
        <li><a id="loginBtn" class="btn btn-primary button-login" href="#myModal" role="button" class="btn" data-toggle="modal">Login</a></li>
        <li><a id="registerBtn" class="btn btn-primary button-register" href="#regModal" role="button" class="btn" data-toggle="modal">Register</a></li>
		<?php } ?>
      </ul>
    </div>
  </div>
</div>
<div class="clearfix"></div>
<div class="red-line"></div>
<?php if(!loggedIn()){ ?>
<!-- Modal Login -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  </div>
  <div class="modal-body" style="padding-bottom:0px">
    <div class="modal-logo"></div>
    <form method="post" id="signin" action="<?=$_SERVER["REQUEST_URI"]?>">
      <fieldset>
		<?php
		if(count($ERRORS['login'])>0){
			echo '<p><center>';
			$countArr = count($ERRORS['register']);
			$i = 0;
			foreach($ERRORS['login'] as $t)
			{
				echo $t . ((++$i == $countArr)?'':'</br>');
			}
			echo '</center></p>';
		}
		?>
	    <input type="hidden" name="postType" value="login" />
        <input class="input" type="text" name="username" placeholder="Username" required maxlength="32" <?=((isset($_POST['username']) && count($ERRORS['login'])>0)?'value="'.$_POST['username'].'" ' : '')?>/>
        <input class="input" type="password" name="password" required placeholder="Password"/>
        <input class="btn btn-large btn-block btn-cupid-green" type="submit" value="Log In" />
      </fieldset>
    </form>
  </div>
  <div class="modal-footer">
    <a class="login-options" href="#">Forgot ID/PW?</a>
  </div>
</div>

<!-- Modal Register-->
<div id="regModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel"></h3>
  </div>
  <div class="modal-body">
    <div class="modal-logo"></div>
    <form method="post" id="signin" action="<?=$_SERVER["REQUEST_URI"]?>">
      <fieldset id="max">
		<input type="hidden" name="postType" value="register" />
		
        <div class="control-group">
          <div class="controls">
			<?php if(count($ERRORS['register'])>0){
				echo '<p><center>';
				$countArr = count($ERRORS['register']);
				$i = 0;
				foreach($ERRORS['register'] as $t)
				{
					echo $t . ((++$i == $countArr)?'':'</br>');
				}
				echo '</center></p>';
			} ?>
			<input type="text" required name="inputEmail" placeholder="Email" title="Email must be valid" <?=((isset($_POST['inputEmail']) && count($ERRORS['register'])>0)?'value="'.$_POST['inputEmail'].'" ' : '')?>/>
            <input type="text" required name="inputUsername" placeholder="Username" title="Minimum 5 characters, no symbols" <?=((isset($_POST['inputUsername']) && count($ERRORS['register'])>0)?'value="'.$_POST['inputUsername'].'" ' : '')?>/>
			<input type="password" required name="inputPassword" placeholder="Password" title="Minimum 8 characters" />
			<input type="password" required name="inputConPassword" placeholder="Re-Enter Password" title="Must be similar" />
			<?php
			require_once('recaptchalib.php');
			echo recaptcha_get_html($CONFIG['reCAPTCHA_publicKey']);
			?>
          </div>
        </div>

        

        <input class="btn btn-large btn-block btn-cupid-green" type="submit" value="Register" />
      </fieldset>
    </form>
  </div>
  <div class="modal-footer">
    <a class="login-options" href="#">Already have an account? Login here!</a>
  </div>
</div>
<?php }
if(count($ERRORS['login'])>0){ ?>
<script>
function FailedToLogin()
{
	document.getElementById('loginBtn').click();
}
window.onload=FailedToLogin;
</script>
<?php }elseif(count($ERRORS['register'])>0){ ?>
<script>
function FailedToRegister()
{
	document.getElementById('registerBtn').click();
}
window.onload=FailedToRegister;
</script>
<?php } ?>