<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit2, com.novell.emframe.dev.eMFrameUtils" %>
<%   JSPConduit2 c = JSPConduit2.getJSPConduit(request);
     c.stringTable("FwResources"); %>

<HTML>
<HEAD>
<TITLE>SearchTitle</TITLE>
<LINK href="<%= c.getModulesUrl() %>/fw/css/osStyles.css" rel="styleSheet" type="text/css">
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
<script>

   //---------------- local constants ----------------------
   var SEARCH_MODE =             "search";
   var BROWSE_MODE =             "browse";
   var ACTIVE_SEARCH =           "<%= c.getModulesUrl() %>/fw/images/<%= c.string("OS.Browser.SearchTabActive") %>";
   var ACTIVE_BROWSE =           "<%= c.getModulesUrl() %>/fw/images/<%= c.string("OS.Browser.BrowseTabActive") %>";
   var INACTIVE_SEARCH =         "<%= c.getModulesUrl() %>/fw/images/<%= c.string("OS.Browser.SearchTabInactive") %>";
   var INACTIVE_BROWSE =         "<%= c.getModulesUrl() %>/fw/images/<%= c.string("OS.Browser.BrowseTabInactive") %>";
   var TABS_BROWSE =         "<%= c.getModulesUrl() %>/fw/images/<%= c.string("OS.Browser.TabsBrowse") %>";
   var SWITCH_TO_BROWSE_HINT =   "<%= c.string("OS.Browser.BrowseActivation") %>";
   var SWITCH_TO_SEARCH_HINT =   "<%= c.string("OS.Browser.SearchActivation") %>";

    //------------- dynamic GUI methods --------------------
   function switchMode(newMode)
   {
      var currentMode = top.m_mode.toLowerCase();
      if (newMode==currentMode)
      {
         //nothing to do
         return;
      }

      //update global variables
      if (newMode==BROWSE_MODE)
      {
         //switch to browse mode
         top.m_mode=BROWSE_MODE;
         top.m_container = top.Query.document.SearchQuery.SQContext.value;
         top.m_nameFilter = top.Query.document.SearchQuery.SQNameFilter.value;
         top.m_searchSubContainers = ((top.Query.document.SearchQuery.SQSubContainer.checked)?"true":"false");
      }
      else
      {
         //switch to search mode
         top.m_mode=SEARCH_MODE;
         top.m_container = top.Query.document.BrowseQuery.BQContext.value;
         top.m_nameFilter = top.Query.document.BrowseQuery.BQNameFilter.value;
      }

      //setup local variables
      var strURL="";
      var strHTML="";
      var modeName = ((newMode==BROWSE_MODE)?"Browse":"Search");
      var sm = ((top.m_multiSelect=="true")?"MS":"SS");
      top.processDisplayCountChange();

      //update Title frame
      setupTabs(newMode);

      //clear query, results title, and results frames
      top.Query.document.open();
      top.Query.document.writeln('<HTML><HEAD></HEAD><BODY bgcolor="'+top.OS_BGCOLOR+'"><form name=PostData method=post></form></BODY>');
      top.Query.document.close();

      top.ResultsTitle.document.open();
      top.ResultsTitle.document.writeln('<HTML><HEAD></HEAD><BODY bgcolor="'+top.OS_BGCOLOR+'"><form name=PostData method=post></form></BODY>');
      top.ResultsTitle.document.close();

      top.ResultButtons.document.open();
      if (MS55)
         top.ResultButtons.document.writeln('<HTML><HEAD></HEAD><BODY bgcolor="#EFEEE9" style="border-style:solid; border-width:1; border-color:#BFBBB2;"><form name=PostData method=post></form></BODY>');
      else
         top.ResultButtons.document.writeln('<HTML><HEAD></HEAD><BODY bgcolor="#EFEEE9"><form name=PostData method=post></form></BODY>');
      top.ResultButtons.document.close();

      top.Results.document.open();
      if (MS55)
         top.Results.document.writeln('<HTML><HEAD></HEAD><BODY bgcolor="#FFFFFF" style="border-style:solid; border-width:1; border-bottom-width:0; border-color:#BFBBB2;"></BODY>');
      else
         top.Results.document.writeln('<HTML><HEAD></HEAD><BODY bgcolor="#FFFFFF"></BODY>');
      top.Results.document.close();

      //update Query frame
      top.resultsLoaded = false;
      strURL="webacc?taskId=dev.Empty&merge=fw.OS."+modeName+"Query&User.context=<%= c.var("User.context") %>";
      top.Query.document.PostData.action=strURL;
      top.Query.document.PostData.submit();

      //update ResultsTitle frame
      strURL="webacc?taskId=dev.Empty&merge=fw.OS."+modeName+"ResultsTitle"+sm+"&User.context=<%= c.var("User.context") %>";
      top.ResultsTitle.document.PostData.action=strURL;
      top.ResultsTitle.document.PostData.submit();

      //update ResultButtons frame
      top.resultButtonsLoaded=false;
      strURL="webacc?taskId=dev.Empty&merge=fw.OS."+modeName+"ResultButtons&User.context=<%= c.var("User.context") %>";
      top.ResultButtons.document.PostData.action=strURL;
      top.ResultButtons.document.PostData.submit();

      //update Results frame
      strURL   = "webacc?taskId=fw.ObjectSelector&error=dev.GenErr&merge=fw.OS."+modeName+"Results"+sm+"&SearchToken=SearchTokenRestart&User.context=<%= c.var("User.context") %>";
      strHTML += '<input type=hidden name="Search.ContextId" value="'      +toTag(top.m_searchContextId)+'">\n';
      strHTML += '<input type=hidden name="OS.AdvancedSelection" value="'  +top.m_advSel+'">\n';
      strHTML += '<input type=hidden name="OS.Container" value="'          +toTag(top.m_container)+'">\n';
      strHTML += '<input type=hidden name="OS.Mode" value="'               +top.m_mode+'">\n';
      strHTML += '<input type=hidden name="OS.ResultsPerPage" value="'     +top.m_resultsPerPage+'">\n';

      if (newMode==BROWSE_MODE)
      {
         //no subcontainer searching in browse mode
         strHTML += '<input type=hidden name="OS.SearchSubContainers" value="false">\n';
      }
      else
      {
         //possible subcontainer searching in search mode
         strHTML += '<input type=hidden name="OS.SearchSubContainers" value="'+top.m_searchSubContainers+'">\n';
         strHTML += '<input type=hidden name="OS.SearchOnStartup" value="'    +top.m_searchOnStartup+'">\n';
      }

      var bAdvanced = top.isAdvSelMode();
      strHTML += '<input type=hidden name="OS.TypeFilter" value="'         +toTag(top.getSelectedTypes(bAdvanced))+'">\n';
      if (bAdvanced)
      {
         strHTML += '<input type=hidden name="OS.NameFilter" value="">\n';
      }
      else
      {
         strHTML += '<input type=hidden name="OS.NameFilter" value="'         +toTag(top.m_nameFilter)+'">\n';
      }

      document.PostData.action=strURL;
      document.getElementById("FormData").innerHTML = strHTML;
      document.PostData.target="Results";
      document.PostData.submit();
   }

   function setupTabs(newMode)
   {
	      if(top.m_simpleBrowsingOnly == "true")
		  {
		  	  //set up tab images
		      document.getElementById("browseGif").src=((newMode==BROWSE_MODE)?ACTIVE_BROWSE:INACTIVE_BROWSE);
		      
		      //set up tab hints
		      document.getElementById("browseGif").alt=((newMode==BROWSE_MODE)?"":SWITCH_TO_BROWSE_HINT);
		  }
		  else
		  {
		  	  //set up tab images
		      document.getElementById("searchGif").src=((newMode==SEARCH_MODE)?ACTIVE_SEARCH:INACTIVE_SEARCH);
		      document.getElementById("browseGif").src=((newMode==BROWSE_MODE)?ACTIVE_BROWSE:INACTIVE_BROWSE);
		      
		      //set up tab hints
		      document.getElementById("searchGif").alt=((newMode==SEARCH_MODE)?"":SWITCH_TO_SEARCH_HINT);
		      document.getElementById("browseGif").alt=((newMode==BROWSE_MODE)?"":SWITCH_TO_BROWSE_HINT);
		  }
   }

   function titleOnLoad()
   {
      setupTabs(top.m_mode.toLowerCase());
   }

