<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/_functions/users.functions.php');



if(isset($_GET['destination'])){

$destination = $_GET['destination'];

}

else {

$destination = '/my–listings';

}



$login = rememberMe($_COOKIE, $destination);



$data = array('email', 'password');

$form = formData($_POST, $data);



if(!$login){

$login = login($_POST, $_SERVER['REMOTE_ADDR'], $destination);

}



$page_title = 'Log in';

$html_class = 'dating_drinks';

require_once($_SERVER['DOCUMENT_ROOT'] . '/_includes/header.php');

?>



<section>



<article id="login" class="half–blocks">

<h2>Log into Tampa Bay Networkers</h2>



<div id="login–form">

<?php if(!empty($login)): ?>

<ul class="errors">

<?php foreach($login['errors'] as $msg): ?>

<li><?php echo $msg; ?></li>

<?php endforeach; ?>

</ul>

<?php endif; ?>



<script>

$(function(){

$('input#email').focus();

});

</script>



<form action="" method="post" class="standard–form">

<label for="email">Email</label>

<input type="text" name="email" id="email" value="<?php echo $form['email']; ?>" placeholder="Email address" />



<label for="password">Password</label>

<input type="password" name="password" id="password" placeholder="Password" />



         <p id="robot">

            <span id="robo–check" class="robot">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> I am not a robot

         </p>



<button class="cta–button" type="submit">Log in</button>



<p>

<a href="/forgot–password.php">Forgot your password?</a>

</p>

</form>

</div>



<div id="login–now">

<p>

Log into your existing Tampa Bay Networkers account.

</p>



<h3>Not a member?</h3>



<p>

<a href="/register.php">Register now</a>

</p>

</div>



<div></div>

</article>



<?php include($_SERVER['DOCUMENT_ROOT'] . '/_includes/side–form.php'); ?>



</section>



      <script>

       $(function(){

         var robotcheck = $('span#robo–check');

         var space = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';



         robotcheck.click(function(){

          if($(this).hasClass('person')){

            $(this).removeClass('person');

            $(this).addClass('robot');

            $(this).html(space);

          }

          else {

            $(this).removeClass('robot');

            $(this).addClass('person');

            $(this).html('&nbsp;&#x2714;&nbsp;');

          }

         });



         $('form').submit(function(){

          if(robotcheck.hasClass('robot')){

            $('p#robot').css('color', '#f00');

            $('button[type=submit]').removeAttr('disabled');

            return false;

          }

          else {

            return true;

          }

         });

       });

      </script>



<?php

   require_once($_SERVER['DOCUMENT_ROOT'] . '/_includes/footer.php');

?>