<%@  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>BrowseResultsSS</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 language="JavaScript">

   //************** Event Handlers *****************
   function doSelectObject(objectName, evt)
   {
      evt = ((evt)?evt:((window.event)?window.event:null));
      if (evt!=null)
      {
         if (!top.m_bSelectionMade)
         {
            top.m_bSelectionMade = true;
            var strURL = "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")) %>";
            document.PostData.action = strURL;
            document.getElementById("osresults").value = urlEncode(objectName);
            document.PostData.submit();
         }
         iman.cancelEvent(evt);  //cancel event propagation/bubbling and default action 
      }
      return false;
   }

   function downOneLevel(objectName, evt)
   {
      evt = ((evt)?evt:((window.event)?window.event:null));
      if (evt!=null)
      {
         top.processDisplayCountChange();
         top.Query.document.BrowseQuery.BQContext.value=objectName;
         top.doSearch();
         iman.cancelEvent(evt);
      }
      return false;
   }

   function upOneLevel(evt)
   {
      evt = ((evt)?evt:((window.event)?window.event:null));
      if (evt!=null)
      {
         top.processDisplayCountChange();
         top.Query.document.BrowseQuery.BQContext.value="<%= c.toScript(c.var("Search.ParentContainer")) %>";
         top.doSearch();
         iman.cancelEvent(evt);
      }
      return false;
   }
   
   
   //************** GUI Utility Functions *****************
   function displayResultButtons()
   {
      <!-- display the next/previous buttons -->
      top.ResultButtons.document.open();
      top.ResultButtons.document.writeln('<html><head><title>BrowseResultButtons</title>');
      if (MS55)
         top.ResultButtons.document.writeln('<body bgcolor="#EFEEE9" style="border-style:solid; border-width:1; border-color:#BFBBB2;" onLoad="javascript:top.resultButtonsLoaded=true;" onFocus="top.ensureOpenerValid();">');
      else
         top.ResultButtons.document.writeln('<body bgcolor="#EFEEE9" onLoad="javascript:top.resultButtonsLoaded=true;" onFocus="top.ensureOpenerValid();">');
      top.ResultButtons.document.writeln('<div style="width:100%;position:absolute;top:4;">');
      top.ResultButtons.document.writeln('<center><table height=100% cellspacing=0 cellpadding=0 border=0>');
      top.ResultButtons.document.writeln('<tr>');
   
      prevEnabled = ("<%= c.toScript(c.var("Search.PreviousElements")) %>" == "true");
      if (prevEnabled)
      {
          visibleButtons=true;
          top.ResultButtons.document.writeln('<td onClick="javascript:top.processResultsButton(' ,
                                             "'webacc?taskId=fw.ObjectSelector&merge=fw.OS.BrowseResultsSS&error=dev.GenErr&User.context=<%= c.var("User.context") %>&SearchToken=SearchTokenUpdate&Movement=Prev'" ,
                                             ')">' ,
                                             '<IMG name="Previous" alt="<%= c.toTag(c.string("Button.Previous.alt")) %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.string("Button.Previous.image") %>" border=0>' ,
                                             '</td>');
      }
      else
      {
         top.ResultButtons.document.writeln( '<td>' ,
                                             '<IMG name="Previous" alt="<%= c.toTag(c.string("Button.PreviousDisabled.alt")) %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.string("Button.PreviousDisabled.image") %>" border=0>' ,
                                             '</td>');
      }
   
      top.ResultButtons.document.writeln('<td>&nbsp;&nbsp</td>');
   
      nextEnabled = ("<%= c.toScript(c.var("Search.NextElements")) %>" == "true");
      if (nextEnabled)
      {
          top.ResultButtons.document.writeln('<td onClick="javascript:top.processResultsButton(' ,
                                            "'webacc?taskId=fw.ObjectSelector&merge=fw.OS.BrowseResultsSS&error=dev.GenErr&User.context=<%= c.var("User.context") %>&SearchToken=SearchTokenUpdate&Movement=Next'" ,
                                            ')">' ,
                                            '<IMG name="Next" alt="<%= c.toTag(c.string("Button.Next.alt")) %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.string("Button.Next.image") %>" border=0>' ,
                                            '</td>');
      }
      else
      {
         top.ResultButtons.document.writeln( '<td>' ,
                                             '<IMG name="Next" alt="<%= c.toTag(c.string("Button.NextDisabled.alt")) %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.string("Button.NextDisabled.image") %>" border=0>' ,
                                             '</td>');
      }
   
      var inputStyle = ((NN6)?"height:18px;width:30px;font-size:9;text-align:center":"height:16px;width:30px;font-size:7pt;text-align:center;");
      top.ResultButtons.document.writeln('<td>&nbsp;&nbsp;' ,
                                         '<input type=text id=ResultsPerPage title="<%=c.toTag(c.string("OS.Browser.ResultsPerPageTip"))%>" maxlength=3 style="'+inputStyle+'" value='+top.m_resultsPerPage+' onChange="javascript:top.processDisplayCountChange()" onKeyPress="javascript:top.processDisplayCountKeyPress(event.keyCode, '+nextEnabled+', '+prevEnabled+')">' ,
                                         '</td>');
   
      top.ResultButtons.document.writeln('</tr>');
      top.ResultButtons.document.writeln('</table></center>');
      top.ResultButtons.document.writeln('</div>');
      top.ResultButtons.document.writeln('<form name=PostData method=post target="" onSubmit="javascript:top.processDisplayCountChange();return false;">');
      top.ResultButtons.document.writeln('<span id=FormData></span>');
      top.ResultButtons.document.writeln('</form>');
      top.ResultButtons.document.writeln('</body></html>');
      top.ResultButtons.document.close();
   }

   
   //**************** OnLoad Processing **********************
   var t = null;
   function queryOnLoad(cnt)
   {
      //wait up to 10 seconds for the Query frame to load
      if (cnt<100)
      {
         if (top.queryLoaded==false ||
             top.resultButtonsLoaded==false)
         {
            cnt++;
            t = setTimeout("queryOnLoad("+cnt+")",100)
         }
         else
         {
            if (t!=null)
            {
               clearTimeout(t);
            }

            // set search context id in query frame
            top.m_searchContextId = "<%= c.toScript(c.var("Search.ContextId")) %>";
            displayResultButtons();
         }
      }
   }

