function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
if(hasClass(document.getElementById("test"), "test")){//do something};
maybe this helps you :-)
With the use of jQuery it would be easier and less code but nevermind !