<%@  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("DevResources");
     c.stringTable("FwResources"); %>

<HTML>
<HEAD>
<TITLE>OSPocketSearch</TITLE>
</HEAD>

<script language="JavaScript">

   function doGenericSearch()
   {
      var strURL = "webacc?taskId=fw.ObjectSelector&merge=fw.OS.Search&error=dev.GenErr&SearchToken=SearchTokenPost";
      strURL += "&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>";
      strURL += parent.buildUrlParms();

      document.SearchPanel.action = strURL;
      document.SearchPanel.submit();
   }

   function changeSubContainerSearch()
   {
      parent.m_searchSubContainers = ((document.SearchPanel.SPSubContainer.checked)?"true":"false");
   }

   function changeContainer()
   {
      parent.m_container = document.SearchPanel.SPContext.value;
      if (parent.m_container == null || parent.m_container.length==0)
      {
         parent.m_container = "<%= c.toScript(c.string("OS.Pocket.RootName")) %>";
         document.SearchPanel.SPContext.value = parent.m_container;
      }
   }

   function changeNameFilter()
   {
      parent.m_nameFilter = document.SearchPanel.SPNameFilter.value;
      if (parent.m_nameFilter == null || parent.m_nameFilter.length==0)
      {
         parent.m_nameFilter = "*";
         document.SearchPanel.SPNameFilter.value = parent.m_nameFilter;
      }
   }

   function switchToBrowseMode()
   {
      parent.m_mode="browse";
      parent.Body.location = "webacc?taskId=fw.ObjectSelector&merge=fw.OS.Browse&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&SearchToken=SearchTokenRestart"+parent.buildUrlParms();
   }

</script>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#EFF0E8">
<% int len = c.toInt("Search.ResultList.Count");
   if (c.var("Search.ShowResultSet").equals("true") && len>0) {
      c.set("TaskHeader.title", c.string("OS.Pocket.SearchResults"));
   } else {
      c.set("TaskHeader.title", c.string("OS.Pocket.SearchDir"));
   } %>
<jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>

