<%@  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"); %>
<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">


var myWindow;  

function setFocusToFormElement()
{
	
	var elementCount 	= document.forms[0].elements.length;
	var index=1;
	var RemoveCB="RemoveCheckBox:" + index;
  
	for (var i = 0; i < elementCount; i++)
  	{
  		if (document.forms[0].elements[i].type == "checkbox")
    	{
        	if (document.forms[0].elements[i].name.search(RemoveCB) != -1)
         	{
            	document.ModifyTrusteesAssignedRightsForm.elements[i].focus();	
				break;
        	}										

     	}
  	}

}

function addButtonSelected()
{
	var swidth = 325;
	var sheight = 375;
	var sleft = (screen.availWidth-swidth)/2;	
	var stop = (screen.availHeight-sheight)/2;	
	var settings = "left="+sleft+", top="+stop+",width="+swidth+",height="+sheight;
	
	var url = "webacc?taskId=<%= c.var("taskId") %>&merge=base.ModifyTrusteesAssignedRightsProperties&User.context=<%= c.toHTML(c.var("User.context")) %>&nextState=buildPropertiesList&showProperties=false";
	collectTableData();


	if (!myWindow || myWindow.closed)
	{
		myWindow = window.open(url,"name",settings+", toolbar=0, status=0, resizable=1, scrollbars=0,menubar=0,directories=0,location=0");

		if(myWindow.opener == null)
		{
			myWindow.opener = self;
		}
	}
	else
	{
		myWindow.focus();
	}


}


function removeButtonSelected()
{
	var strResults="";
	var index=1;
	var RemoveCB="RemoveCheckBox:" + index;

	collectTableData();

	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].name.search(RemoveCB) != -1)
				{
					if (document.forms[0].elements[i].checked)
					{
						var propertyName = document.forms[0].elements[i].value;

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

						strResults += urlEncode(propertyName);
					}

					index++;
					RemoveCB = "RemoveCheckBox:" + index;
				}
			}

		}



		document.ModifyTrusteesAssignedRightsForm.elements["removedProperties"].value = strResults;
		document.ModifyTrusteesAssignedRightsForm.elements["merge"].value="base.ModifyTrusteesAssignedRights";
		document.ModifyTrusteesAssignedRightsForm.elements["nextState"].value="removePropertiesFromTable";
		document.ModifyTrusteesAssignedRightsForm.submit();

	}
}



function checkBoxStatus()
{
	var elementCount 	= document.forms[0].elements.length;
	var index=1;
	var RemoveCB="RemoveCheckBox:" + index;

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

				index++;
				RemoveCB = "RemoveCheckBox:" + index;

        	}

     	}
  	}

	return false;
}


function setAddedProperty(property)
{
	document.ModifyTrusteesAssignedRightsForm.elements["addedProperty"].value = property;
	document.ModifyTrusteesAssignedRightsForm.elements["merge"].value="base.ModifyTrusteesAssignedRights";
	document.ModifyTrusteesAssignedRightsForm.elements["nextState"].value="addPropertyToTable";
	document.ModifyTrusteesAssignedRightsForm.submit();
}


