<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils" %>
<%   JSPConduit c = JSPConduit.getJSPConduit(request);
   c.stringTable("DevResources");
   c.stringTable("BaseResources");
   c.stringTable("FwResources"); %>
<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<HTML><HEAD><TITLE></TITLE>
<LINK rel='stylesheet' href='<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>'>
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/OSScripts_inc.jsp") %>' flush="true" />
<SCRIPT language="JavaScript">



function setFocusToFormElement()
{
	var elementCount 	= document.forms[0].elements.length;
   var focusSet = false;

	for (var i = 0; i < elementCount; i++)
  	{
  		if (document.forms[0].elements[i].type == "checkbox")
    	{
        	if (document.forms[0].elements[i].name.search("RowCheckBox") != -1)
         	{
            	document.RightsToOtherObjectsForm.elements[i].focus();
               focusSet = true;
	   			break;
        	}
     	}
  	}

   if(!focusSet)
   {
      document.getElementById("removeButton").focus();
   }
}


function assignedRightsSelected(object)
{
	var strResults="";
	strResults += urlEncode(object);
	document.RightsToOtherObjectsForm.elements["otherObject"].value = strResults;
	document.RightsToOtherObjectsForm.elements["merge"].value="base.RightsToOtherObjectsAssignedRights";
	document.RightsToOtherObjectsForm.elements["nextState"].value="buildInitialPropertiesTable";
	document.RightsToOtherObjectsForm.submit();
}

function addButtonSelected(controlName, results)
{
	var strResults="";
	for(i=0;i < results.length; i++)
	{
		if(i > 0)
		{
			strResults += "$";
		}

		strResults += urlEncode(results[i]);
	}

	document.RightsToOtherObjectsForm.elements["addedObjects"].value = strResults;
	document.RightsToOtherObjectsForm.elements["merge"].value="base.RightsToOtherObjects";
	document.RightsToOtherObjectsForm.elements["nextState"].value="addObjectsToTable" ;
	document.RightsToOtherObjectsForm.submit();
}


function removeButtonSelected()
{
	var strResults="";

	if(checkBoxStatus() == true)
	{
		var elementCount = document.forms[0].elements.length;

		for(var i = 0; i < elementCount; i++)
		{
			if(document.forms[0].elements[i].type == "checkbox")
			{

				if (document.forms[0].elements[i].checked)
				{
					var objectName = document.forms[0].elements[i].value;

					if(i > 0)
					{
						strResults += "$";
					}

					strResults += urlEncode(objectName);
				}
			}

		}

		document.RightsToOtherObjectsForm.elements["removedObjects"].value = strResults;
		document.RightsToOtherObjectsForm.elements["merge"].value="base.RightsToOtherObjects";
		document.RightsToOtherObjectsForm.elements["nextState"].value="removeObjectsFromTable";
		document.RightsToOtherObjectsForm.submit();

	}
}



// Returns true if any scope checkboxes are checked
function checkBoxStatus()
{
	var elementCount 	= document.forms[0].elements.length;

	for (var i = 0; i < elementCount; i++)
  	{
  		if (document.forms[0].elements[i].type == "checkbox")
    	{
        	if (document.forms[0].elements[i].name.search("RowCheckBox") != -1)
         	{
            	if (document.forms[0].elements[i].checked)
            	{
               		return true;
            	}
        	}
     	}
  	}

	return false;
}

function applySelected()
{
	document.RightsToOtherObjectsForm.elements["merge"].value="base.RightsToOtherObjects";
	document.RightsToOtherObjectsForm.elements["nextState"].value="apply";
	document.RightsToOtherObjectsForm.submit();
}