</script>
</HEAD>
<script>
   if (MS55)
      document.writeln('<BODY bgcolor="#FFFFFF" style="border-style:solid; border-width:1; border-bottom-width:0; border-color:#BFBBB2;" onLoad="top.resultsLoaded=true;queryOnLoad(0)" onFocus="top.ensureOpenerValid();" onDragStart="iman.cancelEvent(event)">');
   else
      document.writeln('<BODY bgcolor="#FFFFFF" onLoad="top.resultsLoaded=true;queryOnLoad(0)" onFocus="top.ensureOpenerValid();">');
</script>
<% boolean showResults = (c.var("Search.ShowResultSet").equals("true"));
   String color = "#EFEEE9";
   String name = "";
   String altTitle = "";
   String onClickCmd = "";
   String auxHint = c.toTag(c.string("OS.Browser.PartitionHint"));
   int w = 20; %>
<div id=resultsDiv style="display:<% if (showResults) { %>inline<% } else { %>none<% } %>">
    <table width="100%" cellspacing=0>

    <!-- display up one level entry -->
<%  if (!c.var("Search.ParentContainer").equals("")) { %>
      <tr bgcolor=<%= color %>>
      <td width=<%= w %>>
      <A href="#" onClick="javascript:upOneLevel(event)" onContextMenu="javascript:upOneLevel(event)">
<%    altTitle = c.toTag(c.string("OS.Browser.UpOneLevel.alt")); %>
      <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/fw/images/uplevel.gif" border=0></A>
      </td>
      <td>
<%    altTitle = c.toTag(c.string("OS.Browser.ParentLevel.alt")); %>
      <IMG alt="<%= altTitle %>" title="<%= altTitle %>" src="<%= c.getModulesUrl() %>/fw/images/doubledots.gif"
           border=0><IMG src="<%= c.getModulesUrl() %>/fw/images/7px_spacer.gif" border=0></A>
      <FONT face="Helvetica,Arial" size=-2><NOBR><%= c.toDisplay(c.string("OS.Browser.UpOneLevel")) %></NOBR></FONT>
      </td>
      </tr>
<%    color = (color.equals("#EFEEE9")?"#FFFFFF":"#EFEEE9");
    }

    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 -->
         <tr bgcolor=<%= color %>>
         <td width=<%= w %>>
         </td>
