function latex_initClientSide()
{
  latex_showClientSide();
  try
  {
    jsMath.Autoload.Check();
    jsMath.Process();
  }
  catch(e)
  {
    if (handleException)
      handleException(e);
  }
  jsMath.Synchronize('latex_hideErrors()');
}

function latex_showClientSide()
{
  var tex = document.getElementsByTagName('SPAN');
  for (k = 0; k < tex.length; k++)
  {
    if (tex[k].className == 'cs')
      tex[k].style.display = 'inline';
    else if (tex[k].className == 'ss')
      tex[k].style.display = 'none';
  }
}


function latex_hideErrors() 
{
  var tex = document.getElementsByTagName('SPAN');
  for (k = 0; k < tex.length; k++)
  {
    if (tex[k].className == 'error' )
    {
      var parent = getParent(tex[k]);
      if (parent && parent.className == 'typeset')
      {
        parent = getParent(parent);
        if (parent && parent.className == 'cs')
        {
          parent = getParent(parent);
          if (parent && parent.className == 'latex')
          {
            parent.childNodes[0].style.display = 'inline';
            parent.childNodes[1].style.display = 'none';                        
          }
        }
      }   
    }
  }
} 
