<%-- #BeginRZ-PageHeader --%>
<%@ page language="java" %>
<% String rzmodule = "calendar_groups"; %>
<%@ include file = "/util/setup_editform_header.jsp" %>
<%-- #EndRZ-PageHeader --%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../calendar_style.css" rel="stylesheet" type="text/css">
<title>Edit Calendar Groups</title>
<style>
select {
  width="3 in";
}
</style>
<%-- #RevizeProperties USE REVIZE MENU (DOCUMENT PROPERTIES) TO EDIT DATA BELOW:
status=edit
options=
server=localhost:8080
projectName=calendar_app
label=calendar_groups_editform
location=calendar_app/calendar_lists/calendar_groups-editform.jsp
version=6
docType=template
subType=unique
moduleName=
fieldName=
channels=revize|
description=
--%></head>
<script>
/*-----------------------------------------------------------------------------
Global variables
-----------------------------------------------------------------------------*/
var topframe = opener.topframe;	//calendar_app/index.html

/*-----------------------------------------------------------------------------
Function which validates the form for blank or duplicate group name
-----------------------------------------------------------------------------*/
function validateForm()
{
	glist = document.XMLForm.group_list.value;
	glist = glist.substring(1,(glist.length-1));
	if(glist!='') groupArr = glist.split(",");

	//----- Group name can not be blank
	if(document.XMLForm.group_name.value == '')
		return topframe.RZfieldError(document.XMLForm.group_name,
		       "Error! Please Enter Group Name",
		       window);

	//----- Group name must be unique
	else if(document.XMLForm.group_action.value == 'create')
	{
		if(!topframe.checkUniqueValue(groupArr, document.XMLForm.group_name.value))
			return topframe.RZfieldError(document.XMLForm.group_name,
			       "Error! Please specify another calendar\nGroup Already Exists!",
			       window);
	}

	//----- Unselect headers
	deselectValue(document.XMLForm.administrators);
	deselectValue(document.XMLForm.editors);

	//----- Indicate data not up-to-date
	topframe.RZ.calendar.isDataLoaded = false;

	return true;
}

/*-----------------------------------------------------------------------------
create a backup opener for this window.
opener is made null for implementing back for exit/save buttons
-----------------------------------------------------------------------------*/
function createBackupOpenerObject()
{
	if ( typeof opener != 'undefined' && opener != null )
	{
		self.bkpOpener = new Object();
		self.bkpOpener = opener;
		opener = null;
	}
}
/*------------------------------------------------------------------------------
reset opener object from backup opener object
called at unload of page
------------------------------------------------------------------------------*/
function resetOpenerFromBkpOpener()
{
	if ( typeof opener == 'undefined' || opener == null )
		opener = self.bkpOpener;
}
/*----------------------------------------------------------------------------*/
</script>
<%
	Vector groupList = new Vector(0, 1);
%>

<body class="adminPage" onLoad="createBackupOpenerObject();" onUnload="resetOpenerFromBkpOpener();">
<%@ include file = "/util/setup_editform_javascript.jsp" %>

<form name="XMLForm" method="post" action="" onSubmit="return validateForm()">
  <input name="XMLString" type="hidden" />
  <input name="group_list" type="hidden" value="" />
  <input name="group_action" type="hidden" value="" />
  	<rz:list module="calendar_groups" sort="group_name asc" output="none" options="" filter="">
  	<% while ( rz.listnext() ){ %>
  	<rz:listbody>
  		<%
  			groupList.add(rz.fetch("calendar_groups", "group_name"));
  		%>
  	</rz:listbody>
  	<%}%>
  	</rz:list>
  	<script>
  	document.XMLForm.group_list.value = "<%= groupList %>";
  	document.XMLForm.group_action.value = RZ.editaction;
	</script>
  <table border="0" align="center" cellpadding="2" cellspacing="3">
    <tr>
      <td align="center" colspan="2"><h3>
        <font color="#666666" face="Arial, Helvetica, sans-serif"><strong>
		<a href="javascript:topframe.topframe.setDebug(window)"><font color="#FFFFFF">&nbsp;&nbsp;&nbsp;</font></a>
		Calendar Group Properties
		<a href="javascript:topframe.RZstartDebugger()"><font color="#FFFFFF">&nbsp;&nbsp;&nbsp;</font></a>
		<script>
		if (topframe.RZ.debug) document.write('<br /><font color="red">Debug Mode</font>')
		</script>
		</strong></font></h3>
	  </td>
    </tr>
    <tr>
      <td valign="top"><font size="2" face="helvetica,arial" color="#616055"><strong>Group Name: </strong></font></td><td valign="top">
      <rz:fetch
 	module="calendar_groups" field="group_name" output="html"
 	options="size=44,wrap=Virtual"/></td>
    </tr>

