<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:eat="http://msqr.us/xsd/ieat"
	xmlns:xweb="http://msqr.us/xsd/jaxb-web"
	exclude-result-prefixes="eat xweb">
	
    <!-- imports -->
	<xsl:import href="tmpl/default-layout.xsl"/>
	
	<!-- layout variables -->
	<xsl:variable name="layout.global.nav.page" select="''"/>
	
	<!-- helper vars -->
	<xsl:variable name="recipe" select="$aux/eat:ui/eat:recipe"/>
	
	<xsl:template match="xweb:x-data" mode="page-title">
		<xsl:value-of select="key('i18n','edit-recipe-image.title')"/>
	</xsl:template>

	<xsl:template match="xweb:x-data" mode="page-head-content">
		<script type="text/javascript" src="{$web-context}/js/jquery-1.3.2.js" xml:space="preserve"> </script>
		<script type="text/javascript" src="{$web-context}/js/jquery.ajaxQueue.js" xml:space="preserve"> </script>
		<script type="text/javascript" src="{$web-context}/js/xweb-locale.js" xml:space="preserve"> </script>
		<script type="text/javascript" src="{$web-context}/js/ieat-util.js" xml:space="preserve"> </script>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="page-body">
		<div class="intro">
			<xsl:value-of select="key('i18n','edit-recipe-image.intro')"/>
		</div>

		<form method="post" action="{$web-context}{$ctx/xweb:path}" enctype="multipart/form-data">
			<table class="form">
				<tr>
					<th>
						<xsl:value-of select="key('i18n','recipe.name.displayName')"/>
					</th>
					<td colspan="3">
						<xsl:value-of select="$recipe/eat:name"/>
					</td>
				</tr>
				<tr>
					<th>
						<xsl:value-of select="key('i18n','recipe.image.displayName')"/>
					</th>
					<td colspan="3">
						<xsl:if test="$err[@field='image']">
							<xsl:attribute name="class">error</xsl:attribute>
						</xsl:if>
						<input type="file" name="image"/>
						<xsl:text> </xsl:text>
						<div class="caption">
							<xsl:value-of select="key('i18n','recipe.image.caption')"/>
						</div>
					</td>
				</tr>
				<xsl:if test="string($recipe/eat:image)">
					<tr>
						<th/>
						<td>
							<input type="checkbox" name="removeImage" value="true"/>
							<span class="caption">
								<xsl:value-of select="key('i18n','edit-recipe-image.removeImage.explain')"/>
								<xsl:text> (</xsl:text>
								<xsl:value-of select="$recipe/eat:image"/>
								<xsl:text>)</xsl:text>
							</span>
						</td>
					</tr>
				</xsl:if>
				<tr>
					<th/>
					<td>
						<input type="submit" value="{key('i18n','save.displayName')}"/>
						<xsl:text> </xsl:text>
						<input type="submit" name="_cancel" value="{key('i18n','cancel.displayName')}"/>
					</td>
				</tr>
			</table>
			
			<input type="hidden" name="recipeId" value="{$recipe/@recipeId}"/>
			
			<!-- handle contextual navigation -->
			<xsl:apply-templates select="$aux/eat:ui/eat:search-results" 
				mode="search-results-contextual-navigation"/>
        </form>
	</xsl:template>
	    
</xsl:stylesheet>