<% boolean showResults = (c.var("Search.ShowResultSet").equals("true"));
   String altTitle = "";
   String auxHint = c.toTag(c.string("OS.Pocket.PartitionHint"));
   int dCnt = 0;
   if (showResults) { %>
      <!-- display search results -->
<%    if ( len<1 && !c.var("Search.PreviousElements").equals("true") &&
         ( c.var("Search.PseudoObjects").length()==0 || c.var("Search.PseudoObjects").equals("...")) ) { %>
         <!-- display "nothing found" message -->
         <center><FONT face="Helvetica,Arial"><b><%= c.toDisplay(c.string("OS.Pocket.ZeroMatch")) %></b></FONT></center><br>
<%       dCnt++;
      } else { %>
         <!-- display search results entries -->
<%       if (c.var("Search.PseudoObjects").length()>0 && !c.var("Search.PseudoObjects").equals("...") && !c.var("Search.PreviousElements").equals("true")) {
            if (c.var("Search.PseudoObjects").charAt(0)=='R') { %>
               <!-- display a selectable root node -->
               <NOBR><IMG src="<%= c.getModulesUrl() %>/fw/images/1px_spacer.gif" border=0>&nbsp;
               <A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=<%= c.urlEncode(c.var("Search.TreeName")) %>">
<%             altTitle = c.toTag(c.string("OS.Pocket.TypePrefix")+" "+c.string("ObjectType.Tree_Root")); %>
               <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/dir/Tree.gif"
                    border=0><IMG alt="<%= auxHint %>" title="<%= auxHint %>" src="<%= c.getModulesUrl() %>/fw/images/partition.gif" border=0></A>
               <A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=<%= c.urlEncode(c.var("Search.TreeName")) %>">
               <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.var("Search.TreeName")) %></NOBR></A></FONT><BR>
<%             dCnt++;
            }

            if (c.var("Search.PseudoObjects").charAt(2)=='P') { %>
               <!-- display a selectable public node -->
               <NOBR><IMG src="<%= c.getModulesUrl() %>/fw/images/1px_spacer.gif" border=0>&nbsp;
               <A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=<%= c.urlEncode(c.string("OS.Public")) %>">
<%             altTitle = c.toTag(c.string("OS.Pocket.TypePrefix")+" "+c.string("OS.Public")); %>
               <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/dir/Tree.gif"
                    border=0><IMG src="<%= c.getModulesUrl() %>/fw/images/7px_spacer.gif" border=0></A>
               <A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=<%= c.urlEncode(c.string("OS.Public")) %>">
               <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OS.Public")) %></NOBR></A></FONT><BR>
<%             dCnt++;
            }

            if (c.var("Search.PseudoObjects").charAt(1)=='T') { %>
               <!-- display a selectable this node -->
               <NOBR><IMG src="<%= c.getModulesUrl() %>/fw/images/1px_spacer.gif" border=0>&nbsp;
               <A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=<%= c.urlEncode(c.string("OS.This")) %>">
<%             altTitle = c.toTag(c.string("OS.Pocket.TypePrefix")+" "+c.string("OS.This")); %>
               <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/dir/Tree.gif"
                    border=0><IMG src="<%= c.getModulesUrl() %>/fw/images/7px_spacer.gif" border=0></A>
               <A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=<%= c.urlEncode(c.string("OS.This")) %>">
               <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OS.This")) %></NOBR></A></FONT><BR>
<%             dCnt++;
            }
         } %>

         <!-- display each of the results -->
<%       if (len>0) {
            int i=0;
            String auxIcon, sDA;
            boolean bSelectable, bPartition, bAlias;
            while (i<len) {
               sDA = c.var("Search.ResultList."+i+".DisplayAttributes");
               if (sDA.length()==4 && !sDA.equals("....")) {
                  bSelectable = (sDA.charAt(1)=='S');
                  bPartition =  (sDA.charAt(2)=='P');
                  bAlias =      (sDA.charAt(3)=='A');
               } else {
                 bSelectable = bPartition = bAlias = false;
               }
               if (bPartition && bAlias)  {auxIcon="aliaspart.gif";  auxHint=c.toTag(c.string("OS.Pocket.AliasPartitionHint")); }
               else if (bAlias)           {auxIcon="alias.gif";      auxHint=c.toTag(c.string("OS.Pocket.AliasHint")); }
               else if (bPartition)       {auxIcon="partition.gif";  auxHint=c.toTag(c.string("OS.Pocket.PartitionHint")); }
               else                       {auxIcon="7px_spacer.gif"; auxHint=""; } %>

<%             altTitle = c.toTag(c.string("OS.Pocket.TypePrefix")+" "+c.var("Search.ResultList."+i+".TypeName"));
               if (bSelectable) { %>
               <!-- a selectable object -->
	            <NOBR><IMG src="<%= c.getModulesUrl() %>/fw/images/1px_spacer.gif" border=0>&nbsp;
	            <A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=<%= c.urlEncode(c.var("Search.ResultList."+i+".Name")) %>">
               <img alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/dir/<%= c.toTag(c.var("Search.ResultList."+i+".TypeIcon")) %>"
                    border=0><img alt="<%= auxHint %>" title="<%= auxHint %>" src="<%= c.getModulesUrl() %>/fw/images/<%= auxIcon %>" border=0></A>
               <A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=<%= c.urlEncode(c.var("Search.ResultList."+i+".Name")) %>">
               <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.var("Search.ResultList."+i+".DisplayName")) %></NOBR></A></FONT><BR>
<%             } else { %>
               <!-- a non-selectable object -->
               <NOBR><IMG src="<%= c.getModulesUrl() %>/fw/images/1px_spacer.gif" border=0>&nbsp;
               <img alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/dir/<%= c.toTag(c.var("Search.ResultList."+i+".TypeIcon")) %>"
                    border=0><img alt="<%= auxHint %>" title="<%= auxHint %>" src="<%= c.getModulesUrl() %>/fw/images/<%= auxIcon %>" border=0>
               <FONT color="gray" face="Helvetica,Arial" size=-2><%= c.toDisplay(c.var("Search.ResultList."+i+".DisplayName")) %></NOBR></FONT><BR>
<%             }

               dCnt++; i++;
            } //while %>

            <script>
               for (var i=<%= dCnt %>; i<parent.m_resultsPerPage;i++)
               {
                  document.writeln('<FONT face="Helvetica,Arial" size=-2><IMG src="<%= c.getModulesUrl() %>/fw/images/16px_spacer.gif" border=0>&nbsp;</FONT><BR>');
               }
            </script>
            <BR>

            <!-- display previous and next buttons -->
            <CENTER>
            <table>
            <tr>
<%          if (c.var("Search.PreviousElements").equals("true") || c.var("Search.NextElements").equals("true")) { %>
               <td>
<%             if (c.var("Search.PreviousElements").equals("true")) { %>
                  <script>
                     document.writeln('<form method=post action="webacc?taskId=fw.ObjectSelector&merge=fw.OS.Search&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Movement=Prev&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&SearchToken=SearchTokenUpdate&OS.ResultsPerPage='+parent.m_resultsPerPage+'">');
                  </script>
<%                altTitle = c.toTag(c.string("Button.Previous.alt")); %>
                  <input type=image name="Previous" alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.toTag(c.string("Button.Previous.image")) %>" border=0>
                  </form>
<%             } %>
              </td>

              <td>
<%            if (c.var("Search.NextElements").equals("true")) { %>
                 <script>
                    document.writeln('<form method=post action="webacc?taskId=fw.ObjectSelector&merge=fw.OS.Search&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Movement=Next&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&SearchToken=SearchTokenUpdate&OS.ResultsPerPage='+parent.m_resultsPerPage+'">');
                 </script>
<%               altTitle = c.toTag(c.string("Button.Next.alt")); %>
                 <input type=image name="Next" alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.toTag(c.string("Button.Next.image")) %>" border=0>
                 </form>
<%            } %>
              </td>

<%          } else { %>
               <td>
                  <IMG src="<%= c.getModulesUrl() %>/fw/images/16px_spacer.gif" border=0>
               </td>
<%          } %>
            </tr>
            </table>
            </CENTER>

         <BR><BR>
<%       c.set("TaskHeader.title", c.string("OS.Pocket.SearchDir")); %>
         <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>
<%       }//len>0
      }
   }//showresults%>

