add:  function prepareForStartup() { gURLBar = document.getElementById("urlbar"); gNavigatorBundle = document.getElementById("bundle_browser"); gProgressMeterPanel = document.getElementById("statusbar-progresspanel"); gBrowser.addEventListener("DOMUpdatePageReport", UpdatePageReport, false);  var webNavigation; try {  appCore = Components.classes["@mozilla.org/appshell/component/browser/instance;1"] .createInstance(Components.interfaces.nsIBrowserInstance); if (!appCore) throw "couldn't create a browser instance";  webNavigation = getWebNavigation(); if (!webNavigation) throw "no XBL binding for browser"; } catch (e) { alert("Error launching browser window:" + e); window.close(); return; }   window.XULBrowserWindow = new nsBrowserStatusHandler(); window.browserContentListener = new nsBrowserContentListener(window, gBrowser);   if ("arguments" in window && window.arguments.length > 1 && window.arguments[1]) { if (window.arguments[1].indexOf("charset=") != -1) { var arrayArgComponents = window.arguments[1].split("="); if (arrayArgComponents) {  getMarkupDocumentViewer().defaultCharacterSet = arrayArgComponents[1]; } } }   appCore.setWebShellWindow(window);    webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"] .createInstance(Components.interfaces.nsISHistory);   var globalHistory = Components.classes["@mozilla.org/browser/global-history;1"] .getService(Components.interfaces.nsIGlobalHistory); gBrowser.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).globalHistory = globalHistory;  const selectedBrowser = gBrowser.selectedBrowser; if (selectedBrowser.securityUI) selectedBrowser.securityUI.init(selectedBrowser.contentWindow);   gBrowser.addProgressListener(window.XULBrowserWindow, Components.interfaces.nsIWebProgress.NOTIFY_ALL); }  function delayedStartup() { if (gIsLoadingBlank) prepareForStartup();   initServices(); initBMService();  gBrowser.addEventListener("load", function(evt) { setTimeout(loadEventHandlers, 0, evt); }, true);  window.addEventListener("keypress", ctrlNumberTabSelection, true);  if (gMustLoadSidebar) { var sidebar = document.getElementById("sidebar"); var sidebarBox = document.getElementById("sidebar-box"); sidebar.setAttribute("src", sidebarBox.getAttribute("src")); }  #ifdef XP_WIN  try { var dialogShown = Components.classes["@mozilla.org/winhooks;1"] .getService(Components.interfaces.nsIWindowsHooks) .checkSettings(window); } catch(e) { } #endif   BMSVC.readBookmarks(); var bt = document.getElementById("bookmarks-ptf"); if (bt) { var btf = BMSVC.getBookmarksToolbarFolder().Value bt.ref = btf; document.getElementById("bookmarks-chevron").ref = btf; bt.database.AddObserver(BookmarksToolbarRDFObserver); } window.addEventListener("resize", BookmarksToolbar.resizeFunc, false); controllers.appendController(BookmarksMenuController);    window.addEventListener("fullscreen", onFullScreen, false);  var element; if (gIsLoadingBlank && gURLBar && !gURLBar.hidden && !gURLBar.parentNode.parentNode.collapsed) element = gURLBar; else element = _content;   var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] .getService(Components.interfaces.nsIWindowWatcher); if (window == ww.activeWindow) { element.focus(); } else {   if (element instanceof Components.interfaces.nsIDOMWindow) { document.commandDispatcher.focusedWindow = element; document.commandDispatcher.focusedElement = null; } else if (element instanceof Components.interfaces.nsIDOMElement) { document.commandDispatcher.focusedWindow = element.ownerDocument.defaultView; document.commandDispatcher.focusedElement = element; } }  SetPageProxyState("invalid", null);  var toolbox = document.getElementById("navigator-toolbox"); toolbox.customizeDone = BrowserToolboxCustomizeDone;  gPrefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); gPrefService = gPrefService.getBranch(null);  var observerService = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); observerService.addObserver(dlObserver, "dl-start", false);   var pbi = gPrefService.QueryInterface(Components.interfaces.nsIPrefBranchInternal); pbi.addObserver(gFormFillPrefListener.domain, gFormFillPrefListener, false);   gFormFillPrefListener.toggleFormFill();  updateHomeTooltip();   const kOverridePref = "browser.download.pluginOverrideTypes"; if (gPrefService.prefHasUserValue(kOverridePref)) { var types = gPrefService.getCharPref(kOverridePref); types = types.split(",");  const kPluginOverrideTypesNotHandled = "browser.download.pluginOverrideTypesNotHandled";  var catman = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager); var typesNotHandled = ""; for (var i = 0; i < types.length; ++i) {     try { var catEntry = catman.getCategoryEntry("Gecko-Content-Viewers", types[i]); } catch (e) { catEntry = ""; } if (catEntry == "") typesNotHandled += types[i] + ",";  catman.deleteCategoryEntry("Gecko-Content-Viewers", types[i], false); }  if (typesNotHandled != "") { typesNotHandled = typesNotHandled.substr(0, typesNotHandled.length - 1); gPrefService.setCharPref(kPluginOverrideTypesNotHandled, typesNotHandled); } else if (gPrefService.prefHasUserValue(kPluginOverrideTypesNotHandled)) gPrefService.clearUserPref(kPluginOverrideTypesNotHandled); } }  function Shutdown() { #ifdef MOZ_ENABLE_XREMOTE  var remoteService; remoteService = Components.classes["@mozilla.org/browser/xremoteservice;1"] .getService(Components.interfaces.nsIXRemoteService); remoteService.removeBrowserInstance(window); #endif try { gBrowser.removeProgressListener(window.XULBrowserWindow); } catch (ex) { }  var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(); var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); var enumerator = windowManagerInterface.getEnumerator(null); enumerator.getNext(); if (!enumerator.hasMoreElements()) { document.persist("sidebar-box", "sidebarcommand"); document.persist("sidebar-box", "width"); document.persist("sidebar-box", "src"); document.persist("sidebar-title", "value"); }  var service = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); service.removeObserver(dlObserver, "dl-start"); service = null;  window.XULBrowserWindow.destroy(); window.XULBrowserWindow = null;  window.browserContentListener.close();  if (appCore) appCore.close(); }  const gFormFillPrefListener = { domain: "browser.formfill.enable", observe: function (aSubject, aTopic, aPrefName) { if (aTopic != "nsPref:changed" || aPrefName != this.domain) return;  this.toggleFormFill(); },  toggleFormFill: function () { try { gFormFillEnabled = gPrefService.getBoolPref(this.domain); } catch (e) { } if (gFormFillEnabled) gBrowser.attachFormFill(); else gBrowser.detachFormFill(); gBrowser.setAttribute("autocompleteenabled", gFormFillEnabled);  var searchBar = document.getElementById("search-bar"); if (searchBar) { if (gFormFillEnabled) searchBar.removeAttribute("disableautocomplete"); else searchBar.setAttribute("disableautocomplete", "true"); } } }  function ctrlNumberTabSelection(event) { if (event.altKey && event.keyCode == KeyEvent.DOM_VK_RETURN) {  event.preventDefault(); return; }  #ifdef XP_MACOSX if (!event.metaKey) #else if (!event.ctrlKey) #endif return;  var index = event.charCode - 49; if (index < 0 || index > 8) return;  if (index >= gBrowser.mTabContainer.childNodes.length) return;  var oldTab = gBrowser.selectedTab; var newTab = gBrowser.mTabContainer.childNodes[index]; if (newTab != oldTab) { oldTab.selected = false; gBrowser.selectedTab = newTab; }  event.preventDefault(); event.preventBubble(); event.preventCapture(); event.stopPropagation(); }  function gotoHistoryIndex(aEvent) { var index = aEvent.target.getAttribute("index"); if (!index) return false; try { getWebNavigation().gotoIndex(index); } catch(ex) { return false; } return true;  }  function BrowserBack() { try { getWebNavigation().goBack(); } catch(ex) { } }  #ifdef XP_WIN function BrowserHandleBackspace() {        var typeAhead = null; const TYPE_AHEAD_FIND_CONTRACTID = "@mozilla.org/typeaheadfind;1"; if (TYPE_AHEAD_FIND_CONTRACTID in Components.classes) { typeAhead = Components.classes[TYPE_AHEAD_FIND_CONTRACTID] .getService(Components.interfaces.nsITypeAheadFind); }  if (!typeAhead || !typeAhead.backOneChar()) { BrowserBack(); } } #endif  function BrowserForward() { try { getWebNavigation().goForward(); } catch(ex) { } }  function BrowserBackMenu(event) { return FillHistoryMenu(event.target, "back"); }  function BrowserForwardMenu(event) { return FillHistoryMenu(event.target, "forward"); }  function BrowserStop() { try { const stopFlags = nsIWebNavigation.STOP_ALL; getWebNavigation().stop(stopFlags); } catch(ex) { } }  function BrowserReload() { const reloadFlags = nsIWebNavigation.LOAD_FLAGS_NONE; return BrowserReloadWithFlags(reloadFlags); }  function BrowserReloadSkipCache() {  const reloadFlags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; return BrowserReloadWithFlags(reloadFlags); }  function BrowserHome() { var homePage = getHomePage(); loadOneOrMoreURIs(homePage); }  function loadOneOrMoreURIs(aURIString) { if (aURIString.indexOf("|") != -1) { var urls = aURIString.split("|"); loadURI(urls[0]); for (var i = 1; i < urls.length; ++i) gBrowser.addTab(urls[i]); } else loadURI(aURIString); }  function constructGoMenuItem(goMenu, beforeItem, url, title) { var menuitem = document.createElementNS(kXULNS, "menuitem"); menuitem.setAttribute("statustext", url); menuitem.setAttribute("label", title); goMenu.insertBefore(menuitem, beforeItem); return menuitem; }  function onGoMenuHidden() { setTimeout("destroyGoMenuItems(document.getElementById('goPopup'));", 0); }  function destroyGoMenuItems(goMenu) { var startSeparator = document.getElementById("startHistorySeparator"); var endSeparator = document.getElementById("endHistorySeparator"); endSeparator.hidden = true;   var destroy = false; for (var i = 0; i < goMenu.childNodes.length; i++) { var item = goMenu.childNodes[i]; if (item == endSeparator) break;  if (destroy) { i--; goMenu.removeChild(item); }  if (item == startSeparator) destroy = true; } }  function updateGoMenu(goMenu) {  destroyGoMenuItems(goMenu);  var history = document.getElementById("hiddenHistoryTree");  if (history.hidden) { history.hidden = false; var globalHistory = Components.classes["@mozilla.org/browser/global-history;1"] .getService(Components.interfaces.nsIGlobalHistory); var dataSource = globalHistory.QueryInterface(Components.interfaces.nsIRDFDataSource); history.database.AddDataSource(dataSource); }  if (!history.ref) history.ref = "NC:HistoryRoot";  var count = history.treeBoxObject.view.rowCount; if (count > 10) count = 10;  if (count == 0) return;  const NC_NS     = "http:  if (!gRDF) gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"] .getService(Components.interfaces.nsIRDFService);  var builder = history.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);  var beforeItem = document.getElementById("endHistorySeparator");  var nameResource = gRDF.GetResource(NC_NS + "Name");  var endSep = beforeItem; var showSep = false;  for (var i = count-1; i >= 0; i--) { var res = builder.getResourceAtIndex(i); var url = res.Value; var titleRes = history.database.GetTarget(res, nameResource, true); if (!titleRes) continue;  showSep = true; var titleLiteral = titleRes.QueryInterface(Components.interfaces.nsIRDFLiteral); beforeItem = constructGoMenuItem(goMenu, beforeItem, url, titleLiteral.Value); }  if (showSep) endSep.hidden = false; }  function addBookmarkAs(aBrowser, aIsWebPanel) { const browsers = aBrowser.browsers; if (browsers && browsers.length > 1) addBookmarkForTabBrowser(aBrowser); else addBookmarkForBrowser(aBrowser.webNavigation, aIsWebPanel); }  function addBookmarkForTabBrowser(aTabBrowser, aSelect) { var tabsInfo = []; var currentTabInfo = { name: "", url: "", charset: null };  const activeBrowser = aTabBrowser.selectedBrowser; const browsers = aTabBrowser.browsers; for (var i = 0; i < browsers.length; ++i) { var webNav = browsers[i].webNavigation; var url = webNav.currentURI.spec; var name = ""; var charSet; try { var doc = webNav.document; name = doc.title || url; charSet = doc.characterSet; } catch (e) { name = url; } tabsInfo[i] = { name: name, url: url, charset: charSet }; if (browsers[i] == activeBrowser) currentTabInfo = tabsInfo[i]; } openDialog("chrome: "centerscreen,chrome,dialog=yes,resizable=no,dependent", currentTabInfo.name, currentTabInfo.url, null, currentTabInfo.charset, "addGroup" + (aSelect ? ",group" : ""), tabsInfo); }  function addBookmarkForBrowser(aDocShell, aIsWebPanel) {      var url = aDocShell.currentURI.spec; var title, charSet = null; try { title = aDocShell.document.title || url; charSet = aDocShell.document.characterSet; } catch (e) { title = url; } BookmarksUtils.addBookmark(url, title, charSet, aIsWebPanel); }  function openLocation() { if (gURLBar && !gURLBar.parentNode.parentNode.collapsed) { gURLBar.focus(); gURLBar.select(); } else { openDialog("chrome: } }  function BrowserOpenTab() { if (!gInPrintPreviewMode) { gBrowser.selectedTab = gBrowser.addTab('about:blank'); if (gURLBar) setTimeout("gURLBar.focus();", 0); } }  /* Called from the openLocation dialog. This allows that dialog to instruct its opener to open a new window and then step completely out of the way. Anything less byzantine is causing horrible crashes, rather believably, though oddly only on Linux. */ function delayedOpenWindow(chrome,flags,url) { setTimeout("openDialog('"+chrome+"','_blank','"+flags+"','"+url+"')", 10); }  /* Required because the tab needs time to set up its content viewers and get the load of the URI kicked off before becoming the active content area. */ function delayedOpenTab(url) { setTimeout(function(aTabElt) { gBrowser.selectedTab = aTabElt; }, 0, gBrowser.addTab(url)); }  function BrowserOpenFileWindow() {  try { const nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); fp.init(window, gNavigatorBundle.getString("openFile"), nsIFilePicker.modeOpen); fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText | nsIFilePicker.filterImages | nsIFilePicker.filterXML | nsIFilePicker.filterHTML);  if (fp.show() == nsIFilePicker.returnOK) openTopWin(fp.fileURL.spec); } catch (ex) { } }  function BrowserCloseTabOrWindow() { if (gBrowser.localName == 'tabbrowser' && gBrowser.mTabContainer.childNodes.length > 1) {  gBrowser.removeCurrentTab(); return; }  BrowserCloseWindow(); }  function BrowserCloseWindow() {        var x = window.screenX; var y = window.screenY; var h = window.outerHeight; var w = window.outerWidth;   var win = document.getElementById( "main-window" ); win.setAttribute( "x", x ); win.setAttribute( "y", y ); win.setAttribute( "height", h ); win.setAttribute( "width", w );  window.close(); }  function loadURI(uri, referrer) { try { getWebNavigation().loadURI(uri, nsIWebNavigation.LOAD_FLAGS_NONE, referrer, null, null); } catch (e) { } }  function BrowserLoadURL(aTriggeringEvent) { var url = gURLBar.value; if (url.match(/^view-source:/)) { BrowserViewSourceOfURL(url.replace(/^view-source:/, ""), null, null); } else { if (gBrowser.localName == "tabbrowser" && aTriggeringEvent && 'altKey' in aTriggeringEvent && aTriggeringEvent.altKey) { _content.focus(); var t = gBrowser.addTab(url); gBrowser.selectedTab = t; gURLBar.value = url; event.preventDefault(); event.preventBubble(); event.preventCapture(); event.stopPropagation(); } else loadURI(url); _content.focus(); } }  function getShortcutOrURI(url) {  try { var shortcutURL = BMSVC.resolveKeyword(url); if (!shortcutURL) {   var aOffset = url.indexOf(" "); if (aOffset > 0) { var cmd = url.substr(0, aOffset); var text = url.substr(aOffset+1); shortcutURL = BMSVC.resolveKeyword(cmd); if (shortcutURL && text) { aOffset = shortcutURL.indexOf("%s"); if (aOffset >= 0) shortcutURL = shortcutURL.substr(0, aOffset) + text + shortcutURL.substr(aOffset+2); else shortcutURL = null; } } }  if (shortcutURL) url = shortcutURL;  } catch (ex) { } return url; }  function readFromClipboard() { var url;  try {  var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"] .getService(Components.interfaces.nsIClipboard);   var trans = Components.classes["@mozilla.org/widget/transferable;1"] .createInstance(Components.interfaces.nsITransferable);  trans.addDataFlavor("text/unicode"); clipboard.getData(trans, clipboard.kSelectionClipboard);  var data = {}; var dataLen = {}; trans.getTransferData("text/unicode", data, dataLen);  if (data) { data = data.value.QueryInterface(Components.interfaces.nsISupportsString); url = data.data.substring(0, dataLen.value / 2); } } catch (ex) { }  return url; }  function BrowserViewSourceOfDocument(aDocument) { var docCharset; var pageCookie; var webNav;   docCharset = "charset=" + aDocument.characterSet;   try { var win; var ifRequestor;      win = aDocument.defaultView; if (win == window) { win = _content; } ifRequestor = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor);  webNav = ifRequestor.getInterface(nsIWebNavigation); } catch(err) {   webNav = getWebNavigation(); }      try{ var PageLoader = webNav.QueryInterface(Components.interfaces.nsIWebPageDescriptor);  pageCookie = PageLoader.currentDescriptor; } catch(err) {  }  BrowserViewSourceOfURL(webNav.currentURI.spec, docCharset, pageCookie); }  function BrowserViewSourceOfURL(url, charset, pageCookie) {  openDialog("chrome: "_blank", "scrollbars,resizable,chrome,dialog=no", url, charset, pageCookie); }   function BrowserPageInfo(doc) { window.openDialog("chrome: "_blank", "chrome,dialog=no", doc); }  #ifdef DEBUG  function LeakDetector(verbose) { this.verbose = verbose; }  const NS_LEAKDETECTOR_CONTRACTID = "@mozilla.org/xpcom/leakdetector;1";  if (NS_LEAKDETECTOR_CONTRACTID in Components.classes) { try { LeakDetector.prototype = Components.classes[NS_LEAKDETECTOR_CONTRACTID] .createInstance(Components.interfaces.nsILeakDetector); } catch (err) { LeakDetector.prototype = Object.prototype; } } else { LeakDetector.prototype = Object.prototype; }  var leakDetector = new LeakDetector(false);   function dumpMemoryLeaks() { leakDetector.dumpLeaks(); }   function traceChrome() { leakDetector.traceObject(document, leakDetector.verbose); }   function traceDocument() {  leakDetector.markObject(document, true); leakDetector.traceObject(_content, leakDetector.verbose); leakDetector.markObject(document, false); }   function traceVerbose(verbose) { leakDetector.verbose = (verbose == "true"); } #endif  function checkForDirectoryListing() { if ( "HTTPIndex" in _content && _content.HTTPIndex instanceof Components.interfaces.nsIHTTPIndex ) { _content.defaultCharacterset = getMarkupDocumentViewer().defaultCharacterSet; } }  function URLBarFocusHandler(aEvent, aElt) { if (gIgnoreFocus) gIgnoreFocus = false; else if (gClickSelectsAll) aElt.select(); }  function URLBarMouseDownHandler(aEvent, aElt) { if (aElt.hasAttribute("focused")) { gIgnoreClick = true; } else { gIgnoreFocus = true; gIgnoreClick = false; aElt.setSelectionRange(0, 0); } }  function URLBarClickHandler(aEvent, aElt) { if (!gIgnoreClick && gClickSelectsAll && aElt.selectionStart == aElt.selectionEnd) aElt.select(); }    function handleURLBarRevert() { var url = getWebNavigation().currentURI.spec; var throbberElement = document.getElementById("navigator-throbber");  var isScrolling = gURLBar.popupOpen;    if ((!throbberElement || !throbberElement.hasAttribute("busy")) && !isScrolling) { if (url != "about:blank") { gURLBar.value = url; gURLBar.select(); SetPageProxyState("valid", null); } else { gURLBar.value = ""; } }    return !isScrolling; }  function handleURLBarCommand(aTriggeringEvent) { canonizeUrl(aTriggeringEvent);  try { addToUrlbarHistory(); } catch (ex) {   }  BrowserLoadURL(aTriggeringEvent); }  function canonizeUrl(aTriggeringEvent) { if (!gURLBar) return;  var url = gURLBar.value;   if (url.match(/^(www|http)|\/\s*$/i)) return;  if (aTriggeringEvent && 'ctrlKey' in aTriggeringEvent && aTriggeringEvent.ctrlKey && 'shiftKey' in aTriggeringEvent && aTriggeringEvent.shiftKey)  url = "http: else if (aTriggeringEvent && 'ctrlKey' in aTriggeringEvent && aTriggeringEvent.ctrlKey)  url = "http: else if (aTriggeringEvent && 'shiftKey' in aTriggeringEvent && aTriggeringEvent.shiftKey)  url = "http:  gURLBar.value = getShortcutOrURI(url); }  function UpdatePageProxyState() { if (gURLBar && gURLBar.value != gLastValidURLStr) SetPageProxyState("invalid", null); }  function SetPageProxyState(aState, aURI) { if (!gURLBar) return;  if (!gProxyButton) gProxyButton = document.getElementById("page-proxy-button"); if (!gProxyFavIcon) gProxyFavIcon = document.getElementById("page-proxy-favicon"); if (!gProxyDeck) gProxyDeck = document.getElementById("page-proxy-deck");  gProxyButton.setAttribute("pageproxystate", aState);  if (aState == "valid") { gLastValidURLStr = gURLBar.value; gURLBar.addEventListener("input", UpdatePageProxyState, false); if (gBrowser.shouldLoadFavIcon(aURI)) { var favStr = gBrowser.buildFavIconString(aURI); if (favStr != gProxyFavIcon.src) { gBrowser.loadFavIcon(aURI, "src", gProxyFavIcon); gProxyDeck.selectedIndex = 0; } else gProxyDeck.selectedIndex = 1; } else { gProxyDeck.selectedIndex = 0; gProxyFavIcon.removeAttribute("src"); } } else if (aState == "invalid") { gURLBar.removeEventListener("input", UpdatePageProxyState, false); gProxyDeck.selectedIndex = 0; } }  function PageProxyDragGesture(aEvent) { if (gProxyButton.getAttribute("pageproxystate") == "valid") { nsDragAndDrop.startDrag(aEvent, proxyIconDNDObserver); return true; } return false; }  function SearchBarPopupShowing(aEvent) { var currItem = document.getElementById("miAddEngines"); if (currItem) aEvent.target.removeChild(currItem);  var browserBundle = document.getElementById("bundle_browser"); var menuitem = document.createElementNS(kXULNS, "menuitem"); menuitem.setAttribute("label", browserBundle.getString("addEngines")); menuitem.id = "miAddEngines"; aEvent.target.appendChild(menuitem); }  function SearchBarPopupCommand(aEvent) {  if (!aEvent.target.id) return;  if (aEvent.target.id == "miAddEngines") { var regionBundle = document.getElementById("bundle_browser_region"); loadURI(regionBundle.getString("searchEnginesURL")); return; }  document.getElementById("search-bar").currentEngine = aEvent.target.id; }  function showSearchEnginePopup() { var searchEnginePopup = document.getElementById("SearchBarPopup"); var searchEngineButton = document.getElementById("search-proxy-button"); searchEnginePopup.showPopup(searchEngineButton); }   function quickFindInPage(aValue) { var focusedWindow = document.commandDispatcher.focusedWindow; if (!focusedWindow || focusedWindow == window) focusedWindow = window._content;  var findInst = gBrowser.webBrowserFind; var findInFrames = findInst.QueryInterface(Components.interfaces.nsIWebBrowserFindInFrames); findInFrames.rootSearchFrame = _content; findInFrames.currentSearchFrame = focusedWindow;  var findService = Components.classes["@mozilla.org/find/find_service;1"] .getService(Components.interfaces.nsIFindService); findInst.searchString  = aValue; findInst.matchCase     = findService.matchCase; findInst.wrapFind      = true; findInst.entireWord    = findService.entireWord; findInst.findBackwards = false;  findInst.findNext(); }  function updateToolbarStates(toolbarMenuElt) { if (!gHaveUpdatedToolbarState) { var mainWindow = document.getElementById("main-window"); if (mainWindow.hasAttribute("chromehidden")) { gHaveUpdatedToolbarState = true; var i; for (i = 0; i < toolbarMenuElt.childNodes.length; ++i) document.getElementById(toolbarMenuElt.childNodes[i].getAttribute("observes")).removeAttribute("checked"); var toolbars = document.getElementsByTagName("toolbar");   for (i = 1; i < toolbars.length; ++i) { if (toolbars[i].getAttribute("class").indexOf("chromeclass") != -1) toolbars[i].setAttribute("hidden", "true"); } var statusbars = document.getElementsByTagName("statusbar"); for (i = 1; i < statusbars.length; ++i) { if (statusbars[i].getAttribute("class").indexOf("chromeclass") != -1) statusbars[i].setAttribute("hidden", "true"); } mainWindow.removeAttribute("chromehidden"); } } }  function BrowserFullScreen() { window.fullScreen = !window.fullScreen; }  function onFullScreen() { FullScreen.toggle();  }  function getWebNavigation() { try { return gBrowser.webNavigation; } catch (e) { return null; } }  function BrowserReloadWithFlags(reloadFlags) { /* First, we'll try to use the session history object to reload so * that framesets are handled properly. If we're in a special * window (such as view-source) that has no session history, fall * back on using the web navigation's reload method. */  var webNav = getWebNavigation(); try { var sh = webNav.sessionHistory; if (sh) webNav = sh.QueryInterface(nsIWebNavigation); } catch (e) { }  try { webNav.reload(reloadFlags); } catch (e) { } }  function toggleAffectedChrome(aHide) {        if (!gChromeState) gChromeState = new Object; var navToolbox = document.getElementById("navigator-toolbox"); navToolbox.hidden = aHide; if (aHide) {   gChromeState.hadTabStrip = gBrowser.getStripVisibility(); gBrowser.setStripVisibilityTo(false);  var sidebar = document.getElementById("sidebar-box"); gChromeState.sidebarOpen = !sidebar.hidden; if (gChromeState.sidebarOpen) { toggleSidebar(); } } else {   gBrowser.setStripVisibilityTo(gChromeState.hadTabStrip); if (gChromeState.sidebarOpen) { toggleSidebar(); } } }  function showPrintPreviewToolbar() { toggleAffectedChrome(true);  var printPreviewTB = document.createElementNS(kXULNS, "toolbar"); printPreviewTB.setAttribute("printpreview", true); printPreviewTB.setAttribute("id", "print-preview-toolbar");  var navToolbox = document.getElementById("navigator-toolbox"); navToolbox.parentNode.insertBefore(printPreviewTB, navToolbox); }  function BrowserExitPrintPreview() { gInPrintPreviewMode = false;  gBrowser.setAttribute("handleCtrlPageUpDown", "true");   var ifreq = _content.QueryInterface( Components.interfaces.nsIInterfaceRequestor); var webBrowserPrint = ifreq.getInterface( Components.interfaces.nsIWebBrowserPrint); webBrowserPrint.exitPrintPreview(); _content.focus();   var navToolbox = document.getElementById("navigator-toolbox"); var printPreviewTB = document.getElementById("print-preview-toolbar"); navToolbox.parentNode.removeChild(printPreviewTB);   toggleAffectedChrome(false);   var mainWin = document.getElementById("main-window"); mainWin.setAttribute("onclose", gOldCloseHandler); }  function setPrinterDefaultsForSelectedPrinter(aPrintService) { if (gPrintSettings.printerName == "") { gPrintSettings.printerName = aPrintService.defaultPrinterName; }   aPrintService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings);   aPrintService.initPrintSettingsFromPrefs(gPrintSettings, true, gPrintSettings.kInitSaveAll); }  function GetPrintSettings() { var prevPS = gPrintSettings; try { if (gPrintSettings == null) { var pref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); if (pref) { gPrintSettingsAreGlobal = pref.getBoolPref("print.use_global_printsettings", false); gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false); }  var printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"] .getService(Components.interfaces.nsIPrintSettingsService); if (gPrintSettingsAreGlobal) { gPrintSettings = printService.globalPrintSettings; setPrinterDefaultsForSelectedPrinter(printService); } else { gPrintSettings = printService.newPrintSettings; } } } catch (e) { dump("GetPrintSettings() "+e+"\n"); }  return gPrintSettings; }   var gPrintPreviewObs = { observe: function(aSubject, aTopic, aData) { setTimeout(FinishPrintPreview, 0); },  QueryInterface : function(iid) { if (iid.equals(Components.interfaces.nsIObserver) || iid.equals(Components.interfaces.nsISupportsWeakReference)) return this;  throw Components.results.NS_NOINTERFACE; } };  function BrowserPrintPreview() { var ifreq; var webBrowserPrint; try { ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor); webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint); gPrintSettings = GetPrintSettings();  } catch (e) {     }        gWebProgress = new Object();  var printPreviewParams    = new Object(); var notifyOnOpen          = new Object(); var printingPromptService = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"] .getService(Components.interfaces.nsIPrintingPromptService); if (printingPromptService) {   try { printingPromptService.showProgress(this, webBrowserPrint, gPrintSettings, gPrintPreviewObs, false, gWebProgress, printPreviewParams, notifyOnOpen); if (printPreviewParams.value) { var webNav = getWebNavigation(); printPreviewParams.value.docTitle = webNav.document.title; printPreviewParams.value.docURL   = webNav.currentURI.spec; }    if (!notifyOnOpen.value.valueOf() || gWebProgress.value == null) { FinishPrintPreview(); } } catch (e) { FinishPrintPreview(); } } }  function FinishPrintPreview() { try { var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor); var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint); if (webBrowserPrint) { gPrintSettings = GetPrintSettings(); webBrowserPrint.printPreview(gPrintSettings, null, gWebProgress.value); }  gBrowser.setAttribute("handleCtrlPageUpDown", "false");  var mainWin = document.getElementById("main-window");   if (mainWin.hasAttribute("onclose")) gOldCloseHandler = mainWin.getAttribute("onclose"); else gOldCloseHandler = null; mainWin.setAttribute("onclose", "BrowserExitPrintPreview(); return false;");    showPrintPreviewToolbar();  _content.focus(); } catch (e) {     } gInPrintPreviewMode = true; }  function BrowserPrintSetup() { var didOK = false; try { var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor); var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint); if (webBrowserPrint) { gPrintSettings = GetPrintSettings(); }  didOK = goPageSetup(window, gPrintSettings); if (didOK) {  if (webBrowserPrint) { if (gPrintSettingsAreGlobal && gSavePrintSettings) { var psService = Components.classes["@mozilla.org/gfx/printsettings-service;1"] .getService(Components.interfaces.nsIPrintSettingsService); psService.savePrintSettingsToPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData); } } } } catch (e) { dump("BrowserPrintSetup "+e); } return didOK; }  function BrowserPrint() { try { var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor); var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint); if (webBrowserPrint) { gPrintSettings = GetPrintSettings(); webBrowserPrint.print(gPrintSettings, null); } } catch (e) {     } }  function BrowserFind() { var focusedWindow = document.commandDispatcher.focusedWindow; if (!focusedWindow || focusedWindow == window) focusedWindow = window._content;  findInPage(gBrowser, window._content, focusedWindow) }  function BrowserFindAgain(reverse) { var focusedWindow = document.commandDispatcher.focusedWindow; if (!focusedWindow || focusedWindow == window) focusedWindow = window._content;  findAgainInPage(gBrowser, window._content, focusedWindow, reverse) }  function BrowserCanFindAgain() { return canFindAgainInPage(); }  function getMarkupDocumentViewer() { return gBrowser.markupDocumentViewer; }  /** * Content area tooltip. * XXX - this must move into XBL binding/equiv! Do not want to pollute *       browser.js with functionality that can be encapsulated into *       browser widget. TEMPORARY! * * NOTE: Any changes to this routine need to be mirrored in ChromeListener::FindTitleText() *       (located in mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp) *       which performs the same function, but for embedded clients that *       don't use a XUL/JS layer. It is important that the logic of *       these two routines be kept more or less in sync. *       (pinkerton) **/ function FillInHTMLTooltip(tipElement) { var retVal = false; if (tipElement.namespaceURI == "http: return retVal;  const XLinkNS = "http:   var titleText = null; var XLinkTitleText = null;  while (!titleText && !XLinkTitleText && tipElement) { if (tipElement.nodeType == Node.ELEMENT_NODE) { titleText = tipElement.getAttribute("title"); XLinkTitleText = tipElement.getAttributeNS(XLinkNS, "title"); } tipElement = tipElement.parentNode; }  var texts = [titleText, XLinkTitleText]; var tipNode = document.getElementById("aHTMLTooltip");  for (var i = 0; i < texts.length; ++i) { var t = texts[i]; if (t && t.search(/\S/) >= 0) { tipNode.setAttribute("label", t); retVal = true; } }  return retVal; }  var proxyIconDNDObserver = { onDragStart: function (aEvent, aXferData, aDragAction) { var value = gURLBar.value;    if (!value) return;  var urlString = value + "\n" + window._content.document.title; var htmlString = "<a href=\"" + value + "\">" + value + "</a>";  aXferData.data = new TransferData(); aXferData.data.addDataForFlavour("text/x-moz-url", urlString); aXferData.data.addDataForFlavour("text/unicode", value); aXferData.data.addDataForFlavour("text/html", htmlString); } }  var homeButtonObserver = { onDrop: function (aEvent, aXferData, aDragSession) { var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType); setTimeout(openHomeDialog, 0, url); },  onDragOver: function (aEvent, aFlavour, aDragSession) { var statusTextFld = document.getElementById("statusbar-display"); statusTextFld.label = gNavigatorBundle.getString("droponhomebutton"); aDragSession.dragAction = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK; },  onDragExit: function (aEvent, aDragSession) { var statusTextFld = document.getElementById("statusbar-display"); statusTextFld.label = ""; },  getSupportedFlavours: function () { var flavourSet = new FlavourSet(); flavourSet.appendFlavour("application/x-moz-file", "nsIFile"); flavourSet.appendFlavour("text/x-moz-url"); flavourSet.appendFlavour("text/unicode"); return flavourSet; } }  function openHomeDialog(aURL) { var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); var promptTitle = gNavigatorBundle.getString("droponhometitle"); var promptMsg   = gNavigatorBundle.getString("droponhomemsg"); var pressedVal  = promptService.confirmEx(window, promptTitle, promptMsg, (promptService.BUTTON_TITLE_YES * promptService.BUTTON_POS_0) + (promptService.BUTTON_TITLE_NO * promptService.BUTTON_POS_1), null, null, null, null, {value:0});  if (pressedVal == 0) { try { var str = Components.classes["@mozilla.org/supports-string;1"] .createInstance(Components.interfaces.nsISupportsString); str.data = aURL; gPrefService.setComplexValue("browser.startup.homepage", Components.interfaces.nsISupportsString, str); var homeButton = document.getElementById("home-button"); homeButton.setAttribute("tooltiptext", aURL); } catch (ex) { dump("Failed to set the home page.\n"+ex+"\n"); } } }  var goButtonObserver = { onDragOver: function(aEvent, aFlavour, aDragSession) { aEvent.target.setAttribute("dragover", "true"); return true; }, onDragExit: function (aEvent, aDragSession) { aEvent.target.removeAttribute("dragover"); }, onDrop: function (aEvent, aXferData, aDragSession) { var xferData = aXferData.data.split("\n"); var uri = xferData[0] ? xferData[0] : xferData[1]; if (uri) loadURI(uri); }, getSupportedFlavours: function () { var flavourSet = new FlavourSet(); flavourSet.appendFlavour("application/x-moz-file", "nsIFile"); flavourSet.appendFlavour("text/x-moz-url"); flavourSet.appendFlavour("text/unicode"); return flavourSet; } }  function focusSearchBar() { var searchBar = document.getElementById("search-bar"); if (searchBar) { searchBar.select(); searchBar.focus(); } }  function OpenSearch(tabName, searchStr, newTabFlag) {     var defaultSearchURL = null; var navigatorRegionBundle = document.getElementById("bundle_browser_region"); var fallbackDefaultSearchURL = navigatorRegionBundle.getString("fallbackDefaultSearchURL");     var urlmatch= /(:\/\/|^ftp\.)[^ \S]+$/ var forceAsURL = urlmatch.test(searchStr);  try { defaultSearchURL = gPrefService.getComplexValue("browser.search.defaulturl", Components.interfaces.nsIPrefLocalizedString).data; } catch (ex) { }   if (!defaultSearchURL) defaultSearchURL = fallbackDefaultSearchURL;  if (!searchStr) { BrowserSearchInternet(); } else {     if (forceAsURL) { BrowserLoadURL() } else { if (searchStr) { var escapedSearchStr = escape(searchStr); defaultSearchURL += escapedSearchStr; var searchDS = Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"] .getService(Components.interfaces.nsIInternetSearchService);  searchDS.RememberLastSearchText(escapedSearchStr); try { var searchEngineURI = gPrefService.getCharPref("browser.search.defaultengine"); if (searchEngineURI) { var searchURL = getSearchUrl("actionButton"); if (searchURL) { defaultSearchURL = searchURL + escapedSearchStr; } else { searchURL = searchDS.GetInternetSearchURL(searchEngineURI, escapedSearchStr, 0, 0, {value:0}); if (searchURL) defaultSearchURL = searchURL; } } } catch (ex) { }  if (!newTabFlag) { loadURI(defaultSearchURL); } else { var newTab = getBrowser().addTab(defaultSearchURL); if (!pref.getBoolPref("browser.tabs.loadInBackground")) getBrowser().selectedTab = newTab; } } } } }  function FillHistoryMenu(aParent, aMenu) {  deleteHistoryItems(aParent);  var sessionHistory = getWebNavigation().sessionHistory;  var count = sessionHistory.count; var index = sessionHistory.index; var end; var j; var entry;  switch (aMenu) { case "back": end = (index > MAX_HISTORY_MENU_ITEMS) ? index - MAX_HISTORY_MENU_ITEMS : 0; if ((index - 1) < end) return false; for (j = index - 1; j >= end; j--) { entry = sessionHistory.getEntryAtIndex(j, false); if (entry) createMenuItem(aParent, j, entry.title); } break; case "forward": end  = ((count-index) > MAX_HISTORY_MENU_ITEMS) ? index + MAX_HISTORY_MENU_ITEMS : count; if ((index + 1) >= end) return false; for (j = index + 1; j < end; j++) { entry = sessionHistory.getEntryAtIndex(j, false); if (entry) createMenuItem(aParent, j, entry.title); } break; case "go": aParent.lastChild.hidden = (count == 0); end = count > MAX_HISTORY_MENU_ITEMS ? count - MAX_HISTORY_MENU_ITEMS : 0; for (j = count - 1; j >= end; j--) { entry = sessionHistory.getEntryAtIndex(j, false); if (entry) createRadioMenuItem(aParent, j, entry.title, j==index); } break; } return true; }  function addToUrlbarHistory() { var urlToAdd = gURLBar.value; if (!urlToAdd) return; if (urlToAdd.search(/[\x00-\x1F]/) != -1) return;  if (!gGlobalHistory) gGlobalHistory = Components.classes["@mozilla.org/browser/global-history;1"] .getService(Components.interfaces.nsIBrowserHistory);  if (!gURIFixup) gURIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"] .getService(Components.interfaces.nsIURIFixup); try { if (urlToAdd.indexOf(" ") == -1) { var fixedUpURI = gURIFixup.createFixupURI(urlToAdd, 0); gGlobalHistory.markPageAsTyped(fixedUpURI.spec); } } catch(ex) { } }  function createMenuItem( aParent, aIndex, aLabel) { var menuitem = document.createElement( "menuitem" ); menuitem.setAttribute( "label", aLabel ); menuitem.setAttribute( "index", aIndex ); aParent.appendChild( menuitem ); }  function createRadioMenuItem( aParent, aIndex, aLabel, aChecked) { var menuitem = document.createElement( "menuitem" ); menuitem.setAttribute( "type", "radio" ); menuitem.setAttribute( "label", aLabel ); menuitem.setAttribute( "index", aIndex ); if (aChecked==true) menuitem.setAttribute( "checked", "true" ); aParent.appendChild( menuitem ); }  function deleteHistoryItems(aParent) { var children = aParent.childNodes; for (var i = 0; i < children.length; i++) { var index = children[i].getAttribute("index"); if (index) aParent.removeChild(children[i]); } }  function toJavaScriptConsole() { toOpenWindowByType("global:console", "chrome: }  function toOpenWindowByType(inType, uri) { var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(); var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); var topWindow = windowManagerInterface.getMostRecentWindow(inType);  if ( topWindow ) topWindow.focus(); else window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); }   function OpenBrowserWindow() { var charsetArg = new String(); var handler = Components.classes['@mozilla.org/commandlinehandler/general-startup;1?type=browser']; handler = handler.getService(); handler = handler.QueryInterface(Components.interfaces.nsICmdLineHandler); var startpage = handler.defaultArgs; var url = handler.chromeUrlForTask; var wintype = document.firstChild.getAttribute('windowtype');     if (window && (wintype == "navigator:browser") && window._content && window._content.document) { var DocCharset = window._content.document.characterSet; charsetArg = "charset="+DocCharset;   window.openDialog(url, "_blank", "chrome,all,dialog=no", startpage, charsetArg); } else { window.openDialog(url, "_blank", "chrome,all,dialog=no", startpage); } }  function openAboutDialog() { window.openDialog("chrome: }  function BrowserCustomizeToolbar() {  var menubar = document.getElementById("main-menubar"); for (var i = 0; i < menubar.childNodes.length; ++i) menubar.childNodes[i].setAttribute("disabled", true);  var cmd = document.getElementById("cmd_CustomizeToolbars"); cmd.setAttribute("disabled", "true");  window.openDialog("chrome: "chrome,all,dependent", document.getElementById("navigator-toolbox")); }  function BrowserToolboxCustomizeDone(aToolboxChanged) {  if (aToolboxChanged) { gURLBar = document.getElementById("urlbar"); gProxyButton = document.getElementById("page-proxy-button"); gProxyFavIcon = document.getElementById("page-proxy-favicon"); gProxyDeck = document.getElementById("page-proxy-deck"); updateHomeTooltip(); window.XULBrowserWindow.init(); }   var url = getWebNavigation().currentURI.spec; if (gURLBar) { gURLBar.value = url; var uri = Components.classes["@mozilla.org/network/standard-url;1"] .createInstance(Components.interfaces.nsIURI); uri.spec = url; SetPageProxyState("valid", uri); }   var menubar = document.getElementById("main-menubar"); for (var i = 0; i < menubar.childNodes.length; ++i) menubar.childNodes[i].setAttribute("disabled", false); var cmd = document.getElementById("cmd_CustomizeToolbars"); cmd.removeAttribute("disabled");   window.focus(); }  var FullScreen = { toggle: function() {  this.showXULChrome("toolbar", window.fullScreen); this.showXULChrome("statusbar", window.fullScreen); },  showXULChrome: function(aTag, aShow) { var XULNS = "http: var els = document.getElementsByTagNameNS(XULNS, aTag);  var i; for (i = 0; i < els.length; ++i) {  if (els[i].getAttribute("fullscreentoolbar") == "true") { if (!aShow) { gToolbarMode = els[i].getAttribute("mode"); gIconSize = els[i].getAttribute("iconsize");   if (gToolbarMode != "text") { els[i].setAttribute("mode", "icons"); els[i].setAttribute("iconsize", "small"); } } else { els[i].setAttribute("mode", gToolbarMode); els[i].setAttribute("iconsize", gIconSize); } } else {   if (aShow) els[i].removeAttribute("moz-collapsed"); else els[i].setAttribute("moz-collapsed", "true"); } }  var controls = document.getElementsByAttribute("fullscreencontrol", "true"); for (i = 0; i < controls.length; ++i) controls[i].hidden = aShow;   var toolbox = document.getElementById("navigator-toolbox"); if (!aShow && gToolbarMode != "text") { toolbox.setAttribute("mode", "icons"); toolbox.setAttribute("iconsize", "small"); } else if (aShow) { toolbox.setAttribute("mode", gToolbarMode); toolbox.setAttribute("iconsize", gIconSize); } } };  function nsBrowserStatusHandler() { this.init(); }  nsBrowserStatusHandler.prototype = { userTyped : { _value : false, browser : null,  get value() { if (this.browser != gBrowser.mCurrentBrowser) this._value = false;  return this._value; },  set value(aValue) { if (this._value != aValue) { this._value = aValue; this.browser = aValue ? gBrowser.mCurrentBrowser : null; }  return aValue; } },   status : "", defaultStatus : "", jsStatus : "", jsDefaultStatus : "", overLink : "", startTime : 0, statusText: "",  statusTimeoutInEffect : false,  hideAboutBlank : true,  QueryInterface : function(aIID) { if (aIID.equals(Components.interfaces.nsIWebProgressListener) || aIID.equals(Components.interfaces.nsISupportsWeakReference) || aIID.equals(Components.interfaces.nsIXULBrowserWindow) || aIID.equals(Components.interfaces.nsISupports)) return this; throw Components.results.NS_NOINTERFACE; },  init : function() { this.throbberElement = document.getElementById("navigator-throbber"); this.statusMeter     = document.getElementById("statusbar-icon"); this.stopCommand     = document.getElementById("Browser:Stop"); this.statusTextField = document.getElementById("statusbar-display"); this.securityButton  = document.getElementById("security-button");   const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; this.onSecurityChange(null, null, nsIWebProgressListener.STATE_IS_INSECURE); },  destroy : function() {  this.throbberElement = null; this.statusMeter     = null; this.stopCommand     = null; this.statusTextField = null; this.securityButton  = null; this.userTyped       = null; this.statusText      = null; },  setJSStatus : function(status) { this.jsStatus = status; this.updateStatusField(); },  setJSDefaultStatus : function(status) { this.jsDefaultStatus = status; this.updateStatusField(); },  setDefaultStatus : function(status) { this.defaultStatus = status; this.updateStatusField(); },  setOverLink : function(link, b) { this.overLink = link; this.updateStatusField(); },  updateStatusField : function() { var text = this.overLink || this.status || this.jsStatus || this.jsDefaultStatus || this.defaultStatus;    if (this.statusText != text) { this.statusTextField.label = text; this.statusText = text; } },  onLinkIconAvailable : function(aHref) { if (gProxyFavIcon) {   gProxyFavIcon.setAttribute("src", aHref); } },  onProgressChange : function (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) { if (aMaxTotalProgress > 0) {    var percentage = (aCurTotalProgress * 100) / aMaxTotalProgress; this.statusMeter.value = percentage; } },  onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) { const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; const nsIChannel = Components.interfaces.nsIChannel; if (aStateFlags & nsIWebProgressListener.STATE_START) {      if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK && aRequest && aWebProgress.DOMWindow == content) this.startDocumentLoad(aRequest);  if (this.throbberElement) {  this.throbberElement.setAttribute("busy", "true"); }   this.statusMeter.value = 0; if (gProgressCollapseTimer) { window.clearTimeout(gProgressCollapseTimer); gProgressCollapseTimer = null; } else this.statusMeter.parentNode.collapsed = false;   this.stopCommand.removeAttribute("disabled"); } else if (aStateFlags & nsIWebProgressListener.STATE_STOP) { if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) { if (aRequest) { if (aWebProgress.DOMWindow == content) this.endDocumentLoad(aRequest, aStatus); } }     if (aRequest) { var msg = "";  var channel; try { channel = aRequest.QueryInterface(nsIChannel); } catch(e) { }; if (channel) { var location = channel.URI.spec; if (location != "about:blank") { const kErrorBindingAborted = 2152398850; const kErrorNetTimeout = 2152398862; switch (aStatus) { case kErrorBindingAborted: msg = gNavigatorBundle.getString("nv_stopped"); break; case kErrorNetTimeout: msg = gNavigatorBundle.getString("nv_timeout"); break; } } }   if (!msg) { msg = gNavigatorBundle.getString("nv_done"); } this.status = ""; this.setDefaultStatus(msg); }   gProgressCollapseTimer = window.setTimeout("gProgressMeterPanel.collapsed = true; gProgressCollapseTimer = null;", 100);  if (this.throbberElement) this.throbberElement.removeAttribute("busy");  this.stopCommand.setAttribute("disabled", "true"); } },  onLocationChange : function(aWebProgress, aRequest, aLocation) { this.setOverLink("", null);  var location = aLocation.spec;  if (this.hideAboutBlank) { this.hideAboutBlank = false; if (location == "about:blank") location = ""; }       if (aWebProgress.DOMWindow == content) {   if (gURLBar && !this.userTyped.value) {    if (/^\s*wyciwyg:\/\/\d+\ location = RegExp.rightContext; setTimeout(function(loc, aloc) { gURLBar.value = loc; SetPageProxyState("valid", aloc);}, 0, location, aLocation);  this.userTyped.value = false; } } UpdateBackForwardButtons();  setTimeout("updatePageTheme();", 0); },  onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) { this.status = aMessage; this.updateStatusField(); },  onSecurityChange : function(aWebProgress, aRequest, aState) { const wpl = Components.interfaces.nsIWebProgressListener;  switch (aState) { case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_HIGH: this.securityButton.setAttribute("level", "high"); break; case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_LOW: this.securityButton.setAttribute("level", "low"); break; case wpl.STATE_IS_BROKEN: this.securityButton.setAttribute("level", "broken"); break; case wpl.STATE_IS_INSECURE: default: this.securityButton.removeAttribute("level"); break; }  var securityUI = gBrowser.securityUI; if (securityUI) this.securityButton.setAttribute("tooltiptext", securityUI.tooltipText); else this.securityButton.removeAttribute("tooltiptext"); },  startDocumentLoad : function(aRequest) {   this.userTyped.value = false;  const nsIChannel = Components.interfaces.nsIChannel; var urlStr = aRequest.QueryInterface(nsIChannel).URI.spec; var observerService = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); try { observerService.notifyObservers(_content, "StartDocumentLoad", urlStr); } catch (e) { } },  endDocumentLoad : function(aRequest, aStatus) { const nsIChannel = Components.interfaces.nsIChannel; var urlStr = aRequest.QueryInterface(nsIChannel).originalURI.spec;  var observerService = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService);  var notification = Components.isSuccessCode(aStatus) ? "EndDocumentLoad" : "FailDocumentLoad"; try { observerService.notifyObservers(_content, notification, urlStr); } catch (e) { } } }  function onViewToolbarsPopupShowing(aEvent) { var popup = aEvent.target; var i;   for (i = popup.childNodes.length-1; i >= 0; --i) { var deadItem = popup.childNodes[i]; if (deadItem.hasAttribute("toolbarindex")) popup.removeChild(deadItem); }  var firstMenuItem = popup.firstChild;  var toolbox = document.getElementById("navigator-toolbox"); for (i = 0; i < toolbox.childNodes.length; ++i) { var toolbar = toolbox.childNodes[i]; var toolbarName = toolbar.getAttribute("toolbarname"); var type = toolbar.getAttribute("type"); if (toolbarName && type != "menubar") { var menuItem = document.createElement("menuitem"); menuItem.setAttribute("toolbarindex", i); menuItem.setAttribute("type", "checkbox"); menuItem.setAttribute("label", toolbarName); menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey")); menuItem.setAttribute("checked", toolbar.getAttribute("collapsed") != "true"); popup.insertBefore(menuItem, firstMenuItem);  menuItem.addEventListener("command", onViewToolbarCommand, false); } toolbar = toolbar.nextSibling; } }  function onViewToolbarCommand(aEvent) { var toolbox = document.getElementById("navigator-toolbox"); var index = aEvent.originalTarget.getAttribute("toolbarindex"); var toolbar = toolbox.childNodes[index];  toolbar.collapsed = aEvent.originalTarget.getAttribute("checked") != "true"; document.persist(toolbar.id, "collapsed"); }  function displayPageInfo() { window.openDialog("chrome: "dialog=no", null, "securityTab"); }  function displayPageReportFirstTime() { window.openDialog("chrome: "modal"); }  function displayPageReport() { window.openDialog("chrome: "dialog,modal,resizable"); }  function nsBrowserContentListener(toplevelWindow, contentWindow) {     this.init(toplevelWindow, contentWindow); }  /* implements nsIURIContentListener */  nsBrowserContentListener.prototype = { init: function(toplevelWindow, contentWindow) { const nsIWebBrowserChrome = Components.interfaces.nsIWebBrowserChrome; this.toplevelWindow = toplevelWindow; this.contentWindow = contentWindow;   var windowDocShell = this.convertWindowToDocShell(toplevelWindow); if (windowDocShell) windowDocshell.parentURIContentListener = this;  var registerWindow = false; try { var treeItem = contentWindow.docShell.QueryInterface(Components.interfaces.nsIDocShellTreeItem); var treeOwner = treeItem.treeOwner; var interfaceRequestor = treeOwner.QueryInterface(Components.interfaces.nsIInterfaceRequestor); var webBrowserChrome = interfaceRequestor.getInterface(nsIWebBrowserChrome); if (webBrowserChrome) { var chromeFlags = webBrowserChrome.chromeFlags; var res = chromeFlags & nsIWebBrowserChrome.CHROME_ALL; var res2 = chromeFlags & nsIWebBrowserChrome.CHROME_DEFAULT; if ( res == nsIWebBrowserChrome.CHROME_ALL || res2 == nsIWebBrowserChrome.CHROME_DEFAULT) { registerWindow = true; } } } catch (ex) {}   if (registerWindow) { var uriLoader = Components.classes["@mozilla.org/uriloader;1"].getService(Components.interfaces.nsIURILoader); uriLoader.registerContentListener(this); } }, close: function() { this.contentWindow = null; var uriLoader = Components.classes["@mozilla.org/uriloader;1"].getService(Components.interfaces.nsIURILoader);  uriLoader.unRegisterContentListener(this); }, QueryInterface: function(iid) { if (iid.equals(Components.interfaces.nsIURIContentListener) || iid.equals(Components.interfaces.nsISupportsWeakReference) || iid.equals(Components.interfaces.nsISupports)) return this; throw Components.results.NS_NOINTERFACE; }, onStartURIOpen: function(uri) {  return false; },  doContent: function(contentType, isContentPreferred, request, contentHandler) {  var docShell = this.contentWindow.docShell; var contentListener; try { contentListener = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIURIContentListener); } catch (ex) { dump(ex); }  if (!contentListener) return false;  return contentListener.doContent(contentType, isContentPreferred, request, contentHandler);  },  isPreferred: function(contentType, desiredContentType) {  switch(contentType) { case "text/html": case "text/xul": case "text/rdf": case "text/xml": case "text/css": case "image/gif": case "image/jpeg": case "image/png": case "text/plain": case "application/http-index-format": return true; } return false; }, canHandleContent: function(contentType, isContentPreferred, desiredContentType) { var docShell = this.contentWindow.docShell; var contentListener; try { contentListener = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIURIContentListener); } catch (ex) { dump(ex); } if (!contentListener) return false;  return contentListener.canHandleContent(contentType, isContentPreferred, desiredContentType); }, convertWindowToDocShell: function(win) {  return null; }, loadCookie: null, parentContentListener: null }    function toggleSidebar(aCommandID, forceOpen) { if (gInPrintPreviewMode) return; var sidebarBox = document.getElementById("sidebar-box"); if (!aCommandID) aCommandID = sidebarBox.getAttribute("sidebarcommand");  var elt = document.getElementById(aCommandID); var sidebar = document.getElementById("sidebar"); var sidebarTitle = document.getElementById("sidebar-title"); var sidebarSplitter = document.getElementById("sidebar-splitter");  if (elt.getAttribute("checked") == "true") { if (!forceOpen) { elt.removeAttribute("checked"); sidebarBox.setAttribute("sidebarcommand", ""); sidebarTitle.setAttribute("value", ""); sidebarBox.hidden = true; sidebarSplitter.hidden = true; } return; }  var elts = document.getElementsByAttribute("group", "sidebar"); for (var i = 0; i < elts.length; ++i) elts[i].removeAttribute("checked");  elt.setAttribute("checked", "true");;  if (sidebarBox.hidden) { sidebarBox.hidden = false; sidebarSplitter.hidden = false; }  var url = elt.getAttribute("sidebarurl"); var title = elt.getAttribute("sidebartitle"); if (!title) title = elt.getAttribute("label"); sidebar.setAttribute("src", url); sidebarBox.setAttribute("src", url); sidebarBox.setAttribute("sidebarcommand", elt.id); sidebarTitle.setAttribute("value", title); }  function openPreferences() { openDialog("chrome: "chrome,titlebar,resizable,modal"); }  function updateHomeTooltip() { var homeButton = document.getElementById("home-button"); if (homeButton) { var homePage = getHomePage(); homePage = homePage.replace(/\|/g,', '); homeButton.setAttribute("tooltiptext", homePage); } }  function nsContextMenu( xulMenu ) { this.target         = null; this.menu           = null; this.onTextInput    = false; this.onImage        = false; this.onLink         = false; this.onMailtoLink   = false; this.onSaveableLink = false; this.onMetaDataItem = false; this.onMathML       = false; this.link           = false; this.inFrame        = false; this.hasBGImage     = false; this.isTextSelected = false; this.inDirList      = false; this.shouldDisplay  = true;   this.initMenu( xulMenu ); }   nsContextMenu.prototype = {  onDestroy : function () { },  initMenu : function ( popup ) {  this.menu = popup;   this.setTarget( document.popupNode );  this.isTextSelected = this.isTextSelection();   this.initItems(); }, initItems : function () { this.initOpenItems(); this.initNavigationItems(); this.initViewItems(); this.initMiscItems(); this.initSaveItems(); this.initClipboardItems(); this.initMetadataItems(); }, initOpenItems : function () { this.showItem( "context-openlink", this.onSaveableLink || ( this.inDirList && this.onLink ) ); this.showItem( "context-openlinkintab", this.onSaveableLink || ( this.inDirList && this.onLink ) );  this.showItem( "context-sep-open", this.onSaveableLink || ( this.inDirList && this.onLink ) ); }, initNavigationItems : function () {  this.setItemAttrFromNode( "context-back", "disabled", "canGoBack" );   this.setItemAttrFromNode( "context-forward", "disabled", "canGoForward" );  this.showItem( "context-back", !( this.isTextSelected || this.onLink || this.onImage || this.onTextInput ) ); this.showItem( "context-forward", !( this.isTextSelected || this.onLink || this.onImage || this.onTextInput ) );  this.showItem( "context-reload", !( this.isTextSelected || this.onLink || this.onImage || this.onTextInput ) );  this.showItem( "context-stop", !( this.isTextSelected || this.onLink || this.onImage || this.onTextInput ) ); this.showItem( "context-sep-stop", !( this.isTextSelected || this.onLink || this.onTextInput ) );    }, initSaveItems : function () { this.showItem( "context-savepage", !( this.inDirList || this.isTextSelected || this.onTextInput || this.onLink )); this.showItem( "context-sendpage", !( this.inDirList || this.isTextSelected || this.onTextInput || this.onLink ));   this.showItem( "context-savelink", this.onSaveableLink );   this.showItem( "context-saveimage", this.onImage );  this.showItem( "context-sendimage", this.onImage );   this.showItem( "context-sendlink", this.onSaveableLink ); }, initViewItems : function () {  this.showItem( "context-viewpartialsource-selection", this.isTextSelected ); this.showItem( "context-viewpartialsource-mathml", this.onMathML && !this.isTextSelected ); this.showItem( "context-viewsource", !( this.inDirList || this.onImage || this.isTextSelected || this.onLink || this.onTextInput ) ); this.showItem( "context-viewinfo", !( this.inDirList || this.onImage || this.isTextSelected || this.onLink || this.onTextInput ) );  this.showItem( "context-sep-properties", !( this.inDirList || this.isTextSelected || this.onTextInput ) );  var isWin = navigator.appVersion.indexOf("Windows") != -1; this.showItem( "context-setWallpaper", isWin && this.onImage );  if( isWin && this.onImage )  this.setItemAttr( "context-setWallpaper", "disabled", (("complete" in this.target) && !this.target.complete) ? "true" : null );   this.showItem( "context-viewimage", this.onImage );   this.showItem( "context-viewbgimage", !( this.inDirList || this.onImage || this.isTextSelected || this.onLink || this.onTextInput ) ); this.showItem( "context-sep-viewbgimage", !( this.inDirList || this.onImage || this.isTextSelected || this.onLink || this.onTextInput ) ); this.setItemAttr( "context-viewbgimage", "disabled", this.hasBGImage ? null : "true"); }, initMiscItems : function () {  this.showItem( "context-bookmarkpage", !( this.isTextSelected || this.onTextInput || this.onLink ) ); this.showItem( "context-bookmarklink", this.onLink && !this.onMailtoLink ); this.showItem( "context-searchselect", this.isTextSelected ); this.showItem( "frame", this.inFrame ); this.showItem( "frame-sep", this.inFrame ); this.showItem( "context-blockimage", this.onImage); if (this.onImage) { var blockImage = document.getElementById("context-blockimage");  var uri = Components.classes['@mozilla.org/network/standard-url;1'].createInstance(Components.interfaces.nsIURI); uri.spec = this.imageURL;  var shortenedUriHost = uri.host.replace(/^www\./i,""); if (shortenedUriHost.length > 15) shortenedUriHost = shortenedUriHost.substr(0,15) + "..."; blockImage.label = gNavigatorBundle.getFormattedString ("blockImages", [shortenedUriHost]);  if (this.isImageBlocked()) { blockImage.setAttribute("checked", "true"); } else blockImage.removeAttribute("checked"); } }, initClipboardItems : function () {       goUpdateGlobalEditMenuItems();  this.showItem( "context-undo", this.onTextInput ); this.showItem( "context-sep-undo", this.onTextInput ); this.showItem( "context-cut", this.onTextInput ); this.showItem( "context-copy", this.isTextSelected || this.onTextInput ); this.showItem( "context-paste", this.onTextInput ); this.showItem( "context-delete", this.onTextInput ); this.showItem( "context-sep-paste", this.onTextInput ); this.showItem( "context-selectall", this.isTextSelected || this.onTextInput ); this.showItem( "context-sep-selectall", this.isTextSelected );        this.showItem( "context-copyemail", this.onMailtoLink );   this.showItem( "context-copylink", this.onLink ); this.showItem( "context-sep-copylink", this.onLink && this.onImage);   this.showItem( "context-copyimage", this.onImage ); this.showItem( "context-sep-copyimage", this.onImage ); }, initMetadataItems : function () {  this.showItem( "context-metadata", this.onMetaDataItem ); },  setTarget : function ( node ) { const xulNS = "http: if ( node.namespaceURI == xulNS ) { this.shouldDisplay = false; return; }  this.onImage    = false; this.onMetaDataItem = false; this.onTextInput = false; this.imageURL   = ""; this.onLink     = false; this.onMathML   = false; this.inFrame    = false; this.hasBGImage = false; this.bgImageURL = "";   this.target = node;   if ( this.target.nodeType == Node.ELEMENT_NODE ) { if ( this.target.localName.toUpperCase() == "IMG" ) { this.onImage = true; this.imageURL = this.target.src;  var mapName = this.target.getAttribute( "usemap" ); if ( mapName ) {  var map = this.target.ownerDocument.getElementById( mapName.substr(1) ); if ( map ) {  var areas = map.childNodes;  areas.length = 0; for ( var i = 0; i < areas.length && !this.onLink; i++ ) { var area = areas[i]; if ( area.nodeType == Node.ELEMENT_NODE && area.localName.toUpperCase() == "AREA" ) {  var type = area.getAttribute( "type" ); var coords = this.parseCoords( area ); switch ( type.toUpperCase() ) { case "RECT": case "RECTANGLE": break; case "CIRC": case "CIRCLE": break; case "POLY": case "POLYGON": break; case "DEFAULT":  this.onLink = true; this.link = area; this.onSaveableLink = this.isLinkSaveable( this.link ); break; } } } } } } else if ( this.target.localName.toUpperCase() == "OBJECT" &&  this.objectIsImage( this.target ) ) {  this.onImage = true;  this.imageURL = this.objectImageURL( this.target ); } else if ( this.target.localName.toUpperCase() == "INPUT") { type = this.target.getAttribute("type"); if(type && type.toUpperCase() == "IMAGE") { this.onImage = true;  this.imageURL = makeURLAbsolute( this.target.baseURI, this.target.src ); } else /* if (this.target.getAttribute( "type" ).toUpperCase() == "TEXT") */ { this.onTextInput = this.isTargetATextBox(this.target); } } else if ( this.target.localName.toUpperCase() == "TEXTAREA" ) { this.onTextInput = true; } else if ( this.target.localName.toUpperCase() == "HTML" ) {  var bodyElt = this.target.ownerDocument.getElementsByTagName("body")[0]; if ( bodyElt ) { var computedURL = this.getComputedURL( bodyElt, "background-image" ); if ( computedURL ) { this.hasBGImage = true; this.bgImageURL = makeURLAbsolute( bodyElt.baseURI, computedURL ); } } } else if ( "HTTPIndex" in _content && _content.HTTPIndex instanceof Components.interfaces.nsIHTTPIndex ) { this.inDirList = true;   var root = this.target; while ( root && !this.link ) { if ( root.tagName == "tree" ) {   break; } if ( root.getAttribute( "URL" ) ) {  this.onLink = true; this.link = { href : root.getAttribute("URL"), getAttribute: function (attr) { if (attr == "title") { return root.firstChild.firstChild.getAttribute("label"); } else { return ""; } } };  if ( root.getAttribute( "container" ) == "true" ) { this.onSaveableLink = false; } else { this.onSaveableLink = true; } } else { root = root.parentNode; } } } }   this.onMetaDataItem = this.onImage;   const NS_MathML = "http: if ((this.target.nodeType == Node.TEXT_NODE && this.target.parentNode.namespaceURI == NS_MathML) || (this.target.namespaceURI == NS_MathML)) this.onMathML = true;   if ( this.target.ownerDocument != window._content.document ) { this.inFrame = true; }   var elem = this.target; while ( elem ) { if ( elem.nodeType == Node.ELEMENT_NODE ) { var localname = elem.localName.toUpperCase();   if ( !this.onLink && ( (localname === "A" && elem.href) || localname === "AREA" || localname === "LINK" || elem.getAttributeNS( "http:  this.onLink = true; this.onMetaDataItem = true;  this.link = elem; this.onMailtoLink = this.isLinkType( "mailto:", this.link );  this.onSaveableLink = this.isLinkSaveable( this.link ); }   if ( !this.onTextInput ) {  this.onTextInput = this.isTargetATextBox(elem); }   if ( !this.onMetaDataItem ) {   if ( ( localname === "BLOCKQUOTE" && 'cite' in elem && elem.cite)  || ( localname === "Q" && 'cite' in elem && elem.cite)           || ( localname === "TABLE" && 'summary' in elem && elem.summary) || ( ( localname === "INS" || localname === "DEL" ) && ( ( 'cite' in elem && elem.cite ) || ( 'dateTime' in elem && elem.dateTime ) ) )               || ( 'title' in elem && elem.title )                             || ( 'lang' in elem && elem.lang ) ) { this.onMetaDataItem = true; } }     if ( !this.hasBGImage ) { var bgImgUrl = this.getComputedURL( elem, "background-image" ); if ( bgImgUrl ) { this.hasBGImage = true; this.bgImageURL = makeURLAbsolute( elem.baseURI, bgImgUrl ); } } } elem = elem.parentNode; } },  getComputedStyle: function( elem, prop ) { return elem.ownerDocument.defaultView.getComputedStyle( elem, '' ).getPropertyValue( prop ); },  getComputedURL: function( elem, prop ) { var url = elem.ownerDocument.defaultView.getComputedStyle( elem, '' ).getPropertyCSSValue( prop ); return ( url.primitiveType == CSSPrimitiveValue.CSS_URI ) ? url.getStringValue() : null; },  isLinkSaveable : function ( link ) {   return !(this.isLinkType( "mailto:" , link )     || this.isLinkType( "javascript:" , link ) || this.isLinkType( "news:", link )        || this.isLinkType( "snews:", link ) ); },  isLinkType : function ( linktype, link ) { try {  if ( !link.protocol ) {  var protocol; if ( link.href ) { protocol = link.href.substr( 0, linktype.length ); } else { protocol = link.getAttributeNS("http: if ( protocol ) { protocol = protocol.substr( 0, linktype.length ); } } return protocol.toLowerCase() === linktype; } else {  return link.protocol.toLowerCase() === linktype; } } catch (e) {   return false; } },  openLink : function () {  openNewWindowWith(this.linkURL(), this.link, true); },  openLinkInTab : function () {  openNewTabWith(this.linkURL(), this.link, null, true); },  openFrameInTab : function () {  openNewTabWith(this.target.ownerDocument.location.href, null, null, true); },  reloadFrame : function () { this.target.ownerDocument.location.reload(); },  openFrame : function () { openNewWindowWith(this.target.ownerDocument.location.href, null, true); },  showOnlyThisFrame : function () { window.loadURI(this.target.ownerDocument.location.href); },  viewPartialSource : function ( context ) { var focusedWindow = document.commandDispatcher.focusedWindow; if (focusedWindow == window) focusedWindow = _content; var docCharset = null; if (focusedWindow) docCharset = "charset=" + focusedWindow.document.characterSet;     var reference = null; if (context == "selection") reference = focusedWindow.__proto__.getSelection.call(focusedWindow); else if (context == "mathml") reference = this.target; else throw "not reached";  var docUrl = null; window.openDialog("chrome: "_blank", "scrollbars,resizable,chrome,dialog=no", docUrl, docCharset, reference, context); },  viewFrameSource : function () { BrowserViewSourceOfDocument(this.target.ownerDocument); }, viewInfo : function () { BrowserPageInfo(); }, viewFrameInfo : function () { BrowserPageInfo(this.target.ownerDocument); },  viewImage : function () { openTopWin( this.imageURL ); },  viewBGImage : function () { openTopWin( this.bgImageURL ); }, setWallpaper: function() { var winhooks = Components.classes[ "@mozilla.org/winhooks;1" ]. getService(Components.interfaces.nsIWindowsHooks);  winhooks.setImageAsWallpaper(this.target, false); },  saveFrame : function () { saveDocument( this.target.ownerDocument ); },  saveLink : function () { saveURL( this.linkURL(), this.linkText(), null, true, true ); }, sendLink : function () { sendLink( this.linkURL(), "" ); },  saveImage : function () { saveURL( this.imageURL, null, "SaveImageTitle", false ); }, sendImage : function () { sendLink(this.imageURL, "" ); }, toggleImageBlocking : function (aBlock) { var nsIPermissionManager = Components.interfaces.nsIPermissionManager; var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"] .getService(nsIPermissionManager); var uri = Components.classes["@mozilla.org/network/standard-url;1"] .createInstance(Components.interfaces.nsIURI); uri.spec = this.imageURL; permissionmanager.add(uri, "image", aBlock ? nsIPermissionManager.DENY_ACTION : nsIPermissionManager.ALLOW_ACTION); }, isImageBlocked : function() { var nsIPermissionManager = Components.interfaces.nsIPermissionManager; var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"] .getService(Components.interfaces.nsIPermissionManager); var uri = Components.classes["@mozilla.org/network/standard-url;1"] .createInstance(Components.interfaces.nsIURI); uri.spec = this.imageURL; return permissionmanager.testPermission(uri, "image") == nsIPermissionManager.DENY_ACTION; },  copyEmail : function () {    var url = this.linkURL(); var qmark = url.indexOf( "?" ); var addresses;  if ( qmark > 7 ) { addresses = url.substring( 7, qmark ); } else { addresses = url.substr( 7 ); }  var clipboard = this.getService( "@mozilla.org/widget/clipboardhelper;1", Components.interfaces.nsIClipboardHelper ); clipboard.copyString(addresses); }, addBookmark : function() { var docshell = document.getElementById( "content" ).webNavigation; BookmarksUtils.addBookmark( docshell.currentURI.spec, docshell.document.title, docshell.document.charset); }, addBookmarkForFrame : function() { var doc = this.target.ownerDocument; var uri = doc.location.href; var title = doc.title; if ( !title ) title = uri; BookmarksUtils.addBookmark(uri, title, doc.charset); },  showMetadata : function () { window.openDialog(  "chrome: "_blank", "scrollbars,resizable,chrome,dialog=no", this.target); },       createInstance : function ( contractId, iidName ) { var iid = Components.interfaces[ iidName ]; return Components.classes[ contractId ].createInstance( iid ); },  getService : function ( contractId, iidName ) { var iid = Components.interfaces[ iidName ]; return Components.classes[ contractId ].getService( iid ); },  showItem : function ( itemOrId, show ) { var item = itemOrId.constructor == String ? document.getElementById(itemOrId) : itemOrId; if (item) item.hidden = !show; },    setItemAttr : function ( id, attr, val ) { var elem = document.getElementById( id ); if ( elem ) { if ( val == null ) {  elem.removeAttribute( attr ); } else {  elem.setAttribute( attr, val ); } } },   setItemAttrFromNode : function ( item_id, attr, other_id ) { var elem = document.getElementById( other_id ); if ( elem && elem.getAttribute( attr ) == "true" ) { this.setItemAttr( item_id, attr, "true" ); } else { this.setItemAttr( item_id, attr, null ); } },  cloneNode : function ( item ) {  var node = document.createElement( item.tagName );   var attrs = item.attributes; for ( var i = 0; i < attrs.length; i++ ) { var attr = attrs.item( i ); node.setAttribute( attr.nodeName, attr.nodeValue ); }   return node; },  linkURL : function () { if (this.link.href) { return this.link.href; } var href = this.link.getAttributeNS("http: if (!href || !href.match(/\S/)) { throw "Empty href"; } href = makeURLAbsolute(this.link.baseURI,href); return href; },  linkText : function () { var text = gatherTextUnder( this.link ); if (!text || !text.match(/\S/)) { text = this.link.getAttribute("title"); if (!text || !text.match(/\S/)) { text = this.link.getAttribute("alt"); if (!text || !text.match(/\S/)) { if (this.link.href) { text = this.link.href; } else { text = getAttributeNS("http: if (text && text.match(/\S/)) { text = makeURLAbsolute(this.link.baseURI, text); } } } } }  return text; },    isTextSelection : function() { var result = false; var selection = this.searchSelected();  var searchSelectText; if (selection != "") { searchSelectText = selection.toString(); if (searchSelectText.length > 15) searchSelectText = searchSelectText.substr(0,15) + "..."; result = true;   searchSelectText = gNavigatorBundle.getFormattedString("searchText", [searchSelectText]); this.setItemAttr("context-searchselect", "label", searchSelectText); } return result; },  searchSelected : function() { var focusedWindow = document.commandDispatcher.focusedWindow; var searchStr = focusedWindow.__proto__.getSelection.call(focusedWindow); searchStr = searchStr.toString(); searchStr = searchStr.replace( /^\s+/, "" ); searchStr = searchStr.replace(/(\n|\r|\t)+/g, " "); searchStr = searchStr.replace(/\s+$/,""); return searchStr; },   objectIsImage : function ( objElem ) { var result = false;  var type = objElem.getAttribute( "type" ); var data = objElem.getAttribute( "data" );   if ( type.substring( 0, 6 ) == "image/" && data && data != "" ) { result = true; } return result; },  objectImageURL : function ( objElem ) {  var data = objElem.getAttribute( "data" );  return makeURLAbsolute( objElem.baseURI, data ); },  parseCoords : function ( area ) { return []; }, toString : function () { return "contextMenu.target     = " + this.target + "\n" + "contextMenu.onImage    = " + this.onImage + "\n" + "contextMenu.onLink     = " + this.onLink + "\n" + "contextMenu.link       = " + this.link + "\n" + "contextMenu.inFrame    = " + this.inFrame + "\n" + "contextMenu.hasBGImage = " + this.hasBGImage + "\n"; }, isTargetATextBox : function ( node ) { if (node.nodeType != Node.ELEMENT_NODE) return false;  if (node.localName.toUpperCase() == "INPUT") { var attrib = ""; var type = node.getAttribute("type");  if (type) attrib = type.toUpperCase();  return( (attrib != "IMAGE") && (attrib != "CHECKBOX") && (attrib != "RADIO") && (attrib != "SUBMIT") && (attrib != "RESET") && (attrib != "FILE") && (attrib != "HIDDEN") && (attrib != "RESET") && (attrib != "BUTTON") ); } else  { return(node.localName.toUpperCase() == "TEXTAREA"); } },     shouldShowSeparator : function ( aSeparatorID ) { var separator = document.getElementById(aSeparatorID); if (separator) { var sibling = separator.previousSibling; while (sibling && sibling.localName != "menuseparator") { if (sibling.getAttribute("hidden") != "true") return true; sibling = sibling.previousSibling; } } return false; } }  var gWebPanelURI; function openWebPanel(aTitle, aURI) {  toggleSidebar('viewWebPanelsSidebar', true);   document.getElementById("sidebar-title").value = aTitle;   var sidebar = document.getElementById("sidebar"); if (sidebar.contentDocument && sidebar.contentDocument.getElementById('web-panels-browser')) { sidebar.contentWindow.loadWebPanel(aURI); if (gWebPanelURI) { gWebPanelURI = ""; sidebar.removeEventListener("load", asyncOpenWebPanel, true); } } else {  if (!gWebPanelURI) sidebar.addEventListener("load", asyncOpenWebPanel, true); gWebPanelURI = aURI; } }  function asyncOpenWebPanel(event) { var sidebar = document.getElementById("sidebar"); if (gWebPanelURI && sidebar.contentDocument && sidebar.contentDocument.getElementById('web-panels-browser')) sidebar.contentWindow.loadWebPanel(gWebPanelURI); gWebPanelURI = ""; sidebar.removeEventListener("load", asyncOpenWebPanel, true); }  /* * - [ Dependencies ] --------------------------------------------------------- *  utilityOverlay.js: *    - gatherTextUnder */     function contentAreaClick(event, fieldNormalClicks) { var target = event.target; var linkNode;  var local_name = target.localName;  if (local_name) { local_name = local_name.toLowerCase(); }  switch (local_name) { case "a": case "area": case "link": if (target.hasAttribute("href")) linkNode = target; break; default: linkNode = findParentNode(event.originalTarget, "a");   if (linkNode && !linkNode.hasAttribute("href")) linkNode = null; break; } if (linkNode) { if (event.button == 0 && !event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) {      var target = linkNode.getAttribute("target"); if (fieldNormalClicks && (!target || target == "_content" || target  == "_main"))  { if (!linkNode.href) return true; if (linkNode.getAttribute("onclick")) return true; var url = getShortcutOrURI(linkNode.href); if (!url) return true; markLinkVisited(linkNode.href, linkNode); loadURI(url); event.preventDefault(); return false; } else if (linkNode.getAttribute("rel") == "sidebar") {    openDialog("chrome: "centerscreen,chrome,dialog=yes,resizable=no,dependent", linkNode.getAttribute("title"), linkNode.href, null, null, null, null, true); event.preventDefault(); return false; } else if (target == "_search") {   openWebPanel(gNavigatorBundle.getString("webPanels"), linkNode.href); event.preventDefault(); return false; } } else handleLinkClick(event, linkNode.href, linkNode); return true; } else {  var href; linkNode = target; while (linkNode) { if (linkNode.nodeType == Node.ELEMENT_NODE) { href = linkNode.getAttributeNS("http: break; } linkNode = linkNode.parentNode; } if (href && href != "") { href = makeURLAbsolute(target.baseURI,href); handleLinkClick(event, href, null); return true; } } if (event.button == 1 && !findParentNode(event.originalTarget, "scrollbar") && gPrefService.getBoolPref("middlemouse.contentLoadURL")) { if (middleMousePaste(event)) { event.preventBubble(); } } return true; }  function handleLinkClick(event, href, linkNode) { switch (event.button) { case 0: #ifdef XP_MACOSX if (event.metaKey) { #else if (event.ctrlKey) { #endif openNewTabWith(href, linkNode, event, true); event.preventBubble(); return true; }  if (event.shiftKey) { openNewWindowWith(href, linkNode, true); event.preventBubble(); return true; }  if (event.altKey) { saveURL(href, linkNode ? gatherTextUnder(linkNode) : "", null, true, true); return true; }  return false; case 1: var tab; try { tab = gPrefService.getBoolPref("browser.tabs.opentabfor.middleclick") } catch(ex) { tab = true; } if (tab) openNewTabWith(href, linkNode, event, true); else openNewWindowWith(href, linkNode, true); event.preventBubble(); return true; } return false; }  function middleMousePaste(event) { var url = readFromClipboard(); if (!url) return false; url = getShortcutOrURI(url); if (!url) return false;   #ifdef XP_MACOSX if (event.metaKey) #else if (event.ctrlKey) #endif openNewTabWith(url, null, event, true);   loadURI(url); event.preventBubble(); return true; }  function makeURLAbsolute( base, url ) {  var ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); var baseURI  = ioService.newURI(base, null, null);  return ioService.newURI(baseURI.resolve(url), null, null).spec; }  function findParentNode(node, parentNode) { if (node && node.nodeType == Node.TEXT_NODE) { node = node.parentNode; } while (node) { var nodeName = node.localName; if (!nodeName) return null; nodeName = nodeName.toLowerCase(); if (nodeName == "body" || nodeName == "html" || nodeName == "#document") { return null; } if (nodeName == parentNode) return node; node = node.parentNode; } return null; }  function saveFrameDocument() { var focusedWindow = document.commandDispatcher.focusedWindow; if (isContentFrame(focusedWindow)) saveDocument(focusedWindow.document); }  /* * Note that most of this routine has been moved into C++ in order to * be available for all <browser> tags as well as gecko embedding. See * mozilla/content/base/src/nsContentAreaDragDrop.cpp. * * Do not add any new fuctionality here other than what is needed for * a standalone product. */  var contentAreaDNDObserver = { onDrop: function (aEvent, aXferData, aDragSession) { var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);   if (!url || !url.length || url.indexOf(" ", 0) != -1) return;  switch (document.firstChild.getAttribute('windowtype')) { case "navigator:browser": loadURI(getShortcutOrURI(url)); break; case "navigator:view-source": viewSource(url); break; }    aEvent.preventDefault(); },  getSupportedFlavours: function () { var flavourSet = new FlavourSet(); flavourSet.appendFlavour("text/x-moz-url"); flavourSet.appendFlavour("text/unicode"); flavourSet.appendFlavour("application/x-moz-file", "nsIFile"); return flavourSet; }  };   function getBrowser() { if (!gBrowser) gBrowser = document.getElementById("content"); return gBrowser; }  function MultiplexHandler(event) { try { var node = event.target; var name = node.getAttribute('name');  if (name == 'detectorGroup') { SetForcedDetector(true); SelectDetector(event, false); } else if (name == 'charsetGroup') { var charset = node.getAttribute('id'); charset = charset.substring('charset.'.length, charset.length) SetForcedCharset(charset); SetDefaultCharacterSet(charset); } else if (name == 'charsetCustomize') {  } else { SetForcedCharset(node.getAttribute('id')); SetDefaultCharacterSet(node.getAttribute('id')); } } catch(ex) { alert(ex); } }  function SetDefaultCharacterSet(charset) { BrowserSetDefaultCharacterSet(charset); }  function SelectDetector(event, doReload) { var uri =  event.target.getAttribute("id"); var prefvalue = uri.substring('chardet.'.length, uri.length); if ("off" == prefvalue) { prefvalue = ""; }  try { var pref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); var str =  Components.classes["@mozilla.org/supports-string;1"] .createInstance(Components.interfaces.nsISupportsString);  str.data = prefvalue; pref.setComplexValue("intl.charset.detector", Components.interfaces.nsISupportsString, str); if (doReload) window._content.location.reload(); } catch (ex) { dump("Failed to set the intl.charset.detector preference.\n"); } }  function SetForcedDetector(doReload) { BrowserSetForcedDetector(doReload); }  function SetForcedCharset(charset) { BrowserSetForcedCharacterSet(charset); }  function BrowserSetDefaultCharacterSet(aCharset) {  }  function BrowserSetForcedCharacterSet(aCharset) { var docCharset = getBrowser().docShell.QueryInterface( Components.interfaces.nsIDocCharset); docCharset.charset = aCharset; BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE); }  function BrowserSetForcedDetector(doReload) { getBrowser().documentCharsetInfo.forcedDetector = true; if (doReload) BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE); }  function UpdateCurrentCharset() { var menuitem = null;   var wnd = document.commandDispatcher.focusedWindow; if ((window == wnd) || (wnd == null)) wnd = window._content; menuitem = document.getElementById('charset.' + wnd.document.characterSet);  if (menuitem) {   if (gPrevCharset) { var pref_item = document.getElementById('charset.' + gPrevCharset); if (pref_item) pref_item.setAttribute('checked', 'false'); } menuitem.setAttribute('checked', 'true'); } }  function UpdateCharsetDetector() { var prefvalue;  try { var pref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); prefvalue = pref.getComplexValue("intl.charset.detector", Components.interfaces.nsIPrefLocalizedString).data; } catch (ex) { prefvalue = ""; }  if (prefvalue == "") prefvalue = "off"; dump("intl.charset.detector = "+ prefvalue + "\n");  prefvalue = 'chardet.' + prefvalue; var menuitem = document.getElementById(prefvalue);  if (menuitem) { menuitem.setAttribute('checked', 'true'); } }  function UpdateMenus(event) {    UpdateCurrentCharset(); setTimeout("UpdateCurrentCharset()", 0); UpdateCharsetDetector(); setTimeout("UpdateCharsetDetector()", 0); }  function CreateMenu(node) { var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); observerService.notifyObservers(null, "charsetmenu-selected", node); }  function charsetLoadListener (event) { var charset = window._content.document.characterSet;  if (charset.length > 0 && (charset != gLastBrowserCharset)) { if (!gCharsetMenu) gCharsetMenu = Components.classes['@mozilla.org/rdf/datasource;1?name=charset-menu'].getService().QueryInterface(Components.interfaces.nsICurrentCharsetListener); gCharsetMenu.SetCurrentCharset(charset); gPrevCharset = gLastBrowserCharset; gLastBrowserCharset = charset; } }    function launchExternalUrl(aURL) { var extProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService); if (extProtocolSvc) extProtocolSvc.loadUrl(aURL); }  function sendLink(url, title) {  var mailtoUrl = url ? "mailto:?body=" + url + "&subject=" + escape(title) : "mailto:";  var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); var uri = ioService.newURI(mailtoUrl, null, null);   launchExternalUrl(uri); }  #ifdef XP_MACOSX const nsIWindowDataSource = Components.interfaces.nsIWindowDataSource;  function checkFocusedWindow() { var windowManagerDS = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService(nsIWindowDataSource);  var sep = document.getElementById("sep-window-list");  while ((sep = sep.nextSibling)) { var url = sep.getAttribute('id'); var win = windowManagerDS.getWindowForResource(url); if (win == window) { sep.setAttribute("checked", "true"); break; } } }  function toOpenWindow( aWindow ) { aWindow.document.commandDispatcher.focusedWindow.focus(); }  function ShowWindowFromResource( node ) { var windowManagerDS = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService(nsIWindowDataSource);  var desiredWindow = null; var url = node.getAttribute('id'); desiredWindow = windowManagerDS.getWindowForResource( url ); if ( desiredWindow ) { toOpenWindow(desiredWindow); } } #endif  /* Begin Page Theme Functions */ function getStyleSheetArray(frame) { var styleSheets = frame.document.styleSheets; var styleSheetsArray = new Array(styleSheets.length); for (var i = 0; i < styleSheets.length; i++) { styleSheetsArray[i] = styleSheets[i]; } return styleSheetsArray; }  function getAllStyleSheets(frameset) { var styleSheetsArray = getStyleSheetArray(frameset); for (var i = 0; i < frameset.frames.length; i++) { var frameSheets = getAllStyleSheets(frameset.frames[i]); styleSheetsArray = styleSheetsArray.concat(frameSheets); } return styleSheetsArray; }  function stylesheetFillPopup(menuPopup) { var plainStyle = menuPopup.firstChild; var normalStyle = plainStyle.nextSibling; var sep = normalStyle.nextSibling; while (sep.nextSibling) menuPopup.removeChild(sep.nextSibling);  var noOptionalStyles = true; var styleSheets = getAllStyleSheets(window._content); var currentStyleSheets = [];  var allDisabled = true; var haveAltSheets = false; var haveAnyNonAltSheets = false;  for (var i = 0; i < styleSheets.length; ++i) { var currentStyleSheet = styleSheets[i];   var media = currentStyleSheet.media.mediaText.toLowerCase(); if (media && (media.indexOf("screen") == -1) && (media.indexOf("all") == -1)) continue;  if (!currentStyleSheet.disabled) allDisabled = false;  if (currentStyleSheet.title) { if (!currentStyleSheet.disabled) noOptionalStyles = false;  haveAltSheets = true;  var lastWithSameTitle = null; if (currentStyleSheet.title in currentStyleSheets) lastWithSameTitle = currentStyleSheets[currentStyleSheet.title];  if (!lastWithSameTitle) { var menuItem = document.createElement("menuitem"); menuItem.setAttribute("type", "radio"); menuItem.setAttribute("label", currentStyleSheet.title); menuItem.setAttribute("data", currentStyleSheet.title); menuItem.setAttribute("checked", !currentStyleSheet.disabled); menuPopup.appendChild(menuItem); currentStyleSheets[currentStyleSheet.title] = menuItem; } else { if (currentStyleSheet.disabled) lastWithSameTitle.removeAttribute("checked"); } } else haveAnyNonAltSheets = true; }  normalStyle.setAttribute("checked", noOptionalStyles && (!haveAnyNonAltSheets || !allDisabled)); plainStyle.setAttribute("checked", allDisabled && haveAnyNonAltSheets);  plainStyle.hidden = !haveAnyNonAltSheets; sep.hidden = !haveAltSheets; }  function stylesheetInFrame(frame, title) { var docStyleSheets = frame.document.styleSheets;  for (var i = 0; i < docStyleSheets.length; ++i) { if (docStyleSheets[i].title == title) return true; } return false; }  function stylesheetSwitchFrame(frame, title) { var docStyleSheets = frame.document.styleSheets;  for (var i = 0; i < docStyleSheets.length; ++i) { var docStyleSheet = docStyleSheets[i];  if (title == "_nostyle") docStyleSheet.disabled = true; else if (docStyleSheet.title) docStyleSheet.disabled = (docStyleSheet.title != title); else if (docStyleSheet.disabled) docStyleSheet.disabled = false; } }  function stylesheetSwitchAll(frameset, title) { if (!title || title == "_nostyle" || stylesheetInFrame(frameset, title)) { stylesheetSwitchFrame(frameset, title); } for (var i = 0; i < frameset.frames.length; i++) { stylesheetSwitchAll(frameset.frames[i], title); } }  function updatePageTheme(evt) { if (!gPageThemeButton) gPageThemeButton = document.getElementById("page-theme-button");  var hasThemes = false; var stylesheets = window._content.document.styleSheets; for (var i = 0; i < stylesheets.length; ++i) { var currentStyleSheet = stylesheets[i];  if (currentStyleSheet.title) {  var media = currentStyleSheet.media.mediaText.toLowerCase(); if (media && (media.indexOf("screen") == -1) && (media.indexOf("all") == -1)) continue; hasThemes = true; break; } }  if (hasThemes) { gPageThemeButton.setAttribute("themes", "true");   } else gPageThemeButton.removeAttribute("themes"); } /* End of the Page Theme functions */ 
context: function Startup(){  gBrowser = document.getElementById("content");  var uriToLoad = null;  // Check for window.arguments[0]. If present, use that for uriToLoad.  if ("arguments" in window && window.arguments.length >= 1 && window.arguments[0])    uriToLoad = window.arguments[0];  gIsLoadingBlank = uriToLoad == "about:blank";  if (!gIsLoadingBlank) {    prepareForStartup();  }#ifdef ENABLE_PAGE_CYCLER  appCore.startPageCycler();#else  // only load url passed in when we're not page cycling   if (uriToLoad && !gIsLoadingBlank) {    if ("arguments" in window && window.arguments.length >= 3)      loadURI(uriToLoad, window.arguments[2]);    else      loadOneOrMoreURIs(uriToLoad);  }#ifdef MOZ_ENABLE_XREMOTE  // hook up remote support  var remoteService;  remoteService = Components.classes["@mozilla.org/browser/xremoteservice;1"]                            .getService(Components.interfaces.nsIXRemoteService);  remoteService.addBrowserInstance(window);  RegisterTabOpenObserver();#endif#endif  var sidebarSplitter;  if (window.opener) {    var openerSidebarBox = window.opener.document.getElementById("sidebar-box");    if (!openerSidebarBox.hidden) {      var sidebarBox = document.getElementById("sidebar-box");      var sidebarTitle = document.getElementById("sidebar-title");      sidebarTitle.setAttribute("value", window.opener.document.getElementById("sidebar-title").getAttribute("value"));      sidebarBox.setAttribute("width", openerSidebarBox.boxObject.width);      var sidebarCmd = openerSidebarBox.getAttribute("sidebarcommand");      sidebarBox.setAttribute("sidebarcommand", sidebarCmd);      sidebarBox.setAttribute("src", window.opener.document.getElementById("sidebar").getAttribute("src"));      gMustLoadSidebar = true;      sidebarBox.hidden = false;      sidebarSplitter = document.getElementById("sidebar-splitter");      sidebarSplitter.hidden = false;      document.getElementById(sidebarCmd).setAttribute("checked", "true");    }  }  else {    var box = document.getElementById("sidebar-box");    if (box.hasAttribute("sidebarcommand")) {       var cmd = box.getAttribute("sidebarcommand");      if (cmd != "") {        gMustLoadSidebar = true;        box.hidden = false;        sidebarSplitter = document.getElementById("sidebar-splitter");        sidebarSplitter.hidden = false;        document.getElementById(cmd).setAttribute("checked", "true");      }    }  }  setTimeout(delayedStartup, 0);}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/2e8ab0a9e11f0cae0f08ebd8ec761899919ef340/browser.js/buggy/browser/base/content/browser.js