<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML+Voice 1.1/EN" "xhtml+voice.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:vxml="http://www.w3.org/2001/vxml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xv="http://www.voicexml.org/2002/xhtml+voice">
<head>
<title>Story</title>
<script type="text/javascript">
function readStory() {alert("Hi");}
</script>

<form xmlns="http://www.w3.org/2001/vxml" id="storyForm">
<block>
Welcome to the Silly Storybook. Today we will create a silly story about Jack or Jill going for a walk.
</block>
<field name="chooseCharacter">
	<grammar>
	<![CDATA[
		#JSGF V1.0;
		grammar character;
		<character> = Jack | Jill ;
	]]>
	</grammar>
	<prompt>
	Please choose a main character.
	</prompt>
	<catch event="help nomatch noinput">
	Please say either Jack or Jill to choose the character.
	</catch>
</field>
<field name="chooseColor">
	<grammar>
	<![CDATA[
		#JSGF V1.0;
		grammar voiceColor;
		<voiceColor> = Red | Pink | Purple | Blue | Green | Orange | Yellow ;
	]]>
	</grammar>
	<prompt>
	Now choose your favorite color.
	</prompt>
	<catch event="help nomatch noinput">
	Please say either Red, Pink, Purple, Blue, Green, Orange, or Yellow.
	</catch>
</field>
<field name="chooseFood">
	<grammar>
	<![CDATA[
		#JSGF V1.0;
		grammar voiceFood;
		<voiceFood> = apple | icecream | pizza ;
	]]>
	</grammar>
	<prompt>
	What is your favorite food.
	</prompt>
	<catch event="help nomatch noinput">
	Please say either apple, icecream, or pizza.
	</catch>
</field>
<field name="choosePlace">
	<grammar>
	<![CDATA[
		#JSGF V1.0;
		grammar voicePlace;
		<voicePlace> = park | store | circus ;
	]]>
	</grammar>
	<prompt>
	Where should we have <value expr="chooseCharacter" /> visit today?
	</prompt>
	<catch event="help nomatch noinput">
	Please say either park, store, or circus.
	</catch>
</field>
<field name="chooseMonster">
	<grammar>
	<![CDATA[
		#JSGF V1.0;
		grammar voiceMonster;
		<voiceMonster> = Godzilla | Tomato ;
	]]>
	</grammar>
	<prompt>
	Which monster is meaner?
	</prompt>
	<catch event="help nomatch noinput">
	Please say either Godzilla or Tomato.
	</catch>
</field>
<filled>
	OK. We are ready for our silly story about
	<value expr="chooseCharacter" /> going for a walk. To have the story read to you, click the Read this page button at the top of the page. To go to the next page use the button at the bottom of the page. Enjoy your story!
	<if cond="chooseCharacter == 'Jack'">
		<var name="pronoun" expr="'he'" />
	<elseif cond="chooseCharacter == 'Jill'" />
		<var name="pronoun" expr="'she'" />
	</if>
	<assign name="document.getElementById('bodyPage').style.backgroundColor" expr="chooseColor" />
	<assign name="document.getElementById('read1').style.backgroundColor" expr="chooseColor" />
	<assign name="document.getElementById('read2').style.backgroundColor" expr="chooseColor" />
	<assign name="document.getElementById('read3').style.backgroundColor" expr="chooseColor" />
	<assign name="document.getElementById('read4').style.backgroundColor" expr="chooseColor" />

	<assign name="document.getElementById('picture1').src" expr="'images/'+chooseCharacter+'.gif'" />
	<assign name="document.getElementById('content1').value" expr="'... there was a young person named '+chooseCharacter+' who wanted to go for a walk. So '+pronoun+' went off to the '+choosePlace+' to see what '+pronoun+' could see.'" />

	<assign name="document.getElementById('picture2').src" expr="'images/'+chooseCharacter+choosePlace+'.gif'" />
	<assign name="document.getElementById('content2').value" expr="'... to the '+choosePlace+', '+chooseCharacter+' became hungry. So '+pronoun+' decided to find something to eat. '+chooseCharacter+' decided that '+pronoun+' was hungry for some '+chooseFood+'.'" />

	<assign name="document.getElementById('picture3').src" expr="'images/'+chooseCharacter+choosePlace+'.gif'" />
	<assign name="document.getElementById('pictureFood').src" expr="'images/'+chooseFood+'.gif'" />
	<assign name="document.getElementById('content3').value" expr="'... '+chooseCharacter+' ate the '+chooseFood+' so quickly that '+pronoun+' got a tummy ache. Suddenly '+pronoun+' could feel a rumbling noise! Perhaps it is my tummy making the noise, thought '+chooseCharacter+'.'" />

	<assign name="document.getElementById('picture4').src" expr="'images/'+chooseCharacter+choosePlace+'.gif'" />
	<assign name="document.getElementById('pictureMonster').src" expr="'images/'+chooseMonster+'.gif'" />
	<assign name="document.getElementById('content4').value" expr="'... '+chooseCharacter+' was suddenly surprised by the killer '+chooseMonster+' who had just destroyed the city and sat on top of '+chooseCharacter+'s head. So that is the end of our silly story about '+chooseCharacter+'s walk.'" />

	<assign name="document.getElementById('entry').style.display" expr="'none'" />
	<assign name="document.getElementById('page1').style.display" expr="'block'" />
