String.prototype.startsWith = function(s) {
    if (!s) return false;
    return this.indexOf(s) == 0;
}
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.equalsIgnoreCase = function(s) {
    if (!s) return false;
    return this.toLowerCase() == s.toLowerCase();
}

Array.prototype.convertToString = function(delim) {
    if (this.length <= 0)
        return "";
    var retStr = this[0];
    for (var i = 1; i < this.length; i++) {
        retStr += (delim + this[i]);
    }
    return retStr;
}

function openMaximizedWindow(url) {
    var adjustHeight = 50;
    var adjustWidth = 10;
    var height = screen.availHeight - adjustHeight;
    var width = screen.availWidth - adjustWidth;
    var winProps = "height=" + height + ",width=" + width + ",left=0,top=0,scrollbars=yes,resizable=yes";
    var theWin = window.open(url, "WinName", winProps);
    theWin.focus();
    return theWin;
}

function openPopupCenter(url, popWidth, popHeight) {
    var documentBody = document.body;
    if (top) {
        documentBody = top.document.body;
    }
    var leftPos = (screen.width - popWidth) / 2;
    var topPos = (screen.height - popHeight) / 2;
    return window.open(url, 'popup', 'width=' + popWidth + ',height=' + popHeight + ',top=' + topPos + ',left=' + leftPos + ',scrollbars=yes,resizable=yes');
}

function confirmDelete() {
    return confirm(msg['areYouSure']);
}

function replaceAll(OldString, FindString, ReplaceString) {
    var SearchIndex = 0;
    var NewString = "";
    while (OldString.indexOf(FindString, SearchIndex) != -1) {
        NewString += OldString.substring(SearchIndex, OldString.indexOf(FindString, SearchIndex));
        NewString += ReplaceString;
        SearchIndex = (OldString.indexOf(FindString, SearchIndex) + FindString.length);
    }
    NewString += OldString.substring(SearchIndex, OldString.length);
    return NewString;
}

