<%@  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 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.ModifyObjectsIRFProperties&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.ModifyObjectsFilteredRightsForm.elements["removedProperties"].value = strResults;
		document.ModifyObjectsFilteredRightsForm.elements["merge"].value="base.ModifyObjectsIRF";
		document.ModifyObjectsFilteredRightsForm.elements["nextState"].value="removePropertiesFromTable";
		document.ModifyObjectsFilteredRightsForm.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.ModifyObjectsFilteredRightsForm.elements["addedProperty"].value = property;
	document.ModifyObjectsFilteredRightsForm.elements["merge"].value="base.ModifyObjectsIRF";
	document.ModifyObjectsFilteredRightsForm.elements["nextState"].value="addPropertyToTable";
	document.ModifyObjectsFilteredRightsForm.submit();
}


function collectTableData()
{

	var elementCount 	= document.forms[0].elements.length;
	var index=1;
	var RemoveCB="RemoveCheckBox:" + index;
	document.ModifyObjectsFilteredRightsForm.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;

				if(propertyName == "[Entry Rights]")
				{
					var ESupervisor = "SupervisorCheckBox:" + index;
					var EBrowse		= "BrowseCheckBox:"		+ index;
					var ECreate		= "CreateCheckBox:"		+ index;
					var ERename		= "RenameCheckBox:"		+ index;
					var EDelete		= "DeleteCheckBox:"		+ 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 + "$";
				}
				else
				{
					var PSupervisor = "SupervisorCheckBox:" + index;
   					var PCompare	= "CompareCheckBox:"	+ index;
					var PRead		= "ReadCheckBox:"		+ index;
					var PWrite		= "WriteCheckBox:"		+ index;
					var PSelf		= "SelfCheckBox:"		+ 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 + "$";

				}

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

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

     	}
  	}

}

function changeInheritedImage(index, right)
{
	var checked = document.forms[0].elements[right + "CheckBox:" + index].checked;
	var element = document.getElementsByName(right + "Image:" + index);
	if (checked == true)
		element[0].src = "<%= c.getModulesUrl() + "/dev/images/inherited.gif" %>";
	else
		element[0].src = "<%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %>";

}




</SCRIPT>
</HEAD>
<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="returnFromOS();">
<FORM name="ModifyObjectsFilteredRightsForm" 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="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.ModifyObjectsIRFTitle"));
      c.set("TaskHeader.iconUrl", "dir/rights.gif");
      c.set("TaskHeader.iconAlt", c.string("eDirRights.ModifyObjectsIRFTitle"));
      c.set("TaskHeader.HelpWindowWidth", "500");
      c.set("TaskHeader.HelpWindowHeight", "500"); %>

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

   <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" height="9" class="formdescriptextCopy">&nbsp;</TD>
	   	</TR>
  	</TABLE>
 	<TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
    	<TR bgcolor="#FFFFFF" ALIGN="LEFT">
			<TD align="left"><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">
      	<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></div>
   			</TD>
			<TD width="60%">
    			<div align="left"><b><font color="#000000"><%= c.string("eDirRights.InheritedRightsFilterHeading") %></font></b></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") %>">
               		</DIV>
		   		</TD>
            	<TD width="30%" height="17">
               		<%= c.var("Property."+c.var("i")+ ".Name") %>
            	</TD>
				<% if (c.var("Property."+c.var("i")+ ".Name").equals("[Entry Rights]")) { %>
					<TD width="60%" height="17" nowrap>
						<DIV class="smalltext2d">
							<img name="SupervisorImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Supervisor").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
			        		<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Supervisor');"><%= c.string("eDirRights.Supervisor") %>
							<img name="BrowseImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Browse").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
							<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Browse');"><%= c.string("eDirRights.Browse") %>
							<img name="CreateImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".AddSelf").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
							<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")+ "Create") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Create');"><%= c.string("eDirRights.Create") %>
							<img name="RenameImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Rename").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
							<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Rename');"><%= c.string("eDirRights.Rename") %>
							<img name="DeleteImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Delete").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
							<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Delete');"><%= c.string("eDirRights.Delete") %>
						</DIV>
		        	</TD>
				<% } else { %>
					<TD width="60%" height="17" nowrap>
						<DIV class="smalltext2d">
							<img name="SupervisorImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Supervisor").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
			        		<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Supervisor');"><%= c.string("eDirRights.Supervisor") %>
							<img name="CompareImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Compare").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
							<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Compare');"><%= c.string("eDirRights.Compare") %>
							<img name="ReadImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Read").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
							<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Read');"><%= c.string("eDirRights.Read") %>
							<img name="WriteImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Write").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
							<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Write');"><%= c.string("eDirRights.Write") %>
							<img name="SelfImage:<%= c.var("i") %>" src="<% if (c.var("Property."+c.var("i")+ ".Self").equals("true")) { %><%= c.getModulesUrl() + "/dev/images/inherited.gif" %><% } else { %><%= c.getModulesUrl() + "/dev/images/downArrowLine.gif" %><% } %>">
							<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") %>" onClick="changeInheritedImage('<%= c.var("i") %>', 'Self');"><%= c.string("eDirRights.Self") %>
						</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" tabindex="1" onClick="collectTableData()" alt="<%= c.string("eDirRights.ModifyObjectsIRFTitle") %>" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.OK.image") %>" border=0><jsp:include page='<%= c.getPath("dev/Cancel_inc.jsp") %>' flush="true" />
         </TD>
      </TR>
   </TABLE>
   </div>
</FORM>
</BODY></HTML>
