I don't know how to fix the indexof as it is bringing error ("object doesn't support this property or method".) in IE8 on win xp
var x = document.getElementById("myDIV");
var classes = x.className.split(" ");
var i = classes.indexOf("mystyle");
if (i >= 0)
classes.splice(i, 1);
else
classes.push("mystyle");
x.className = classes.join(" ");