  // Source Code for Outlining
  // adopted from the code I am using at http://alexfung.fly.to/js/outline.js
  //
  // Alex Fung Dec 1998
  //  modified 12 Jan 1998 to avoid <a> tags
  //  modified Feb 1999 to 
  //   added support for className=outline 
  //                     (like Hn, but <span> and is black instead of navy)
  //                 and className=hand
  //                     (just hand cursor, don't procees the element)
  //  modified Jul 2000 to 
  //    double click body to hide, single click body now is ignored
  //      As a result, you can now select/hilite body text
  //        without the whole paragraph suddenly disappears
  //      However you still flips the display status when you 
  //        select section setings.
  //    use one single function for click and double click
  //    use one single function for mouseover and mouseout
  //    mouseover/out checks event.from/to element
  //

  if (document.all) document.styleSheets["outlineg"].addRule("span.clDetail","display:none");
  
  // see if a parent of src is Hx or class is outline
  // and don't handle hand class
  function checkParent(src) {
    while (src!=null) {
      var st = src.tagName;
      var sc = src.className;
      if (st.substr(0,1) == "H") {
        if ("1234565789".indexOf(st.substr(1,1)) != -1) {
          if ((src.href == null) || (event.type != "click")) {
            return src;
          } else {
            window.location.href = src.href;
            return null;
          }
        }
      }
      if (st == "A" || sc == "hand") return null;
      // if (sc == "outline" || sc == "clDetail") return src;
      if (sc == "outline") return src;
      if (sc == "clDetail") {
        if (event.type == "dblclick") return src;
        else return null;
      }
      src = src.parentElement;
    }
    return null;
  }

  // see if el after srcel has class clDetail
  function outDet(srcel) {
    var da = document.all;
    var dal = da.length;
    for (var pos = srcel.sourceIndex+1; srcel.contains(da[pos]); ++pos) {
      if (pos >= dal) return null;
    }
    if ("clDetail"==da[pos].className) return da[pos];
    return null;
  }


  function outline() {     
    var srcel = checkParent(event.srcElement);
    if (null==srcel) return;
    if ("clDetail"==srcel.className) {
      if (window.event.type == 'dblclick') {
        // single click body now no longer hides. use dblclick instead
        srcel.style.display = "none";
        srcel.scrollIntoView(true);
      }
    } else {
      var el = outDet(srcel);
      if (el==null) return;
      el.style.display = (el.style.display == "block") ? "none" : "block";
    }
    event.cancelBubble = true;
  }

  function outover() {     
    var srcel = checkParent(event.srcElement);
    if (null==srcel) return;
    if (srcel.contains(event.type == 'mouseover' ? event.fromElement : event.toElement)) return;
    if (outDet(srcel)==null) return;
    srcel.style.color = event.type == 'mouseover' ? "red" : (srcel.className == "outline" ? "black" : "navy")
    event.cancelBubble = true;
  }

  function doOutlineLoad() {
    // Do Loading
    if (window.DaisyChain) {
      window.DaisyChain.add("mouseover", outover);
      window.DaisyChain.add("mouseout", outover);
      window.DaisyChain.add("click", outline);
      window.DaisyChain.add("dblclick", outline);
    } else {
      with (document) {
        onmouseout = onmouseover = outover;    
        ondblclick = onclick = outline;
      }
    }
  }

  if (window.DaisyChain) window.DaisyChain.add("load", doOutlineLoad);
  else window.onload = doOutlineLoad;



