<?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/util.xsl"/>
	
	<!-- layout variables -->
	<xsl:variable name="layout.global.nav.page" select="''"/>
	
	<!-- helper variables -->
	<xsl:variable name="ingredient" select="xweb:x-data/xweb:x-model/eat:edit/eat:ingredient"/>
	
	<!-- no global nav on this view -->
	<xsl:template match="xweb:x-data" mode="page-global-nav"/>
	
	<xsl:template match="xweb:x-data" mode="page-head-content">
		<script type="text/javascript" xml:space="preserve">
			<xsl:comment>
			function init() {
				if ( !window.opener ) {
					alert("No opener!");
					return;
				}
				
				var newName = "<xsl:call-template name="javascript-string">
					<xsl:with-param name="output-string" select="xweb:x-model/eat:edit/eat:ingredient/eat:name"/>
				</xsl:call-template>";
				var newId = <xsl:value-of select="$ingredient/@ingredientId"/>;
				
				window.opener.addedNewIngredient('<xsl:value-of select="xweb:x-model/eat:edit/@mode"/>', 
					newId, newName);
				
				window.close();
			}
			init();
			//</xsl:comment>
		</script>
	</xsl:template>

</xsl:stylesheet>
