Использовать классы!
#test {color: blue;}
#test:hover, #test.foo:hover {color:green;}
#test.foo { color : #cc0000 }
Основной JavaScript:
function change() {document.getElementById("test").className = "foo"; };
Конечно, вам нужно было бы переключать классы.