{stored_object name=$smarty.session.session_id|truncate:10:"" type="newcomp" from="newcomp" assign="newcomp"}

{if $smarty.request.confirmReset}{stored_object name=$smarty.session.session_id|truncate:10:"" type="signup" destroy="true"}{/if}

{include_php file="shared_handle:newcomp.prepareInvitation"}

<form name="compStartForm" method="post" style="margin:0px;">
<input type="hidden" name="pg" value="{toc_next}">
<input type="hidden" name="no_expire" value="true">

{toc_next assign="next"}
{toc_prev assign="prev"}

<h1 class="underline">Create a Competition: Step 3</h1>
<br />
<h2 class="withBG">
	<div class="topRight hideShow">
		<a href="javascript:toggle('letter', 'hideLetter', 'showHide');"><img id="letter_img" src="./img/blank.gif" class="showHide_{if $newcomp.hideLetter}off{else}on{/if}" alt="show/hide" border="0" /></a></div>
	Review Your Invitation:</h2>
	<input type="hidden" id="hideLetter" name="newcomp[hideLetter]" value="{$newcomp.hideLetter|default:"0"}">

<div><em> Here is your Letter!</em> Take a minute to review your letter to Make sure that you are satisfied with the invitation you will be sending to the other competitors.<br /><br /></div>

<div id="letter" align="left" style="display:{if $newcomp.hideLetter eq "1"}none{else}block{/if};">
	<div class="pixel underline2">&nbsp;</div>
	<br />
	<div style="margin:10px;padding:17px;" class="notepaperBG">
		{eval var=$invitationLetter|nl2br}
	</div>
</div>
<br />
<div class="pixel underline2">&nbsp;</div>
<br />

<a name="invitations" />
<h2 class="withBG">
	<div class="topRight hideShow">
		<a href="javascript:toggle('enterEmails', 'hideEnterEmails', 'showHide');"><img id="enterEmails_img" src="./img/blank.gif" class="showHide_{if $newcomp.hideEnterEmails}off{else}on{/if}" alt="show/hide" border="0" /></a></div>
	Invite Some Competitors:</h2>
	<input type="hidden" id="hideEnterEmails" name="newcomp[hideEnterEmails]" value="{$newcomp.hideEnterEmails|default:"0"}">

<div>Enter a contact name and email address for each person you would like to invite into this competition. Don't worry about gathering everyone's email address right now, you can always add more later.<br /><br /></div>

<div id="enterEmails" style="display:{if $newcomp.hideEnterEmails eq "1"}none{else}block{/if};">
	<div class="pixel underline2">&nbsp;</div>
	<div id="inviteList">
	<table align="center" style="margin:10px;">
	<tr>
		<td><div>&nbsp;</div></td>
		<td><h3 class="withBG">Name</h2></td>
		<td><h3 class="withBG">E-Mail</h2></td>
		<td><h3 class="withBG">Your Relation</h2></td>
	</tr> 
	{section name="contactLoop" loop=$addCount}  {* $addCount is assigned by the handler... *}
	<tr>
		<td><div>#{$smarty.section.contactLoop.iteration}</div></td>
		<td><div><input type="text" class="textInput" name="newcomp[invite][name][{$smarty.section.contactLoop.iteration}]"></div></td>
		<td><div><input type="text" class="textInput" style="width:200px;" name="newcomp[invite][email][{$smarty.section.contactLoop.iteration}]"></div></td>
		<td><div><input type="text" class="textInput" name="newcomp[invite][relation][{$smarty.section.contactLoop.iteration}]"></div></td>
	</tr>
	{/section}
	</table>
	</div>
	
	<div align="right" style="margin-right:30px;">
		<a href="javascript://" onclick="addEmailRows();return false;">&gt; Click to add more now! &lt;</a>
	</div>
</div>
<div class="pixel underline2">&nbsp;</div>


<script language="javascript">
	var addCount = {$addCount};
	{literal}
	function addEmailRows() {
		addCount++;
		var obj = document.getElementById('inviteList');
		var html = obj.innerHTML;
		html = html.replace(/\<\/TABLE\>/i, '');
		html += '<tr><td><div>#'+addCount+'</div></td><td><div><input type="text" class="textInput" name="newcomp[invite][name]['+addCount+']"></div></td><td><div><input type="text" class="textInput" style="width:200px;" name="newcomp[invite][email]['+addCount+']"></div></td><td><div><input type="text" class="textInput" name="newcomp[invite][relation]['+addCount+']"></div></td></tr></table>';
		obj.innerHTML = html;
	}
	{/literal}
</script>

{stored_object_fill_form object=$newcomp name="newcomp"}

<div class="hBox" style="text-align:right;">
	{if $prev.pageName}<input type="image" src="{$skinFolder}images/btn_back.gif" class="btn_image" onclick="pg.value='{$prev.pageName}';">&nbsp; {/if}
	{if $next.pageName}<input type="image" src="{$skinFolder}images/btn_next.gif" class="btn_image" onclick="pg.value='{$next.pageName}';">{/if}	
</div>

</form>