</SCRIPT>
</HEAD>
<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onload="returnFromOS();setFocusToFormElement();">
<FORM name="RightsToOtherObjectsForm" method=post action="webacc">
   <input type=hidden name="taskId" value="<%= c.var("taskId") %>">
   <input type=hidden name="merge" value="dev.GenConf">
   <input type=hidden name="error" value="dev.GenErr">
   <input type=hidden name="User.context" value="<%= c.var("User.context") %>">
   <input type=hidden name="nextState" value="update">
   <input type=hidden name="addedObjects" value="">
   <input type=hidden name="removedObjects" value="">
   <input type=hidden name="otherObject" value="">
   <!-- End of hidden tags -->



   <% c.set("TaskHeader.title", c.string("eDirRights.RightsToOtherObjectsTitle"));
      c.set("TaskHeader.iconUrl", "dir/rights.gif");
      c.set("TaskHeader.iconAlt", c.string("eDirRights.RightsToOtherObjectsTitle"));
      c.set("TaskHeader.helpFile", "base/rightstootherobjects.html");
      c.set("TaskHeader.HelpWindowWidth", "500");
      c.set("TaskHeader.HelpWindowHeight", "500"); %>

   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" />
   <br/>
   <iman:messagebar />

   <BR>
	<TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
   		<TR bgcolor="#FFFFFF">
	    	<TD colspan="4" nowrap valign="top" class="mediumtext"><b><%= c.string("eDirRights.TrusteeNameLabel") %></b>&nbsp;<%= c.var("TrusteeDisplayName") %></TD>
		</TR>
	    <TR bgcolor="#FFFFFF">
	    	<TD colspan="4" nowrap valign="top" height="9" class="formdescriptextCopy">&nbsp;</TD>
	   	</TR>
  	</TABLE><% if(c.var("RightsDataDirty").equals("true")) { %><div id="notice" style="display: block">
     <div class="head4" style="margin-bottom: 0.5em;">
				<img height="32" width="32" src="<%= c.getModulesUrl() %>/dev/images/notice32.gif" align="absmiddle" border="0"></a> <span class="typegold1"><%= c.string("eDirRights.Notice") %></span>
               <b><%= c.string("eDirRights.UnsavedWarningPart1") %></b></div>
			   <div class="mediumtext" style="margin-left: 2.8em; margin-bottom: 2em; line-height: 1.3em; width: 60%">
				<%= c.string("eDirRights.UnsavedWarningPart2") %></div>
		</div>
   <% } %>
 	<TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
    	<TR bgcolor="#FFFFFF" ALIGN="RIGHT">
		<TD align="left"><a name="removeButton" id="removeButton" href="javascript:removeButtonSelected()"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.RemoveSelected.image") %>"  alt="<%= c.string("Button.Remove.alt") %>" title="<%= c.string("Button.Remove.alt") %>" border=0 align="absmiddle"></a></TD>
		<TD colspan="1">&nbsp;</TD>
		    <TD  valign="top">
				<% c.set("OS.Control", "RowCheckBox");
				   c.set("OS.TypeFilter", "*,[root]");
				   c.set("OS.Mode", "browse");
				   c.set("OS.MultiSelect", "true");
				   c.set("OS.AltText", c.string("eDirRights.AddObjectAlt"));
				   c.set("OS.IconName", c.plus("dev/images/", c.string("Button.AddObject.image")));
				   c.set("OS.CallBack", "addButtonSelected");
               c.set("OS.Windowed", "true");
            %>
				<jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
      		</TD>
    	</TR>
	</TABLE>
   <TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
      	<TR bgcolor="#DFDDD5">
      		<TD width="5%">&nbsp;</TD>
   			<TD width="45%" height="24">
     			<div align="left"><font color="#FFFFFF"><b><font color="#000000"><%= c.string("eDirRights.ObjectNameHeading") %></font></b></font></div>
   			</TD>
			<TD width="45%">&nbsp;</TD>
 		</TR>
    	<!-- Load table info -->
      	<% c.set("i", "1");
	  	   c.set("count", c.var("Object.Member.Count"));
      	   c.set("color", "#FFFFFF");
    	   while (c.lte(c.var("i"), c.var("count"))) { %>
	  		<TR bgcolor=<%= c.var("color") %>>
	    		<TD width="5%" height="17">
            		<DIV align="left">
		        		<input type="checkbox" name="RowCheckBox" width="16" height="16" value="<%= c.var("Object.Member."+c.var("i")+ ".FullName") %>">
               		</DIV>
		   		</TD>		   		
            	<TD width="45%" height="17">
            	    <img src="<%= c.getModulesUrl()+"/dev/images/dir/"+ c.var("Object.Member."+c.var("i")+ ".ImageName")%>" />
               		<%= c.var("Object.Member."+c.var("i")+ ".FullName") %>
            	</TD>
				<TD width="45%"	height="17">
					<a href="#" onClick="javascript:assignedRightsSelected('<%= c.toHTML((c.toScript(c.var("Object.Member."+c.var("i")+ ".FullName")))) %>');return false"><%= c.string("eDirRights.AssignedRightsHeading") %></a>
				</TD>
        	</TR>
	   	<% c.inc("i");
           if (c.var("color").equals("#FFFFFF")) {
	   		   c.set("color", "#EFEEE9");
	       } else {
	    	   c.set("color", "#FFFFFF");
	       }
   	  	   } %>
	</TABLE>
	<p align="center">&nbsp;</p>
   <BR>
   <div class="ruleabove">
   <TABLE width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
  		<TR>
      	<TD align="left">
		   <INPUT type=image name="Modify" alt="<%= c.string("eDirRights.RightsToOtherObjectsTitle") %>" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.OK.image") %>" border=0><jsp:include page='<%= c.getPath("dev/Cancel_inc.jsp") %>' flush="true" />
         &nbsp;<A href="javascript:applySelected();" ><img src="<%= c.getModulesUrl() %>/dev/images/<%= c.string("Button.Apply.image") %>" alt="<%= c.string("Button.Apply.alt") %>" border=0 ></a>
         </TD>
      </TR>
   </TABLE>
   </div>
</FORM>
<jsp:include page='<%= c.getPath("dev/OSFooter_inc.jsp") %>' flush="true" />
</BODY></HTML>
