<?xml version="1.0"?> 

<!DOCTYPE overlay SYSTEM "chrome://inspector/locale/tasksOverlay.dtd" >

<overlay id="ovBrowser"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/x-javascript" src="chrome://inspector/content/hooks.js"/>
  
  <script type="application/x-javascript"><![CDATA[
  
  window.addEventListener("load", inspectorNavOnLoad, true);
  
  function inspectorNavOnLoad()
  {
    var prefService = Components.classes["@mozilla.org/preferences-service;1"]
                                .getService(Components.interfaces.nsIPrefService);
    var pref = prefService.getBranch(null);

    var enabled = pref.getBoolPref("inspector.hooks.navigator");
    if (!enabled) {
      document.getElementById("context-inspect").setAttribute("hidden", "true");
      document.getElementById("menu_inspectPage").setAttribute("hidden", "true");
    } else {
      var popup = document.getElementById("contentAreaContextMenu");
      popup.addEventListener("popupshowing", inspectorContextCreate, false);
    }
  }
  
  function inspectorContextCreate()
  {
    var mi = document.getElementById("context-inspect");
    mi.setAttribute("label", "Inspect <"+inspectorGetContextNode().localName+">");
  }
  
  function inspectPopupNode()
  {
    inspectDOMNode(inspectorGetContextNode());
  }
  
  function inspectorGetContextNode()
  {
    var n = document.popupNode;
    while (n && n.nodeType != Node.ELEMENT_NODE)
      n = n.parentNode;
  
    return n;
  }
  
  ]]></script>
  
  <popup id="contentAreaContextMenu">
    <menuitem id="context-inspect"
              insertbefore="context-sep-view"
              oncommand="inspectPopupNode();"/>
  </popup>

  <menupopup id="menu_FilePopup">
    <menuitem id="menu_inspectPage" label="&inspectPageTaskCmd.label;" command="Tasks:InspectPage" 
              accesskey="&inspectPageTaskCmd.accesskey;" key="key_inspectPage" 
              insertbefore="menu_sendPage"/>
  </menupopup>

</overlay>
