function hasClass (obj, cls) { // class located in a word boundary pattern is determined whether class already exists return obj.className.match (new RegExp ( '( \\ s | ^)' + cls + '(\\ s | $ ) ')); } // class added to the obj function. addClass (obj, CLS) { IF (this.hasClass (obj, CLS)) {! obj.className = +' '+ CLS; } } // remove obj corresponding class function removeClass (obj, CLS) { IF (hasClass (obj, CLS)) { var new new REG = the RegExp ( '(S \\ | ^)' + + CLS '(S \\ | $)'); = obj.className.replace obj.className (REG, ''); } }