{include file="layouts/forceLoggedIn.tpl"}
{assign var="pgLayout" value="layouts/withLeftNav.tpl"}
{include_php file="shared_handle:acceptRejectRequests"} 
{include_php file="shared_handle:myHome"}
<h1>{$page.title}</h1>

<table width="100%"><tr><td valign="top">
	<img class="iconRacers" src="blank.gif" width="1" height="1" alt="" />
</td><td valign="top" width="100%">
	<h2 class="withBG">
		<div class="topRight hideShow">
		<a href="javascript:toggle('inComps', '', 'showHide');"><img id="inComps_img" src="./img/blank.gif" class="showHide_on" alt="show/hide" border="0" /></a></div> 
		Competitions I Am In</h2>
	
<div id="inComps" style="display:block;">	
	<div style="margin:10px;padding:5px;background-color:#FFF;border:#999 1px solid;">
	<table cellspacing="0" cellpadding="1" align="center">
	<tr>
		<td class="underline2"><span>&nbsp;<b>ID</b></span></td>
		<td class="underline2"><span>&nbsp;<b>Title</b></span></td>
		{*
		<td class="underline2"><span>&nbsp;<b>Type</b></span></td>
		*}
		<td class="underline2"><span>&nbsp;<b>Style</b></span></td>
		{* <td class="underline2"><span>&nbsp;<b>Rank</b></span></td> *}
		{* <td class="underline2" nowrap><span>&nbsp;<b>Time Remaining</b></span></td> *}
		<td class="underline2" nowrap><span>&nbsp;<b>Ends</b></span></td>
		{* <td class="underline2" nowrap><span>&nbsp;<b>Prize</b></span></td> *}
	</tr>
	{* Set up the warning period... 7 days from now (604800 = 7 days in seconds) *}
	{math assign="endsSoon" equation="x + y" x=$smarty.now y="604800"}
	{foreach from=$competitions item="comp"}
	<tr>
		<td nowrap="nowrap"><span><small>&nbsp;<a href="?pg=competition&cid={$comp.id}">{$comp.id}</a> &nbsp;</small></span></td>
		<td nowrap="nowrap"><span><small>&nbsp;<a href="?pg=competition&cid={$comp.id}">{$comp.title|truncate:35:"..."}</a> &nbsp;</small></span></td>
		{*
		<td nowrap="nowrap"><span><small>&nbsp;{$comp.type|niceText}</small> &nbsp;</span></td>
		*}
		<td nowrap="nowrap"><span><small>&nbsp;{if $comp.style eq "Group-vs-Group"}Team{else}Individual{/if}</small> &nbsp;</span></td>
		{* <td nowrap="nowrap"><span><small>&nbsp;{if $comp.rank ne "N/A"}{$comp.rank}/{$comp.rankOutOf}{else}N/A{/if}</small> &nbsp;</span></td> *}
		{* <td nowrap><span><small{if $comp.endDate lt $smarty.now} style="font-weight:bold;"{elseif $comp.endDate lt $endsSoon} style="color:#C00;font-weight:bold;"{/if}>&nbsp;{$comp.timeLeft}</small> &nbsp;</span></td> *}
		<td nowrap="nowrap"><span><small{if $comp.endDate lt $smarty.now} style="font-weight:bold;"{elseif $comp.endDate lt $endsSoon} style="color:#C00;font-weight:bold;"{/if}>&nbsp;{$comp.endDate|date_format2:"D n/j/y"}</small> &nbsp;</span></td>
		{* <td nowrap="nowrap" align="right"><span><small>&nbsp;{if not $comp.potAmount and $comp.potDescription}(Special){else}{math assign="fontSizeFactor" equation="x / y" x=$comp.potAmount y="100"}{math assign="fontSize" equation="x + y" x="11" y=$fontSizeFactor|number_format:"0"}<span style="font-size:{$fontSize}px;">${$comp.potAmount|number_format:"0"}</span>{/if}</small> &nbsp;</span></td> *}
	</tr>
	{foreachelse}
	<tr>
		<td colspan="6"><span><small>You have not joined any competitions.</small></span></td>
	</tr>
	{/foreach}
	</table>
	</div>
	<span style="margin-left:65px;"><small>(NOTE: <b>Bold Date</b> = Ended, <span style="color:#C00;"><b>Red Date</b></span> = Ends Soon)</small></span>
