<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>



<!-- Loading Theme file(s) -->
    <link rel="stylesheet" href="http://www.zapatec.com/website/main/../ajax/zpcal/themes/aqua.css" />

<!-- Loading Calendar JavaScript files -->
    <script type="text/javascript" src="http://www.zapatec.com/website/main/../ajax/zpcal/../utils/zapatec.js"></script>
    <script type="text/javascript" src="http://www.zapatec.com/website/main/../ajax/zpcal/src/calendar.js"></script>
<!-- Loading language definition file -->
    <script type="text/javascript" src="http://www.zapatec.com/website/main/../ajax/zpcal/lang/calendar-en.js"></script>
<link href="SpryAccordian2.css" rel="stylesheet" type="text/css">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>UserHub</title>

<style type="text/css">
<!--
body {
    background-image: url();
    background-color: #000000;
    background-repeat: no-repeat;
    background-position:center;    
}
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    color: #000000;
}
-->
</style>
<script src="SpryAccordion.js" type="text/javascript"></script>
<link href="SpryAccordion.css" rel="stylesheet" type="text/css">
<link href="myLadderCSS.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style2 {
    font-size: 18px
}
.style3 {font-size: 24px}
.style5 {
    font-size: 24px;
    font-weight: bold;
    font-style: italic;
}
.style9 {font-size: 16px}
.styleTableHead {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: bold;
}
.style11 {color: #333333; font-weight: bold; font-style: italic; font-size: 24px; }
.style12 {font-size: 12px}
.style13 {font-size: 10px}
.style14 {
    font-size: 14px;
    font-weight: bold;
}
.error {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #FF0000;
    text-decoration: blink;
}
-->
</style>


</head>
<body>




<?php 

session_start
(); 

if (empty(
$_SESSION['currentUser']))
{
    
header ("Location: ladder.php");
}

if (empty(
$_SESSION['defaultPanel']))
{
    
$_SESSION['defaultPanel'] = 0;
}

if (empty(
$_SESSION['error']))
{
    
$_SESSION['error'] = NULL;
}

if (empty(
$_SESSION['errorChal']))
{
    
$_SESSION['errorChal'] = NULL;
}

?>


<table width="100%" border="0"cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3"><img src="../pics/BWfade.jpg" alt="top curve" width="100%" height="20"></td>
  </tr>
  <tr>
    <td width="100px" bgcolor="#DCDCDC"><div align="center" class="style5"></div></td>
    <td bgcolor="#DCDCDC"><div align="center"><span class="style5">Welcome to the Ladder <?php echo $_SESSION['currentUser']; ?></span></div></td>
    <td width="100px" align="left" valign="bottom" nowrap bgcolor="#DCDCDC"><a href="logout.php" target="_self"><em><strong>Log Out</strong></em></a></td>
  </tr>
  <tr>
    <td colspan="3"><img src="../pics/BWfadeLow.jpg" alt="bottom curve" width="100%" height="20"></td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
  </tr>
</table>

<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="170">&nbsp;</td>
    <td rowspan="3">&nbsp;</td>
    <td width="550" rowspan="3">&nbsp;</td>
    <td rowspan="3">&nbsp;</td>
    <td width="170">&nbsp;</td>
  </tr>
  <tr>
    <td width="170"><img src="../pics/white_curve.jpg" alt="top curve" width="170" height="5" align="bottom"></td>
    <td width="170"><img src="../pics/white_curve.jpg" alt="top curve" width="170" height="5"></td>
  </tr>
  <tr>
    <td width="170" bgcolor="#FFFFFF"><div align="center"><span class="style11">Statistics</span></div></td>
    <td width="170" bgcolor="#FFFFFF"><div align="center"><span class="style11">Info</span></div></td>
  </tr>
  <tr>
    <td width="170" bgcolor="#FFFFFF">
    
    <div id="Accordion2">
      <div class="AccordionPanel">
        <div class="AccordionPanelTab style9">
        <div align="left">Current Standings</div>
        </div>
        <div class="AccordionPanelContent2">
        <br>
        <?php $connection = new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
    
$result $connection->query("SELECT username, rank FROM Player WHERE active=true ORDER BY rank");
    
    echo 
'<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">';
    echo 
"<tr>";
        echo 
"<td><B>NAME</B></td>";
        echo 
"<td><B>RANK</B></td>";
    echo
"</tr>";
    foreach (
$result as $resultRow)
    {
    
          echo 
"<tr>";
            echo 
"<td>{$resultRow['username']}</td>";
            echo 
"<td>{$resultRow['rank']}</td>";
          echo
"</tr>";
    }
    echo 
"</table>";
    
?>
    
    <p></p>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab style9">
          <div align="left">Match Winning %</div>
        </div>
        <div class="AccordionPanelContent2"> <br />
            <?php
    
    $connection 
= new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
    
$result $connection->query('SELECT sub1.username, cast(((wins*1.0)/((wins*1.0)+(loses*1.0)))*100 as INT) as "win%"
FROM Player  
LEFT OUTER JOIN
(SELECT username, count(winner) AS wins FROM Match RIGHT OUTER JOIN Player ON Match.winner = Player.username GROUP BY Match.winner, Player.username) AS sub1
ON sub1.username = Player.username
LEFT OUTER JOIN
(SELECT username, count(loser) AS loses FROM Match RIGHT OUTER JOIN Player ON Player.username = Match.loser GROUP BY Match.loser, Player.username) AS sub2
ON sub1.username = sub2.username AND (wins != 0 OR loses != 0) WHERE active=true ORDER BY rank'
);
    
    echo 
'<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">';
    echo 
"<tr>";
        echo 
"<td><B>NAME</B></td>";
        echo 
"<td><B>WIN%</B></td>";
    echo
"</tr>";
    foreach (
$result as $resultRow)
    {
        
          echo 
"<tr>";
            echo 
"<td>";
            if (
$resultRow['username'] == $_SESSION['currentUser'])
            {
                echo 
"<i>";
            }
            echo 
"{$resultRow['username']}";
            if (
$resultRow['username'] == $_SESSION['currentUser'])
            {
                echo 
"</i>";
            }
            echo
"</td>";
            echo 
"<td>";
            if (
$resultRow['username'] == $_SESSION['currentUser'])
            {
                echo 
"<i>";
            }
            if (
$resultRow['win%'] != NULL)
            {
                echo 
"{$resultRow['win%']}";
            }
            else
            {
                echo 
"0";
            }
            if (
$resultRow['username'] == $_SESSION['currentUser'])
            {
                echo 
"</i>";
            }
            echo 
"</td>";
          echo
"</tr>";
          if (
$resultRow['username'] == $_SESSION['currentUser'])
          {
            echo 
"</i>";
          }
    }
    echo 
"</table>";
    
    
?>
            <p></p>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Games Won</div>
        <div class="AccordionPanelContent"> <br />
            <?php $connection = new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
    
$result $connection->query("SELECT username, count(winner) as num FROM player, game WHERE active=true and username=winner group by username ORDER BY num DESC");
    
    echo 
'<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">';
    echo 
"<tr>";
        echo 
"<td><B>NAME</B></td>";
        echo 
"<td><B>WON</B></td>";
    echo
"</tr>";
    foreach (
$result as $resultRow)
    {
    
          echo 
"<tr>";
            echo 
"<td>{$resultRow['username']}</td>";
            echo 
"<td>{$resultRow['num']}</td>";
          echo
"</tr>";
    }
    echo 
"</table>";
    
?>
            <p></p>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Games Lost</div>
        <div class="AccordionPanelContent"> <br />
            <?php $connection = new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
    
$result $connection->query("SELECT username, count(loser) as num FROM player, game WHERE active=true and username=loser group by username ORDER BY num");
    
    echo 
'<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">';
    echo 
"<tr>";
        echo 
"<td><B>NAME</B></td>";
        echo 
"<td><B>LOST</B></td>";
    echo
"</tr>";
    foreach (
$result as $resultRow)
    {
    
          echo 
"<tr>";
            echo 
"<td>{$resultRow['username']}</td>";
            echo 
"<td>{$resultRow['num']}</td>";
          echo
"</tr>";
    }
    echo 
"</table>";
    
?>
            <p></p>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Matches Won</div>
        <div class="AccordionPanelContent"> <br />
            <?php $connection = new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
    
$result $connection->query("SELECT username, count(winner) as num FROM player, match WHERE active=true and username=winner group by username ORDER BY num");
    
    echo 
'<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">';
    echo 
"<tr>";
        echo 
"<td><B>NAME</B></td>";
        echo 
"<td><B>WON</B></td>";
    echo
"</tr>";
    foreach (
$result as $resultRow)
    {
    
          echo 
"<tr>";
            echo 
"<td>{$resultRow['username']}</td>";
            echo 
"<td>{$resultRow['num']}</td>";
          echo
"</tr>";
    }
    echo 
"</table>";
    
?>
            <p></p>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Matches Lost</div>
        <div class="AccordionPanelContent"> <br />
        <?php $connection = new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
    
$result $connection->query("SELECT username, count(loser) as num FROM player, match WHERE active=true and username=loser group by username ORDER BY num");
    
    echo 
'<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">';
    echo 
"<tr>";
        echo 
"<td><B>NAME</B></td>";
        echo 
"<td><B>WON</B></td>";
    echo
"</tr>";
    foreach (
$result as $resultRow)
    {
    
          echo 
"<tr>";
            echo 
"<td>{$resultRow['username']}</td>";
            echo 
"<td>{$resultRow['num']}</td>";
          echo
"</tr>";
    }
    echo 
"</table>";
    
?>
        
        
        
        <p></p>
        </div>
      </div>
    </div>    </td>
    <td>&nbsp;</td>
    <td width="550">
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
            <td width="100%"><img src="../pics/white_curve.jpg" alt="top curve" width="550" height="10"></td>
        </tr>
          <tr>
            <td width="100%" align="center" bgcolor="#FFFFFF"><div align="center" class="style1">
              <div id="Accordion1">
                <div class="AccordionPanel">
                    <div class="AccordionPanelTab style2">
                      <div align="center">Recent Matches</div>
                    </div>
                  <div class="AccordionPanelContent style3">
                      <br />

                              <?php 
                            $textMonth 
date('F');
                            
$lastmonth mktime(000date("m")-1date("d"),   date("Y"));
                            
$textLastMonth date('F'$lastmonth);
                            
                            echo 
"<p>Matches in $textMonth and $textLastMonth</p>";

                            
?>

                     
                      <?php $connection = new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
                      
$result $connection->query("select * from match ORDER BY played DESC");
    
                        echo 
"<table width='90%' border='0' cellspacing='0' cellpadding='0'>";
                        
                            echo 
"<tr>";
                              echo 
"<td><span class='styleTableHead'>Winner</span></td>";
                              echo 
"<td><span class='styleTableHead'>Loser</span></td>";
                              echo 
"<td><span class='styleTableHead'>Time</span></td>";
                              echo 
"<td><span class='styleTableHead'>Won</span></td>";
                              echo 
"<td><span class='styleTableHead'>Lost</span></td>";
                            echo 
"</tr>";
                            
                            echo 
"<tr>";
                              echo 
"<td><span class='style15'> </span></td>";
                              echo 
"<td><span class='style15'> </span></td>";
                              echo 
"<td><span class='style15'> </span></td>";
                              echo 
"<td><span class='style15'> </span></td>";
                              echo 
"<td><span class='style15'> </span></td>";
                            echo 
"</tr>";
                        
                        foreach (
$result as $resultRow)
                        {
                            
$isRecent $resultRow['played'];
                            
$month substr($isRecent52);
                            
                            
//print $month;
                            //print " ";
                            //print date('m');
                            
                            
                            
if ($month == date('m') || $month == date('m')-|| $month == date('m')+11)
                            {
                            
                              echo 
"<tr>";
                                echo 
"<td><span class='style9'>{$resultRow['winner']}</span></td>";
                                echo 
"<td><span class='style9'>{$resultRow['loser']}</span></td>";
                                echo 
"<td><span class='style9'>{$resultRow['played']}</span></td>";
                                echo 
"<td><span class='style9'>{$resultRow['won']}</span></td>";
                                echo 
"<td><span class='style9'>{$resultRow['lost']}</span></td>";
                              echo
"</tr>";
                              
                            }
                        }
                        echo 
"</table>";
                        
?>
                  </div>
                </div>
                  <div class="AccordionPanel">
                    <div class="AccordionPanelTab style2">
                      <div align="center">Enter Match Results</div>
                    </div>
                    <div class="AccordionPanelContent">
                    <br />
                      <p class="style3">Record Results For a Previous Match</p>
                      <p></p>
                      <?php
                      
                              
//$now = date('U');
                      
                              
$connection = new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
                            
$result $connection->query("SELECT challenger, challengee, scheduled FROM Challenge WHERE accepted IS NOT NULL");
                            

                            foreach (
$result as $resultRow)
                            {
                                if (
$_SESSION['currentUser'] == $resultRow['challenger'] || $_SESSION['currentUser'] == $resultRow['challengee'])
                                {
                                    echo 
"<p class='style12'>Please Enter Results for Match Scheduled at: ".$resultRow['scheduled']."</p>";
                                    
                                    echo 
"<p></p>";
                                    echo 
"<p class='error'>{$_SESSION['error']}</p>";
                                    echo 
"<p></p>";
                                    
                                    echo 
"<form id='matchResults' name='matchResults' method='post' action='recordMatch.php'>";
                                
                                    echo 
"<table width='50%' border='0' align='center' cellpadding='0' cellspacing='8'>";
                                    
                                    
                                    echo 
"<tr>";
                                        echo 
"<td><div align='center'><B>Game#</B></div></td>";
                                        echo 
"<td><div align='center'><B>Your Score</B></div></td>";
                                        echo 
"<td><div align='center'><B>Opponent Score</B></div></td>";
                                    echo
"</tr>";
                                    
                                    echo 
"<tr>";
                                        echo 
"<td><div align='center'><B>1</B></div></td>";
                                        echo 
"<td><div align='center'><input name='Y1' type='text' value='' size='2' maxlength='2'/></div></td>";
                                        echo 
"<td><div align='center'><input name='E1' type='text' value='' size='2' maxlength='2'/></div></td>";
                                    echo
"</tr>";
                                    
                                    echo 
"<tr>";
                                        echo 
"<td><div align='center'><B>2</B></div></td>";
                                        echo 
"<td><div align='center'><input name='Y2' type='text' value='' size='2' maxlength='2'/></div></td>";
                                        echo 
"<td><div align='center'><input name='E2' type='text' value='' size='2' maxlength='2'/></div></td>";
                                    echo
"</tr>";
                                    
                                    echo 
"<tr>";
                                        echo 
"<td><div align='center'><B>3</B></div></td>";
                                        echo 
"<td><div align='center'><input name='Y3' type='text' value='' size='2' maxlength='2'/></div></td>";
                                        echo 
"<td><div align='center'><input name='E3' type='text' value='' size='2' maxlength='2'/></div></td>";
                                    echo
"</tr>";
                                    
                                    echo 
"<tr>";
                                        echo 
"<td><div align='center'><B>4</B></div></td>";
                                        echo 
"<td><div align='center'><input name='Y4' type='text' value='' size='2' maxlength='2'/></div></td>";
                                        echo 
"<td><div align='center'><input name='E4' type='text' value='' size='2' maxlength='2'/></div></td>";
                                    echo
"</tr>";
                                    
                                    echo 
"<tr>";
                                        echo 
"<td><div align='center'><B>5</B></div></td>";
                                        echo 
"<td><div align='center'><input name='Y5' type='text' value='' size='2' maxlength='2'/></div></td>";
                                        echo 
"<td><div align='center'><input name='E5' type='text' value='' size='2' maxlength='2'/></div></td>";
                                    echo 
"</tr>";
                                    
                                    echo 
"<tr>";
                                        echo 
"<td colspan='3'><p></p></div></td>";
                                    echo 
"</tr>";
                                    
                                    echo 
"<tr>";
                                        echo 
"<td colspan='3'><div align='center'><input type='submit' name='submitMatchResults' id='submitMatchResults' value='Submit'/></div></td>";
                                    echo 
"</tr>";
                                    
                                    if (
$_SESSION['currentUser'] == $resultRow['challenger'])
                                    {
                                        
$enemy $resultRow['challengee'];
                                    }
                                    else
                                    {
                                        
$enemy $resultRow['challenger'];
                                    }
                                    
                                    echo 
"</table>";
                                    echo 
"<input name='hiddenEnemy' type='hidden' id='hiddenEnemy' value='{$enemy}'/>";
                                    echo 
"<input name='hiddenTime' type='hidden' id='hiddenTime' value='{$resultRow['scheduled']}'/>";
                                    echo 
"</form>";
                                    
                                }

                                
                            }
                            
                            
$nothing $result->fetch(PDO::FETCH_BOTH);
                            
$nothing $nothing[0];
                            
                            
//if ($nothing == NULL)
                            //{
                            //    echo "<p class='style14'>Play a Match to Enter Match Results</p>";
                            //}

                      
?>
                      <p></p>
                    </div>
                  </div>
                  <div class="AccordionPanel">
                    <div class="AccordionPanelTab style2">
                      <div align="center">Make a Challenge</div>
                    </div>
                    <div class="AccordionPanelContent">
                    <br />
                      <p class="style3">Challenge Another Player!</p>
                      <p class="style13">Note: Only legal challengees are shown.<br>
                      You cannot make a challenge if you have a pending accepted match.</p>
                      <?php echo "<p class='error'>{$_SESSION['errorChal']}</p>"?>
                      <form action="makeChal.php" method="post" name="form1" class="style12">
                        <table width="80%" height="46" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td width="54%"><span class="style14">Challengee</span></td>
                            <td width="46%"><p>
                            
                              <?php
                            
                            $connection 
= new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
                              
$result $connection->query("select p.username as challenger, c.username as challengee
                                                        from player as p, player as c
                                                        where p.active=true and c.active=true and p.username <> c.username and
                                                        c.rank between (p.rank-3) and (p.rank-1) and
                                                        not exists (select * from challenge
                                                        where (challenger = c.username or
                                                        challengee = c.username) and
                                                        accepted notNull)"
);
                                                        
                            echo 
"<select name='challengeWho' id='challengeWho'>";
                            
                            foreach (
$result as $resultRow)
                            {
                                if (
$resultRow['challenger'] == $_SESSION['currentUser'])
                                {
                                    echo 
"<option value='{$resultRow['challengee']}'>{$resultRow['challengee']}</option>";
                                }
                            }
                            
                              echo 
"</select>"
                            
                            
                            
?>
                            </p>                            </td>
                          </tr>
                          <tr>
                            <td colspan="2">                          </td>
                          </tr>
                          <tr>
                            <td><span class="style14">Match Date/Time</span></td>
                            <td>
                                <input type="text" id="scheduled" name="scheduled" readonly ="true" />
                                <button id="trigger">...</button>
                              <script type="text/javascript">//<![CDATA[
                                  Zapatec.Calendar.setup({
                                    firstDay          : 1,
                                    weekNumbers       : false,
                                    showsTime         : true,
                                    range             : [2007.01, 2999.12],
                                    electric          : false,
                                    inputField        : "scheduled",
                                    button            : "trigger",
                                    ifFormat          : "%Y-%m-%d %H:%M",
                                    daFormat          : "%Y/%m/%d",
                                    timeInterval          : 01
                                  });
                                //]]></script>
                            <noscript>
                            Enable Javascript!
                          </noscript>                            </tr>
                          <tr>
                            <td colspan="2">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="2">&nbsp;                          </td>
                          </tr>
                          <tr>
                            <td colspan="2"><div align="center">
                              
                                <input type="submit" name="submitChallenge" id="submitChallenge" value="Challenge!">
                              
                              </div></td>
                          </tr>
                        </table>
                      </form>
                    </div>
                  </div>
              </div>
            </div></td>
        </tr>
          <tr>
            <td width="100%" class="style12"><img src="../pics/white_curve_bottom.jpg" alt="bottom curve" width="550" height="10"></td>
        </tr>
    </table></td>
    <td>&nbsp;</td>
    <td width="170" valign="top" bgcolor="#FFFFFF" class="style12">
    <div id="Accordion3">
      <div class="AccordionPanel">
        <div class="AccordionPanelTab style9">
        <div align="left">Notifications</div>
        </div>
        <div class="AccordionPanelContent2">
        <br>
        
        <?php 
        
        $empty 
true;
        
        
$connection = new PDO("pgsql:dbname=natesladder host=cs.georgefox.edu password=natepost00 user=ngeorgeson","ngeorgeson","natepost00");
    
    
$result $connection->query("select * from challenge");
    
    echo 
'<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">';

    foreach (
$result as $resultRow)
    {
    
        if (
$resultRow['challengee'] == $_SESSION['currentUser'])
        {
            
$empty false;
            
            if (
$resultRow['accepted'] == '')
            {
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><i><span class='style14'>You Have a CHALLENGE Request!</i></span></div></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><p></p></div></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td width='65%'><B>BY</B></td>";
                    echo 
"<td><B>TIME</B></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td>{$resultRow['challenger']}</td>";
                    echo 
"<td>{$resultRow['scheduled']}</td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><p></p></div></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'>";
                    echo 
"<form id='chalRespondForm' name='chalRespondForm' method='post' action='respondChal.php'>";
                    echo 
"<input name='hiddenChallenger' type='hidden' id='hiddenChallenger' value='{$resultRow['challenger']}' />";
                    echo 
"<input name='hiddenTime' type='hidden' id='hiddenTime' value='{$resultRow['scheduled']}' />";
                    echo 
"<input type='submit' name='respondChal' id='respondChal' value='accept'/>";
                    echo 
"<input type='submit' name='respondChal' id='respondChal' value='decline'/>";
                    echo 
"</form>";
                    echo 
"</div></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><HR></div></td>";
                echo 
"</tr>";
            }
            
            else
            {
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><i><span class='style14'>You Have a Match Scheduled!</i></span></div></td>";
                echo 
"</tr>";
            
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><p></p></div></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td width='65%'><B>WITH</B></td>";
                    echo 
"<td><B>SCHEDULED</B></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td>{$resultRow['challenger']}</td>";
                    echo 
"<td>{$resultRow['scheduled']}</td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><HR></div></td>";
                echo 
"</tr>";
            }
        }
        
        else if (
$resultRow['challenger'] == $_SESSION['currentUser'])
        {
            
$empty false;
        
            if (
$resultRow['accepted'] == '')
            {
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><i><span class='style14'>You Are WAITING for Challenge Acceptance!</i></span></div></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><p></p></div></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td width='65%'><B>FOR</B></td>";
                    echo 
"<td><B>SCHEDULED</B></td>";
                echo 
"</tr>";
            
                echo 
"<tr>";
                    echo 
"<td>{$resultRow['challengee']}</td>";
                    echo 
"<td>{$resultRow['scheduled']}</td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><HR></div></td>";
                echo 
"</tr>";
            }
            
            else
            {
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><i><span class='style14'>Your Challenge has been ACCEPTED!</i></span></div></td>";
                echo 
"</tr>";
            
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><p></p></div></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td width='65%'><B>WITH</B></td>";
                    echo 
"<td><B>SCHEDULED</B></td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td>{$resultRow['challengee']}</td>";
                    echo 
"<td>{$resultRow['scheduled']}</td>";
                echo 
"</tr>";
                
                echo 
"<tr>";
                    echo 
"<td colspan='2'><div align='center'><HR></div></td>";
                echo 
"</tr>";
                
            }
        }
    }
        
    if (
$empty == true)
    {
        echo 
"<tr>";
            echo 
"<td colspan='2'><div align='center'><i><span class='style14'>You Have No Current Challenges. Make a New Challenge!</span></i></B></div></td>";
        echo 
"</tr>";
    }
            
    echo 
"</table>";
    
?>
             
        <p></p>
        </div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab style9">
        <div align="left">Account Settings</div>
        </div>
        <div class="AccordionPanelContent2">
            
            <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><div align="center"><a href="leaveTheLadder.php">Click Here</a><br />
                 to Permanently Leave the Ladder?</div></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td><div align="center"></div></td>
              </tr>
            </table>
            <p></p>
        </div>
      </div>
    </div></td>
  </tr>
  
  <tr>
    <td width="170" height="5" class="style12"><img src="../pics/white_curve_bottom.jpg" alt="bottom curve" width="170" height="5" hspace="0" vspace="0" align="bottom"></td>
    <td rowspan="2" class="style12">&nbsp;</td>
    <td width="550" rowspan="2" class="style12">&nbsp;</td>
    <td rowspan="2" class="style12">&nbsp;</td>
    <td width="170" class="style12"><img src="../pics/white_curve_bottom.jpg" alt="bottom curve" width="170" height="5" hspace="0" vspace="0" align="top"></td>
  </tr>
  <tr>
    <td width="170" class="style12">&nbsp;</td>
    <td width="170" class="style12">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>

<script type="text/javascript">
<!--
var Accordion1 = new Spry.Widget.Accordion("Accordion1", {defaultPanel: <?php echo "{$_SESSION['defaultPanel']}"?>});
var Accordion2 = new Spry.Widget.Accordion("Accordion2");
var Accordion3 = new Spry.Widget.Accordion("Accordion3");
//-->
</script>
<?php $connection NULL?>
</body>
</html>