  ///
  /// NetForce Tecnologia
  /// Biblioteca de funções STRING de JavaScript
  ///

  /**
   * Adicionar função trim do objeto string
   * @return string
   */
  String.prototype.trim = function() {
    var str = this;
    var ini = false;
    var fim = false;

    for (var i = 0; i < str.length; i++)
    {
      // Achar início
      if ((ini === false) && (str.charAt(i) != ' '))
        ini = i;

      // Achar fim
      if (str.charAt(i) != ' ')
        fim = i;
    }

    // Verificar se toda string é branca
    if (fim === false)
      return '';

    return str.substr(ini, ((fim - ini) + 1));
  }

  /**
   * Adicionar função repleaceAll do objeto string
   *
   * @param string oldStr
   * @param string newStr
   * @return string
   */
  String.prototype.replaceAll = function(oldStr, newStr) {
    var str = this;
    var pos = str.indexOf(oldStr);
    while (pos > -1)
    {
      str = str.replace(oldStr, newStr);
      pos = str.indexOf(oldStr);
    }
    return (str);
  }

  /**
   * Adicionar função repleaceChar do objeto string
   *
   * @param string oldChar
   * @param string newChar
   * @return string
   */
  String.prototype.replaceChar = function(oldChar, newChar) {
    var str = this;
    var res = '';
    for (var i = 0; i < str.length; i++)
    {
      if (str.charAt(i) == oldChar)
        res += newChar;
      else
        res += str.charAt(i);
    }
    return res;
  }

  /**
   * Adicionar função fillChars do objeto string
   *
   * @param integer len
   * @return string
   */
  String.prototype.fillChars = function(len) {
    var str = this;
    while (str.length < len)
      str  = '0' + str;
    return str;
  }

  /**
   * Adicionar função intVal do objeto string
   *
   * @return Number
   */
  String.prototype.intVal = function() {
    var str = this;
    var res   = '';

    for (var i = 0; i < str.length; i++)
    {
      switch (str.charAt(i))
      {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
          res += str.charAt(i);
          break;
      }
    }
    return new Number(res);
  }

  /**
   * Adicionar função toDate do objeto string (no formato dd/mm/yyyy ou dd/mm/yyyy hh:nn)
   *
   * @return Date
   */
  String.prototype.toDate = function() {
    var str = this;

    // Verificar se string tem o tamanho certo
    if ((str.length != 10) && (str.length != 16))
      return false;

    var dd = str.substr(0,  2).intVal();
    var mm = str.substr(3,  2).intVal();
    var yy = str.substr(6,  4).intVal();
    var hh = str.substr(11, 2).intVal();
    var nn = str.substr(14, 2).intVal();

    var dt = new Date();
    dt.makeDate(dd, mm, yy, hh, nn);
    return dt;
  }

