{assign var="pgLayout" value="layouts/withLeftNav.tpl"}
<h1>{$page.title}</h1>
<h2>{$smarty.session.company.companyName}</h2>

<hr />

{include_php file="shared_handle:availableCompetitions"}

<form name="joinCompetitions" method="post" action="index.php" style="margin:0px;">
<input type="hidden" name="pg" value="{$page.name}" />
<input type="hidden" name="no_expire" value="true" />

{style_table folder="img/st/floatbox"}
  <table border="0" cellspacing="1" cellpadding="2" width="100%">
	<tr>
		<td bgcolor="#CCCCCC">&nbsp;</td>
		<td bgcolor="#CCCCCC"><b>ID #</b></td>
		<td bgcolor="#CCCCCC"><b>Title</b></td>
		<td bgcolor="#CCCCCC"><b>Start Date</b></td>
		<td bgcolor="#CCCCCC"><b>End Date</b></td>
		<td bgcolor="#CCCCCC"><b>Style</b></td>
		<td bgcolor="#CCCCCC"><b>Scoring Method</b></td>
	</tr>
	{foreach from=$availableCompetitions item="comp"}
	<tr>
		{if not $user->inGroupName($comp.code)}
		{assign var="isJoinable" value="true"}
		<td><input type="checkbox" name="joinComp[]" value="{$comp.id}" /></td>
		<td>{$comp.id}</td>
		<td>{$comp.title}</td>
		<td>{$comp.startDate|date_format2:"D n/j/y"}</td>
		<td>{$comp.endDate|date_format2:"D n/j/y"}</td>
		<td>{$comp.style}</td>
		<td>{$comp.scoringMethod}</td>
		{else}
		{assign var="isInComps" value="true"}
		<td bgcolor="#FFCCCC">&times;</td>
		<td bgcolor="#FFCCCC"><i>{$comp.id}</i></td>
		<td bgcolor="#FFCCCC"><i>{$comp.title}</i></td>
		<td bgcolor="#FFCCCC"><i>{$comp.startDate|date_format2:"D n/j/y"}</i></td>
		<td bgcolor="#FFCCCC"><i>{$comp.endDate|date_format2:"D n/j/y"}</i></td>
		<td bgcolor="#FFCCCC"><i>{$comp.style}</i></td>
		<td bgcolor="#FFCCCC"><i>{$comp.scoringMethod}</i></td>
		{/if}
	</tr>
	{foreachelse}
	<tr>
		<td colspan="7" align="center">Sorry. There are currently no active competitions available.</td>
	</tr>	
	{/foreach}
  </table>
{/style_table}

<br />
<div align="center">{if $isJoinable}<input type="submit" name="submitBtn" value="Join Selected Competitions" />{else}<b>No Competitions To Join</b>{/if}</div>
{if $isInComps}
<br />
<div style="background-color:#FCC; margin-left:20px; width:250px;">&times; - You are already a member</div>
{/if}

</form>

<div>
Does this work?
</div>