<?xml version="1.0" ?> 
<!DOCTYPE vxml PUBLIC "-//Tellme Networks//Voice Markup Language 1.0//EN" "http://resources.tellme.com/toolbox/vxml-tellme.dtd">
<vxml>
<form id="greeting" anchor="false">
<block>
<audio>Welcome to Schwab Voice white pages</audio> 
<pause>500</pause> 
<goto next="#main" method="get" /> 
</block>
</form>
<form id="main" anchor="false">
<block>
<script type="Javascript">
<![CDATA[ 
  function ParseGrammar(optionStr)
    {
    sChoice = vxmldata.get(optionStr);
    arrNames = new Array();
    arrValues = new Array();
    arrNameValuePair = new Array();

    arrNamesValues = sChoice.split('^');

    for (var i = 0; i < arrNamesValues.length; i++)
      {
      arrNameValuePair = arrNamesValues[i].split('=');
      arrNames[i] = arrNameValuePair[0];
      arrValues[i] = arrNameValuePair[1];
      }

    // Special Case: US_MONEY, US_BIG_MONEY
    if (arrNames[0] == "dollars" && arrNames[1] == "cents")
      {
      if (arrValues[1] == "xx")
        {
            // arrValues[0] is the dollars, arrValues[1] is the cents
        arrValues[1] = arrValues[0];
        arrValues[0] = Math.floor(arrValues[0]/100);
        arrValues[1] = Math.floor(arrValues[1]%100);
        }
      vxmldata.set("session.toolbox.parsegrammar.dollars", arrValues[0]);
      vxmldata.set("session.toolbox.parsegrammar.cents", arrValues[1]);
      }

    // Special Case: TIME
    else if (arrNames[0] == "hour" &&
         arrNames[1] == "minute" &&
         arrNames[2] == "am_pm")
        {
        if (arrValues[1] == "xx")
          {
          // arrValues[0] is the hours, arrValues[1] is the minutes
              arrValues[1] = arrValues[0];
              arrValues[0] = Math.floor(arrValues[0]/100);
              arrValues[1] = Math.floor(arrValues[1]%100);
          }

        vxmldata.set("session.toolbox.parsegrammar.hour", arrValues[0]);
        vxmldata.set("session.toolbox.parsegrammar.minute", arrValues[1]);
        vxmldata.set("session.toolbox.parsegrammar.am_pm", arrValues[2]);
        }

    // if this grammar is not a special case
    else
      {
      for (var j = 0; j < arrNames.length; j++)
        {
        vxmldata.set("session.toolbox.parsegrammar."+arrNames[j], arrValues[j]);
        }
      }
    }


]]> 
</script>
</block>
<field name="document.contactinfo" timeoutondtmf="false" confirm="no" bargein="true" magicword="false" phoneticpruning="false">
<grammar src="http://homepages.go.com/~tomcounts/employees.gsl" type="application/x-gsl" /> 
<prompt>
<audio>Please speak an employee name</audio> 
</prompt>
<filled>
<script type="Javascript">
<![CDATA[  ParseGrammar("document.contactinfo"); 
]]> 
</script>
<script type="javascript">
<![CDATA[ 

    phone = vxmldata.get("session.toolbox.parsegrammar.phone");
    areacode = phone.substring(0,3);
    prefix = phone.substring(3,6);
    extension = phone.substring(6,10);
    phonenumber = areacode + "-" + prefix + "-" + extension;
    vxmldata.set("document.formatedphone", phonenumber);
    
    // now parse out location into building, floor and office#
    separator = "-"; // delimiter of building, floor, and office
    tempstring = vxmldata.get("session.toolbox.parsegrammar.location");
    arrayOfStrings = tempstring.split(separator);
    vxmldata.set("document.building", arrayOfStrings[0]);
    vxmldata.set("document.floor", arrayOfStrings[1]);
    vxmldata.set("document.officenumber", arrayOfStrings[2]);
    

]]> 
</script>
<assign name="application.phonenumber" expr="{session.toolbox.parsegrammar.phone}" /> 
<goto next="#ReportInfo" method="get" /> 
</filled>
<nomatch>
<audio>Sorry, I don't know that person</audio> 
<reprompt order="curr" /> 
</nomatch>
<noinput>
<audio>sorry, I didn't hear you.</audio> 
<pause>1000</pause> 
<reprompt order="curr" /> 
</noinput>
</field>
</form>
<form id="ReportInfo" anchor="false">
<field name="document.whatnext" timeoutondtmf="false" confirm="no" bargein="true" magicword="false" phoneticpruning="false">
<grammar type="application/x-gsl">
<![CDATA[ 
  [
    ([call connect transfer] ?me)      {<option transfer>}
    ([(start over) (new ?name) (cancel) ])   {<option goback>}
    ([page beep])           {<option page>} 
    (?[more additional] [info information])  {<option more>}
  ]


]]> 
</grammar>
<prompt>
<audio>{session.toolbox.parsegrammar.firstname}</audio> 
<audio>{session.toolbox.parsegrammar.lastname}</audio> 
<audio>phone number</audio> 
<audio>{document.formatedphone}</audio> 
<pause>500</pause> 
<audio>To transfer this call, say transfer. For more information say more information. To search a new name, say new name.</audio> 
</prompt>
<filled>
<result name="goback">
<goto next="#main" method="get" /> 
</result>
<result name="transfer">
<goto next="#transfer_caller" method="get" /> 
</result>
<result name="page">
<audio>I'm sorry but paging is not yet available"</audio> 
<reprompt order="curr" /> 
</result>
<result name="more">
<audio>Building</audio> 
<audio>{document.building}</audio> 
<audio>Floor</audio> 
<audio>{document.floor}</audio> 
<audio>Office</audio> 
<audio>{document.officenumber}</audio> 
<pause>1500</pause> 
<reprompt order="curr" /> 
</result>
</filled>
<nomatch>
<audio>I'm sorry, I didn't understand you.</audio> 
<pause>500</pause> 
<audio>To transfer this call, say transfer. To search a new name, say new name.</audio> 
<reprompt order="curr" /> 
</nomatch>
<noinput>
<reprompt order="curr" /> 
</noinput>
</field>
</form>
<form id="transfer_caller" anchor="false">
<block>
<audio>One moment while I connect you to</audio> 
<audio>{session.toolbox.parsegrammar.firstname}</audio> 
<audio>{session.toolbox.parsegrammar.lastname}</audio> 
<audio>There is a one minute maximum for this call</audio> 
</block>
<transfer maxlength="60" dest="{application.phonenumber}" /> 
</form>
</vxml>