</script>
</HEAD>

<script>document.writeln('<body id=BodyData bgcolor="'+top.OS_TITLECOLOR+'" onLoad="javascript:top.titleLoaded=true; titleOnLoad()" onFocus="top.ensureOpenerValid();">');</script>
<div style="position:absolute;top:0;left:0">
<table align=bottom align=left cellspacing=0 cellpadding=0 border=0>
   <tr>
   <script>
	  if(top.m_simpleBrowsingOnly == "true")
	  {
	  		document.writeln('<td><a href="javascript:switchMode(BROWSE_MODE)"><img id="browseGif" src="'+TABS_BROWSE+'" border=0></a></td>');
	  }
	  else
	  {
	      document.writeln('<td><a href="javascript:switchMode(BROWSE_MODE)"><img id="browseGif" src="'+INACTIVE_BROWSE+'" border=0></a></td>');
	      document.writeln('<td><a href="javascript:switchMode(SEARCH_MODE)"><img id="searchGif" src="'+INACTIVE_SEARCH+'" border=0></a></td>');
	  }	      
   </script>
   </tr>
</table>
</div>

<form name=PostData method=post action="webacc" target="">
<span id=FormData>
   <!-- switchMode will use innerHTML to dynamically create the input fields here -->
</span>
</form>

</body>
</HTML>
