{include file="layouts/forceLoggedIn.tpl"}
{assign var="pgLayout" value="layouts/withLeftNav.tpl"}
{include_php file="shared_handle:tellAFriend"}

<h1>{$page.title}</h1>
<h2>{$page.description}</h2>

<form name="submitYourSuccessForm" action="index.php" method="post">
<input type="hidden" name="pg" value="{$page.name}">
<input type="hidden" name="no_expire" value="true">

<table>
<tr>
	<td><span>Your Name:</span></td>
	<td><input type="text" name="Name" value="{$smarty.request.Name|default:$user->firstName|stripslashes|htmlspecialchars}"></td>
</tr>
<tr>
	<td><span>Your E-mail Address:</span></td>
	<td><input type="text" name="Email" value="{$smarty.request.Email|default:$user->email|stripslashes|htmlspecialchars}"></td>
</tr>
<tr>
	<td valign="top"><span>Your Friend's Address:</span></td>
	<td><div id="friendEmailList">
		{foreach from=$smarty.request.FriendEmail item="FriendEmail"}
			<input type="text" name="FriendEmail[]" value="{$FriendEmail|stripslashes|htmlspecialchars}"><br />
		{foreachelse}
			<input type="text" name="FriendEmail[]" value=""><br />
		{/foreach}
		
	</div><a href="javascript://" onclick="addFriend(); return false;">Click to invite more friends...</a></td>
</tr>

<tr>
	<td valign="top"><span>Your Message:</span></td>
	<td><textarea cols="45" rows="10" name="Message">{if not $smarty.request.Message}Friends:

I'd like to invite you to eHealthCompete. Just go to http://{$smarty.session.company.companyVanity}.ehealthcompete.com and sign up!

Hope to see you there!

{$user->firstName}{else}{$smarty.request.Message|stripslashes|htmlspecialchars}{/if}</textarea></td>
</tr>
<tr>
	<td><span>&nbsp;</span></td>
	<td><input type="submit" value="Send Now"></td>
</tr>
</table>

<script type="text/javascript">
var count = {$smarty.request.FriendEmail|@count};
{literal}
function addFriend() {
	count++;
	if (count > 10) {
		alert('You cannot send to more than 10 friends at a time.');
	} else {
		document.getElementById('friendEmailList').innerHTML += '<input type="text" name="FriendEmail[]" value=""><br />';
	}
{/literal}
</script>

</form>