<%@  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>SearchResultsSS</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">

	//------------- find OVTop ----------------
   var OVTop=top.Mainscreen.ObjectView;
   
   
   //************** Event Handlers *****************
   function doTaskList(refPos, objectName, evt)
   {
      evt = ((evt)?evt:((window.event)?window.event:null));
      if (evt!=null)
      {
         OVTop.doTaskList(refPos, objectName, evt);
         iman.cancelEvent(evt);  //cancel event propagation/bubbling and default action 
      }
      return false;
   }

      
   //************** GUI Utility Functions *****************
   function displayResultButtons()
   {
      <!-- display the next/previous buttons -->
      OVTop.ResultButtons.document.open();
      OVTop.ResultButtons.document.writeln('<html><head><title>SearchResultButtons</title>');
      OVTop.ResultButtons.document.writeln('\u003Cscript>');
      OVTop.ResultButtons.document.writeln('var OVTop=top.Mainscreen.ObjectView;');
      OVTop.ResultButtons.document.writeln('\u003C/script>');
      OVTop.ResultButtons.document.writeln('</head>');
      if (MS55)
         OVTop.ResultButtons.document.writeln('<body bgcolor="#EFEEE9" style="border-style:solid; border-width:1; border-color:#BFBBB2;" onLoad="javascript:OVTop.resultButtonsLoaded=true;">');
      else
         OVTop.ResultButtons.document.writeln('<body bgcolor="#EFEEE9" onLoad="javascript:OVTop.resultButtonsLoaded=true;">');
      OVTop.ResultButtons.document.writeln('<div style="width:100%;position:absolute;top:4;">');
      OVTop.ResultButtons.document.writeln('<center><table height=100% cellspacing=0 cellpadding=0 border=0>');
      OVTop.ResultButtons.document.writeln('<tr>');

      prevEnabled = ("<%= c.toScript(c.var("Search.PreviousElements")) %>" == "true");
      if (prevEnabled)
      {
         OVTop.ResultButtons.document.writeln('<td onClick="javascript:OVTop.processResultsButton(' ,
                                             "'webacc?taskId=fw.ObjectView&merge=fw.OV.SearchResultsSS&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.toTag(c.string("Button.Previous.image")) %>" border=0>' ,
                                             '</td>');
      }
      else
      {
         OVTop.ResultButtons.document.writeln( '<td>' ,
                                             '<IMG name="Previous" alt="<%= c.string("Button.PreviousDisabled.alt") %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.toTag(c.string("Button.PreviousDisabled.image")) %>" border=0>' ,
                                             '</td>');
      }

      OVTop.ResultButtons.document.writeln('<td>&nbsp;&nbsp</td>');

      nextEnabled = ("<%= c.toScript(c.var("Search.NextElements")) %>" == "true");
      if (nextEnabled)
      {
         OVTop.ResultButtons.document.writeln('<td onClick="javascript:OVTop.processResultsButton(' ,
                                            "'webacc?taskId=fw.ObjectView&merge=fw.OV.SearchResultsSS&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.toTag(c.string("Button.Next.image")) %>" border=0>' ,
                                            '</td>');
      }
      else
      {
         OVTop.ResultButtons.document.writeln( '<td>' ,
                                             '<IMG name="Next" alt="<%= c.toTag(c.string("Button.NextDisabled.alt")) %>" src="<%= c.getModulesUrl() %>/dev/images/<%= c.toTag(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;");
      OVTop.ResultButtons.document.writeln('<td>&nbsp;&nbsp;' ,
                                         '<input type=text id=ResultsPerPage title="<%=c.toTag(c.string("OV.Browser.ResultsPerPageTip"))%>" maxlength=3 style="'+inputStyle+'" value='+OVTop.m_resultsPerPage+' onChange="javascript:OVTop.processDisplayCountChange()" onKeyPress="javascript:OVTop.processDisplayCountKeyPress(event.keyCode, '+nextEnabled+', '+prevEnabled+')">' ,
                                         '</td>');

      OVTop.ResultButtons.document.writeln('</tr>');
      OVTop.ResultButtons.document.writeln('</table></center>');
      OVTop.ResultButtons.document.writeln('</div>');
      OVTop.ResultButtons.document.writeln('<form name=PostData method=post target="" onSubmit="javascript:OVTop.processDisplayCountChange();return false;">');
      OVTop.ResultButtons.document.writeln('<span id=FormData></span>');
      OVTop.ResultButtons.document.writeln('</form>');
      OVTop.ResultButtons.document.writeln('</body></html>');
      OVTop.ResultButtons.document.close();
   }

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

            // set search context id in query frame
            OVTop.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="OVTop.resultsLoaded=true;resultsOnLoad(0);" onDragStart="iman.cancelEvent(event)">');
   else
      document.writeln('<BODY bgcolor="#FFFFFF" onLoad="OVTop.resultsLoaded=true;resultsOnLoad(0);">');
</script>
<% if (c.var("Search.ShowResultSet").equals("true")) { %>
      <!-- show the search results -->
<%    if ( c.toInt("Search.ResultList.Count")==0 && !c.var("Search.PreviousElements").equals("true") && ( c.var("Search.PseudoObjects").length()==0 || c.var("Search.PseudoObjects").equals("...") ) ) { %>
         <!-- nothing found -->
         <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OV.Browser.ZeroMatch")) %></FONT>
<%    } else { %>
         <!-- something was found -->
<%       String color = "#EFEEE9";
         String onClickCmd = "";
         String altTitle = "";
         String auxHint = c.toTag(c.string("OV.Browser.PartitionHint")); %>
         <table width="100%" cellspacing=0>
<%       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 -->
               <tr bgcolor=<%= color %>>
<%             onClickCmd = "javascript:doTaskList(this, ['"+c.toTag(c.toScript(c.var("Search.TreeName")))+"'], event)"; %>
               <td onClick="<%= onClickCmd %>" onContextMenu="<%= onClickCmd %>">
<%             altTitle = c.toTag(c.string("OV.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("OV.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 %>>
<%             onClickCmd = "javascript:doTaskList(this, ['"+c.toTag(c.toScript(c.string("OV.Public")))+"'], event)"; %>
               <td onClick="<%= onClickCmd %>" onContextMenu="<%= onClickCmd %>">
<%             altTitle = c.toTag(c.string("OV.Browser.TypePrefix")+" "+c.string("OV.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("OV.Browser.SelectHint")) %>">
               <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OV.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 %>>
<%             onClickCmd = "javascript:doTaskList(this, ['"+c.toTag(c.toScript(c.string("OV.This")))+"'], event)"; %>
               <td onClick="<%= onClickCmd %>" onContextMenu="<%= onClickCmd %>">
<%             altTitle = c.toTag(c.string("OV.Browser.TypePrefix")+" "+c.string("OV.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("OV.Browser.SelectHint")) %>">
               <FONT face="Helvetica,Arial" size=-2><%= c.toDisplay(c.string("OV.This")) %></NOBR></A></FONT><BR>
               </td>
               </tr>
<%             color = (color.equals("#EFEEE9")?"#FFFFFF":"#EFEEE9");
            }
         } %>

         <!-- display each of the results in alternating colors -->
<%       int len = c.toInt("Search.ResultList.Count");
         if (len>0) {
            int i=0;
            String auxIcon, sDA;
            boolean bSelectable, bPartition, bAlias, bGlue, bJunction;
            while (i<len) {
               sDA = c.var("Search.ResultList."+i+".DisplayAttributes");
               if (sDA.length()==6 && !sDA.equals(".>....")) {
                  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 {
                 bSelectable = bPartition = bAlias = bGlue = bJunction = false;
               }
               if (bPartition && bAlias)  {auxIcon="aliaspart.gif";  auxHint=c.toTag(c.string("OV.Browser.AliasPartitionHint")); }
               else if (bAlias)           {auxIcon="alias.gif";      auxHint=c.toTag(c.string("OV.Browser.AliasHint")); }
               else if (bPartition)       {auxIcon="partition.gif";  auxHint=c.toTag(c.string("OV.Browser.PartitionHint")); }
               else if (bGlue)            {auxIcon="glue.gif";       auxHint=c.toTag(c.string("OV.Browser.GlueHint")); }
               else if (bJunction)       {auxIcon="junction.gif"; auxHint=""; }
               else                       {auxIcon="7px_spacer.gif"; auxHint=""; } %>

               <tr bgcolor=<%= color %>>
<%             altTitle = c.toTag(c.string("OV.Browser.TypePrefix")+" "+c.var("Search.ResultList."+i+".TypeName"));
               if (bSelectable) { %>
                  <!-- a selectable object -->
<%                onClickCmd = "javascript:doTaskList(this, ['"+c.toTag(c.toScript(c.var("Search.ResultList."+i+".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("OV.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="<%= 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>
                  <%= 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 %>

         </font>
         </table>
<%    } //endif something found %>

<% } else { %>

      <!-- show enter search criterion message if not searchingOnStartup -->
      <script>
      if (OVTop.m_searchOnStartup!="true")
      {
         document.writeln('<center><table height=100% cellpadding=8>');
         document.writeln('<tr><td></td><td style="width:200px; color:red; text-align:center; valign:middle"><FONT face="Helvetica,Arial" size=-1><%= c.string("OV.Browser.ClickSearch") %></font></td></tr>');  //intentionally not calling toDisplay
         document.writeln('</table></center>');
      }
      </script>

<% } %>
<div style="display:none">
   <form name="PostData" method=post action="webacc">
   <input type=hidden name="OV.Results" id="ovresults" value=""></form>
</div>
</BODY></HTML>
