text: /*
   *
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
   *   http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing,
   * software distributed under the License is distributed on an
   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   * KIND, either express or implied.  See the License for the
   * specific language governing permissions and limitations
   * under the License.
   *
   */
  var transport = ripple('platform/webworks.core/2.0.0/client/transport'),
      _uri = "blackberry/ui/dialog/",
      _self;
  
  function getButtonsForDialogType(dialogType) {
      switch (dialogType) {
      case _self.D_OK:
          return ["Ok"];
      case _self.D_SAVE:
          return ["Save", "Discard"];
      case _self.D_DELETE:
          return ["Delete", "Cancel"];
      case _self.D_YES_NO:
          return ["Yes", "No"];
      case _self.D_OK_CANCEL:
          return ["Ok", "Cancel"];
      default:
          throw new Error("Invalid dialog type: " + dialogType);
      }
  }
  
  _self = {
      customAskAsync: function (message, choices, callback, settings) {
          return transport.call(_uri + "ask", {
              async: true,
              get: {
                  message: message,
                  buttons: choices,
                  settings: settings
              }
          }, function (response) {
              if (callback) {
                  callback(response);
              }
          });
      },
  
      standardAskAsync: function (message, type, callback, settings) {
          var choices = getButtonsForDialogType(type);
          return transport.call(_uri + "ask", {
              async: true,
              get: {
                  message: message,
                  buttons: choices,
                  settings: settings
              }
          }, function (response) {
              if (callback) {
                  callback(response);
              }
          });
      }
  };
  
  _self.__defineGetter__("D_OK", function () {
      return 0;
  });
  
  _self.__defineGetter__("D_SAVE", function () {
      return 1;
  });
  
  _self.__defineGetter__("D_DELETE", function () {
      return 2;
  });
  
  _self.__defineGetter__("D_YES_NO", function () {
      return 3;
  });
  
  _self.__defineGetter__("D_OK_CANCEL", function () {
      return 4;
  });
  
  _self.__defineGetter__("BOTTOM", function () {
      return "bottomCenter";
  });
  
  _self.__defineGetter__("CENTER", function () {
      return "middleCenter";
  });
  
  _self.__defineGetter__("TOP", function () {
      return "topCenter";
  });
  
  _self.__defineGetter__("SIZE_FULL", function () {
      return "full";
  });
  
  _self.__defineGetter__("SIZE_LARGE", function () {
      return "large";
  });
  
  _self.__defineGetter__("SIZE_MEDIUM", function () {
      return "medium";
  });
  
  _self.__defineGetter__("SIZE_SMALL", function () {
      return "small";
  });
  
  _self.__defineGetter__("SIZE_TALL", function () {
      return "tall";
  });
  
  module.exports = _self;
  