<?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','email-recipe.title')"/>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="page-head-content">
		<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>
		<script type="text/javascript" xml:space="preserve">
			<xsl:comment>
			function init() {
				installTextAreaFocusHandler();
				document.forms[0].elements['to'].focus();
			}
			
			window.onload = init;
			//</xsl:comment>
		</script>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="page-body">
		<div class="intro">
			<xsl:value-of select="key('i18n','email-recipe.intro')" 
				disable-output-escaping="yes"/>
		</div>
		
		<div class="formLabel">
			<xsl:value-of select="key('i18n','recipe.displayName')"/>
			<xsl:text>: </xsl:text>
		</div>
		
		<div class="read-only">
			<xsl:value-of select="$recipe/eat:name"/>
		</div>
		
		<br clear="left" />
	
		<form method="post" action="{$web-context}{$ctx/xweb:path}">
			<table class="form">
				<tr>
					<th>
						<xsl:if test="$err[@field='to']">
							<xsl:attribute name="class">error</xsl:attribute>
						</xsl:if>
						<xsl:value-of select="key('i18n','email.to.displayName')"/>
					</th>
					<td colspan="3">
						<textarea name="to" class="small">
							<xsl:value-of select="$req/eat:param[@key='to']"/>
							<!-- the following space prevents browser rendering mishaps -->
							<xsl:text> </xsl:text>
						</textarea>
						<div class="caption">
							<xsl:value-of select="key('i18n','email.to.caption')"/>
						</div>
					</td>
				</tr>
				<tr>
					<th>
						<xsl:if test="$err[@field='message']">
							<xsl:attribute name="class">error</xsl:attribute>
						</xsl:if>
						<xsl:value-of select="key('i18n','email.message.displayName')"/>
					</th>
					<td colspan="3">
						<textarea name="message" class="small">
							<xsl:value-of select="$req/eat:param[@key='message']"/>
							<!-- the following space prevents browser rendering mishaps -->
							<xsl:text> </xsl:text>
						</textarea>
						<div class="caption">
							<xsl:value-of select="key('i18n','email.message.caption')"/>
						</div>
					</td>
				</tr>
				<tr>
					<th/>
					<td>
						<input type="submit" value="{key('i18n','send.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="contextual-navigation"/>
		</form>                
	</xsl:template>

</xsl:stylesheet>
