
if ( typeof String.prototype.replaceAll === 'undefined' ) {
	String.prototype.replaceAll = function(_this, _that) {
		return this.replace(new RegExp(_this,"g"), _that);
	};
}

Object.extend(String, {

    format: function(format) {
        var args = (Array.from(arguments)).slice(1);

        return format.replace(/\{(\d+)\}/g, function(pat, index) {
          return args[Number(index)];
        });
    },

    escapeHTML: function() {
        return (
            this.replace(/&/g,'&amp;').
                 replace(/>/g,'&gt;').
                 replace(/</g,'&lt;').
                 replace(/"/g,'&quot;')
        );
    }
});


