<%@ page language="java" %> 
<%@taglib uri="/WEB-INF/tld/com_iplanet_jato/jato.tld" prefix="jato"%> 
<%@taglib uri="/WEB-INF/tld/com_sun_web_ui/cc.tld" prefix="cc"%>
<%@taglib uri="/WEB-INF/lib/sa.tld" prefix="sa"%>

<jato:useViewBean className="com.sun.netstorage.mgmt.fm.storade.ui.viewbeans.admin.AgentsViewBean">

<script language="javascript">
// This function will toggle the disabled state of action buttons
// depending on single or multiple selections.

function toggleDisabledState() {
   // Action button and menu names.
   var actionMenu = "Agents.actionMenu";
   var runAgentButton = "Agents.runAgentButton";
   var modifyButton = "Agents.modifyButton";

   // Element name (prefix) of selection checkbox/radiobutton.
   var elementName = "Agents.AgentsTable.Selection";
  
   // Document form.
   var form = document.agentForm;
 
   // Flag indicating to disable action button and menu options.
   var disabled = true;
 
   // Set flags according to single or multiple selections.
   var numChecked = 0;

   for (i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];

        if (e.name.indexOf(elementName) != -1) {
             if (e.checked) {
                disabled = false;
                numChecked ++;
            }
        }
   }
  
   // Toggle action button disabled state.
   ccSetDropDownMenuOptionDisabled(actionMenu, "agentForm", disabled, 1);
   ccSetDropDownMenuOptionDisabled(actionMenu, "agentForm", disabled, 2);
   ccSetDropDownMenuOptionDisabled(actionMenu, "agentForm", disabled, 3);

   if(numChecked > 1) {
        ccSetButtonDisabled(modifyButton, "agentForm", true);
	ccSetButtonDisabled(runAgentButton, "agentForm", true);
   } else {
        ccSetButtonDisabled(modifyButton, "agentForm", disabled);
	ccSetButtonDisabled(runAgentButton, "agentForm", disabled);
   }
}
</script>

<sa:primarymasthead name="Masthead" showDefaultPageTitle="simple">
<jato:form name="agentForm" method="post">
<!-- Bread Crumb component -->

<cc:spacer name="spacer" height="15" newline="true"/>

<cc:actiontable 
 name="AgentsTable" 
 bundleID="appBundle" 
 title="table.title.agents" 
 summary="table.summary.agents" 
 empty="table.empty.agents" 
 selectionType="multiple"
 selectionJavascript="toggleDisabledState()"
 showAdvancedSortingIcon="true" 
 showLowerActions="true" 
 showPaginationControls="true" 
 showPaginationIcon="false" 
 showSelectionIcons="true" 
 page="1" />

</jato:form>
</sa:primarymasthead>
</jato:useViewBean>
