add:  ensureSearchPref()  
context: function SearchPanelStartup(){  searchBundle = document.getElementById("searchBundle");  var rdf  = Components.classes[RDFSERVICE_CONTRACTID].getService(nsIRDFService);  rootNode = rdf.GetResource("NC:LastSearchRoot", true);  textArc  = rdf.GetResource("http://home.netscape.com/NC-rdf#LastText", true);  modeArc  = rdf.GetResource("http://home.netscape.com/NC-rdf#SearchMode", true);  var tree = document.getElementById("Tree");  tree.database.AddObserver(RDF_observer);  var categoryList = document.getElementById("categoryList");  var internetSearch = Components.classes[ISEARCH_CONTRACTID].getService(nsIInternetSearchService);  var catDS = internetSearch.GetCategoryDataSource();  if (catDS) {    catDS = catDS.QueryInterface(nsIRDFDataSource);    categoryList.database.AddDataSource(catDS);    var ref = categoryList.getAttribute("ref");    if (ref)      categoryList.setAttribute("ref", ref);    var engineTree = document.getElementById("searchengines");    engineTree.database.AddDataSource(catDS);    ref = engineTree.getAttribute("ref");    if (ref)      engineTree.setAttribute("ref", ref);  }  // try and determine last category name used  var lastCategoryName = nsPreferences.copyUnicharPref("browser.search.last_search_category", "");  if (lastCategoryName) {    // strip off the prefix if necessary    var prefix = "NC:SearchCategory?category=";    if (lastCategoryName.indexOf(prefix) == 0)      lastCategoryName = lastCategoryName.substr(prefix.length);  }  // select the appropriate category  var categoryPopup = document.getElementById("categoryPopup");  var found = false;  for (var i = 0; i < categoryPopup.childNodes.length; ++i) {    if (lastCategoryName == "" &&        categoryPopup.childNodes[i].getAttribute("value") == "NC:SearchEngineRoot" ||        categoryPopup.childNodes[i].getAttribute("id") == lastCategoryName)    {      categoryList.selectedItem = categoryPopup.childNodes[i];      found = true;      break;    }  }  if (!found)    categoryList.selectedItem = categoryPopup.childNodes[0];  if (!lastCategoryName)    lastCategoryName = "NC:SearchEngineRoot";  else if (lastCategoryName != "NC:SearchEngineRoot")    lastCategoryName = "NC:SearchCategory?category=" + lastCategoryName;  var treeNode = document.getElementById("searchengines");  treeNode.setAttribute("ref", lastCategoryName);  loadEngines(lastCategoryName);  // if we have search results, show them, otherwise show engines  if (haveSearchResults() || updateSearchMode() == 0)    switchTab(0);  else    switchTab(1);  focusTextBox();}
meta: 5459	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/5459/5ade017c37f874059c4a950abc912db0986e88d9/search-panel.js/buggy/xpfe/components/search/resources/search-panel.js