{assign var="pgLayout" value="file:layouts/blank.tpl"}
{capture name="headExtra"}
<script language="javascript">{literal}
function xWindow(name, w, h, x, y, loc, men, res, scr, sta, too)
{
  var f = '';
  if (w && h) {
    if (document.layers) f = 'screenX=' + x + ',screenY=' + y;
    else f = 'left=' + x + ',top=' + y;
    f += ',width=' + w + ',height=' + h + ',';
  }
  f += ('location='+loc+',menubar='+men+',resizable='+res
    +',scrollbars='+scr+',status='+sta+',toolbar='+too);
  this.features = f;
  this.name = name;
  this.load = function(sUrl) {
    if (this.wnd && !this.wnd.closed) this.wnd.location.href = sUrl;
    else this.wnd = window.open(sUrl, this.name, this.features);
    this.wnd.focus();
    return false;
  }
}
winUpdater = new xWindow('nutritionWin', 750, 500, 10, 10, 'yes', 'no', 'yes', 'yes', 'yes', 'no');
{/literal}</script>
{/capture}

{include_php file="shared_handle:updateStats"}

{if $userInfo.id}
<form name="updateForm" method="post" action="index.php" style="margin:0px;">
<input type="hidden" name="pg" value="{$page.name}">
<input type="hidden" name="no_expire" value="true">
<input type="hidden" name="start" value="{$smarty.request.start}">
<input type="hidden" name="userId" value="{$smarty.request.userId}">

<table cellpadding="2" cellspacing="2">
<tr>
	<td colspan="8"><h2 class="withBG">Update Stats{if $userInfo.id neq $user->id} For: {$userInfo.firstName} {$userInfo.lastName} ({$userInfo.username}){/if}</h2></td>
</tr>
<tr>
	<td colspan="4" align="left"><div>{if $lastWeek}<a class="button" href="?pg={$page.name}&start={$lastWeek}&userId={$userInfo.id}">&lt; Previous Week</a>{/if}</div></td>
	<td colspan="4" align="right"><div>{if $nextWeek}<a class="button" href="?pg={$page.name}&start={$nextWeek}&userId={$userInfo.id}">Next Week &gt;</a>{/if}</div></td>
</tr>
<tr>
	<td class="datacell"><div>&nbsp;</div></td>
	{section loop="7" name="day"}{assign var="dayNo" value=$smarty.section.day.iteration}
		<td width="75" align="right" class="datacell"><b>{$dayInfo.$dayNo.timestamp|date_format2:"l"}</b><br />{$dayInfo.$dayNo.timestamp|date_format2:"n/j/y"}</td>
	{/section}
</tr>
<tr>
	<td align="right" class="datacell">Weight</td>
	{section loop="7" name="day"}{assign var="dayNo" value=$smarty.section.day.iteration}
		<td align="right" class="datacell"><input tabindex="{$smarty.section.day.iteration*7}" type="text" class="largeInput" name="day[{$dayNo}][weight]" value="{if $dayInfo.$dayNo.weight gt 0}{$dayInfo.$dayNo.weight}{/if}" onfocus="this.className='largeInputSelected';" onblur="this.className='largeInput';"><input type="hidden" name="day[{$dayNo}][id]" value="{$dayInfo.$dayNo.id}"></td>
	{/section}
</tr>
<tr>
	<td align="right" class="datacell"><small>(<a href="javascript://" onclick="winUpdater.load('?pg=nutrition&layout=false');return false;">Help</a>)</small> Calories</td>
	{section loop="7" name="day"}{assign var="dayNo" value=$smarty.section.day.iteration}
		<td align="right" class="datacell"><input tabindex="{$smarty.section.day.iteration*7+1}" type="text" class="largeInput" name="day[{$dayNo}][calories]" value="{if $dayInfo.$dayNo.calories gt 0}{$dayInfo.$dayNo.calories}{/if}" onfocus="this.className='largeInputSelected';" onblur="this.className='largeInput';"></td>
	{/section}
</tr>
<tr>
	<td align="right" class="datacell"><small>(<a href="javascript://" onclick="winUpdater.load('?pg=nutrition&layout=false');return false;">Help</a>)</small> Carbs<small>(g)</small></td>
	{section loop="7" name="day"}{assign var="dayNo" value=$smarty.section.day.iteration}
		<td align="right" class="datacell"><input tabindex="{$smarty.section.day.iteration*7+2}" type="text" class="largeInput" name="day[{$dayNo}][carbs]" value="{if $dayInfo.$dayNo.carbs gt 0}{$dayInfo.$dayNo.carbs}{/if}" onfocus="this.className='largeInputSelected';" onblur="this.className='largeInput';"></td>
	{/section}
</tr>
<tr>
	<td align="right" class="datacell"><small>(<a href="javascript://" onclick="winUpdater.load('?pg=nutrition&layout=false');return false;">Help</a>)</small> Fat<small>(g)</small></td>
	{section loop="7" name="day"}{assign var="dayNo" value=$smarty.section.day.iteration}
		<td align="right" class="datacell"><input tabindex="{$smarty.section.day.iteration*7+3}" type="text" class="largeInput" name="day[{$dayNo}][fat]" value="{if $dayInfo.$dayNo.fat gt 0}{$dayInfo.$dayNo.fat}{/if}" onfocus="this.className='largeInputSelected';" onblur="this.className='largeInput';"></td>
	{/section}
</tr>
<tr>
	<td align="right" class="datacell">Water</td>
	{section loop="7" name="day"}{assign var="dayNo" value=$smarty.section.day.iteration}
		<td align="right" class="datacell"><input tabindex="{$smarty.section.day.iteration*7+4}" type="text" class="largeInput" name="day[{$dayNo}][water]" value="{if $dayInfo.$dayNo.water gt 0}{$dayInfo.$dayNo.water}{/if}" onfocus="this.className='largeInputSelected';" onblur="this.className='largeInput';"></td>
	{/section}
</tr>
<tr>
	<td align="right" class="datacell">Minutes Exercise</td>
	{section loop="7" name="day"}{assign var="dayNo" value=$smarty.section.day.iteration}
		<td align="right" class="datacell"><input tabindex="{$smarty.section.day.iteration*7+5}" type="text" class="largeInput" name="day[{$dayNo}][minutesExercise]" value="{$dayInfo.$dayNo.minutesExercise}" onfocus="this.className='largeInputSelected';" onblur="this.className='largeInput';"></td>
	{/section}
</tr>
<tr>
	<td align="right" class="datacell">Distance Exercised</td>
	{section loop="7" name="day"}{assign var="dayNo" value=$smarty.section.day.iteration}
		<td align="right" class="datacell"><input tabindex="{$smarty.section.day.iteration*7+6}" type="text" class="largeInput" name="day[{$dayNo}][distanceExercised]" value="{$dayInfo.$dayNo.distanceExercised}" onfocus="this.className='largeInputSelected';" onblur="this.className='largeInput';"></td>
	{/section}
</tr>
<tr>
	<td colspan="8" align="right"><br /><input type="submit" class="button" value="Submit Updates!"></td>
</tr>
</table>

</form>
{/if}