In the DOM, the class of an element is just each class separated by a space. You would just need to implement the parsing logic to insert / remove the classes as necesary.
I wonder though... why wouldn't you want to use jQuery? It makes this kind of problem trivially easy.