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

  /**
   * Adicionar função indexOf do objeto Array
   * 
   * @return Array
   */
  Array.prototype.indexOf = function(value) {
    for (var i = 0; i < this.count(); i++)
    {
      if (this[i] == value)
        return i;
    }

    return false;
  }

  /**
   * Adicionar função add do objeto Array
   * 
   * @return integer
   */
  Array.prototype.add = function(value) {
    this.push(value);
    return (this.count());
  }

  /**
   * Adicionar função remove do objeto Array
   */
  Array.prototype.remove = function(index) {
    for (var i = index; i < this.count()-1; i++)
      this[i] = this[i + 1];
    this.pop();
  }

  /**
   * Adicionar função count do objeto Array
   * 
   * @return integer
   */
  Array.prototype.count = function() {
    return this.length;
  }

  /**
   * Adicionar função implode do objeto Array
   * 
   * @param string sep Separador
   * @return string
   */
  Array.prototype.implode = function(sep) {
    var res = '';
    for (var i = 0; i < this.count(); i++)
    {
      if (i > 0)
        res += sep;
      res += this[i];
    }
    return res;
  }


  /**
   * Classe KeyArray
   * Classe de chaves e valores
   */
   function KeyArray()
   {
     this.itens     = new Array();

     /**
      * Adicionar key na lista
      *
      * @param string key
      * @param string value
      * @return integer
      */
      this.add = function(key, value)
      {
        var i = this.indexOf(key);
        if (i === false)
        {
          var code = 'var item = {';
          code += 'key: "' + key + '",';
          code += 'value: "' + value + '"';
          code += ' }';
          eval(code);
          i = this.itens.add(item);
        } else {
          this.itens[i].value = value;
        }

        return i;
      };

     /**
      * Remove um key da lista
      *
      * @param string key
      */
      this.remove = function(key)
      {
        var i = this.indexOf(key);
        if (i !== false)
          this.itens.remove(i);
      };

     /**
      * Retorna o indice de um key
      *
      * @param string key
      * @return integer
      */
      this.indexOf = function(key)
      {
        for (var i = 0; i < this.itens.count(); i++)
        {
          if (this.itens[i].key == key)
            return i;
        }

        return false;
      };

     /**
      * Retorna a lista em formato de Struct (Object)
      *
      * @return object
      */
      this.GetStruct = function()
      {
        var code = 'var res = {';
        for (var i = 0; i < this.itens.count(); i++)
        {
          if (i > 0)
            code += ', ';

          code += this.itens[i].key + ': ';
          code += '"' + this.itens[i].value + '"';
        }
        code += ' }';
        eval(code);

        return res;
      };
   }
