<?php
$time_start = microtime(true);
require('setClassPath.php');
require_once('db/TransManager.php');
require_once('object/User.php');
require_once('db/UserDB.php');
require_once('ui/Component.php');

$trans = TransManager::getInstance();
$trans->beginTrans();
$userdb = new UserDB();

$users = $userdb->getLatestUsers($trans->getPDO(), 14);

$trans->commit();
$trans->disconnect();

session_start();
$user = $_SESSION['user'];

$ui = Component::getInstance();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Would I Date You?</title>
<link type="text/css" rel="stylesheet" href="/css/main.css">
<link type="text/css" rel="stylesheet" href="/css/index.css">
<!--[if IE]>
<style type="text/css">
#mpPix b { margin-top: -18px; }
</style>
<![endif]-->
</head>
<body>

<div id="body">

<table id="top" cellspacing="0">
  <tr>
    <td id="couplepic">
<?php
$ui->drawRandomCouplePic();
?></td>
    <td id="toptxt">
      <h1>Free Online Dating With a Twist!</h1>
      <p class="lg">Our members (<i>membership is free!</i>) create personalized quizzes to find dating matches. Other dating sites have one-size-fits-all matching: an algorithm written by someone you've never met. We let you be an individual!  No one knows what you're looking for better than you. <a href="/account/join1.html" class="wh">Start now</a>.</p>
    </td>
  </tr>
</table>

<?php
$ui->drawSearchForm($user);
?>

<div id="mpPixBlock">
<h3>Below Are Some of Our New Members</h3>
<ul id="mpPix">
<?php
if (!$users) 
    echo '<li>No accounts yet!</li>';
else {
    for ($i = 0, $n = count($users); $i < $n; ++$i) {
        echo '<li'. ($i % 2 == 1 ? ' class="a"' : '') .'><b><a class="wh" href="/profile/'. $users[$i]->getFName() .'">'. $users[$i]->getName() .'</a>, '. $users[$i]->getAge() . strtolower($users[$i]->getGender()) .'</b>';
        if ($users[$i]->hasPicture()) {
            $picture = $users[$i]->getPicture();
            echo '<a class="wh" href="/profile/'. $users[$i]->getFName() .'"><img src="/pic/'. $picture->getDirName() . $picture->getThumbName() .'"></a>';
        }
        else
            echo '<a class="wh" href="/profile/'. $users[$i]->getFName() .'"><img src="/i/nopicsm.gif"></a>';
?>
      <div class="loc"><?= $users[$i]->getLocation()->getDescriptiveName() ?></div>
      <div class="pdesc"><?= strip_tags($users[$i]->getProfileDetails()->getDescription()) ?>...</div>
    </li>
<?php
    }
}
?>
</ul>
</div>

<div id="xtra">
  <div id="xtra2">
    <div id="xtra3">
      <img src="/i/couple2.jpg" alt="Happy Couple" id="xtraimg">
      If you've been looking for a free dating site that offers a bit more than the bare-bones features that 
      most such sites offer, you're at the right place.<br>
      <b>The idea is simple:</b> engage your creativity by creating your own compatability quiz for others to take. 
      Our quiz-maker tool enables you to do this easily.  Then when someone takes your quiz, we'll show you 
      the results, and you decide whether you want to get to know this person better.  It's fun, easy, and free!
      <br>
      Looking for something fun? Try our <a href="/pquiz/quiz1.html">Dating Profile Quiz</a>. It will list your top 
        compatability traits.
    </div>
  </div>
</div>
<br style="clear: both;">

<?php
$ui->drawHeader($user);
$ui->drawFooter();
?>

<?php
$time_end = microtime(true);
$time = $time_end - $time_start;

echo "<!-- page generated in $time seconds -->\n";
?>
</div>

</body>
</html>
