<?xml version="1.0" encoding="utf-8"?>
<%@page contentType="application/voicexml+xml; charset=UTF-8"%>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN" "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">

    <!--<property name="timeout" value="15s"/>--> <!-- el tiempo que espera el sistema despues de cada 'prompt' a la espera de tener una respuesta del caller -->

    <!-- The maxage property specifies the maximum acceptable age, in seconds, of cached resource. The value is a time interval expressed as an 
    unsigned number followed by s for time in seconds; ms for time in milliseconds.
    An unexpired cached file that does not exceed the maximum age will be used; a cached file that exceeds the maximum will be fetched again.-->
    <!-- These properties need to be removed once coding is finished
    <property name="scriptmaxage" value="0s"/>    
    <property name="audiomaxstale" value="0s"/>-->
    <property name="datamaxage" value="0s"/>
    <property name="grammarmaxage" value="0s"/>

    <property name="bevocal.voice.name" value="bv_adam_en_us"/>
    <property name="bevocal.maxdialogerrors" value="5" />
    <property name="termchar" value=""/>

    <script src="../javascript/global.js"/>
    <script src="../javascript/json.js"/>
    <script src="../javascript/prompts.js"/>
    <script src="../javascript/configuration.js"/>

    <var name="random"/>

    <link event="repeat">
        <grammar srcexpr="context.paths.grammar + 'Global.gsl#REPEAT'"/>
    </link>

    <link event="mainMenu">
        <grammar srcexpr="context.paths.grammar + 'Global.gsl#MAINMENU'"/>
    </link>

    <link event="doneHere">
        <grammar srcexpr="context.paths.grammar + 'Global.gsl#DONEHERE'"/>
    </link>

    <catch event="error.bevocal.maxdialogerrors_exceeded">
        <audio expr="promptPath('maxdialogerrors')">
            <value expr="promptValue('maxdialogerrors')"/>
        </audio>
        <audio expr="promptPath('failurebehavior03')">
            <value expr="promptValue('failurebehavior03')"/>
        </audio>
        <prompt>
            <break time="500ms"/>
        </prompt>
        <goto next="#GoodBye" />
    </catch>

    <catch event="repeat">
       <clear/>
       <reprompt/>
    </catch>

    <catch event="mainMenu">
       <goto next="#SearchCriteria" />
    </catch>

    <catch event="doneHere">
       <goto next="#GoodBye" />
    </catch>

   
    <form id="Welcome">
        <block>
            <audio expr="promptPath('welcome')">
                <value expr="promptValue('welcome')"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <assign name="context.vars.comingFrom" expr="'Welcome'"/>
            <goto next="#GetCity"/>
        </block>
    </form>


    <form id="GetCity" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <block>
            <audio expr="promptPath('getcity01')">
               <value expr="promptValue('getcity01')"/>
            </audio>
        </block>
        <field name="choice">
            <grammar srcexpr="context.paths.grammar + 'GetCity.jsp#CITIES'" xml:lang="en-US"/>
            <filled> <!-- La parte esta,se ejecuta solo cuando el caller diga algo valido y que esta definido en la gramatica -->
                <assign name="context.vars.comingFrom" expr="'GetCity'"/>
                <assign name="context.vars.city" expr="choice"/>                
                <if cond="application.lastresult$.confidence &gt; confirmConfidence">
                    <audio expr="promptPath('okay')">
                        <value expr="promptValue('okay')"/>
                    </audio>
                    <audio expr="cityPromptPath(context.vars.city)">
                        <value expr="promptValue(context.vars.city)"/>
                    </audio>
                    <prompt>
                        <break time="1s"/>
                    </prompt>
                    <goto next="#SearchCriteria" />
                <else/>
                    <goto next="#ConfirmCity" />
                </if>
            </filled>
        </field>

        <catch event="mainMenu">
           <throw event="nomatch"/>
        </catch>

        <catch event="noinput">
            <var name="index" expr="(noinput_count == 0)?0:1"/>
            <assign name="noinput_count" expr="noinput_count+1"/>
            <audio expr="promptPath('noinput'+index)">
                <value expr="promptValue('noinput'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('getcity10')">
                <value expr="promptValue('getcity10')"/>
            </audio>        
        </catch>

        <catch event="nomatch">
            <var name="index" expr="(nomatch_count == 0)?0:1"/>
            <assign name="nomatch_count" expr="nomatch_count+1"/>
            <audio expr="promptPath('nomatch'+index)">
                <value expr="promptValue('nomatch'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('getcity10')">
                <value expr="promptValue('getcity10')"/>
            </audio>
        </catch>
    </form>

    <form id="ConfirmCity">
          <var name="noinput_count" expr="0"/>
          <var name="nomatch_count" expr="0"/>
          <block>
               <assign name="random" expr="randomize(2)"/>
               <audio expr="promptPath('thatwas'+ random)">
                   <value expr="promptValue('thatwas'+ random)"/>
               </audio>
               <audio expr="cityPromptPath(context.vars.city)">
                   <value expr="promptValue(context.vars.city)"/>
               </audio>
               <prompt>
                   <break time="1s"/>
               </prompt>
               <assign name="random" expr="randomize(2)"/>
               <audio expr="promptPath('isright'+ random)">
                   <value expr="promptValue('isright'+ random)"/>
               </audio>
          </block>
          <field name="choice">
               <grammar src="builtin:grammar/boolean?y=1;n=2"/>
                 <filled>
                   <assign name="context.vars.comingFrom" expr="'ConfirmCity'"/>
                   <if cond="choice==true">
                       <assign name="random" expr="randomize(3)"/>
                       <audio expr="promptPath('thanks' + random)">
                          <value expr="promptValue('thanks' + random)"/>
                       </audio>
                       <prompt>
                           <break time="1s"/>
                       </prompt>
                       <goto next="#SearchCriteria" />
                   <else/>
                      <assign name="random" expr="randomize(2)"/>
                      <audio expr="promptPath('mymistake'+ random)">
                           <value expr="promptValue('mymistake'+ random)"/>
                      </audio>
                      <prompt>
                           <break time="1s"/>
                      </prompt>
                      <goto next="#GetCity" />
                   </if>
                 </filled>
          </field>

          <catch event="mainMenu">
             <throw event="nomatch"/>
          </catch>
          
          <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="cityPromptPath(context.vars.city)">
                    <value expr="promptValue(context.vars.city)"/>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="cityPromptPath(context.vars.city)">
                    <value expr="promptValue(context.vars.city)"/>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>
    </form>


    <form id="SearchCriteria" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <script> resetVariables();
        </script>  
        <block>
            <audio expr="promptPath('searchcriteria00')">
               <value expr="promptValue('searchcriteria00')"/>
            </audio>
            <audio expr="promptPath('searchcriteria01')">
               <value expr="promptValue('searchcriteria01')"/>
            </audio>
        </block>
        <field name="choice">
            <grammar srcexpr="context.paths.grammar + 'SearchCriteria.gsl#CRITERIA'" xml:lang="en-US"/>
            <filled>
                <assign name="context.vars.comingFrom" expr="'SearchCriteria'"/>
                <assign name="context.vars.criteria" expr="choice"/>
                <audio expr="promptPath('justsec')">
                   <value expr="promptValue('justsec')"/>
                </audio>
                <prompt>
                   <break time="2s"/>
                </prompt>
                <if cond="choice == 'film'">
                    <goto next="#FilmLookup" />
                <else/><!-- el caso de haber elegido la categoria cinema --> 
                    <goto next="#CinemaLookup" />
                </if>
            </filled>
        </field>
        <catch event="noinput">
            <var name="index" expr="(noinput_count == 0)?0:1"/>
            <assign name="noinput_count" expr="noinput_count+1"/>
            <audio expr="promptPath('noinput'+index)">
                <value expr="promptValue('noinput'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('searchcriteria10')">
                <value expr="promptValue('searchcriteria10')"/>
            </audio>
        </catch>

        <catch event="nomatch">
            <var name="index" expr="(nomatch_count == 0)?0:1"/>
            <assign name="nomatch_count" expr="nomatch_count+1"/>
            <audio expr="promptPath('nomatch'+index)">
                <value expr="promptValue('nomatch'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('searchcriteria10')">
                <value expr="promptValue('searchcriteria10')"/>
            </audio>
        </catch>
    </form>


    <form id="FilmLookup" >
       <script> context.vars.categories = [];
                context.vars.films = [];
       </script>
       <block>
            <assign name="context.vars.comingFrom" expr="'FilmLookup'"/>
            <var name="city" expr="context.vars.city"/>
            <data name="mydata" srcexpr="context.paths.data + 'GetFilmsList'" namelist="city"/>
            <!--<var name="result" expr="mydata.documentElement.firstChild.data"/>-->
            <var name="result" expr="GetData(mydata)"/>
            <if cond="result == undefined">
              <goto next="#FailureBehavior" />
            <elseif cond="result.status == 'failure'"/>
              <goto next="#FailureBehavior" />
            <else/>
              <assign name="context.vars.categories" expr="result.categories"/>
              <assign name="context.vars.films" expr="result.films"/>
              <goto next="#GetFilm" />
            </if>
       </block>
    </form>


    <form id="GetFilm" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <var name="films" expr="replaceQuestionMark(context.vars.films.toJSONString())"/>
        <block>
            <log>films : <value expr="films"/> </log>
            <if cond="context.vars.comingFrom != 'ConfirmFilm'">
                <audio expr="promptPath('getfilm01')">
                    <value expr="promptValue('getfilm01')"/>
                </audio>
            <else/>   
                <audio expr="promptPath('getfilm02')">
                    <value expr="promptValue('getfilm02')"/>
                </audio>            
            </if>
        </block>
           <field name="choice">
                <grammar srcexpr="context.paths.grammar + 'GetFilm.jsp?films=' + films + '&amp;all=yes'" xml:lang="en-US"/>
                <filled>
                    <assign name="context.vars.comingFrom" expr="'GetFilm'"/>
                    <if cond="choice == 'all'">
                        <audio expr="promptPath('okaysure')">
                            <value expr="promptValue('okaysure')"/>
                        </audio>
                        <prompt>
                            <break time="2s"/>
                        </prompt>
                        <goto next="#CategoryFilm" />
                    <else/>    
                        <assign name="context.vars.film" expr="choice"/>
                        <goto next="#ConfirmFilm" />
                    </if>
                </filled>
           </field>
           <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('getfilm10')">
                    <value expr="promptValue('getfilm10')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('getfilm10')">
                    <value expr="promptValue('getfilm10')"/>
                </audio>
           </catch>
    </form>


    <form id="ConfirmFilm">
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
          <block>
               <assign name="random" expr="randomize(2)"/>
               <audio expr="promptPath('thatwas'+ random)">
                   <value expr="promptValue('thatwas'+ random)"/>
               </audio>    
               <audio expr="filmPromptPath(context.vars.film)">
                   <value expr="promptValue(context.vars.film)"/>
               </audio>
               <prompt>
                   <break time="1s"/>
               </prompt>
               <assign name="random" expr="randomize(2)"/>
               <audio expr="promptPath('isright'+ random)">
                   <value expr="promptValue('isright'+ random)"/>
               </audio>
          </block>
          <field name="choice">
               <grammar src="builtin:grammar/boolean?y=1;n=2"/>
                 <filled>                    
                    <if cond="choice==true">
                           <audio expr="promptPath('okay')">
                              <value expr="promptValue('okay')"/>
                           </audio>
                           <assign name="random" expr="randomize(2)"/>
                           <audio expr="promptPath('goodchoice'+ random)">
                               <value expr="promptValue('goodchoice'+ random)"/>
                           </audio>
                           <prompt>
                               <break time="1s"/>
                           </prompt> 
                           <if cond="context.vars.comingFrom == 'ListOfFilms'">
                              <assign name="context.vars.comingFrom" expr="'ConfirmFilm'"/>
                              <goto next="#TimeLookup" />
                           <else/>
                              <assign name="context.vars.comingFrom" expr="'ConfirmFilm'"/>
                              <goto next="#GetDate" />
                           </if>
                    <else/>
                           <assign name="random" expr="randomize(2)"/>
                           <audio expr="promptPath('mymistake'+ random)">
                               <value expr="promptValue('mymistake'+ random)"/>
                           </audio>
                           <prompt>
                               <break time="1s"/>
                           </prompt>
                           <if cond="context.vars.comingFrom == 'GetFilm'">
                               <assign name="context.vars.comingFrom" expr="'ConfirmFilm'"/>
                               <goto next="#GetFilm" />
                           <elseif cond="context.vars.comingFrom == 'ListOfFilms'"/>
                               <assign name="context.vars.comingFrom" expr="'ConfirmFilm'"/>
                               <goto next="#ListOfFilms" />
                           <else/>
                               <assign name="context.vars.comingFrom" expr="'ConfirmFilm'"/>
                               <goto next="#GetFilmForSelectedCategory" />
                           </if>
                     </if>
                 </filled>
          </field>
          <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="filmPromptPath(context.vars.film)">
                   <value expr="promptValue(context.vars.film)"/>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="filmPromptPath(context.vars.film)">
                   <value expr="promptValue(context.vars.film)"/>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>  
           </catch>
    </form>


    <form id="CategoryFilm">
          <var name="noinput_count" expr="0"/>
          <var name="nomatch_count" expr="0"/>

            <block>
                <audio expr="promptPath('categoryfilm01')">
                  <value expr="promptValue('categoryfilm01')"/>
                </audio>
            </block>
            
            <field name="choice">
            <grammar srcexpr="context.paths.grammar + 'CategoryFilm.jsp#CATEGORIES'" xml:lang="en-US"/>
                <filled>
                   <assign name="context.vars.comingFrom" expr="'CategoryFilm'"/>
                   <assign name="context.vars.category" expr="choice"/>
                   <if cond="application.lastresult$.confidence &gt; confirmConfidence &amp;&amp; isValidCategory(context.vars.category,context.vars.categories)">
                        <audio expr="promptPath('okay')">
                            <value expr="promptValue('okay')"/>
                        </audio>
                        <audio expr="categoryPromptPath(context.vars.category)">
                            <value expr="promptValue(context.vars.category)"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <goto next="#GetFilmForSelectedCategory" />
                   <elseif cond="application.lastresult$.confidence &gt; confirmConfidence &amp;&amp; !isValidCategory(context.vars.category,context.vars.categories)"/>
                        <goto next="#AnotherCategory" />
                   <else/>
                        <goto next="#ConfirmCategoryFilm" />
                   </if>
                </filled>
            </field>
            
          <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('categoryfilm10')">
                    <value expr="promptValue('categoryfilm10')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('categoryfilm10')">
                    <value expr="promptValue('categoryfilm10')"/>
                </audio> 
           </catch>
    </form>


    <form id="ConfirmCategoryFilm">
          <var name="noinput_count" expr="0"/>
          <var name="nomatch_count" expr="0"/>
          <block>
               <assign name="random" expr="randomize(2)"/>
               <audio expr="promptPath('thatwas'+ random)">
                   <value expr="promptValue('thatwas'+ random)"/>
               </audio>
               <audio expr="categoryPromptPath(context.vars.category)">
                   <value expr="promptValue(context.vars.category)"/>
               </audio>
               <prompt>
                   <break time="1s"/>
               </prompt>
               <assign name="random" expr="randomize(2)"/>
               <audio expr="promptPath('isright'+ random)">
                   <value expr="promptValue('isright'+ random)"/>
               </audio> 
          </block>
          <field name="choice">
               <grammar src="builtin:grammar/boolean?y=1;n=2"/> 
                 <filled>
                   <assign name="context.vars.comingFrom" expr="'ConfirmCategoryFilm'"/>
                   <if cond="choice==true &amp;&amp; isValidCategory(context.vars.category,context.vars.categories)">
                       <assign name="random" expr="randomize(3)"/>
                       <audio expr="promptPath('thanks' + random)">
                          <value expr="promptValue('thanks' + random)"/>
                       </audio>
                       <prompt>
                           <break time="1s"/>
                       </prompt>
                       <goto next="#GetFilmForSelectedCategory" />
                   <elseif cond="choice==true &amp;&amp; !isValidCategory(context.vars.category,context.vars.categories)"/>                   
                      <goto next="#AnotherCategory" />
                   <else/>
                      <assign name="random" expr="randomize(2)"/>
                      <audio expr="promptPath('mymistake'+ random)">
                           <value expr="promptValue('mymistake'+ random)"/>
                      </audio>
                      <prompt>
                           <break time="1s"/>
                      </prompt>
                      <goto next="#CategoryFilm" />
                   </if>
                 </filled>
          </field>
          <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="categoryPromptPath(context.vars.category)">
                   <value expr="promptValue(context.vars.category)"/>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="categoryPromptPath(context.vars.category)">
                   <value expr="promptValue(context.vars.category)"/>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>
    </form>


     <form id="AnotherCategory">
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
            <block>
                <audio expr="promptPath('anothercategory01')">
                    <value expr="promptValue('anothercategory01')"/>
                </audio>
               <audio expr="categoryPromptPath(context.vars.category)">
                   <value expr="promptValue(context.vars.category)"/>
               </audio>
               <prompt>
                   <break time="1s"/>
               </prompt>
               <audio expr="promptPath('anothercategory02')">
                   <value expr="promptValue('anothercategory02')"/>
               </audio>
            </block>
            <field name="choice">
                <grammar src="builtin:grammar/boolean?y=1;n=2"/>
                <filled>
                    <assign name="context.vars.comingFrom" expr="'AnotherCategory'"/>
                    <if cond="choice==true">
                       <audio expr="promptPath('sure')">
                           <value expr="promptValue('sure')"/>
                       </audio>
                       <prompt>
                           <break time="1s"/>
                       </prompt>  
                       <goto next="#CategoryFilm" />
                    <else/>
                        <goto next="#GoodBye" />
                    </if>
                </filled>
            </field>
          <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('anothercategory10')">
                    <value expr="promptValue('anothercategory10')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('anothercategory10')">
                    <value expr="promptValue('anothercategory10')"/>
                </audio>
           </catch>
     </form>


     <form id="GetFilmForSelectedCategory">
            <var name="noinput_count" expr="0"/>
            <var name="nomatch_count" expr="0"/>
            <var name="filmsForSelectedCategoryArray" expr="GetFilmForSelectedCategory(context.vars.category,context.vars.films)"/>
            <var name="filmsForSelectedCategory" expr="replaceQuestionMark(filmsForSelectedCategoryArray.toJSONString())"/>

            <block>
                <if cond="context.vars.comingFrom != 'ConfirmFilm'" >
                    <audio expr="promptPath('getfilmforselectedcategory01')">
                        <value expr="promptValue('getfilmforselectedcategory01')"/>
                    </audio>
                <else/>
                    <audio expr="promptPath('getfilmforselectedcategory02')">
                        <value expr="promptValue('getfilmforselectedcategory02')"/>
                    </audio>
                </if>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <foreach item="film" array="filmsForSelectedCategoryArray">
                    <audio expr="filmPromptPath(film.name)">
                        <value expr="promptValue(film.name)"/>
                    </audio>
                    <prompt>
                        <break time="2s"/>
                    </prompt>
                </foreach>
                <audio expr="promptPath('hearlistagain')">
                    <value expr="promptValue('hearlistagain')"/>
                </audio>
            </block>
            <field name="choice">
                <grammar srcexpr="context.paths.grammar + 'filmsForSelectedCategory.jsp?filmsForSelectedCategory=' + filmsForSelectedCategory" xml:lang="en-US"/>
                <filled>
                      <assign name="context.vars.comingFrom" expr="'GetFilmForSelectedCategory'"/>
                      <assign name="context.vars.film" expr="choice"/>                      
                      <goto next="#ConfirmFilm" />
                </filled>
            </field>
            <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('getfilmforselectedcategory02')">
                    <value expr="promptValue('getfilmforselectedcategory02')"/>
                </audio>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <foreach item="film" array="filmsForSelectedCategoryArray">
                    <audio expr="filmPromptPath(film.name)">
                        <value expr="promptValue(film.name)"/>
                    </audio>
                    <prompt>
                        <break time="2s"/>
                    </prompt>
                </foreach>
                <audio expr="promptPath('hearlistagain')">
                    <value expr="promptValue('hearlistagain')"/>
                </audio>                
            </catch>

            <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('getfilmforselectedcategory02')">
                    <value expr="promptValue('getfilmforselectedcategory02')"/>
                </audio>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <foreach item="film" array="filmsForSelectedCategoryArray">
                    <audio expr="filmPromptPath(film.name)">
                        <value expr="promptValue(film.name)"/>
                    </audio>
                    <prompt>
                        <break time="2s"/>
                    </prompt>
                </foreach>
                <audio expr="promptPath('hearlistagain')">
                    <value expr="promptValue('hearlistagain')"/>
                </audio>
            </catch>
     </form>

     <form id="CinemaLookup" >
        <script> context.vars.cinemas = [];
        </script>
        <block>
            <assign name="context.vars.comingFrom" expr="'CinemaLookup'"/>
            <var name="city" expr="context.vars.city"/>
            <data name="mydata" srcexpr="context.paths.data + 'GetCinemasList'" namelist="city"/>
            <var name="result" expr="GetData(mydata)"/>
            <if cond="result == undefined">
              <goto next="#FailureBehavior" />
            <elseif cond="result.status == 'failure'"/>
              <goto next="#FailureBehavior" />
            <else/>
              <assign name="context.vars.cinemas" expr="result.cinemas"/>
              <goto next="#GetCinema" />
            </if>
        </block>
     </form>



    <form id="GetCinema" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <var name="cinemas" expr="replaceQuestionMark(context.vars.cinemas.toJSONString())"/>
        <block>
           <log>cinemas : <value expr="cinemas"/> </log>
            <if cond="context.vars.comingFrom != 'ConfirmCinema'">
                <audio expr="promptPath('getcinema01')">
                    <value expr="promptValue('getcinema01')"/>
                </audio>
            <else/>
                <audio expr="promptPath('getcinema02')">
                    <value expr="promptValue('getcinema02')"/>
                </audio>
            </if>
        </block>
        <field name="choice">
            <grammar srcexpr="context.paths.grammar + 'GetCinema.jsp?cinemas=' + cinemas + '&amp;all=yes'" xml:lang="en-US"/>
            <filled>
                <assign name="context.vars.comingFrom" expr="'GetCinema'"/>
                <if cond="choice == 'all'">
                    <audio expr="promptPath('okaysure')">
                        <value expr="promptValue('okaysure')"/>
                    </audio>
                    <prompt>
                        <break time="2s"/>
                    </prompt>
                    <goto next="#CinemaList" />
                <else/>
                    <assign name="context.vars.cinema" expr="choice"/>
                    <goto next="#ConfirmCinema" />
                </if>
            </filled>
        </field>
           <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('getcinema10')">
                    <value expr="promptValue('getcinema10')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('getcinema10')">
                    <value expr="promptValue('getcinema10')"/>
                </audio>
           </catch>
    </form> 


    <form id="CinemaList">
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <var name="ListOfCinemas" expr="replaceQuestionMark(context.vars.cinemas.toJSONString())"/>
        <block>
            <if cond="context.vars.comingFrom != 'ConfirmCinema'" >
                <audio expr="promptPath('cinemalist01')">
                    <value expr="promptValue('cinemalist01')"/>
                </audio>
            <else/>
                <audio expr="promptPath('cinemalist02')">
                    <value expr="promptValue('cinemalist02')"/>
                </audio>
            </if> 
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="cinema" array="context.vars.cinemas">
                <audio expr="cinemaPromptPath(cinema.name)">
                    <value expr="promptValue(cinema.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </block>
        <field name="choice">
            <grammar srcexpr="context.paths.grammar + 'GetCinema.jsp?cinemas=' + ListOfCinemas + '&amp;all=no'" xml:lang="en-US"/>
            <filled>
                <assign name="context.vars.comingFrom" expr="'CinemaList'"/>
                <assign name="context.vars.cinema" expr="choice"/>
                <goto next="#ConfirmCinema" />
            </filled>
        </field>
        
        <catch event="noinput">
            <var name="index" expr="(noinput_count == 0)?0:1"/>
            <assign name="noinput_count" expr="noinput_count+1"/>
            <audio expr="promptPath('noinput'+index)">
                <value expr="promptValue('noinput'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('cinemalist02')">
                <value expr="promptValue('cinemalist02')"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="cinema" array="context.vars.cinemas">
                <audio expr="cinemaPromptPath(cinema.name)">
                    <value expr="promptValue(cinema.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </catch>

        <catch event="nomatch">
            <var name="index" expr="(nomatch_count == 0)?0:1"/>
            <assign name="nomatch_count" expr="nomatch_count+1"/>
            <audio expr="promptPath('nomatch'+index)">
                <value expr="promptValue('nomatch'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('cinemalist02')">
                <value expr="promptValue('cinemalist02')"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="cinema" array="context.vars.cinemas">
                <audio expr="cinemaPromptPath(cinema.name)">
                    <value expr="promptValue(cinema.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </catch>
    </form>


    <form id="ConfirmCinema">
          <var name="noinput_count" expr="0"/>
          <var name="nomatch_count" expr="0"/>
          <block>
               <assign name="random" expr="randomize(2)"/>
               <audio expr="promptPath('thatwas'+ random)">
                   <value expr="promptValue('thatwas'+ random)"/>
               </audio>
               <audio expr="cinemaPromptPath(context.vars.cinema)">
                   <value expr="promptValue(context.vars.cinema)"/>
               </audio>
               <prompt>
                   <break time="1s"/>
               </prompt>
               <assign name="random" expr="randomize(2)"/>
               <audio expr="promptPath('isright'+ random)">
                   <value expr="promptValue('isright'+ random)"/>
               </audio>
          </block>
          <field name="choice">
               <grammar src="builtin:grammar/boolean?y=1;n=2"/>
                 <filled>                    
                    <if cond="choice==true">                          
                           <assign name="random" expr="randomize(3)"/>
                           <audio expr="promptPath('thanks'+ random)">
                               <value expr="promptValue('thanks'+ random)"/>
                           </audio>
                           <prompt>
                               <break time="1s"/>
                           </prompt>
                           <if cond="context.vars.comingFrom == 'ListOfCinemas'">
                              <assign name="context.vars.comingFrom" expr="'ConfirmCinema'"/>
                              <goto next="#TimeLookup" />
                           <else/>
                              <assign name="context.vars.comingFrom" expr="'ConfirmCinema'"/>
                              <goto next="#GetDate" />
                           </if>
                    <else/>
                           <assign name="random" expr="randomize(2)"/>
                           <audio expr="promptPath('mymistake'+ random)">
                               <value expr="promptValue('mymistake'+ random)"/>
                           </audio>
                           <prompt>
                               <break time="1s"/>
                           </prompt>
                           <if cond="context.vars.comingFrom == 'GetCinema'">
                               <assign name="context.vars.comingFrom" expr="'ConfirmCinema'"/>
                               <goto next="#GetCinema" />
                           <elseif cond="context.vars.comingFrom == 'ListOfCinemas'"/>
                               <assign name="context.vars.comingFrom" expr="'ConfirmCinema'"/>
                               <goto next="#ListOfCinemas" />
                           <else/>
                               <assign name="context.vars.comingFrom" expr="'ConfirmCinema'"/>
                               <goto next="#CinemaList" />
                           </if>
                     </if>
                 </filled>
          </field>
         <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="cinemaPromptPath(context.vars.cinema)">
                   <value expr="promptValue(context.vars.cinema)"/>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="cinemaPromptPath(context.vars.cinema)">
                   <value expr="promptValue(context.vars.cinema)"/>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>
    </form>


    <form id="GetDate">
            <var name="noinput_count" expr="0"/>
            <var name="nomatch_count" expr="0"/>
            <block>
                <if cond="context.vars.comingFrom != 'GetDate'" >
                    <audio expr="promptPath('getdate01')">
                        <value expr="promptValue('getdate01')"/>
                    </audio>
                <else/>
                    <audio expr="promptPath('getdate02')">
                        <value expr="promptValue('getdate02')"/>
                    </audio>
                </if> 
            </block>
            <field name="choice">
                <grammar src="builtin:grammar/date"/>
                <filled>
                    <assign name="context.vars.comingFrom" expr="'GetDate'"/>
                    <assign name="context.vars.date" expr="choice"/>
                    <log>SelectedDate : <value expr="context.vars.date"/> </log>
                    <if cond="!isValidDate(context.vars.date)">
                      <audio expr="promptPath('getdate03')">
                           <value expr="promptValue('getdate03')"/>
                      </audio>
                      <goto next="#GetDate" /> 
                    <elseif cond="application.lastresult$.confidence &gt; confirmConfidence"/>
                      <goto next="#Criteria" />
                    <else/>
                      <goto next="#ConfirmDate" />
                    </if>
                </filled>
            </field>
            <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('getdate10')">
                    <value expr="promptValue('getdate10')"/>
                </audio>
            </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('getdate10')">
                    <value expr="promptValue('getdate10')"/>
                </audio>
           </catch>
    </form>

    <form id="ConfirmDate">
          <var name="mm" expr="context.vars.date.substring(4,6)"/>
          <var name="dd" expr="context.vars.date.substring(6,8)"/>
          <var name="yyyy" expr="context.vars.date.substring(0,4)"/>
          <var name="noinput_count" expr="0"/>
          <var name="nomatch_count" expr="0"/>
          <block>
                <assign name="random" expr="randomize(2)"/>
                <audio expr="promptPath('thatwas'+ random)">
                    <value expr="promptValue('thatwas'+ random)"/>
                </audio>
                <audio expr="datePromptPath(mm + '-m')">
                    <say-as type="date:m"> <value expr="mm"/></say-as>
                </audio>
                <audio expr="datePromptPath(dd + '-d')">
                    <say-as type="date:d"> <value expr="dd"/></say-as>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="datePromptPath(yyyy + '-y')">
                    <say-as type="date:y"> <value expr="yyyy"/></say-as>
                </audio>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <assign name="random" expr="randomize(2)"/>
                <audio expr="promptPath('isright'+ random)">
                    <value expr="promptValue('isright'+ random)"/>
                </audio>
          </block>
          <field name="choice">
               <grammar src="builtin:grammar/boolean?y=1;n=2"/> <!-- la tecla 1 para confirmar si esta bien,y la tecla 2 para en el caso no-->
                 <filled>
                    <assign name="context.vars.comingFrom" expr="'ConfirmDate'"/>
                    <if cond="choice==true">
                        <assign name="random" expr="randomize(3)"/>
                        <audio expr="promptPath('thanks' + random)">
                            <value expr="promptValue('thanks' + random)"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <goto next="#Criteria" />
                    <else/>
                        <assign name="random" expr="randomize(2)"/>
                        <audio expr="promptPath('mymistake'+ random)">
                            <value expr="promptValue('mymistake'+ random)"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <goto next="#GetDate" />
                    </if>
                 </filled>
          </field>
         <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="datePromptPath(mm + '-m')">
                    <say-as type="date:m"> <value expr="mm"/></say-as>
                </audio>
                <audio expr="datePromptPath(dd + '-d')">
                    <say-as type="date:d"> <value expr="dd"/></say-as>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="datePromptPath(yyyy + '-y')">
                    <say-as type="date:y"> <value expr="yyyy"/></say-as>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="datePromptPath(mm + '-m')">
                    <say-as type="date:m"> <value expr="mm"/></say-as>
                </audio>
                <audio expr="datePromptPath(dd + '-d')">
                    <say-as type="date:d"> <value expr="dd"/></say-as>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="datePromptPath(yyyy + '-y')">
                    <say-as type="date:y"> <value expr="yyyy"/></say-as>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>
    </form>


    <form id="Criteria">
            <block>
                <audio expr="promptPath('Criteria01')">
                    <value expr="promptValue('Criteria01')"/>
                </audio>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <assign name="context.vars.comingFrom" expr="'Criteria'"/>
                <if cond="context.vars.criteria == 'film'">
                    <goto next="#FilmOnDateLookup" />
                <elseif cond="context.vars.criteria == 'cinema'"/>
                    <goto next="#CinemaOnDateLookup" />
                </if>
            </block>
    </form>


    <form id="FilmOnDateLookup" >
        <block>
            <assign name="context.vars.comingFrom" expr="'FilmOnDateLookup'"/>
            <var name="city" expr="context.vars.city"/>
            <var name="date" expr="context.vars.date"/>
            <var name="film" expr="context.vars.film"/>
            
            <data name="mydata" srcexpr="context.paths.data + 'GetCinemasListForFilm'" namelist="city film date" />
            <var name="result" expr="GetData(mydata)"/>
            <if cond="result == undefined">
              <goto next="#FailureBehavior" />
            <elseif cond="result.status == 'failure'"/>
              <goto next="#FailureBehavior" />
            <elseif cond="result.cinemas.length==0"/>
              <audio expr="promptPath('zerocinema01')">
                   <value expr="promptValue('zerocinema01')"/>
              </audio>
              <prompt>
                   <break time="1s"/>
              </prompt>
              <goto next="#ChooseAnotherDate" />
            <elseif cond="result.cinemas.length==1"/>
              <assign name="context.vars.cinemaResult" expr="result.cinemas[0]"/>
              <goto next="#OneCinema" />
            <else/>
              <assign name="context.vars.cinemasResults" expr="result.cinemas"/>
              <goto next="#ListOfCinemas" />
            </if>
        </block>
    </form>



    <form id="ChooseAnotherDate" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <block>
            <audio expr="promptPath('chooseanotherdate01')">
                <value expr="promptValue('chooseanotherdate01')"/>
            </audio>
        </block>
        <field name="choice">
               <grammar srcexpr="context.paths.grammar + 'ChooseAnother.gsl#CONFIRM'" xml:lang="en-US"/>
               <filled>
                   <assign name="context.vars.comingFrom" expr="'ChooseAnotherDate'"/>
                   <if cond="choice =='yes'">
                      <audio expr="promptPath('sure')">
                           <value expr="promptValue('sure')"/>
                      </audio>
                      <prompt>
                           <break time="1s"/>
                      </prompt>
                      <goto next="#GetDate" />
                   <else/>
                      <goto next="#SearchCriteria" />
                   </if>
               </filled>
        </field>
        <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('chooseanotherdate10')">
                    <value expr="promptValue('chooseanotherdate10')"/>
                </audio>                
        </catch>
        <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('chooseanotherdate10')">
                    <value expr="promptValue('chooseanotherdate10')"/>
                </audio> 
           </catch>
    </form>


    <form id="OneCinema" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <block>
            <audio expr="promptPath('onecinema01')">
                <value expr="promptValue('onecinema01')"/>
            </audio>
            <audio expr="cinemaPromptPath(context.vars.cinemaResult.name)">
                <value expr="promptValue(context.vars.cinemaResult.name)"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <audio expr="promptPath('onecinema02')">
                <value expr="promptValue('onecinema02')"/>
            </audio>
        </block>
        <field name="choice">
           <grammar src="builtin:grammar/boolean?y=1;n=2"/>
             <filled>
               <assign name="context.vars.comingFrom" expr="'OneCinema'"/>
               <if cond="choice==true">
                  <assign name="context.vars.cinema" expr="context.vars.cinemaResult.name"/>
                  <goto next="#TimeLookup" />
               <else/>
                  <audio expr="promptPath('noproblem')">
                     <value expr="promptValue('noproblem')"/>
                  </audio>
                  <prompt>
                     <break time="1s"/>
                  </prompt>
                  <goto next="#ChooseAnotherDate" />
               </if>
             </filled>
          </field>
          
          <catch event="noinput">
            <var name="index" expr="(noinput_count == 0)?0:1"/>
            <assign name="noinput_count" expr="noinput_count+1"/>
            <audio expr="promptPath('noinput'+index)">
                <value expr="promptValue('noinput'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <clear/>
            <reprompt/>
          </catch>

          <catch event="nomatch">
            <var name="index" expr="(nomatch_count == 0)?0:1"/>
            <assign name="nomatch_count" expr="nomatch_count+1"/>
            <audio expr="promptPath('nomatch'+index)">
                <value expr="promptValue('nomatch'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <clear/>
            <reprompt/>
          </catch>
    </form>


    <form id="ListOfCinemas" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <var name="cinemas" expr="replaceQuestionMark(context.vars.cinemasResults.toJSONString())"/>
        <block>
            <if cond="context.vars.comingFrom != 'ConfirmCinema'" >
                <audio expr="promptPath('listofcinemas01')">
                    <value expr="promptValue('listofcinemas01')"/>
                </audio>
            <else/>
                <audio expr="promptPath('listofcinemas02')">
                    <value expr="promptValue('listofcinemas02')"/>
                </audio>
            </if>            
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="cinema" array="context.vars.cinemasResults">
                <audio expr="cinemaPromptPath(cinema.name)">
                    <value expr="promptValue(cinema.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </block> 
        <field name="choice">
            <grammar srcexpr="context.paths.grammar + 'GetCinema.jsp?cinemas=' + cinemas + '&amp;all=no'" xml:lang="en-US"/>
            <filled>
                <assign name="context.vars.comingFrom" expr="'ListOfCinemas'"/>
                <assign name="context.vars.cinema" expr="choice"/>
                <goto next="#ConfirmCinema" />
            </filled>
        </field>
        
        <catch event="noinput">
            <var name="index" expr="(noinput_count == 0)?0:1"/>
            <assign name="noinput_count" expr="noinput_count+1"/>
            <audio expr="promptPath('noinput'+index)">
                <value expr="promptValue('noinput'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('listofcinemas02')">
                <value expr="promptValue('listofcinemas02')"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="cinema" array="context.vars.cinemasResults">
                <audio expr="cinemaPromptPath(cinema.name)">
                    <value expr="promptValue(cinema.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </catch>        

        <catch event="nomatch">
            <var name="index" expr="(nomatch_count == 0)?0:1"/>
            <assign name="nomatch_count" expr="nomatch_count+1"/>
            <audio expr="promptPath('nomatch'+index)">
                <value expr="promptValue('nomatch'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('listofcinemas02')">
                <value expr="promptValue('listofcinemas02')"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="cinema" array="context.vars.cinemasResults">
                <audio expr="cinemaPromptPath(cinema.name)">
                    <value expr="promptValue(cinema.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </catch>
    </form>


    <form id="CinemaOnDateLookup" >
        <block>
            <assign name="context.vars.comingFrom" expr="'CinemaOnDateLookup'"/>
            <var name="city" expr="context.vars.city"/>
            <var name="date" expr="context.vars.date"/>
            <var name="cinema" expr="context.vars.cinema"/>

            <data name="mydata" srcexpr="context.paths.data + 'GetFilmsListForCinema'" namelist="city cinema date" />
            <var name="result" expr="GetData(mydata)"/>
            <if cond="result == undefined">
              <goto next="#FailureBehavior" />
            <elseif cond="result.status == 'failure'"/>
              <goto next="#FailureBehavior" />
            <elseif cond="result.films.length==0"/>
              <audio expr="promptPath('sorry')">
                   <value expr="promptValue('sorry')"/>
              </audio>
              <prompt>
                   <break time="500ms"/>
              </prompt>
              <audio expr="cinemaPromptPath(context.vars.cinema)">
                   <value expr="promptValue(context.vars.cinema)"/>
              </audio>
              <audio expr="promptPath('zerofilm01')">
                   <value expr="promptValue('zerofilm01')"/>
              </audio>
              <prompt>
                   <break time="1s"/>
              </prompt>
              <goto next="#ChooseAnotherDate" />
            <elseif cond="result.films.length==1"/>
              <assign name="context.vars.filmResult" expr="result.films[0]"/>
              <goto next="#OneFilm" />
            <else/>
              <assign name="context.vars.filmsResults" expr="result.films"/>
              <goto next="#ListOfFilms" />
            </if>
        </block>
     </form>


    <form id="OneFilm" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <block>
            <audio expr="promptPath('onefilm01')">
                <value expr="promptValue('onefilm01')"/>
            </audio>
            <audio expr="filmPromptPath(context.vars.filmResult.name)">
                <value expr="promptValue(context.vars.filmResult.name)"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <audio expr="promptPath('onefilm02')">
                <value expr="promptValue('onefilm02')"/>
            </audio>
        </block>
        <field name="choice">
           <grammar src="builtin:grammar/boolean?y=1;n=2"/>
             <filled>
               <assign name="context.vars.comingFrom" expr="'OneFilm'"/>
               <if cond="choice==true">
                  <assign name="context.vars.film" expr="context.vars.filmResult.name"/>
                  <goto next="#TimeLookup" />
               <else/>
                  <audio expr="promptPath('noproblem')">
                     <value expr="promptValue('noproblem')"/>
                  </audio>
                  <prompt>
                     <break time="1s"/>
                  </prompt>
                  <goto next="#ChooseAnotherDate" />
               </if>
             </filled>
          </field>

        <catch event="noinput">
            <var name="index" expr="(noinput_count == 0)?0:1"/>
            <assign name="noinput_count" expr="noinput_count+1"/>
            <audio expr="promptPath('noinput'+index)">
                <value expr="promptValue('noinput'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <clear/>
            <reprompt/>
        </catch>

        <catch event="nomatch">
            <var name="index" expr="(nomatch_count == 0)?0:1"/>
            <assign name="nomatch_count" expr="nomatch_count+1"/>
            <audio expr="promptPath('nomatch'+index)">
                <value expr="promptValue('nomatch'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <clear/>
            <reprompt/>
        </catch>
    </form>


    <form id="ListOfFilms" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <var name="films" expr="replaceQuestionMark(context.vars.filmsResults.toJSONString())"/>
        <block>
            <if cond="context.vars.comingFrom != 'ConfirmFilm'" >
                <audio expr="promptPath('listoffilms01')">
                    <value expr="promptValue('listoffilms01')"/>
                </audio>
            <else/>
                <audio expr="promptPath('listoffilms02')">
                    <value expr="promptValue('listoffilms02')"/>
                </audio>
            </if>
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="film" array="context.vars.filmsResults">
                <audio expr="filmPromptPath(film.name)">
                    <value expr="promptValue(film.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </block>
        <field name="choice">
            <grammar srcexpr="context.paths.grammar + 'GetFilm.jsp?films=' + films + '&amp;all=no'" xml:lang="en-US"/>
            <filled>
                <assign name="context.vars.comingFrom" expr="'ListOfFilms'"/>
                <assign name="context.vars.film" expr="choice"/>
                <goto next="#ConfirmFilm" />
            </filled>
        </field>

        <catch event="noinput">
            <var name="index" expr="(noinput_count == 0)?0:1"/>
            <assign name="noinput_count" expr="noinput_count+1"/>
            <audio expr="promptPath('noinput'+index)">
                <value expr="promptValue('noinput'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('listoffilms02')">
                <value expr="promptValue('listoffilms02')"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="film" array="context.vars.filmsResults">
                <audio expr="filmPromptPath(film.name)">
                    <value expr="promptValue(film.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </catch>

        <catch event="nomatch">
            <var name="index" expr="(nomatch_count == 0)?0:1"/>
            <assign name="nomatch_count" expr="nomatch_count+1"/>
            <audio expr="promptPath('nomatch'+index)">
                <value expr="promptValue('nomatch'+index)"/>
            </audio>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('listoffilms02')">
                <value expr="promptValue('listoffilms02')"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="film" array="context.vars.filmsResults">
                <audio expr="filmPromptPath(film.name)">
                    <value expr="promptValue(film.name)"/>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </catch>
   </form>



    <form id="TimeLookup" > 
        <block>
            <assign name="context.vars.comingFrom" expr="'TimeLookup'"/>
            <var name="city" expr="context.vars.city"/>
            <var name="date" expr="context.vars.date"/>
            <var name="cinema" expr="context.vars.cinema"/>
            <var name="film" expr="context.vars.film"/>

            <data name="mydata" srcexpr="context.paths.data + 'GetTimeLookup'" namelist="city cinema film date " />
            <var name="result" expr="GetData(mydata)"/>
            <if cond="result == undefined">
              <goto next="#FailureBehavior" />
            <elseif cond="result.status == 'failure'"/>
              <goto next="#FailureBehavior" />
            <elseif cond="result.ShowTimes.length==1"/>
              <assign name="context.vars.timeResult" expr="result.ShowTimes[0]"/>
              <goto next="#OneTime" />
            <else/>
              <assign name="context.vars.timesResult" expr="result.ShowTimes"/>
              <goto next="#MultipleTimes" />
            </if>
        </block>
    </form>


    <form id="MultipleTimes" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <block>
            <assign name="context.vars.onlyOneTime" expr="false"/>
            <audio expr="promptPath('multipletimes01')">
                <value expr="promptValue('multipletimes01')"/>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <foreach item="time" array="context.vars.timesResult">
                <audio expr="timePromptPath(time)">
                    <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(time)"/></say-as>
                </audio>
                <prompt>
                    <break time="2s"/>
                </prompt>
            </foreach>
            <audio expr="promptPath('hearlistagain')">
                <value expr="promptValue('hearlistagain')"/>
            </audio>
        </block>
        <field name="choice">
            <!-- time—Grammar for recognizing a time. Returns a string with format hhmmx
            where and x is one of: a for AM, p for PM, h for 24 hour notation, or ? for an
            ambiguous time (could be AM or PM). -->
            <grammar src="builtin:grammar/time"/>
            <filled>
                <assign name="context.vars.comingFrom" expr="'MultipleTimes'"/>
                <assign name="context.vars.time" expr="timeHHMMX_to_HHMM(choice)"/>
                <log>SelectedTime : <value expr="context.vars.time"/> </log>
                <if cond="isValidTime(context.vars.timesResult,context.vars.time)">
                    <goto next="#ConfirmTime" />
                <else/>
                    <clear/>
                    <throw event="nomatch"/>
                </if>
            </filled>
        </field>
        
        <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('multipletimes10')">
                    <value expr="promptValue('multipletimes10')"/>
                </audio>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <foreach item="time" array="context.vars.timesResult">
                    <audio expr="timePromptPath(time)">
                        <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(time)"/></say-as>
                    </audio>
                    <prompt>
                        <break time="2s"/>
                    </prompt>
                </foreach>
                <audio expr="promptPath('hearlistagain')">
                    <value expr="promptValue('hearlistagain')"/>
                </audio>
        </catch>
        <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('multipletimes10')">
                    <value expr="promptValue('multipletimes10')"/>
                </audio>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <foreach item="time" array="context.vars.timesResult">
                    <audio expr="timePromptPath(time)">
                        <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(time)"/></say-as>
                    </audio>
                    <prompt>
                        <break time="2s"/>
                    </prompt>
                </foreach>
                <audio expr="promptPath('hearlistagain')">
                    <value expr="promptValue('hearlistagain')"/>
                </audio>
        </catch>
    </form>


    <form id="ConfirmTime">
          <var name="noinput_count" expr="0"/>
          <var name="nomatch_count" expr="0"/>
          <block>
            <assign name="random" expr="randomize(2)"/>
            <audio expr="promptPath('thatwas'+ random)">
              <value expr="promptValue('thatwas'+ random)"/>
            </audio>
            <audio expr="timePromptPath(context.vars.time)">
                <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(context.vars.time)"/></say-as>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <assign name="random" expr="randomize(2)"/>
            <audio expr="promptPath('isright'+ random)">
               <value expr="promptValue('isright'+ random)"/>
            </audio>
          </block>
          <field name="choice">
               <grammar src="builtin:grammar/boolean?y=1;n=2"/> <!-- la tecla 1 para confirmar si esta bien,y la tecla 2 para en el caso no-->
                 <filled>
                    <assign name="context.vars.comingFrom" expr="'ConfirmDate'"/>
                    <if cond="choice==true">
                        <assign name="random" expr="randomize(3)"/>
                        <audio expr="promptPath('thanks' + random)">
                            <value expr="promptValue('thanks' + random)"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <if cond="context.vars.numTickets == undefined">
                            <goto next="#AskPayment" />
                        <else/>
                            <goto next="#AvailableTickets" />
                        </if>
                    <else/>
                        <assign name="random" expr="randomize(2)"/>
                        <audio expr="promptPath('mymistake'+ random)">
                            <value expr="promptValue('mymistake'+ random)"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <goto next="#MultipleTimes" />
                    </if>
                 </filled>
          </field>
         <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="timePromptPath(context.vars.time)">
                    <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(context.vars.time)"/></say-as>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>

           <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="timePromptPath(context.vars.time)">
                    <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(context.vars.time)"/></say-as>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
           </catch>
    </form>


    <form id="OneTime" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <block>
            <assign name="context.vars.onlyOneTime" expr="true"/>
            <audio expr="promptPath('onetime01')">
                <value expr="promptValue('onetime01')"/>
            </audio>
            <audio expr="timePromptPath(context.vars.timeResult)">                
                <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(context.vars.timeResult)"/></say-as>
            </audio>
            <prompt>
                <break time="1s"/>
            </prompt>
            <audio expr="promptPath('onetime02')">
                <value expr="promptValue('onetime02')"/>
            </audio>
        </block>
        <field name="choice">
           <grammar src="builtin:grammar/boolean?y=1;n=2"/>
             <filled>
               <assign name="context.vars.comingFrom" expr="'OneTime'"/>
               <if cond="choice==true">
                  <assign name="random" expr="randomize(3)"/>
                  <audio expr="promptPath('thanks'+ random)">
                       <value expr="promptValue('thanks'+ random)"/>
                  </audio>
                  <prompt>
                       <break time="1s"/>
                  </prompt>
                  <assign name="context.vars.time" expr="context.vars.timeResult"/>
                  <goto next="#AskPayment" />
               <else/>
                  <goto next="#ChooseAnotherDate" />
               </if>
             </filled>
          </field>

          <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('onetime10')">
                    <value expr="promptValue('onetime10')"/>
                </audio>
                <audio expr="timePromptPath(context.vars.timeResult)">
                    <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(context.vars.timeResult)"/></say-as>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
          </catch>
          <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('onetime10')">
                    <value expr="promptValue('onetime10')"/>
                </audio>
                <audio expr="timePromptPath(context.vars.timeResult)">
                    <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(context.vars.timeResult)"/></say-as>
                </audio>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
          </catch>
    </form>


    <form id="AskPayment" >
            <var name="mm" expr="context.vars.date.substring(4,6)"/>
            <var name="dd" expr="context.vars.date.substring(6,8)"/>
            <var name="yyyy" expr="context.vars.date.substring(0,4)"/>
            <var name="noinput_count" expr="0"/>
            <var name="nomatch_count" expr="0"/>
            <block>
                <audio expr="promptPath('askpayment01')">
                    <value expr="promptValue('askpayment01')"/>
                </audio>
                <audio expr="filmPromptPath(context.vars.film)">
                    <value expr="promptValue(context.vars.film)"/>
                </audio>
                <audio expr="promptPath('in')">
                    <value expr="promptValue('in')"/>
                </audio>
                <audio expr="cinemaPromptPath(context.vars.cinema)">
                    <value expr="promptValue(context.vars.cinema)"/>
                </audio>
                <prompt>
                    <break time="500ms"/>
                </prompt>
                <if cond="isTomorrow(context.vars.date)">
                    <audio expr="promptPath('tomorrow')">
                        <value expr="promptValue('tomorrow')"/>
                    </audio>   
                <else/>
                    <audio expr="promptPath('on')">
                        <value expr="promptValue('on')"/>
                    </audio>
                    <audio expr="datePromptPath(mm + '-m')">
                        <say-as type="date:m"> <value expr="mm"/></say-as>
                    </audio>
                    <audio expr="datePromptPath(dd + '-d')">
                        <say-as type="date:d"> <value expr="dd"/></say-as>
                    </audio>
                    <prompt>
                        <break time="250ms"/>
                    </prompt>
                    <audio expr="datePromptPath(yyyy + '-y')">
                        <say-as type="date:y"> <value expr="yyyy"/></say-as>
                    </audio>
                </if>
                <prompt>
                    <break time="500ms"/>
                </prompt>
                <audio expr="promptPath('at')">
                    <value expr="promptValue('at')"/>
                </audio>
                <audio expr="timePromptPath(context.vars.time)">
                    <say-as type="time:hm"> <value expr="timeHHMM_to_HHMMxm(context.vars.time)"/></say-as>
                </audio>
                <prompt>
                    <break time="1500ms"/>
                </prompt>
                <audio expr="promptPath('askpayment02')">
                    <value expr="promptValue('askpayment02')"/>
                </audio>
            </block>
            <field name="choice">
                <grammar srcexpr="context.paths.grammar + 'AskPayment.gsl#PAYMENT'" xml:lang="en-US"/>
                <filled>
                    <assign name="context.vars.comingFrom" expr="'AskPayment'"/>
                    <if cond="choice == 'makePayment'">
                        <audio expr="promptPath('sure')">
                            <value expr="promptValue('sure')"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <goto next="#AskNumberOfTickets" />
                    <elseif cond="choice == 'mainMenu'"/>
                        <goto next="#SearchCriteria" />
                    <elseif cond="choice == 'done'"/>
                        <goto next="#GoodBye" />
                    </if>
                </filled>
            </field>

            <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('askpayment10')">
                    <value expr="promptValue('askpayment10')"/>
                </audio>
            </catch>
            <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('askpayment10')">
                    <value expr="promptValue('askpayment10')"/>
                </audio>
            </catch>
    </form>


    <form id="AskNumberOfTickets" >
            <var name="noinput_count" expr="0"/>
            <var name="nomatch_count" expr="0"/>
            <block>
                <audio expr="promptPath('asknumberoftickets01')">
                    <value expr="promptValue('asknumberoftickets01')"/>
                </audio>
            </block>
            <field name="choice">
                <grammar src="builtin:grammar/number"/>
                <filled>
                    <assign name="context.vars.comingFrom" expr="'AskNumberOfTickets'"/>
                    <assign name="context.vars.numTickets" expr="parseInt(choice)"/>
                    <if cond="context.vars.numTickets &lt;= 0">
                        <log>Number of tickets should be a valid number</log>
                        <clear/>
                        <throw event="nomatch"/>
                    </if>
                    <if cond="application.lastresult$.confidence &gt; confirmConfidence">
                        <audio expr="promptPath('okaysure')">
                            <value expr="promptValue('okaysure')"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <goto next="#AvailableTickets" />
                    <else/>
                        <goto next="#ConfirmNumberOfTickets" />
                    </if>
                </filled>
            </field>

            <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('asknumberoftickets10')">
                    <value expr="promptValue('asknumberoftickets10')"/>
                </audio>
            </catch>
            <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('asknumberoftickets10')">
                    <value expr="promptValue('asknumberoftickets10')"/>
                </audio>
            </catch>
    </form>


    <form id="ConfirmNumberOfTickets">
          <var name="noinput_count" expr="0"/>
          <var name="nomatch_count" expr="0"/>
          <block>
                <assign name="random" expr="randomize(2)"/>
                <audio expr="promptPath('thatwas'+ random)">
                    <value expr="promptValue('thatwas'+ random)"/>
                </audio>
                <audio expr="numberPromptPath(context.vars.numTickets)">
                    <say-as type="number:ordinal"><value expr="context.vars.numTickets.toString()"/></say-as>
                </audio>
                <if cond="context.vars.numTickets &gt; 1">
                    <audio expr="promptPath('tickets')">
                        <value expr="promptValue('tickets')"/>
                    </audio>
                <else/>
                    <audio expr="promptPath('ticket')">
                        <value expr="promptValue('ticket')"/>
                    </audio>
                </if>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <assign name="random" expr="randomize(2)"/>
                <audio expr="promptPath('isright'+ random)">
                    <value expr="promptValue('isright'+ random)"/>
                </audio>
          </block>
          <field name="choice">
               <grammar src="builtin:grammar/boolean?y=1;n=2"/> 
                 <filled>
                   <assign name="context.vars.comingFrom" expr="'ConfirmNumberOfTickets'"/>
                   <if cond="choice==true">
                        <assign name="random" expr="randomize(3)"/>
                        <audio expr="promptPath('thanks' + random)">
                            <value expr="promptValue('thanks' + random)"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <goto next="#AvailableTickets" />
                   <else/>
                        <assign name="random" expr="randomize(2)"/>
                        <audio expr="promptPath('mymistake'+ random)">
                            <value expr="promptValue('mymistake'+ random)"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <goto next="#AskNumberOfTickets" />
                   </if>
                 </filled>
          </field>

          <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="numberPromptPath(context.vars.numTickets)">
                    <say-as type="number:ordinal"><value expr="context.vars.numTickets.toString()"/></say-as>
                </audio>
                <if cond="context.vars.numTickets &gt; 1">
                    <audio expr="promptPath('tickets')">
                        <value expr="promptValue('tickets')"/>
                    </audio>
                <else/>
                    <audio expr="promptPath('ticket')">
                        <value expr="promptValue('ticket')"/>
                    </audio>
                </if>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
          </catch>
          <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('ifthatwas')">
                    <value expr="promptValue('ifthatwas')"/>
                </audio>
                <audio expr="numberPromptPath(context.vars.numTickets)">
                    <say-as type="number:ordinal"><value expr="context.vars.numTickets.toString()"/></say-as>
                </audio>
                <if cond="context.vars.numTickets &gt; 1">
                    <audio expr="promptPath('tickets')">
                        <value expr="promptValue('tickets')"/>
                    </audio>
                <else/>
                    <audio expr="promptPath('ticket')">
                        <value expr="promptValue('ticket')"/>
                    </audio>
                </if>
                <audio expr="promptPath('sayyesorno')">
                    <value expr="promptValue('sayyesorno')"/>
                </audio>
          </catch>
    </form>


    <form id="AvailableTickets" >
            <block>
                <assign name="context.vars.comingFrom" expr="'AvailableTickets'"/>
                <var name="city" expr="context.vars.city"/>
                <var name="date" expr="context.vars.date"/>
                <var name="cinema" expr="context.vars.cinema"/>
                <var name="film" expr="context.vars.film"/>
                <var name="time" expr="context.vars.time"/>

                <data name="mydata" srcexpr="context.paths.data + 'GetAvailableTickets'" namelist="city cinema film date time" />
                <var name="result" expr="GetData(mydata)"/>
                <audio expr="promptPath('availabletickets01')">
                    <value expr="promptValue('availabletickets01')"/>
                </audio>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <if cond="result == undefined">
                    <goto next="#FailureBehavior" />
                <elseif cond="result.status == 'failure'"/>
                    <goto next="#FailureBehavior" />
                <else/>
                    <assign name="context.vars.availableTickets" expr="result.AvailableTickets"/>
                    <assign name="context.vars.Show_id" expr="result.Show_id"/>
                    <assign name="context.vars.Show_price" expr="result.Show_price"/>
                    <assign name="context.vars.Capacity" expr="result.Capacity"/>
                    <if cond="context.vars.availableTickets &gt;= context.vars.numTickets">
                        <goto next="#ConfirmPayment" />
                    <else/>
                        <audio expr="promptPath('availabletickets02')">
                            <value expr="promptValue('availabletickets02')"/>
                        </audio>
                        <prompt>
                            <break time="1s"/>
                        </prompt>
                        <if cond="context.vars.onlyOneTime == true">
                            <goto next="#ChooseAnotherDate" />
                        <else/>
                            <goto next="#ChooseAnotherTime" />
                        </if>
                    </if>
                </if>
            </block>
    </form>


    <form id="ConfirmPayment" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <block>
            <audio expr="promptPath('confirmpayment01')">
                <value expr="promptValue('confirmpayment01')"/>
            </audio>
            <prompt>
                <say-as type="currency"><value expr="context.vars.Show_price"/></say-as>
            </prompt>
            <prompt>
                <break time="1s"/>
            </prompt>
            <if cond="context.vars.numTickets &gt; 1">
                <audio expr="promptPath('confirmpayment02')">
                    <value expr="promptValue('confirmpayment02')"/>
                </audio>
                <prompt>
                    <say-as type="currency"><value expr="(context.vars.Show_price * context.vars.numTickets)"/></say-as>
                </prompt>
                <prompt>
                    <break time="1s"/>
                </prompt>
            </if>
            <audio expr="promptPath('confirmpayment03')">
                <value expr="promptValue('confirmpayment03')"/>
            </audio>
        </block>
        <field name="choice">
            <grammar srcexpr="context.paths.grammar + 'ConfirmPayment.gsl#CONFIRMPAYMENT'" xml:lang="en-US"/>
            <filled>
            <assign name="context.vars.comingFrom" expr="'ConfirmPayment'"/>
            <if cond="choice == 'makePayment'">
                <audio expr="promptPath('sure')">
                    <value expr="promptValue('sure')"/>
                </audio>
                <prompt>
                    <break time="1s"/>
                </prompt>
                <goto next="#CreditCardModule" />
            <elseif cond="choice == 'mainMenu'"/>
                <goto next="#SearchCriteria" />
            <else/><!-- choice == 'done-->
                <goto next="#GoodBye" />
            </if>
            </filled>
        </field>

        <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('confirmpayment10')">
                    <value expr="promptValue('confirmpayment10')"/>
                </audio>
          </catch>
          <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('confirmpayment10')">
                    <value expr="promptValue('confirmpayment10')"/>
                </audio>
          </catch>
    </form>


    <form id="ChooseAnotherTime" >
        <var name="noinput_count" expr="0"/>
        <var name="nomatch_count" expr="0"/>
        <block>
            <audio expr="promptPath('chooseanothertime01')">
                <value expr="promptValue('chooseanothertime01')"/>
            </audio>
        </block>
        <field name="choice">
               <grammar srcexpr="context.paths.grammar + 'ChooseAnotherTime.gsl#CONFIRM'" xml:lang="en-US"/>
               <filled>
                   <assign name="context.vars.comingFrom" expr="'ChooseAnotherTime'"/>
                   <if cond="choice =='yes'">
                      <audio expr="promptPath('sure')">
                           <value expr="promptValue('sure')"/>
                      </audio>
                      <prompt>
                           <break time="1s"/>
                      </prompt>
                      <goto next="#MultipleTimes" />
                   <else/>
                      <goto next="#ChooseAnotherDate" />
                   </if>
               </filled>
        </field>
        <catch event="noinput">
                <var name="index" expr="(noinput_count == 0)?0:1"/>
                <assign name="noinput_count" expr="noinput_count+1"/>
                <audio expr="promptPath('noinput'+index)">
                    <value expr="promptValue('noinput'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('chooseanothertime10')">
                    <value expr="promptValue('chooseanothertime10')"/>
                </audio>
        </catch>
        <catch event="nomatch">
                <var name="index" expr="(nomatch_count == 0)?0:1"/>
                <assign name="nomatch_count" expr="nomatch_count+1"/>
                <audio expr="promptPath('nomatch'+index)">
                    <value expr="promptValue('nomatch'+index)"/>
                </audio>
                <prompt>
                    <break time="250ms"/>
                </prompt>
                <audio expr="promptPath('chooseanothertime10')">
                    <value expr="promptValue('chooseanothertime10')"/>
                </audio>
           </catch>
    </form>


    <form id="CreditCardModule" >
        <block>
            <assign name="context.vars.comingFrom" expr="'CreditCardModule'"/>
            <log>CreditCardModule subdialog start</log>
        </block>
        <subdialog name="CCModule" src="CCM.vxml.jsp">
            <param name="subcontext" expr="context"/>
            <filled>
                <log>CreditCardModule subdialog end</log>
                <assign name="context.vars.result" expr="CCModule.result"/>                
                <goto next="#PlayPrompt" />
            </filled>
        </subdialog>
    </form>


    <form id="PlayPrompt" >
        <block>
            <assign name="context.vars.comingFrom" expr="'PlayPrompt'"/>
            <if cond="context.vars.result == 'success'">                            
                <goto next="#SearchCriteria" />            
            <elseif  cond="context.vars.result == 'failure'"/>
                <goto next="#FailureBehavior" />
            <else/> <!-- result == 'goodbye' -->
                <goto next="#GoodBye" />
            </if>
        </block>
    </form>


    <form id="FailureBehavior" >
        <block>
            <if cond="context.vars.comingFrom != 'PlayPrompt'" >
                <audio expr="promptPath('failurebehavior01')">
                    <value expr="promptValue('failurebehavior01')"/>
                </audio>
            <else/>
                <audio expr="promptPath('failurebehavior02')">
                    <value expr="promptValue('failurebehavior02')"/>
                </audio>
            </if>
            <prompt>
                <break time="250ms"/>
            </prompt>
            <audio expr="promptPath('failurebehavior03')">
                <value expr="promptValue('failurebehavior03')"/>
            </audio>
            <prompt>
                <break time="500ms"/>
            </prompt>
            <assign name="context.vars.comingFrom" expr="'FailureBehavior'"/>
            <goto next="#GoodBye" />
        </block>
    </form>


    <form id="GoodBye">
            <block>
                <audio expr="promptPath('goodbye')">
                    <value expr="promptValue('goodbye')"/>
                </audio>
                <disconnect/>
            </block>
    </form>
</vxml>