﻿
String.prototype.trim = function() {
    return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""));
}

String.prototype.startsWith = function(str) {
    return (this.match("^" + str) == str);
}

String.prototype.endsWith = function(str) {
    return (this.match(str + "$") == str);
}

function $(id) {
    return document.getElementById(id);
}

function limitText(field, limit) {
    if (field.value.length > limit) {
        field.value = field.value.substring(0, limit);
    }
}

function clearDefault(element, text) {
    if (element.value == text)
        element.value = '';
}

function setDefault(element, text) {
    if (element.value == '')
        element.value = text;
}