<%       name = c.toTag(c.toScript(c.var("Search.TreeName")));
         onClickCmd = "javascript:doSelectObject('"+name+"',event)"; %>
         <td onClick="<%= onClickCmd %>" onContextMenu="<%= onClickCmd %>">
<%       altTitle = c.toTag(c.string("OS.Browser.TypePrefix")+" "+c.string("ObjectType.Tree_Root")); %>
         <NOBR><A href="#"><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="#" title="<%= c.toTag(c.string("OS.Browser.SelectHint")) %>">
         <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.var("Search.TreeName")) %></NOBR></A></FONT><BR>
         </td>
         </tr>
<%       color = (color.equals("#EFEEE9")?"#FFFFFF":"#EFEEE9");
       }

       if (c.var("Search.PseudoObjects").charAt(2)=='P') { %>
         <!-- display a selectable public node -->
         <tr bgcolor=<%= color %>>
         <td width=<%= w %>>
         </td>
<%       name = c.toTag(c.toScript(c.string("OS.Public")));
         onClickCmd = "javascript:doSelectObject('"+name+"',event)"; %>
         <td onClick="<%= onClickCmd %>" onContextMenu="<%= onClickCmd %>">
<%       altTitle = c.toTag(c.string("OS.Browser.TypePrefix")+" "+c.string("OS.Public")); %>
         <NOBR><A href="#"><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="#" title="<%= c.toTag(c.string("OS.Browser.SelectHint")) %>">
         <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OS.Public")) %></NOBR></A></FONT><BR>
         </td>
         </tr>
<%       color = (color.equals("#EFEEE9")?"#FFFFFF":"#EFEEE9");
       }

       if (c.var("Search.PseudoObjects").charAt(1)=='T') { %>
         <!-- display a selectable this node -->
         <tr bgcolor=<%= color %>>
         <td width=<%= w %>>
         </td>
<%       name = c.toTag(c.toScript(c.string("OS.This")));
         onClickCmd = "javascript:doSelectObject('"+name+"',event)"; %>
         <td onClick="<%= onClickCmd %>" onContextMenu="<%= onClickCmd %>">
<%       altTitle = c.toTag(c.string("OS.Browser.TypePrefix")+" "+c.string("OS.This")); %>
         <NOBR><A href="#"><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="#" title="<%= c.toTag(c.string("OS.Browser.SelectHint")) %>">
         <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OS.This")) %></NOBR></A></FONT><BR>
         </td>
         </tr>
<%       color = (color.equals("#EFEEE9")?"#FFFFFF":"#EFEEE9");
       }
    } %>

    <!-- display search contents in list -->
