function rewriteLayer (idOrPath, html) {
  if (document.layers) {
    var l = idOrPath.indexOf('.') != -1 ? eval(idOrPath)
             : document[idOrPath];
    if (l) {
      if (!l.ol) {
        var ol = l.ol = new Layer (l.clip.width, l);
        ol.clip.width = l.clip.width;
        ol.clip.height = l.clip.height;
        ol.bgColor = l.bgColor;
        l.visibility = 'hide';
        ol.visibility = 'show';
      }
      var ol = l.ol;
      ol.document.open();
      ol.document.write(html);
      ol.document.close();
    }
  }
  else if (document.all || document.getElementById) {
    var p = idOrPath.indexOf('.');
    var id = p != -1 ?
              idOrPath.substring(idOrPath.lastIndexOf('.') + 1)
              : idOrPath;
    if (document.all)
      document.all[id].innerHTML = html;
    else {
      var l = document.getElementById(id);
      var r = document.createRange();
      r.setStartAfter(l);
      var docFrag = r.createContextualFragment(html);
      while (l.hasChildNodes())
        l.removeChild(l.firstChild);
      l.appendChild(docFrag);
    }
  }
}
