
if (typeof String.prototype.endsWith === 'undefined')
{
    String.prototype.endsWith = function(str)
    {
        var len = this.length;
        return (len >= str.length)
               && (this.substr(len - str.length) == str);
    };
}

if (typeof String.prototype.startsWith === 'undefined')
{
    String.prototype.startsWith = function(str)
    {
        return (this.length >= str.length)
               && (this.substr(0, str.length) == str);
    };
}

if (typeof String.prototype.trim === 'undefined')
{
    String.prototype.trim = function()
    {
        var str = this.replace(/^\s+/, '');
        str = str.replace(/\s+$/, '');
        return str;
    };
}
