
if (!String.prototype.entitize)
{
  String.prototype.entitize = function()
  {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example: 'Kevin & van Zonneveld'.entitize();
    // *     returns: 'Kevin &amp; van Zonneveld'
    var div = document.createElement('div');
    var text = document.createTextNode(this);
    div.appendChild(text);
    return div.innerHTML;
  }
}

if (!String.prototype.trim)
{
  //from http://blog.stevenlevithan.com/archives/faster-trim-javascript
  String.prototype.trim = function()
  {
    var str = this.replace(/^\s\s*/, ''),
    ws = /\s/,
    i = str.length;
    while (ws.test(str.charAt(--i)));
    
    return str.slice(0, i + 1);
  }
}
if (!String.prototype.escapeRegex)
{
  String.prototype.escapeRegex = function()
  {
    return this.replace(/([\/\\$^\[\].*(){}|?])/g, '\\$1');
  }
}

if (!String.prototype.rawurlencode)
{
  String.prototype.rawurlencode = function ()
  {
    return escape(this);
  };
}

if (!String.prototype.rawurldecode)
{
  String.prototype.rawurldecode = function ()
  {
    return unescape(this);
  };
}

if (!String.prototype.extractId)
{
  String.prototype.extractId = function()
  {
    var id_str = this;
    var breakPoint = id_str.lastIndexOf('_');
    if ( breakPoint === -1 )  return id_str;
    
    var id_number = id_str.substring(breakPoint + 1);
    return id_number;
  };
}
