﻿// declare String.replaces function
String.prototype.replaces = function(oldChar, newChar) {
    var word = this;
    while (word.indexOf(oldChar) >= 0) word = word.replace(oldChar, newChar);
    return word;
};

String.prototype.padLeft = function(len) {
    var s = this;
    if (s.length < len) { s = ('0000000000' + s).slice(-len); }
    return s;
};

String.prototype.safeText = function() {
    var pattern = /[\'\">]/;
    var s = this;
    while (s.match(pattern)) {
        s = s.replace(/[\'\">]/, "");
    }
    return s;
};



// Number prototype
Number.prototype.toFixed = function(precision) {
    var power = Math.pow(10, precision || 0);
    return String(Math.round(this * power) / power);
}