</filled>
</form>

<form xmlns="http://www.w3.org/2001/vxml" id="goPage1">
<block>
	<prompt xv:src="#read1" />
</block>
</form>

<form xmlns="http://www.w3.org/2001/vxml" id="turnPage2">
<block>
	<assign name="document.getElementById('page1').style.display" expr="'none'" />
	<assign name="document.getElementById('page2').style.display" expr="'block'" />
</block>
</form>

<form xmlns="http://www.w3.org/2001/vxml" id="goPage2">
<block>
	<prompt xv:src="#read2" />
</block>
</form>

<form xmlns="http://www.w3.org/2001/vxml" id="turnPage3">
<block>
	<assign name="document.getElementById('page2').style.display" expr="'none'" />
	<assign name="document.getElementById('page3').style.display" expr="'block'" />
</block>
</form>

<form xmlns="http://www.w3.org/2001/vxml" id="goPage3">
<block>
	<prompt xv:src="#read3" />
</block>
</form>

<form xmlns="http://www.w3.org/2001/vxml" id="turnPage4">
<block>
	<assign name="document.getElementById('page3').style.display" expr="'none'" />
	<assign name="document.getElementById('page4').style.display" expr="'block'" />
</block>
</form>

<form xmlns="http://www.w3.org/2001/vxml" id="goPage4">
<block>
	<prompt xv:src="#read4" />
</block>
</form>

<style type="text/css">
#entry {display:block;width:500px;margin:0 auto;}
div {display:none;width:320px;margin:1em auto;padding:0;}
form {background-color:#fff;width:320px;}
form fieldset {padding:5px;border:5px solid #000;}
form legend {background-color:#fff;font-weight:bold;padding:1em;margin:0;border:1px solid #000;font-size:1.5em;}
form textarea {voice-family: male 1;}
p {text-align:center;}
img {padding:0;margin:0;}
</style>

</head>
<body ev:event="load" ev:handler="#storyForm" id="bodyPage">
<form id="entry">
<fieldset>
	<legend>Make a Story</legend>
	<ol>
		<li>Choose a main character:
			<ul>
				<li>Jack</li>
				<li>Jill</li>
			</ul>
		</li>
		<li>Choose a color:
			<ul>
				<li>Red</li>
				<li>Pink</li>
				<li>Purple</li>
				<li>Blue</li>
				<li>Green</li>
				<li>Orange</li>
				<li>Yellow</li>
			</ul>
		</li>
		<li>Choose your favorite food:
			<ul>
				<li>Apple</li>
				<li>Ice Cream</li>
				<li>Pizza</li>
			</ul>
		</li>
		<li>Choose a place to visit:
			<ul>
				<li>Park</li>
				<li>Store</li>
				<li>Circus</li>
			</ul>
		</li>
		<li>Which monster is meaner?
			<ul>
				<li>Godzilla</li>
				<li>Tomato</li>
			</ul>
		</li>
	</ol>
</fieldset>
</form>

<div id="page1">
<p><button ev:event="click" ev:handler="#goPage1">Read this page.</button></p>
	<form id="read1">
	<fieldset>
		<legend>Once upon a time...</legend>
		<img id="picture1" src="" alt="" />
		<textarea name="content1" id="content1" rows="6" cols="33" value="" />
	</fieldset>
	</form>
<p><button ev:event="click" ev:handler="#turnPage2">Go to the next page.</button></p>
</div>

<div id="page2">
<p><button ev:event="click" ev:handler="#goPage2">Read this page.</button></p>
	<form id="read2">
	<fieldset>
		<legend>During the walk...</legend>
		<img id="picture2" src="" alt="" />
		<textarea name="content2" id="content2" rows="6" cols="33" value="" />
	</fieldset>
	</form>
<p><button ev:event="click" ev:handler="#turnPage3">Go to the next page.</button></p>
</div>

<div id="page3">
<p><button ev:event="click" ev:handler="#goPage3">Read this page.</button></p>
	<form id="read3">
	<fieldset>
		<legend>Being hungry...</legend>
		<img id="picture3" src="" alt="" />
		<img id="pictureFood" src="" alt="" style="margin-top:-350px;" />
		<textarea name="content3" id="content3" rows="6" cols="33" value="" />
	</fieldset>
	</form>
<p><button ev:event="click" ev:handler="#turnPage4">Go to the next page.</button></p>
</div>

<div id="page4">
<p><button ev:event="click" ev:handler="#goPage4">Read this page.</button></p>
	<form id="read4">
	<fieldset>
		<legend>Still feeling the rumbling...</legend>
		<img id="picture4" src="" alt="" />
		<img id="pictureMonster" src="" alt="" style="margin-top:-350px;" />
		<textarea name="content4" id="content4" rows="6" cols="33" value="" />
		<h2 style="text-align:center;">The End.</h2>
	</fieldset>
	</form>
</div>

</body>
</html>