text: var WindowManager = require('helper/WindowManager');
  var Utils = require('helper/Utils');
  var Cloud = require('ti.cloud');
  exports['Show Threads'] = function (evt) {
      var win = WindowManager.createWindow({
          backgroundColor: 'white'
      });
  
      var table = Ti.UI.createTableView({
          backgroundColor: '#fff',
          top: 0, bottom: 0,
          data: [
              { title: 'Loading, please wait...' }
          ]
      });
  
      table.addEventListener('click', function (evt) {
          if (evt.row.id) {
  	        WindowManager.handleOpenWindow({ target: 'Show Messages In Thread', id: evt.row.id });
          }
      });
      win.add(table);
  
      function showThreads() {
          Cloud.Messages.showThreads(function (e) {
              if (e.success) {
  	            if (e.messages.length == 0) {
                      table.setData([
                          { title: 'No messages' }
                      ]);
                  } else {
  	                var data = [];
  		            for (var i = 0, l = e.messages.length; i < l; i++) {
                	        var message = e.messages[i];
                          var row = Ti.UI.createTableViewRow({
                              title: message.subject,
                              id: message.thread_id
                          });
                          data.push(row);
                      }
  		            table.setData(data);
  	            }
              } else {
                  table.setData([
                      { title: (e.error && e.message) || e }
                  ]);
                  Utils.error(e);
              }
          })
      }
  
      win.addEventListener('open', showThreads);
      return win;
  };