<%@  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"); %>

<HEAD>
<TITLE>OSPocketBrowse</TITLE>
</HEAD>

<script language="JavaScript">

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

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

   function downOneLevel(objectName)
   {
      parent.m_container=objectName;
      doGenericSearch();
   }

   function upOneLevel()
   {
      parent.m_container="<%= c.toScript(c.var("Search.ParentContainer")) %>";
      doGenericSearch();
   }

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

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

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

   function getTitle()
   {
      var container=parent.m_container;
      if (container=="") container="<%= c.string("OS.Pocket.RootName") %>";
      return container;
   }
</script>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#EFF0E8">
<% if (c.var("Search.ShowResultSet").equals("true")) {
      c.set("TaskHeader.callback", "getTitle");
   } else {
      c.set("TaskHeader.title", c.string("OS.Pocket.BrowseDir"));
   } %>
<jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>
<% c.set("TaskHeader.callback", ""); %>

<% 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 (!c.var("Search.ParentContainer").equals("")) { %>
         <!-- display up one level entry -->
         <NOBR><A href="javascript:upOneLevel()">
<%       altTitle = c.toTag(c.string("OS.Pocket.UpOneLevel.alt")); %>
         <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/fw/images/uplevel.gif" border=0></A>&nbsp;&nbsp;
<%       altTitle = c.toTag(c.string("OS.Pocket.CurrentLevel.alt")); %>
         <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/fw/images/doubledots.gif"
<%       altTitle = c.toTag(c.string("OS.Pocket.ParentLevel.alt")); %>
              border=0><IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/fw/images/7px_spacer.gif" border=0></A>
         <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OS.Pocket.UpOneLevel")) %></NOBR></FONT><BR>
<%       dCnt++;
      }

      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' && c.var("Search.ParentContainer").equals("")) { %>
            <!-- display selectable tree root -->
            <NOBR><IMG src="<%= c.getModulesUrl() %>/fw/images/16px_spacer.gif" border=0>&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=<%= 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 selectable public node -->
            <NOBR><IMG src="<%= c.getModulesUrl() %>/fw/images/16px_spacer.gif" border=0>&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=<%= 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 selectable this node -->
            <NOBR><IMG src="<%= c.getModulesUrl() %>/fw/images/16px_spacer.gif" border=0>&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=<%= 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 search contents in list -->
<%    int len = c.toInt("Search.ResultList.Count");
      if ( len<1 &&
         ( c.var("Search.PseudoObjects").length()==0 || c.var("Search.PseudoObjects").equals("...")) ) { %>
         <!-- display "nothing found" message -->
         <FONT face="Helvetica,Arial" size=-2><b><%= c.toDisplay(c.string("OS.Pocket.ZeroMatch")) %></b></FONT>
         <IMG src="<%= c.getModulesUrl() %>/fw/images/16px_spacer.gif" border=0><BR>
<%       dCnt++;
      } %>

      <!-- display search results entries -->
<%    if (len>0) {
         int i=0;
         String auxIcon, sDA;
         boolean bContainer, bSelectable, bPartition, bAlias;
         while (i<len) {
            sDA = c.var("Search.ResultList."+i+".DisplayAttributes");
            if (sDA.length()==4 && !sDA.equals("....")) {
               bContainer =  (sDA.charAt(0)=='C');
               bSelectable = (sDA.charAt(1)=='S');
               bPartition =  (sDA.charAt(2)=='P');
               bAlias =      (sDA.charAt(3)=='A');
            } else {
               bContainer = 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=""; } %>

<%          if (bContainer) { %>
               <!-- display container navigation button -->
               <A href="#" onClick="javascript:downOneLevel('<%= c.toDisplay((c.toScript(c.var("Search.ResultList."+i+".Name")))) %>');return false">
<%             altTitle = c.toTag(c.string("OS.Pocket.DownOneLevel.alt")); %>
               <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/fw/images/downlevel.gif" border=0></A>&nbsp;&nbsp;
<%          } else { %>
               <IMG src="<%= c.getModulesUrl() %>/fw/images/16px_spacer.gif" border=0>&nbsp;&nbsp;
<%          }

            altTitle = c.toTag(c.string("OS.Pocket.TypePrefix")+" "+c.var("Search.ResultList."+i+".TypeName"));
            if (bSelectable) { %>
               <!-- a selectable object -->
	            <NOBR><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></FONT></A><BR>
<%          } else { %>
               <!-- a non-selectable object -->
               <NOBR><img alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/dir/<%= c.toDisplay(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.Browse&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.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.Browse&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.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.BrowseDir")); %>
         <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>
<%    }
   }//showResults %>
   </FONT>

<form name="BrowsePanel" 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.BrowseFrom")) %></b>&nbsp;&nbsp;<%= c.toDisplay(c.string("OS.Pocket.BrowseFromEx")) %></NOBR></FONT>
<BR>
<script>
   var container=parent.m_container;
   if (container=="") container="<%= c.string("OS.Pocket.RootName") %>";
   document.writeln('<input type=text name="BPContext" value="'+parent.toTag(container)+'" size=20 onChange="changeContainer()"><BR>');
</script>
</FONT>

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

<!-- display browse and cancel buttons -->
<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.Browse.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.toTag(c.string("Button.Cancel.image")) %>" border=0></a>
<BR><BR>

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

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