// <Function>.method: Adds a method to a class function. Code by Douglas Crockford.
// name - the name of the method
// func - the function implementing the method
Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
};

// <String>.trim: Removes whitespace characters from the beginning and end of a string.
//      Code by Douglas Crockford.
String.method('trim', function () {
    return this.replace(/^\s+|\s+$/g, '');
});

// readFile: Retrieves the text of a file specified by the given URL.
// fileUrl - the URL of the file
var readFile = function (fileUrl) {
    var xmlHttpObj;
    
    if (window.XMLHttpRequest) {
        xmlHttpObj = new XMLHttpRequest();
    } else {
        try {
            xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    
    xmlHttpObj.open("GET", fileUrl, false);
    xmlHttpObj.send();
    return xmlHttpObj.responseText;
};


