<?xml version="1.0"?>
<%@page contentType="text/xml" %>
  
  <vxml version="1.0">
<!-- Asks what the user wants to do next. Redirects to EmailServlet with the request type specified by the user. -->
  <form>
      <%
      // Get the number of new messages and old messages
      int newMsgNum = Integer.parseInt((String)session.getAttribute("newmsgnum"));
      int oldMsgNum = Integer.parseInt((String)session.getAttribute("oldmsgnum"));
      %>
      <block>
	<audio>
	  <% 
	  if(newMsgNum == 0) {
	  out.println("You have no new messages.");
	  }
	  else {
	  out.println("You have "+newMsgNum+" new ");
	  if(newMsgNum == 1)		   
	  out.println("message.");
	  else
	  out.println("messages.");
	  }
	  
	  if(oldMsgNum == 0) {
	  out.println("You have no old messages.");
	  }
	  else {
	  out.println("You have "+oldMsgNum+" old ");
	  if(oldMsgNum == 1)		   
	  out.println("message.");
	  else
	  out.println("messages.");
	  }
	  
	  %>	
	</audio>
	<goto next="#menu"/>
      </block>
    </form>

    <!-- Ask what the user wants to do next -->
    <menu id="menu" dtmf="true">
      <prompt>
	<audio>
	  <%
	  if(newMsgNum ==0 && oldMsgNum == 0)
	  out.println("To send a message, say compose or press 3.");
	  else if(newMsgNum == 0 && oldMsgNum > 0)
	  out.println("To listen to your old messages, say old or press 2; or to compose a new message, say compose or press 3.");
	  else if(newMsgNum > 0 && oldMsgNum == 0)
	  out.println("To listen to your new messages, say new or press 1, or to compoase a new message, says compose or press 3.");
	  else 
	  out.println("To listen to your new messages, say new or press 1; to listen to your old messages, say old or press 2; or to compose a new message, say compose or press 3.");
	  
	  %>
	</audio>
	<audio src="http://resources.tellme.com/audio/earcons/timeout.wav"/>
      </prompt>
      <%
      // List choices
      if(newMsgNum > 0)
      out.println("<choice dtmf=\"1\" next=\"apps.email.EmailServlet?action=disphdr&amp;readnew=true&amp;msgnum=1\">([new (dtmf-1)])</choice>");
      if(oldMsgNum > 0)		
      out.println("<choice dtmf=\"2\" next=\"apps.email.EmailServlet?action=disphdr&amp;readnew=false&amp;msgnum=1\">([old (dtmf-2)])</choice>");
      %>
      <choice dtmf="3" next="apps.email.EmailServlet?action=compose&amp;msgnum=1&amp;readnew=true">([compose (dtmf-3)])</choice>	
      <noinput><reprompt/></noinput>
      <default><reprompt/></default>
    </menu>
  </vxml>