</div>
{if $user->inGroupName('coordinators')}
<br />
<form name="requestsForm" action="index.php" method="post" style="margin:0px;">
<input type="hidden" name="pg" value="{$page.name}">
<input type="hidden" name="no_expire" value="true">
<input type="hidden" name="acceptReject" value="">

<h2 class="withBG">
	<div class="topRight hideShow">
		<a href="javascript:toggle('myComps', '', 'showHide');"><img id="myComps_img" src="./img/blank.gif" class="showHide_on" alt="show/hide" border="0" /></a></div> 
	Competitions I Have Started</h2>

<div id="myComps" style="display:block;">
{if $myCompetitions|@count gt 0}
	<div style="margin:0px;padding:5px;background-color:#FFF;border:#999 1px solid;">
	<table cellspacing="0" cellpadding="1" align="center">
	<tr>
		<td class="underline2" nowrap><span>&nbsp;<b>ID</b> &nbsp;</span></td>
		<td class="underline2" nowrap><span>&nbsp;<b>Title</b> &nbsp;</span></td>
		<td class="underline2" nowrap><span>&nbsp;<b>Type</b> &nbsp;</span></td>
		<td class="underline2" nowrap><span>&nbsp;<b>People wanting to join</b> &nbsp;</span></td>
	</tr>
	{foreach from=$myCompetitions item="comp"}
	<tr>
		<td valign="top"><span>&nbsp;<small><a href="?pg=competition&cid={$comp.id}">{$comp.id}</a></small></span></td>
		<td valign="top" nowrap="nowrap" style="overflow:hidden;"><span>&nbsp;<small><a href="?pg=competition&cid={$comp.id}">{$comp.title}</a></small></span></td>
		<td valign="top" nowrap="nowrap">&nbsp;<span><small>{$comp.type}</small></td>
		<td valign="top" style="border-left:1px solid #000;"><span>{if $comp.requests|@count}{assign var="isRequests" value="true"}{/if}{foreach from=$comp.requests item="request"}<div class="hangingIndent"><input type="checkbox" name="request[{$comp.id}][]" value="{$request.id}"><small>({$request.dateAdded|date_format2:"n/j/y"}) {$request.name} &lt;{mailto address=$request.email encode="javascript"}&gt;: &quot;<i>{$request.comment|strip_tags}</i>&quot;</small></div>{foreachelse}&nbsp;None right now.{/foreach}</span></td>
	</tr>
	{/foreach}
	{if $isRequests}
	<tr>
		<td colspan="4" align="center">
			<span><br /><a href="javascript://" onclick="acceptReject.value='accept';requestsForm.submit();return false;" class="button">Accept Selected</a>
			<a href="javascript://" onclick="acceptReject.value='reject';requestsForm.submit();return false;" class="button">Reject Selected</a><small><br /><br /></small></span></td>
	</tr>
	{/if}
	</table>
	</div>
{/if}
</div>
</form>
{/if}
</td></tr>
</table>

<blockquote>
<table width="100%">
<tr><td valign="top" width="50%">
	<a href="?pg=my_competitions/available">
	<img src="blank.gif" width="1" height="1" hspace="5" alt="" border="0" class="icoMedal" style="float:left;" /></a>
	<b>Other Available Competitions:</b><br />
	Click below to join in on any of the competitions specific to {$smarty.session.company.companyName|default:"your company"}.
	<ul>
		<li><a href="?pg=my_competitions/available">Show Available Company Competitions</a></li>
	</ul></td>
    <td valign="top" width="50%">
	{*
	<img src="blank.gif" width="1" height="1" alt="" class="icoClick" />
	<a href="#">Competitions I have started</a>
	*}</td>
</tr>
</table>
</blockquote>

</div>