String.prototype.interpolate =
  function interpolate(vars)                                                                            
  {
    return this.replace(/\$([0-9a-z-A-Z_]+)/g,
      function (m, id)
      {   
        return (typeof vars[id] === "undefined") ? m : vars[id]
      }
    )
  }

String.prototype.asHTML =
  function asHTML ()                                                                            
  {
    return this
      .replace(/\&/g, '&amp;')
      .replace(/</g, '&lt;')
      .replace(/>/g, '&gt;')
  }

if (!Array.prototype.map)
{
    Array.prototype.map = function(fun /*, thisp*/)
    {
        var len = this.length;
        if (typeof fun != "function")
            throw new TypeError();

        var res = new Array(len);
        var thisp = arguments[1];
        for (var i = 0; i < len; i++)
        {
            if (i in this)
                res[i] = fun.call(thisp, this[i], i, this);
        }
        return res;
    };
}

