exports.voice = function(req, res) {
	var tropowebapi = require('tropo-webapi');
	var tropo = new tropowebapi.TropoWebAPI();
  
	//tropo.say("<speak><prosody rate='70%'>Welcome to my Tropo Web API demo.</prosody></speak>");

  	// Demonstrates how to use the base Tropo action classes.
  	var say = new Say("<speak><prosody rate='70%'>Enter a number</prosody></speak>", null, null, null, null, null);

  	var choices = new Choices("[1 DIGIT]", "dtmf", "#");
  
  	// Action classes can be passes as parameters to TropoWebAPI class methods.
  	tropo.ask(choices, 5, false, null, "foo", null, true, say, 5, null);
  	tropo.on("continue", null, "http://coneeds.98labs.com:8080/globe/voice/askSearch", true);

  	res.send(tropowebapi.TropoJSON(tropo));
}

exports.askSearch = function(req, res) {
	var tropowebapi = require('tropo-webapi');
	var tropo = new tropowebapi.TropoWebAPI();
	var say = new Say("<speak><prosody rate='70%'>What is you category?</prosody></speak>", null, null, null, null, null);

	var choices = new Choices("test, Tutor, Teacher, Lawyer, Nurse");
	tropo.ask(choices, 5, false, null, "foo", null, true, say, 5, null);
  	tropo.on("continue", null, "http://coneeds.98labs.com:8080/globe/voice/doSearch", true);
  	res.send(tropowebapi.TropoJSON(tropo));

/*
	var actionValue = req.body.result.actions.value;
	tropo.say("You selected" + actionValue);
	res.send(tropowebapi.TropoJSON(tropo));
*/
}


exports.doSearch = function(req, res) {
	var searchQuery = [{'description' : 'I am Raymande Leano', 'number' : '123456'}, {'description' : 'Boom Panis!', 'number' : '123456'}];
	doSearching(res, searchQuery);
}

function doSearching(res, searchQuery) {
	var tropowebapi = require('tropo-webapi');
	var tropo = new tropowebapi.TropoWebAPI();

	var say = new Say("<speak><prosody rate='70%'>"+ searchQuery[0].description +"</prosody></speak>", null, null, null, null, null);

	var choices = new Choices("call, next, end");

	tropo.ask(choices, 5, false, null, "foo", null, true, say, 5, null);
  	tropo.on("continue", null, "http://coneeds.98labs.com:8080/globe/voice/processSearch", true);
  	res.send(tropowebapi.TropoJSON(tropo));
}

exports.processSearch = function(req, res) {
	var actionValue = req.body.result.actions.value;
	/*
	tropo.say(actionValue);
	res.send(tropowebapi.TropoJSON(tropo));
	*/
	if (actionValue == 'next') {
		delete searchQuery[0];
		doSearching(res, searchQuery);
	}
}
@@ -1466,30 +1466,145 @@
 arch
-Query = %5B%7B'description
+Ids = %5B1, 2, 3%5D;%0A%09doSearching(res, searchIds);%0A%7D%0A%0Afunction doSearching(res, searchIds) %7B%0A%09var searchQuery = %7B 'data': %5B%7B 'id': '1', 'name
 ' : 
@@ -1652,21 +1652,35 @@
 '%7D, 
-%7B'description
+%0A%09%09%09%09%09%09%09%09%7B 'id': '2', 'name
 ' : 
@@ -1719,85 +1719,18 @@
 6'%7D%5D
-;%0A%09doSearching(res, searchQuery);%0A%7D%0A%0Afunction doSearching(res, searchQuery) %7B
+ %0A%09%09%09%09%09%09%7D;
 %0A%09va
@@ -1811,24 +1811,26 @@
 oWebAPI();%0A%0A
+%09%0A
 %09var say = n
@@ -1882,23 +1882,36 @@
 uery
-%5B0%5D.description
+.data%5BsearchIds%5B0%5D - 1%5D.name
  +%22%3C
@@ -1954,32 +1954,73 @@
 , null, null);%0A%0A
+%09var arrayString = searchIds.join(',');%0A%0A
 %09var choices = n
@@ -2204,25 +2204,42 @@
 rocessSearch
-%22
+?id=%22+ arrayString
 , true);%0A  %09
@@ -2486,29 +2486,87 @@
 %7B%0A%09%09
-delete searchQuery%5B0%5D
+var ids = req.query.id;%0A%09%09var arrayIds = ids.split(',');%0A%09%09arrayIds.splice(0,1)
 ;%0A%09%09
@@ -2582,26 +2582,23 @@
 ng(res, 
-searchQuery
+arrayIds
 );%0A%09%7D%0A%7D

update search voice