<!-- group default administrator and default editor do not inherit for new calendars, so it is disabled
    <tr><td height="20" colspan="2"></td></tr>
	<tr>
      <td valign="top"><font size="2" face="helvetica,arial" color="#616055"><strong>Default<br>Administrators: </strong></font></td>
      <td valign="top">
        <select name="administrators" multiple>
			<option value="">-- ROLES --</option>
			<%
			String[] roles = rz.getroles();
			String[] users = rz.getusers();
			for (int i=0;i<roles.length;i++)
			{
				if (roles[i].equals("workflow_developer")) continue;
				%><option value="<%=roles[i]%>"><%=roles[i]%></option><%
			}
			%>
			<option value="">-- USERS --</option>
			<%
			for (int i=0;i<users.length;i++)
			{
			  %><option value="_<%=users[i]%>"><%=users[i]%></option><%
			}
			%>
		</select>
	  </td>
	</tr>
    <tr><td height="20" colspan="2"></td></tr>
	<tr>
      <td valign="top"><font size="2" face="helvetica,arial" color="#616055"><strong>Default<br>Editors: </strong></font></td>
      <td valign="top">
      	<select name="editors" multiple>
			<option value="">-- ROLES --</option>
			<%
			for (int i=0;i<roles.length;i++)
			{
				if (roles[i].equals("workflow_developer")) continue;
				%><option value="<%=roles[i]%>"><%=roles[i]%></option><%
			}
			%>
			<option value="">-- USERS --</option>
			<%
			for (int i=0;i<users.length;i++)
			{
			  %><option value="_<%=users[i]%>"><%=users[i]%></option><%
			}
			%>
        </select>
      </td>
	</tr>
-->
    <tr><td height="20" colspan="2"></td></tr>
    <tr>
      <td align="center" colspan="2">
<%-- #BeginRZ-ActionImage --%>
<%-- Option:type=EditFormSaveImage --%>
<%-- Option:imageSrcURL=images/edit/save.gif --%>
<!-- REVIZE SAVE NEW OR UPDATED CONTENT -->
<script language="JavaScript" type="text/JavaScript">
RZ.nexturl = RZ.page.pathname + '/calendar_groups.html';
RZ.img = '<rz:link file="/calendar_app/images/buttons/save.gif" border="0" />';
RZ.options = '';
if (typeof RZaction != 'undefined') RZaction('save');
</script>
<%-- #EndRZ-ActionImage --%>
<%-- #BeginRZ-ActionImage --%>
<%-- Option:type=EditFormCancelImage --%>
<%-- Option:imageSrcURL=images/edit/cancel.gif --%>
<!-- REVIZE CANCEL UPDATE AND RETURN TO PRIOR PAGE -->
<script language="JavaScript" type="text/JavaScript">
RZ.nexturl = RZ.page.pathname + '/calendar_groups.html';
RZ.img = '<rz:link file="/calendar_app/images/buttons/cancel.gif" border="0" />';
RZ.options = '';
if (typeof RZaction != 'undefined') RZaction('cancel');
</script>
<%-- #EndRZ-ActionImage --%></td>

	</tr>
  </table>
</form>
</body>
</html>