<form name="SearchPanel" method=post action="webacc" onSubmit="javascript:doGenericSearch()">
<INPUT type="hidden" name="User.context" value="<%= c.var("User.context") %>">

<BR>
<NOBR><FONT face="Helvetica,Arial" size=-1><b><%= c.toDisplay(c.string("OS.Pocket.SearchFrom")) %></b>&nbsp;&nbsp;<%= c.toDisplay(c.string("OS.Pocket.SearchFromEx")) %></NOBR></FONT>
<BR>

<script>
   var container=parent.m_container;
   if (container=="") container="<%= c.toScript(c.string("OS.Pocket.RootName")) %>";
   document.writeln('<input type=text name="SPContext" value="'+parent.toTag(container)+'" size=20 onChange="changeContainer()"><BR>');
</script>
</FONT>

<FONT face="Helvetica,Arial" size=-1>
<NOBR>&nbsp;&nbsp;&nbsp;&nbsp;
<script>
   var checked = ((parent.m_searchSubContainers=="true")?"CHECKED":"");
   document.writeln('<input type=checkbox name="SPSubContainer" '+checked+' onClick="changeSubContainerSearch()">');
</script>
&nbsp;&nbsp<%= c.toDisplay(c.string("OS.Pocket.SearchSubContainer")) %></NOBR><BR><BR>

<NOBR><FONT face="Helvetica,Arial" size=-1><b><%= c.toDisplay(c.string("OS.Pocket.SearchFor")) %></b>&nbsp;&nbsp;<%= c.toDisplay(c.string("OS.Pocket.SearchForEx")) %></NOBR><BR>
<script>
   var filter=parent.m_nameFilter;
   if (filter=="") filter="*";
   document.writeln('<input type=text name="SPNameFilter" value="'+parent.toTag(filter)+'" size=20 maxlength="128" onChange="changeNameFilter()"><BR>');
</script>

<NOBR></FONT>
<BR>
<FONT face="Helvetica,Arial" size=-1>
<NOBR><b><%= c.toDisplay(c.string("OS.Pocket.SearchObjectTypes")) %></b></NOBR><BR>
</FONT>
   <table>
   <tr>
   <td>&nbsp;&nbsp;</td>
   <td><FONT face="Helvetica,Arial" size=-2>
   <script>
      for (var i=0; i<parent.m_displayTypes.length; i++)
      {
         document.writeln("<NOBR>"+parent.m_displayTypes[i]+"</NOBR><BR>");
      }
      for (var i=0; i<parent.m_pseudoDisplayTypes.length; i++)
      {
         document.writeln("<NOBR>"+parent.m_pseudoDisplayTypes[i]+"</NOBR><BR>");
      }
   </script>
   </FONT>
   </td>
   </tr>
   </table>

<BR>
<CENTER>
<a href="javascript:doGenericSearch()">
<% altTitle = c.toTag(c.string("Button.Browse.alt")); %>
<img alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.toTag(c.string("Button.Search.image")) %>" border=0></a>
&nbsp;&nbsp;
<A target=_parent href="webacc?taskId=fw.ObjectSelectorFinish&merge=fw.OS.ObjectSelectorFinish&error=dev.GenErr&User.context=<%= c.var("User.context") %>&Search.ContextId=<%= c.urlEncode(c.var("Search.ContextId")) %>&OS.Results=">
<% altTitle = c.toTag(c.string("Button.Cancel.alt")); %>
<img alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.string("Button.Cancel.image") %>" border=0></a>
<BR><BR>

<!-- switch to browse mode link -->
<a href="javascript:switchToBrowseMode()">
<FONT size=-2><%= c.toDisplay(c.string("OS.Pocket.SwitchToBrowseMode")) %></FONT></a>
<BR><BR>&nbsp;
</CENTER>

</form>
</BODY>
</HTML>
