<?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"/>
	<xsl:import href="tmpl/display-recipe.xsl"/>
	
	<!-- layout variables -->
	<xsl:variable name="layout.global.nav.page" select="'vew-recipe'"/>
	
	<!-- helper vars -->
	<xsl:variable name="search-results" select="xweb:x-data/xweb:x-model/eat:search-results"/>
	<xsl:variable name="index-section" 
			select="$search-results/eat:ui-index/eat:index-section[@selected = 'true']"/>
	<xsl:variable name="recipe-criteria" select="$search-results/eat:recipe-criteria"/>
	<xsl:variable name="recipe" select="$search-results/eat:recipe"/>

	<xsl:template match="xweb:x-data" mode="page-title">
		<xsl:apply-templates select="$recipe" mode="title"/>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="page-body">
		<div class="return-nav">
			<xsl:apply-templates select="$recipe" mode="return-nav"/>
		</div>
		
		<div class="recipe-view">
			<xsl:apply-templates select="$recipe" mode="display-internal"/>
		</div>
	</xsl:template>
	
	<xsl:template match="eat:recipe" mode="title">
		<xsl:value-of select="eat:name"/>
		<xsl:text> (</xsl:text>
		<xsl:value-of select="key('i18n',$search-results/@mode)"/>
		<xsl:text>)</xsl:text>
	</xsl:template>
	
	<xsl:template match="eat:recipe" mode="return-nav">
		<a class="back">
			<xsl:attribute name="href">
				<xsl:value-of select="$web-context"/>
				<xsl:text>/recipe.do?recipeId=</xsl:text>
				<xsl:value-of select="@recipeId"/>
				<xsl:apply-templates select="$index-section" mode="href"/>
				<xsl:apply-templates select="$recipe-criteria" mode="href"/>
			</xsl:attribute>
			<xsl:value-of select="key('i18n','back.to')"/>
			<xsl:text> </xsl:text>
			<xsl:value-of select="eat:name"/>
		</a>
	</xsl:template>
    
</xsl:stylesheet>
