How to change CSS Parameter with JavaScript?
<p><em>I know it is not common way to modify CSS classes... but anyway >> I have the following function to change CSS parameter with JavaScript:</em></p>

<pre><code>function changeCSSParameter(classId, param, value)
{
  var CSSRules;
  if (document.all)
  {
    CSSRules = 'rules';
  }
  else if (document.getElementById)
  {
    CSSRules = 'cssRules';
  }
  for (var i = 0; i &lt; document.styleSheets[0][CSSRules].length; i++)
  {
    var classes = document.styleSheets[0][CSSRules][i].selectorText.split(/\s*,\s*/);
    for (var j = 0; j &lt; classes.length; j++)
    {
      if (classes[j] == classId)
      {
        document.styleSheets[0][CSSRules][i].style.setProperty(param, value, '');
      }
    }
  } 
}
</code></pre>

<p><em>However this function would not work as I wish if style classes are defined in groups, such as</em></p>

<pre><code>.first, .second
{
  color: red;
}
</code></pre>

<p><em>...because any change would apply to both classes. How can I solve this issue? Please advice.</em></p>

<p><em>No jQuery, please, just old-fashion JavaScript.</em></p>
