String.prototype.escapeXML = function() {
    return this.replace(/\"/g, "&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&/g, "");
}
String.prototype.escapeHTML = function() {
    return this.replace(/\"/g, "&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
}
String.prototype.asPlainText = function() {
    return this.replace(/\r?\n/g, "<br/>");
}
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.isEmpty = function() {
    return this.trim() == "";
}
String.prototype.startsWith = function(str) {
    return this.indexOf(str) == 0;
}
String.prototype.endsWith = function(str) {
    return this.indexOf(str) == this.length - str.length;
}
String.prototype.isEmail = function () {
    var avail = new RegExp("[A-z]{1}[A-z0-9\\x2d\\.]*[A-z0-9]{1}@[A-z0-9\\x2d\\.]*[A-z-9]{1}\\.[A-z]{2,5}","igm");
    var inval = /^.*((\x2d\.)|(\.\x2d)|(\.\.)|(\x2d\x2d)).*$/gi;
    return !this.isEmpty() && !inval.test(this) && avail.test(this)
}
String.prototype.isIntegerValue = function(){
    return new RegExp("^[0-9]+$").test(this);
}
