//
// Contains routines to display messages.
//

  // Processes an array generating a string to be used in an alert message.
  //
  // @param msg the message to display to the user to be followed by a list...
  // @param msgArr the array of strings to list after the message.
  //
  // @return the message to be displayed in an alert or confirm dialog or null
  //   if there are no fields.
  function genMsgFromArr(msg, msgArr)
  {
    var result = null;
    if (msgArr != null && msgArr.length > 0)
    {
      result = msg + "\n\n";
      for (var i=0; i < msgArr.length; i++)
      {
        result = result + "  - " + msgArr[i] + "\n";
      }
    }
    return result;
  }

  // Displays an alert if there is a message and returns true, else returns false.
  //
  // @param msg the message to display - if null or empty string, it will not display anything.
  //
  // @return true if there is a message to display, else false.
  function displayMsg(msg)
  {
    var result = false;
    if (msg != null && msg != "")
    {
      result = true;
      alert(msg);
    }
    return result;
  }
  
  // Display the message if the condition is true.
  // 
  // @param msg the message to display.
  // @param cond the condition to test.
  // 
  // @return true if the message displayed.
  function condDispMsg(msg, cond)
  {
    var result = false;
    if (cond)
    {
      result = displayMsg(msg);
    }
    return result;
  }

  // If the second message is not null, concatenate the messages and display them,
  // otherwise, do not display any message.
  // 
  // @param msg the message to display.
  // @param cond the condition message.
  // 
  // @return true if the message displayed.
  function concatDispMsg(msg, cond)
  {
    var result = false;
    if (cond != null)
    {
      result = displayMsg(msg + cond);
    }
    return result;
  }

