context: function SearchPanelStartup(){	bundle = srGetStrBundle( "chrome://communicator/locale/search/search-panel.properties" );	var tree = document.getElementById("Tree");	if (tree)	{		var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();		if (rdf)   rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);		if (rdf)		{			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);			tree.database.AddObserver(RDF_observer);		}	}	var internetSearch = Components.classes["component://netscape/rdf/datasource?name=internetsearch"].getService();	if (internetSearch)	internetSearch = internetSearch.QueryInterface(Components.interfaces.nsIInternetSearchService);	if (internetSearch)	{		var catDS = internetSearch.GetCategoryDataSource();		if (catDS)	catDS = catDS.QueryInterface(Components.interfaces.nsIRDFDataSource);		if (catDS)		{			var categoryList = document.getElementById("categoryList");			if (categoryList)			{				categoryList.database.AddDataSource(catDS);				var ref = categoryList.getAttribute("ref");				if (ref)	categoryList.setAttribute("ref", ref);			}			var engineTree = document.getElementById("searchengines");			if (engineTree)			{				engineTree.database.AddDataSource(catDS);				var ref = engineTree.getAttribute("ref");				if (ref)	engineTree.setAttribute("ref", ref);			}		}	}	// try and determine last category name used	var lastCategoryName = "";	try	{		if (pref)	lastCategoryName = pref.CopyCharPref( "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);			}		}	}	catch( e )	{		debug("Exception in SearchPanelStartup\n");		lastCategoryName = "";	}	debug("\nSearchPanelStartup: lastCategoryName = '" + lastCategoryName + "'\n");	// select the appropriate category	var categoryList = document.getElementById( "categoryList" );	var categoryPopup = document.getElementById( "categoryPopup" );	if( categoryList && categoryPopup )	{		//set to default value 'Web'		//hack: hardcoded postion in here replace with a function that finds the entry 'the web'	 	 	var found = false;		for( var i = 0; i < categoryPopup.childNodes.length; i++ )		{			if( ( lastCategoryName == "" && categoryPopup.childNodes[i].getAttribute("data") == "NC:SearchEngineRoot" ) ||			    ( categoryPopup.childNodes[i].getAttribute("id") == lastCategoryName ) )			{				categoryList.selectedItem = categoryPopup.childNodes[i];				found = true;				break;			}		}		if (found == false)		{			categoryList.selectedItem = categoryPopup.childNodes[0];		}    		if (( lastCategoryName == "" ) || (lastCategoryName == null))		{			lastCategoryName = "NC:SearchEngineRoot";		}		if (lastCategoryName != "NC:SearchEngineRoot")		{			lastCategoryName = "NC:SearchCategory?category=" + lastCategoryName;		}		var treeNode = document.getElementById("searchengines");		treeNode.setAttribute( "ref", lastCategoryName );	}	loadEngines( lastCategoryName );	var searchMode = updateSearchMode();	// if we have search results, show them, otherwise show engines	if ((haveSearchResults() == true) || (searchMode == 0))	{		switchTab(0);	}	else	{		switchTab(1);	}}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/6a80dfc41c74ac5b49360af43d1f736a30d98b45/search-panel.js/clean/suite/common/search/search-panel.js