<%@  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>SelectedObjectsTitle</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>

   //------------- find OVTop ----------------
   var OVTop=top.Mainscreen.ObjectView;

   // global array of selected objects
   var selectedObjects = new Array();
   var soHashTable = new Array();

   function isAnObjectSelected()
   {
      var ret=false;
      for (i=0; i<selectedObjects.length; i++)
      {
         if (selectedObjects[i]!=null)
         {
            //found a selected object
            ret = true;
            break;
         }
      }
      return ret;
   }

   function doDeselectObject(idx)
   {
      if (idx>=0 && idx<selectedObjects.length && selectedObjects[idx]!=null)
      {
         soHashTable[selectedObjects[idx][0]] = null;  // delete hash table entry
         selectedObjects[idx] = null;                  // delete object
         displaySelectedObjects();
      }
   }

   function clearAllSelections()
   {
      selectedObjects = new Array();   // clear out global array
      soHashTable = new Array()        // clear out hash table
      displaySelectedObjects();
      OVTop.SelectedObjectsButtons.enableButtons(false);
   }

   function getAuxIcon(entry)
   {
      var auxIcon="";
      var sDA=entry[4];
      var bPartition=false;
      var bAlias=false;
      if (sDA!=null && sDA.length==4)
      {
         bPartition=(sDA.charAt(2)=="P");
         bAlias=(sDA.charAt(3)=="A");
      }

      if (bPartition && bAlias)  auxIcon = "aliaspart.gif";
      else if (bAlias)           auxIcon = "alias.gif";
      else if (bPartition)       auxIcon = "partition.gif";
      else                       auxIcon = "7px_spacer.gif";
      return auxIcon;
   }

   function displaySelectedObjects()
   {
      var imagePath = "<%= c.getModulesUrl() %>";
      var s;
      var numSelected = 0;
      OVTop.SelectedObjects.document.open();
      OVTop.SelectedObjects.document.writeln('<HTML><HEAD><TITLE>SelectedObjects</TITLE>');
      OVTop.SelectedObjects.document.writeln('<LINK href="'+imagePath+'/fw/css/osStyles.css" rel="styleSheet" type="text/css">');
      OVTop.SelectedObjects.document.writeln('\u003Cscript>');
      OVTop.SelectedObjects.document.writeln('var OVTop=top.Mainscreen.ObjectView;');
      OVTop.SelectedObjects.document.writeln('\u003C/script>');
      OVTop.SelectedObjects.document.writeln('</head>');
      OVTop.SelectedObjects.document.writeln('<LINK href="'+imagePath+'"/fw/css/osStyles.css" rel="styleSheet" type="text/css"></HEAD>');
      if (MS55)
         OVTop.SelectedObjects.document.writeln('<BODY bgcolor="#FFFFFF" style="border-style:solid; border-width:1; border-bottom-width:0; border-color:#BFBBB2;" onDragStart="OVTop.iman.cancelEvent(event)">');
      else
         OVTop.SelectedObjects.document.writeln('<BODY bgcolor="#FFFFFF">');
      OVTop.SelectedObjects.document.writeln('<table cellpadding=0 cellspacing=0>');
      for (var i=selectedObjects.length-1; i>=0; i--)
      {
         var onClickCmd = "javascript:OVTop.SelectedObjectsTitle.doDeselectObject("+i+");return false;";
         if (selectedObjects[i] != null)
         {
            numSelected++;
            OVTop.SelectedObjects.document.writeln("<tr>");
            OVTop.SelectedObjects.document.writeln("   <td><nobr>");
            OVTop.SelectedObjects.document.writeln('   <A href="#" onClick="'+onClickCmd+'" onContextMenu="'+onClickCmd+'"></A><img alt="<%= c.toTag(c.string("OV.Browser.UnselectHint")) %>" title="<%= c.toTag(c.string("OV.Browser.UnselectHint")) %>" src="'+imagePath+'/dev/images/dir/'+selectedObjects[i][2]+'" border=0><img alt="<%= c.toTag(c.string("OV.Browser.UnselectHint")) %>" title="<%= c.toTag(c.string("OV.Browser.UnselectHint")) %>" src="'+imagePath+'/fw/images/'+getAuxIcon(selectedObjects[i])+'" border=0></A>');
            OVTop.SelectedObjects.document.writeln('   <A href="#" title="<%= c.toTag(c.string("OV.Browser.UnselectHint")) %>" onClick="'+onClickCmd+'" onContextMenu="'+onClickCmd+'"><FONT face="Helvetica,Arial" size=-2>'+toDisplay(selectedObjects[i][0])+'<BR></FONT></A>');
            OVTop.SelectedObjects.document.writeln("   </nobr></td>");
            OVTop.SelectedObjects.document.writeln("</tr>");
         }
      }
      OVTop.SelectedObjects.document.writeln('</table>');
      OVTop.SelectedObjects.document.writeln('</body></html>');
      OVTop.SelectedObjects.document.close();

      OVTop.SelectedObjectsButtons.enableButtons(isAnObjectSelected());
      
      document.getElementById("numSelected").innerHTML=" "+numSelected;
   }

</script>
</HEAD>

<script>document.writeln('<body bgcolor="'+OVTop.OV_BGCOLOR+'" onLoad="javascript:OVTop.ovTitleLoaded=true">');</script>
<table height="100%" width="100%" cellspacing=0 cellpadding=0>
<tr>
<td align=left valign=center>
   <table border=0 cellspacing=0 cellpadding=0>
   <tr>
   <td class=head2 align=left valign=center>
   <nobr><%= c.toDisplay(c.string("OV.Browser.SelectedObjects")) %>&nbsp;<span id=numSelected style="font-size:11">0</span></nobr>
   </td>
   <td class=smalltext  align=left valign=center>
   <nobr>&nbsp;&nbsp;&nbsp;<%= c.toDisplay(c.string("OV.Browser.ClickToUnselect")) %></nobr>
   </td>
   </tr>
   </table>
</td>
</tr>
</table>
</body>
</HTML>
