String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

/**
 * Make a string's first character uppercase.
 * @return Returns the resulting string.
 * @type {string}
 */
String.prototype.ucfirst = function() {
    //return this.charAt(0).toUpperCase() + this.slice(1);
    return this.replace(/^\w/, function($0) {return $0.toUpperCase();});
};

/**
 * Make a string's first character lowercase.
 * @return Returns the resulting string.
 * @type {string}
 */
String.prototype.lcfirst = function(a) {
    //return this.charAt(0).toUpperCase() + this.slice(1);
    return this.replace(/^\w/, function($0) {return $0.toLowerCase();});
};

function slugify(text)
{
    return text
        .replace(/\&\#039\;/g,"'")
        .replace(/\&qout\;/g,"\"")
        .replace(/\&amp\;/g,"&")
        .replace(/\&/g,"and")
        .replace(/[\s\+\_\(\)\=\.\-]{1,}/g," ")
        .replace(/[\/\'\\\"\!\?\t\,]/g,"")
        .trim().toLowerCase()
        .replace(/\s/g,"-");
}

function var_dump(obj, name, maxDepth, indent, depth) {
// dump the contents of any object.
// debug function.
// return object dumping

    if (typeof indent == "undefined") indent="";
    if (typeof depth == "undefined") depth=0;
    if (typeof maxDepth == "undefined") maxDepth=10;
    if (depth >= maxDepth) {
        return indent + name + ": <Maximum Depth Reached>\n";
    }
    if (typeof obj == "object") {
        var child = null;
        var output = indent + name + "\n";
        indent += "\t";
        for (var item in obj)
        {
            try {
                child = obj[item];
            } catch (e) {
                child = "<Unable to Evaluate>";
            }
            if (typeof child == "object") {
                output += var_dump(child, item, maxDepth, indent, depth + 1);
            } else {
                output += indent + item + ": " + child + "\n";
            }
        }
        return output;
    } else {
        return obj;
    }
}