function collectTableData()
{

	var elementCount 	= document.forms[0].elements.length;
	var index=1;
	var RemoveCB="RemoveCheckBox:" + index;
	document.ModifyTrusteesAssignedRightsForm.elements["propertyRights"].value = "";


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

        	if (document.forms[0].elements[i].name.search(RemoveCB) != -1)
         	{

				var propertyName = document.forms[0].elements[i].value.substring(0,document.forms[0].elements[i].value.lastIndexOf(":"));

				if(propertyName == "[Entry Rights]")
				{
					var ESupervisor = "SupervisorCheckBox:" + index;
					var EBrowse		= "BrowseCheckBox:"		+ index;
					var ECreate		= "CreateCheckBox:"		+ index;
					var ERename		= "RenameCheckBox:"		+ index;
					var EDelete		= "DeleteCheckBox:"		+ index;
					var EInherit	= "InheritCheckBox:"	+ index;
					var EDynamic	= "DynamicCheckBox:"	+ index;
					var ENested     = "NestedCheckBox:"     + index;
					propertyName += "+";
					propertyName += document.forms[0].elements[ESupervisor].checked + ":";
					propertyName += document.forms[0].elements[EBrowse].checked + ":";
					propertyName += document.forms[0].elements[ECreate].checked + ":";
					propertyName += document.forms[0].elements[ERename].checked + ":";
					propertyName += document.forms[0].elements[EDelete].checked + ":";
					propertyName += document.forms[0].elements[EInherit].checked + ":";
					propertyName += document.forms[0].elements[EDynamic].checked + ":";
					propertyName += document.forms[0].elements[ENested].checked + "$";
				}
				else
				{
					var PSupervisor = "SupervisorCheckBox:" + index;
   					var PCompare	= "CompareCheckBox:"	+ index;
					var PRead		= "ReadCheckBox:"		+ index;
					var PWrite		= "WriteCheckBox:"		+ index;
					var PSelf		= "SelfCheckBox:"		+ index;
					var PInherit	= "InheritCheckBox:"	+ index;
					var PDynamic	= "DynamicCheckBox:"	+ index;
					var PNested     = "NestedCheckBox:"     + index;

					propertyName += "+";
					propertyName += document.forms[0].elements[PSupervisor].checked + ":";
					propertyName += document.forms[0].elements[PCompare].checked + ":";
					propertyName += document.forms[0].elements[PRead].checked + ":";
					propertyName += document.forms[0].elements[PWrite].checked + ":";
					propertyName += document.forms[0].elements[PSelf].checked + ":";
					propertyName += document.forms[0].elements[PInherit].checked + ":";
					propertyName += document.forms[0].elements[PDynamic].checked + ":";
					propertyName += document.forms[0].elements[PNested].checked + "$";

				}

				document.ModifyTrusteesAssignedRightsForm.elements["propertyRights"].value += propertyName;

				index++;
				RemoveCB = "RemoveCheckBox:" + index;
        	}

     	}
  	}

}


function changeValues(inheritCB)
{
	var newCBState = inheritCB.checked;
	var currentCBValue = inheritCB.value;
	var currentCBName  = inheritCB.name;
	var index = currentCBName.substring(currentCBName.indexOf(":")+1,currentCBName.length);
	var propertyName = currentCBValue.substring(0,currentCBValue.lastIndexOf(":"));
	var Remove = "RemoveCheckBox:" + index;

	inheritCB.value = propertyName + ":" + newCBState;
	document.forms[0].elements[Remove].value = propertyName + ":" + newCBState;

	if(propertyName == "[Entry Rights]")
	{
		var ESupervisor = "SupervisorCheckBox:" + index;
		var EBrowse		= "BrowseCheckBox:"		+ index;
		var ECreate		= "CreateCheckBox:"		+ index;
		var ERename		= "RenameCheckBox:"		+ index;
		var EDelete		= "DeleteCheckBox:"		+ index;
		var EDynamic   	= "DynamicCheckBox:"	+ index;
		var ENested     = "NestedCheckBox:"     + index;
		document.forms[0].elements[ESupervisor].value = propertyName + ":" + newCBState;
		document.forms[0].elements[EBrowse].value = propertyName + ":" + newCBState;
		document.forms[0].elements[ECreate].value = propertyName + ":" + newCBState;
		document.forms[0].elements[ERename].value = propertyName + ":" + newCBState;
		document.forms[0].elements[EDelete].value = propertyName + ":" + newCBState;
		document.forms[0].elements[EDynamic].value= propertyName + ":" + newCBState;
		document.forms[0].elements[ENested].value= propertyName + ":" + newCBState;
	}
	else
	{
		var PSupervisor = "SupervisorCheckBox:" + index;
		var PCompare	= "CompareCheckBox:"	+ index;
		var PRead		= "ReadCheckBox:"		+ index;
		var PWrite		= "WriteCheckBox:"		+ index;
		var PSelf		= "SelfCheckBox:"		+ index;
		var PDynamic   	= "DynamicCheckBox:"	+ index;
		var PNested     = "NestedCheckBox"      + index;
		document.forms[0].elements[PSupervisor].value = propertyName + ":" + newCBState;
		document.forms[0].elements[PCompare].value = propertyName + ":" + newCBState;
		document.forms[0].elements[PRead].value = propertyName + ":" + newCBState;
		document.forms[0].elements[PWrite].value = propertyName + ":" + newCBState;
		document.forms[0].elements[PSelf].value = propertyName + ":" + newCBState;
		document.forms[0].elements[PDynamic].value = propertyName + ":" + newCBState;
		document.forms[0].elements[PNested].value = propertyName + ":" + newCBState;
	}

}