<%  int len = c.toInt("Search.ResultList.Count");
    if (len>0) {
       int i=0;
       String auxIcon, sDA;
       boolean bContainer, bSelectable, bPartition, bAlias, bGlue, bJunction;
       while (i<len) {
          sDA = c.var("Search.ResultList."+i+".DisplayAttributes");
          if (sDA.length()==6 && !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');
             bJunction =       (sDA.charAt(5)=='J');
          } else {
            bContainer = bSelectable = bPartition = bAlias = bGlue = bJunction = false;
          }
          if (bPartition && bAlias)  {auxIcon="aliaspart.gif";  auxHint=c.toTag(c.string("OS.Browser.AliasPartitionHint")); }
          else if (bAlias)           {auxIcon="alias.gif";      auxHint=c.toTag(c.string("OS.Browser.AliasHint")); }
          else if (bPartition)       {auxIcon="partition.gif";  auxHint=c.toTag(c.string("OS.Browser.PartitionHint")); }
          else if (bGlue)            {auxIcon="glue.gif";       auxHint=c.toTag(c.string("OS.Browser.GlueHint")); }
          else if (bJunction)       {auxIcon="junction.gif"; auxHint=""; }
          else                       {auxIcon="7px_spacer.gif"; auxHint=""; } %>

         <tr bgcolor=<%= color %>>
         <td width=<%= w %>>
<%        if (bContainer) { %>
<%           name = c.toTag(c.toScript(c.var("Search.ResultList."+i+".Name")));
             onClickCmd = "javascript:downOneLevel('"+name+"',event)"; %>
             <A href="#" onClick="<%= onClickCmd %>" onContextMenu="<%= onClickCmd %>">
             <IMG alt="<%= c.toTag(c.string("OS.Browser.DownOneLevel.alt")) %>" src="<%= c.getModulesUrl() %>/fw/images/downlevel.gif" border=0></A>
<%        } %>
         </td>

<%       altTitle = c.toTag(c.string("OS.Browser.TypePrefix")+" "+c.var("Search.ResultList."+i+".TypeName"));
         if (bSelectable) { %>
            <!-- a selectable object -->
<%          name = c.toTag(c.toScript(c.var("Search.ResultList."+i+".Name")));
            onClickCmd = "javascript:doSelectObject('"+name+"',event)"; %>
            <td onClick="<%= onClickCmd %>" onContextMenu="<%= onClickCmd %>">
            <NOBR><FONT face="Helvetica,Arial" size=-2>
            <A href="#"><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="#" title="<%= c.toTag(c.string("OS.Browser.SelectHint")) %>"><%= c.toDisplay(c.var("Search.ResultList."+i+".DisplayName")) %></A>
            &nbsp;&nbsp;<%=c.var("Search.ResultList."+i+".SubordinateCount")%></FONT></NOBR>
            </td>
<%        } else { %>
            <!-- a non-selectable object -->
            <td>
            <NOBR><FONT color="gray" face="Helvetica,Arial" size=-2>
            <img alt="<%= c.toTag(c.string("OS.Browser.TypePrefix")) %><%= c.toTag(c.var("Search.ResultList."+i+".TypeName")) %>" 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>
            <%= c.toDisplay(c.var("Search.ResultList."+i+".DisplayName")) %>
             &nbsp;&nbsp;<%=c.var("Search.ResultList."+i+".SubordinateCount")%></FONT></NOBR>
            </td>
<%        } %>
          </tr>

<%        i++;
          color = (color.equals("#EFEEE9")?"#FFFFFF":"#EFEEE9");
       } //endwhile
    } //endif %>

   </table>

<%  if ( c.toInt("Search.ResultList.Count")<1 &&
         ( c.var("Search.PseudoObjects").length()==0 || c.var("Search.PseudoObjects").equals("...")) ) { %>
       <FONT face="Helvetica,Arial" size=-2><b><%= c.toDisplay(c.string("OS.Browser.ZeroMatch")) %></b></FONT>
<%  } %>

</div>
<div id=browsingDiv style="display:<% if (!showResults) { %>inline<% } else { %>none<% } %>">
   <p><font face="Helvetica,Arial" size=-1 color=red><b><%= c.toDisplay(c.string("OS.Browser.Browsing")) %></b></font></p>
   <form name="PostData" method=post action="webacc">
   <input type=hidden name="OS.Results" id="osresults" value=""></form>
</div>
</BODY></HTML>
