﻿
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 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;
}

var cache = [];

function preloadImages() {
    var args_len = arguments.length;
    for (var i = args_len; i--; ) {
        var cacheImage = document.createElement('img');
        cacheImage.src = arguments[i];
        cache.push(cacheImage);
    }
}
