<?xml version="1.0"?>

<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml"
	application="../../root.xml">

<%@ include file="NumberPlayBack.txt" %>

<%
	String leadinPrompt = "";
	String promptsToPlay = "";
	String secondaryNumber = request.getParameter( "secondaryNumber.cassFormat" );
	java.util.StringTokenizer st =
		new java.util.StringTokenizer( secondaryNumber );

	if( st.countTokens() > 1 )
	{
		leadinPrompt =
			"<audio src=\"../../prompts/ConfirmSecondaryUnit1.ulaw\">" +
			"So you're at</audio>\n";
	}
	else
	{
		leadinPrompt =
			"<audio src=\"../../prompts/ConfirmSecondaryUnit2.ulaw\">" +
			"So you're in the</audio>\n";
	}

	String type = st.nextToken().toLowerCase();
	String expanded = type;
	if( type.equals( "apt" ) == true ) expanded = "apartment";
	else if( type.equals( "bldg" ) == true ) expanded = "building";
	else if( type.equals( "bsmt" ) == true ) expanded = "basement";
	else if( type.equals( "dept" ) == true ) expanded = "department";
	else if( type.equals( "fl" ) == true ) expanded = "floor";
	else if( type.equals( "frnt" ) == true ) expanded = "front";
	else if( type.equals( "hngr" ) == true ) expanded = "hangar";
	else if( type.equals( "key" ) == true ) expanded = "key";
	else if( type.equals( "lbby" ) == true ) expanded = "lobby";
	else if( type.equals( "lot" ) == true ) expanded = "lot";
	else if( type.equals( "lowr" ) == true ) expanded = "lowr";
	else if( type.equals( "ofc" ) == true ) expanded = "ofc";
	else if( type.equals( "ph" ) == true ) expanded = "penthouse";
	else if( type.equals( "pier" ) == true ) expanded = "pier";
	else if( type.equals( "rear" ) == true ) expanded = "rear";
	else if( type.equals( "rm" ) == true ) expanded = "room";
	else if( type.equals( "side" ) == true ) expanded = "side";
	else if( type.equals( "slip" ) == true ) expanded = "slip";
	else if( type.equals( "spc" ) == true ) expanded = "space";
	else if( type.equals( "ste" ) == true ) expanded = "suite";
	else if( type.equals( "stop" ) == true ) expanded = "stop";
	else if( type.equals( "trlr" ) == true ) expanded = "trailer";
	else if( type.equals( "unit" ) == true ) expanded = "unit";
	else if( type.equals( "upper" ) == true ) expanded = "upper";
	else if( type.equals( "#" ) == true ) { type = "number"; expanded = "number"; }

	if( expanded.length() > 0 )
	{
		promptsToPlay =
			"<audio src=\"../../prompts/" + type + ".ulaw\">" +
			expanded + "</audio>\n";
	}

	while( st.hasMoreTokens() )
	{
		promptsToPlay = promptsToPlay +
			numberPlayBack( st.nextToken() );
	}
%>

<!-- Confirm secondary unit information collected from caller. -->
<form id="ConfirmIt">
	<link event="repeat">
		<grammar xml:lang="en-US" version="1.0" root="ROOT">
			<rule id="ROOT" scope="public">
				<one-of><item>repeat</item></one-of>
			</rule>
		</grammar>
	</link>

	<block>
		<prompt bargein="false">
			<%= leadinPrompt %>
		</prompt>
	</block>

	<field name="status" type="boolean">
		<prompt>
			<%= promptsToPlay %>
			<audio src="../../prompts/ConfirmSecondaryUnit3.ulaw">
				is that right?
			</audio>
		</prompt>

		<catch event="repeat">
			<audio src="../../prompts/sure.ulaw">
				Sure.
			</audio>
			<reprompt/>
		</catch>

		<noinput count="1">
			<audio src="../../prompts/ConfirmSecondaryUnitTO.ulaw">
				Sorry, I didn't hear anything. I just need you
				to tell me if I got this information right or
				not.
			</audio>
			<reprompt/>
		</noinput>

		<nomatch count="1">
			<prompt bargein="false">
				<audio src="../../prompts/ConfirmSecondaryUnitER.ulaw">
					Sorry, I just need you to tell me
					if I got this information right or
					not.
				</audio>
			</prompt>
			<reprompt/>
		</nomatch>

		<filled>
			<return namelist="status"/>
		</filled>

		<catch event="nomatch noinput" count="2">
			<var name="status" expr="'No Answer'"/>
			<return namelist="status"/>
		</catch>
	</field>

</form>

</vxml>
