var autoClose = 0;
var oldObject = null;

function closestId(elem) {
  while (elem) {
    if (elem.id != "") {
      return elem.id;
    } else {
      elem = elem.parentElement;
    }
  }
  return false;
}

function setLastTocItemSelected(tocleaf) {
  var is_chrome = /chrome/i.test( navigator.userAgent );
  var current_href = window.location.href;
  if (is_chrome && current_href.indexOf('file://') === 0) {
    //Do nothing
  } else {
    var nearestId =  closestId(tocleaf);
    parent.lastTocItemSelected = closestId(tocleaf);
  }
}

function showHide(objectID) {
  if ((oldObject) &&(autoClose == 1)) oldObject.style.display = 'none'
  var browserName = navigator.appName;
  try {
    var object = document.getElementById(objectID);
    if (object.style.display == 'block') {
      object.style.display = 'none';
      if (browserName == "Microsoft Internet Explorer") {
        object.parentNode.style.setAttribute('cssText', 'list-style-image: url(collapse.gif)', 0);
      } else {
        object.parentNode.setAttribute('style', 'list-style-image: url(collapse.gif)');
      }
    } else {
      object.style.display = 'block';
      if (browserName == "Microsoft Internet Explorer") {
        object.parentNode.style.setAttribute('cssText', 'list-style-image: url(expanded.gif)', 0);
      } else {
        object.parentNode.setAttribute('style', 'list-style-image: url(expanded.gif)');
      }
    }
    oldObject = object;
  }
  catch (e) {
    /*
    Ignore errors from getElementById(). We do not care about attempts
    to showHide non-existing ids.
     */
  }
  return;
}

function setConWinTo(hrefTarget) {
  lastViewedTopic = hrefTarget;
  parent.contentwin.location.href = hrefTarget;
}