if( String.prototype.trim === undefined )
{
  String.prototype.trim = function()
  {
    return( this.replace(new RegExp("^([\\s]+)|([\\s]+)$", "gm"), "") );
  };
}

if( String.prototype.leftTrim === undefined )
{
  String.prototype.leftTrim = function()
  {
    return( this.replace(new RegExp("^[\\s]+", "gm"), "") );
  };
}

if( String.prototype.rightTrim === undefined )
{
  String.prototype.rightTrim = function()
  {
    return( this.replace(new RegExp("[\\s]+$", "gm"), "") );
  };
}

if( String.prototype.repeat === undefined )
{
  String.prototype.repeat = function(l)
  {
    var x = [];
    x[l] = undefined;
    return x.join(this);
  };
}

if( String.prototype.leftPad === undefined )
{
  String.prototype.leftPad = function(l,c)
  {
    l = l-1;
    var s = this;
    if(l >= this.length)
    {
      s = c.toString().repeat(l) + s;
    }
    return s;
  };
}

if( String.prototype.rightPad === undefined )
{
  String.prototype.rightPad = function(l,c)
  {
    l = l-1;
    var s = this;
    if(l >= this.length)
    {
      s += c.toString().repeat(l);
    }
    return s;
  };
}

if( String.prototype.startsWith === undefined )
{
  String.prototype.startsWith =  function(s)
  {
    return this.indexOf(s) === 0;
  };
}

if( String.prototype.endsWith === undefined )
{
  String.prototype.endsWith = function(s)
  {
    var d = this.length - s.length;
    return d >= 0 && this.lastIndexOf(s) === d;
  };
}

if( String.prototype.toInt === undefined )
{
  String.prototype.toInt = function()
  {
    var a = [];
    for (var i = 0; i < this.length; i++) {
      a[i] = this.charCodeAt(i);
    }
    return a;
  };
}

if( String.prototype.substringAfter === undefined )
{
  String.prototype.substringAfter = function(c)
  {
    return this.substr(this.indexOf(c)+1);
  };
}

if( String.prototype.substringBefore === undefined )
{
  String.prototype.substringBefore = function(c)
  {
    return this.substr(0, this.indexOf(c));
  };
}

if( String.prototype.toProperCase === undefined)
{
  String.prototype.toProperCase = function(){
       return this.toLowerCase().replace(/\w+/g,function(s){
            return s.charAt(0).toUpperCase() + s.substr(1);
       });
  };
}