function closeSelected()
{
	document.ModifyTrusteesAssignedRightsForm.elements["merge"].value="base.ModifyTrustees";
	document.ModifyTrusteesAssignedRightsForm.elements["nextState"].value="refresh";
	document.ModifyTrusteesAssignedRightsForm.submit();
}


</SCRIPT>
</HEAD>
<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="setFocusToFormElement();">
<FORM name="ModifyTrusteesAssignedRightsForm" method=post action="webacc">
   <input type=hidden name="taskId" value="<%= c.var("taskId") %>">
   <input type=hidden name="merge" value="base.ModifyTrustees">
   <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="updateAssignedRights">
   <input type=hidden name="removedProperties" value="">
   <input type=hidden name="addedProperty" value="">
   <input type=hidden name="showProperties" value="">
   <input type=hidden name="propertyRights" value="">
   <!-- End of hidden tags -->

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

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

   
   <BR>
	<TABLE width="100%" border="0" cellspacing="0" cellpadding="3" height="69">
   		<TR bgcolor="#FFFFFF">
	    	<TD colspan="4" nowrap valign="top" class="mediumtext"><b><%= c.string("eDirRights.ObjectNameLabel") %></b>&nbsp;<%= c.var("ObjectDisplayName") %></TD>
		</TR>
   		<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>
 	<TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
    	<TR bgcolor="#FFFFFF" ALIGN="LEFT">
        	<TD><a 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 ></a></TD>
      		<TD valign="top" colspan="3" ALIGN="RIGHT" nowrap>  
         		<a href="javascript:addButtonSelected()"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.AddProperty.image") %>" alt="<%= c.string("eDirRights.AddPropertyAlt") %>" title="<%= c.string("eDirRights.AddPropertyAlt") %>" border=0></a>
      		</TD>
    	</TR>
	</TABLE>
	<TABLE width="100%" border="0" cellspacing="0" cellpadding="3" height="69">
      	<TR bgcolor="#DFDDD5"> 
      		<TD width="5%">&nbsp;</TD>
   			<TD width="30%" height="24"> 
     			<div align="left"><b><font color="#000000"><%= c.string("eDirRights.PropertyNameHeading") %></font></b></font></div>
   			</TD>
			<TD width="60%">
    			<div align="left"><b><font color="#000000"><%= c.string("eDirRights.AssignedRightsHeading") %></font></b></font></div>
			</TD>
			<TD width="5%">
    			<div align="left"><b><font color="#000000"><%= c.string("eDirRights.InheritHeading") %></font></b></font></div>
			</TD>
 		</TR>
    	<!-- Load table info -->
      	<% c.set("i", "1"); 
	  	   c.set("count", c.var("Property.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="RemoveCheckBox:<%= c.var("i") %>" width="16" height="16" value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"> 
               		</DIV>
		   		</TD>
            	<TD width="30%" height="17">
					<DIV class="smalltext2d">
               			<%= c.var("Property."+c.var("i")+ ".Name") %>
					</DIV>
            	</TD>
				<% if (c.var("Property."+c.var("i")+ ".Name").equals("[Entry Rights]")) { %>
					<TD width="60%" height="17" nowrap>
						<DIV class="smalltext2d">
			        		<input type="checkbox" name="SupervisorCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Supervisor").equals("true")) { %> CHECKED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Supervisor") %>
							<input type="checkbox" name="BrowseCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Browse").equals("true")) { %> CHECKED <% } %>value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Browse") %>
							<input type="checkbox" name="CreateCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".AddSelf").equals("true")) { %> CHECKED <% }     if (c.var("No_Create").equals("true")) { %> DISABLED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Create") %>
							<input type="checkbox" name="RenameCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Rename").equals("true")) { %> CHECKED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Rename") %>
							<input type="checkbox" name="DeleteCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Delete").equals("true")) { %> CHECKED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Delete") %>
							<input type="checkbox" name="DynamicCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Dynamic").equals("true")) { %> CHECKED <% }     if (c.var("No_Dynamic").equals("true")) { %> DISABLED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Dynamic") %>
							<input type="checkbox" name="NestedCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Nested").equals("true")) { %> CHECKED <% } if (c.var("No_Nested").equals("true")) { %> DISABLED <% }   %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Nested") %>
						</DIV>
		        	</TD>
					<TD width="5%" height="17" nowrap>
					   <DIV class="smalltext2e">
					  	<input type="checkbox" onClick="changeValues(this)" name="InheritCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Inheritable").equals("true")) { %> CHECKED <% }     if (c.var("Property."+c.var("i")+ ".DisableInherit").equals("true")) { %> DISABLED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>">
					   </DIV>
					</TD>
				<% } else { %>
					<TD width="60%" height="17" nowrap>
						<DIV class="smalltext2d">
			        		<input type="checkbox" name="SupervisorCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Supervisor").equals("true")) { %> CHECKED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Supervisor") %>
							<input type="checkbox" name="CompareCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Compare").equals("true")) { %> CHECKED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Compare") %>
							<input type="checkbox" name="ReadCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Read").equals("true")) { %> CHECKED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Read") %>
							<input type="checkbox" name="WriteCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Write").equals("true")) { %> CHECKED <% } %>  value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Write") %>
							<input type="checkbox" name="SelfCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Self").equals("true")) { %> CHECKED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Self") %>
							<input type="checkbox" name="DynamicCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Dynamic").equals("true")) { %> CHECKED <% }     if (c.var("No_Dynamic").equals("true")) { %> DISABLED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Dynamic") %>
							<input type="checkbox" name="NestedCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Nested").equals("true")) { %> CHECKED <% } if (c.var("No_Nested").equals("true")) { %> DISABLED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>"><%= c.string("eDirRights.Nested") %>
						</DIV>
					</TD>
					<TD width="5%" height="17" nowrap>
					   <DIV class="smalltext2e">
					  	<input type="checkbox" onClick="changeValues(this)" name="InheritCheckBox:<%= c.var("i") %>" width="16" height="16" <% if (c.var("Property."+c.var("i")+ ".Inheritable").equals("true")) { %> CHECKED <% }      if (c.var("Property."+c.var("i")+ ".DisableInherit").equals("true")) { %> DISABLED <% } %> value="<%= c.var("Property."+c.var("i")+ ".Name") %>:<%= c.var("Property."+c.var("i")+ ".Inheritable") %>">
					   </DIV>
					</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" onClick="collectTableData()" alt="<%= c.string("Button.Done.alt") %>" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Done.image") %>" border=0>
               &nbsp;<A HREF="#" onClick="javascript:closeSelected();return false"><IMG name="Cancel" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Cancel.image") %>" alt="<%= c.string("Button.Cancel.alt") %>" title="<%= c.string("Button.Cancel.alt") %>" border=0></A>
         	</TD>
      </TR>
   </TABLE>
   </div>
</FORM>
</BODY></HTML>
