Can you write a better Javascript function than this?

Yesterday, I decided to write a bit of JavaScript code to evaluate classes.

The first version of my code looked like this.

function hasClass(el, className) {
    var r;
    r = new RegExp('(^| )' + className + '( |$)');
    return r.test(el.className);
}

function addClass(el, className) {
    if (hasClass(el, className)) {
        return false;
    }
    el.className += ' ' + className;
}

function removeClass(el, className) {
    var r;
    r = new RegExp('(^| )' + className + '( |$)');
    el.className = el.className.replace(r, ' ');
}

Then I asked the R/GA Technology group if they knew a better way to optimize it. Want to know what they came up with?

See the evolution of the source code on Gist.