<%@  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>OSSimpleBrowse</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" />
</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()
   {
      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.Simple.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();
   }
   
</script>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#EFEEE9" onLoad="javascript:document.BrowsePanel.BPContext.focus()" onDragStart="iman.cancelEvent(event)">
<% c.set("TaskHeader.title", c.string("OS.Simple.BrowseDir")); 
   c.set("TaskHeader.iconUrl", "dev/" + c.string("Button.OS.image"));
   c.set("TaskHeader.bgcolor", "#EFEEE9"); %>  
<jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>

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

<!-- display look in entry field -->
<NOBR><FONT face="Helvetica,Arial" size=-1><b><%= c.toDisplay(c.string("OS.Simple.BrowseFrom")) %></b></FONT>
&nbsp;&nbsp;<FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OS.Simple.BrowseFromEx")) %></FONT></NOBR>
<BR>
<script>
   var container=parent.m_container;
   if (container=="") container="<%= c.toScript(c.string("OS.Simple.RootName")) %>";
   document.writeln('<input type=text name="BPContext" value="'+toTag(container)+'" size=35 onChange="changeContainer()"><BR>');
</script>
<BR>

<% boolean showResults = (c.var("Search.ShowResultSet").equals("true"));
   String altTitle = "";
   String auxHint = c.toTag(c.string("OS.Simple.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.Simple.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.Simple.CurrentLevel.alt")); %>
         <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/fw/images/doubledots.gif"
<%       altTitle = c.toTag(c.string("OS.Simple.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.Simple.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 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.Simple.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 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 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.Simple.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 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 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.Simple.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 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.Simple.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, bGlue;
         while (i<len) {
            sDA = c.var("Search.ResultList."+i+".DisplayAttributes");
            if (sDA.length()==5 && !sDA.equals(".....")) {
               bContainer =  (sDA.charAt(0)=='C');
               bSelectable = (sDA.charAt(1)=='S');
               bPartition =  (sDA.charAt(2)=='P');
               bAlias =      (sDA.charAt(3)=='A');
               bGlue =       (sDA.charAt(4)=='G');
            } else {
               bContainer = bSelectable = bPartition = bAlias = bGlue = false;
            }
            if (bPartition && bAlias)  {auxIcon="aliaspart.gif";  auxHint=c.toTag(c.string("OS.Simple.AliasPartitionHint")); }
            else if (bAlias)           {auxIcon="alias.gif";      auxHint=c.toTag(c.string("OS.Simple.AliasHint")); }
            else if (bPartition)       {auxIcon="partition.gif";  auxHint=c.toTag(c.string("OS.Simple.PartitionHint")); }
            else if (bGlue)            {auxIcon="glue.gif";       auxHint=c.toTag(c.string("OS.Browser.GlueHint")); }
            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.Simple.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.Simple.TypePrefix")+" "+c.var("Search.ResultList."+i+".TypeName"));
            if (bSelectable) { %>
               <!-- a selectable object -->
	     	      <NOBR><A 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 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 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>
         </font>

         <!-- display previous and next buttons -->
<%       if (c.var("Search.PreviousElements").equals("true") || c.var("Search.NextElements").equals("true")) { %>
            <BR>
<%          if (c.var("Search.PreviousElements").equals("true")) { %>
               <script>
                  document.writeln('<a href="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")); %>
               <img alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.toTag(c.string("Button.Previous.image")) %>" border=0></a>
<%          }
         
            if (c.var("Search.NextElements").equals("true")) { %>
               <script>
               document.writeln('<a href="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")); %>
               <img alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.toTag(c.string("Button.Next.image")) %>" border=0></a>
<%          } %>
            <BR>
<%       }
      } %>
   <BR>
<% }//showResults %>

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

<!-- display search type filter -->
<FONT face="Helvetica,Arial" size=-1>
<NOBR><b><%= c.toDisplay(c.string("OS.Simple.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 -->
<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 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>

<!-- switch to search mode link -->
<% if (c.toLower(c.var("OS.Simple.Browsing.Only")).equals("false")) { %>
	&nbsp;&nbsp;&nbsp;&nbsp;
	<a style="color: #039;" href="#" onClick="javascript:switchToSearchMode()">
	<FONT size=-2><%= c.toDisplay(c.string("OS.Simple.SwitchToSearchMode")) %></FONT></a>
	<BR><BR>
<% } %>

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