Index: trunk/calendar/inc/class.uicalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.uicalendar.inc.php	(revision 2748)
+++ trunk/calendar/inc/class.uicalendar.inc.php	(revision 2802)
@@ -4897,16 +4897,16 @@
 				$this->index();
 			}
-			
+
 			if(isset($param['event']))
 			{
 				$event = $param['event'];
 			}
-			
+
 			$hourformat = substr($this->bo->users_timeformat,0,1);
-			
+
 			// $sb = CreateObject('phpgwapi.sbox');
 			$sb = CreateObject('phpgwapi.sbox2');
 			$jscal = CreateObject('phpgwapi.jscalendar');	// before phpgw_header() !!!
-			
+
 			//unset($GLOBALS['phpgw_info']['flags']['noheader']);
 			//unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
@@ -4915,5 +4915,5 @@
 			$GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding event');
 			if ($param['plain'] != "True"){
-			//	$GLOBALS['phpgw']->common->phpgw_header();
+				//	$GLOBALS['phpgw']->common->phpgw_header();
 			}
 			else{
@@ -4932,5 +4932,5 @@
 			$p->set_block('edit','list','list');
 			$p->set_block('edit','hr','hr');
-			
+
 			$vars = Array(
 				'font'			=> $this->theme['font'],
@@ -4939,16 +4939,16 @@
 				'accounts_link'		=> $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'),
 				'common_hidden'	=> '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n"
-					. '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n"
-					. '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n"
-					. ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n":
-					(@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":''))
-					. (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']?
-					'<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''),
+				. '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n"
+				. '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n"
+				. ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n":
+				(@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":''))
+				. (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']?
+				'<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''),
 				'errormsg'		=> ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'')
 			);
-			
+
 			$p->set_var($vars);
 
-// Brief Description
+			// Brief Description
 			$var['title'] = Array(
 				'tr_color' => $this->theme['th_bg'],
@@ -4957,5 +4957,5 @@
 			);
 
-// Full Description
+			// Full Description
 			$var['description'] = Array(
 				'field'	=> lang('Full Description'),
@@ -4963,5 +4963,5 @@
 			);
 
-// Display Categories
+			// Display Categories
 			if(strpos($event['category'],','))
 			{
@@ -4986,5 +4986,5 @@
 			);
 
-// Location
+			// Location
 			$var['location'] = Array(
 				'field'	=> lang('Location'),
@@ -4992,10 +4992,10 @@
 			);
 
-// Date
+			// Date
 
 			$start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
 			$var['startdate'] = Array(
 				'field'	=> lang('Start Date'),
-/*
+			/*
 				'data'	=> $GLOBALS['phpgw']->common->dateformatorder(
 				   $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')),
@@ -5003,9 +5003,9 @@
 				   $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d'))
 				)
-*/
+			*/
 				'data' => $jscal->input('start[str]',$start)
 			);
 
-// Time
+			// Time
 			if ($this->bo->prefs['common']['timeformat'] == '12')
 			{
@@ -5018,9 +5018,9 @@
 			);
 
-// End Date
+			// End Date
 			$end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
 			$var['enddate'] = Array(
 				'field'	=> lang('End Date'),
-/*
+			/*
 				'data'	=> $GLOBALS['phpgw']->common->dateformatorder(
 				   $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')),
@@ -5028,9 +5028,9 @@
 				   $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d'))
 				)
-*/
+			*/
 				'data' => $jscal->input('end[str]',$end)
 			);
 
-// End Time
+			// End Time
 			if ($this->bo->prefs['common']['timeformat'] == '12')
 			{
@@ -5043,5 +5043,5 @@
 			);
 
-// Priority
+			// Priority
 			$var['priority'] = Array(
 				'field'	=> lang('Priority'),
@@ -5051,6 +5051,6 @@
 			// Access
 			$var['access'] = Array(
-			'field' => lang('Type'),
-			'data'  => '<select onchange="javascript:changeViewMode(this.value);" id="cal[type]" name="cal[type]" '.($event['type'] == 'H'?'DISABLED':'').'><option value="normal" '.(($event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'.lang('Normal').'</option><option value="private" '.((!$event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'. lang('Restrict').'</option><option value="privateHiddenFields" '.($event['type']=='P'?'SELECTED':'').' >'. lang('Private').'</option><option value="hourAppointment" '.($event['type'] == 'H'?'SELECTED':'').' >'.lang('Hours Appointment').'</option></select>'
+				'field' => lang('Type'),
+				'data'  => '<select onchange="javascript:changeViewMode(this.value);" id="cal[type]" name="cal[type]" '.($event['type'] == 'H'?'DISABLED':'').'><option value="normal" '.(($event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'.lang('Normal').'</option><option value="private" '.((!$event['public'] && $event['type'] == 'E')?'SELECTED':'').' >'. lang('Restrict').'</option><option value="privateHiddenFields" '.($event['type']=='P'?'SELECTED':'').' >'. lang('Private').'</option><option value="hourAppointment" '.($event['type'] == 'H'?'SELECTED':'').' >'.lang('Hours Appointment').'</option></select>'
 			); //event['public']
 
@@ -5066,13 +5066,13 @@
 							{
 								$str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id)
-										.') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n";
+									.') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n";
 							}
 						}
 						$var['participants'] = array
-						(
-							'field'	=> '<input type="button" value="' . lang('Participants') . '" onClick="accounts_popup();">' . "\n"
-									. '<input type="hidden" name="accountid" value="' . $accountid . '">',
-							'data'	=> "\n".'   <select name="participants[]" multiple size="7">' . "\n" . $str . '</select>'
-						);
+							(
+								'field'	=> '<input type="button" value="' . lang('Participants') . '" onClick="accounts_popup();">' . "\n"
+								. '<input type="hidden" name="accountid" value="' . $accountid . '">',
+								'data'	=> "\n".'   <select name="participants[]" multiple size="7">' . "\n" . $str . '</select>'
+							);
 						break;
 					default:
@@ -5089,47 +5089,47 @@
 						$str = utf8_decode($str);
 						$footer_ext_participantes =	'<br>&nbsp;&nbsp;'.lang("The email addresses must be separated by ','");						
-						
+
 						$var['participants'] = array
 						(
 							'field'	=> lang('Participants'),							
 							'data'	=> "
-									<table width='100%' border='0'>
-										<tr>
-											<td width='30%'>										
-												<center>Participantes</center>												
-											</td>
-											<td width='8%' >&nbsp;</td>
-											<td width='40%'>&nbsp;</td>
-										</tr>																		
-										<tr>		
-											<td width='30%'>											
-												<center><select id='user_list' name='participants[]' style='width: 220px' multiple size='7'>".$str."</select></center>										
-											</td>				
-											<td width='8%'>
-											<center>
-												<table width='100%' border='0'>									
-													<tr height='5'><td>&nbsp;</td></tr>									
-													<tr><td align='center'>									
-														<button type='button' onClick='javascript:openListUsers(340,533, "
-														.$event['owner'].
-														")'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/add.png' style='vertical-align: middle;' >&nbsp;Adicionar</button>
-														</td>
-													</tr>							
-													<tr height='5'><td>&nbsp;</td></tr>
-													<tr><td  align='center'>
-														<button type='button' onClick='javascript:rem()'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/rem.png' style='vertical-align: middle;' >&nbsp;Remover</button>
-														</td>
-													</tr>
-												</table>
-											</center>
-											</td>
-											<td width='40%'>&nbsp;</td>
-										</tr>
-										</table>
-										<script src='{$GLOBALS['phpgw'] -> link( '/calendar' )}/js/edit.js' type='text/javascript'></script>
-									"
+							<table width='100%' border='0'>
+							<tr>
+							<td width='30%'>										
+							<center>Participantes</center>												
+							</td>
+							<td width='8%' >&nbsp;</td>
+							<td width='40%'>&nbsp;</td>
+							</tr>																		
+							<tr>		
+							<td width='30%'>											
+							<center><select id='user_list' name='participants[]' style='width: 220px' multiple size='7'>".$str."</select></center>										
+							</td>				
+							<td width='8%'>
+							<center>
+							<table width='100%' border='0'>									
+							<tr height='5'><td>&nbsp;</td></tr>									
+							<tr><td align='center'>									
+							<button type='button' onClick='javascript:openListUsers(340,533, "
+							.$event['owner'].
+							")'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/add.png' style='vertical-align: middle;' >&nbsp;Adicionar</button>
+							</td>
+							</tr>							
+							<tr height='5'><td>&nbsp;</td></tr>
+							<tr><td  align='center'>
+							<button type='button' onClick='javascript:rem()'><img src='calendar/templates/".$_SESSION['phpgw_info']['calendar']['user']['preferences']['common']['template_set']."/images/rem.png' style='vertical-align: middle;' >&nbsp;Remover</button>
+							</td>
+							</tr>
+							</table>
+							</center>
+							</td>
+							<td width='40%'>&nbsp;</td>
+							</tr>
+							</table>
+							<script src='{$GLOBALS['phpgw'] -> link( '/calendar' )}/js/edit.js' type='text/javascript'></script>"
 						);
+
 						// if ExpressoMail 1.2 has been installed and enabled, show the plugin using AJAX. 
-						if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) {							
+						if($GLOBALS['phpgw_info']['server']['cal_expressoMail']) {
 							$module_name = 'expressoMail'.(str_replace("1.","1_",$GLOBALS['phpgw_info']['server']['cal_expressoMail']));
 
@@ -5179,54 +5179,54 @@
 									'field'	=> '
 									<script src="'.$GLOBALS['phpgw'] -> link( '/calendar' ).'/js/edit.js" type="text/javascript"></script><div id=\'disponibility\' style=\'display:none;position:absolute\' bgcolor=\'#FFFFFF\'>
-	<iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\' height=\'200px\'></iframe>
-</div>
+									<iframe src=\'#\' id=\'frame_disponibility\' width=\'500\' marginHeight=\'0\' marginWidth=\'0\' height=\'200px\'></iframe>
+									</div>
 									'.lang('Participants'),
-									'data'	=> '
-											<input type="hidden" id="txt_loading" value="'.lang("Loading").'">' .
-											'<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' .
-											'<input type="hidden" id="txt_users" value="'.lang("Users").'">' .							
-											'<input type="hidden" id="txt_groups" value="'.lang("Groups").'">' .
-											'<table width="100%" border="0">'.
-											'<tr>'.
-											'<td width="25%"><br><br>'.
-											'<br><br>&nbsp;&nbsp;<b>'.lang("Event's participants").'</b><br>'.
-											'	<select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'.
-											'</td>'.
-											'<td width="30px" valign="middle" align="center">&nbsp;'.
-											'</td>'.
-											'<td valign="bottom">'.
-											'	'.lang("Organization").': '.
-											'	<select name="org_context" id="combo_org" onchange="javascript:get_available_users(\''.$module_name.'\',this.value,\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\');">'.$combo_org.'</select>'.
-											'	<br>'.
-											'	<font color="red"><span id="cal_span_searching">&nbsp;</span></font>'.									
-											'	<br>'.lang("Search for").':'.
-											'	<input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].',\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\')"><br>'.
-											'	<b>'.lang("Available users and groups").'</b><br>'.
-											'	<select id="user_list_in" style="width: 300px" multiple size="13"></select>'.
-											'</td>'.
-											'</tr>'.
-                                            '<tr>'.
-                                            '<td width="25%">'.
-                                            '<button type="button" id="time_map" onClick="javascript:show_disponibility();">'.lang("Disponibility map").'</button>'.
-                                            '</td>'.
-                                            '<td width="30px" valign="middle" align="center">&nbsp;'.
-											'</td>'.
-                                            '<td valign="bottom">'.
-                                            '<button type="button" onClick="javascript:add_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/add.png" style="vertical-align: middle;" >&nbsp;'.lang("Add").'</button>'.
-											'&nbsp;&nbsp;<button type="button" onClick="javascript:remove_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/rem.png" style="vertical-align: middle;" >&nbsp;'.lang("Remove").'</button>'.
-                                            '</td>'.
-											'</tr>'.
-											'</table>'. 
-											'<script type="text/javascript" src="' . $GLOBALS[ 'phpgw' ] -> link( '/phpgwapi/js/dJSWin/dJSWin.js' ) .'"></script>'.		
-											'<script src="' . $GLOBALS[ 'phpgw' ] -> link( '/calendar/js/edit_exmail.js' ) . '" type="text/javascript"></script>' .
-											$load_lang_vars.				
-											"<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ".											
-											"<script type='text/javascript'>" .
-											"var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\',\'".($recursive ? "" : "search")."\',\'".$GLOBALS['phpgw_info']['server']['auto_search']."\')',1000);". 
-											"</script> "
+										'data'	=> '
+										<input type="hidden" id="txt_loading" value="'.lang("Loading").'">' .
+										'<input type="hidden" id="txt_searching" value="'.lang("Searching").'">' .
+										'<input type="hidden" id="txt_users" value="'.lang("Users").'">' .							
+										'<input type="hidden" id="txt_groups" value="'.lang("Groups").'">' .
+										'<table width="100%" border="0">'.
+										'<tr>'.
+										'<td width="25%"><br><br>'.
+										'<br><br>&nbsp;&nbsp;<b>'.lang("Event's participants").'</b><br>'.
+										'	<select id="user_list" name="participants[]" style="width: 300px" multiple size="13">'.$str.'</select>'.
+										'</td>'.
+										'<td width="30px" valign="middle" align="center">&nbsp;'.
+										'</td>'.
+										'<td valign="bottom">'.
+										'	'.lang("Organization").': '.
+										'	<select name="org_context" id="combo_org" onchange="javascript:get_available_users(\''.$module_name.'\',this.value,\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\');">'.$combo_org.'</select>'.
+										'	<br>'.
+										'	<font color="red"><span id="cal_span_searching">&nbsp;</span></font>'.									
+										'	<br>'.lang("Search for").':'.
+										'	<input value="" id="cal_input_searchUser" size="35" autocomplete="off" onkeyup="javascript:optionFinderTimeout(this,'.$GLOBALS['phpgw_info']['server']['min_num_characters'].',\''.($recursive ? "" : "search").'\',\''.$GLOBALS['phpgw_info']['server']['auto_search'].'\')"><br>'.
+										'	<b>'.lang("Available users and groups").'</b><br>'.
+										'	<select id="user_list_in" style="width: 300px" multiple size="13"></select>'.
+										'</td>'.
+										'</tr>'.
+										'<tr>'.
+										'<td width="25%">'.
+										'<button type="button" id="time_map" onClick="javascript:show_disponibility();">'.lang("Disponibility map").'</button>'.
+										'</td>'.
+										'<td width="30px" valign="middle" align="center">&nbsp;'.
+										'</td>'.
+										'<td valign="bottom">'.
+										'<button type="button" onClick="javascript:add_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/add.png" style="vertical-align: middle;" >&nbsp;'.lang("Add").'</button>'.
+										'&nbsp;&nbsp;<button type="button" onClick="javascript:remove_user();"><img src="calendar/templates/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'].'/images/rem.png" style="vertical-align: middle;" >&nbsp;'.lang("Remove").'</button>'.
+										'</td>'.
+										'</tr>'.
+										'</table>'. 
+										'<script type="text/javascript" src="' . $GLOBALS[ 'phpgw' ] -> link( '/phpgwapi/js/dJSWin/dJSWin.js' ) .'"></script>'.		
+										'<script src="' . $GLOBALS[ 'phpgw' ] -> link( '/calendar/js/edit_exmail.js' ) . '" type="text/javascript"></script>' .
+										$load_lang_vars.				
+										"<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ".											
+										"<script type='text/javascript'>" .
+										"var timeout_get_available_users = setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\',\'".($recursive ? "" : "search")."\',\'".$GLOBALS['phpgw_info']['server']['auto_search']."\')',1000);". 
+										"</script> "
 								);
 							}						
 						}						
-						
+
 						$var['participants']['data'] .= '<br /><a id="a_ext_participants" title="'.lang("It types below the email addresses, if you want to invite other people out" .
 							" of this system").'" name="a_ext_participants" onClick="javascript:showExParticipants(this,\''.$module_name.'\');return false;" href="#a_ext_participants"><b>'.lang("Inform").' '.lang("external participants").'</b>&nbsp;<img align="top" ' .
@@ -5246,6 +5246,6 @@
 							'</table>';
 						break;
-						
-				}
+
+					}
 				if((($event['id'] > 0) && isset($event['participants'][$event['owner']])) || !$event['id'])
 				{
Index: trunk/calendar/js/edit_exmail.js
===================================================================
--- trunk/calendar/js/edit_exmail.js	(revision 2748)
+++ trunk/calendar/js/edit_exmail.js	(revision 2802)
@@ -164,5 +164,13 @@
 	var count_users = select_users.options.length;
 	var new_options = '';
-	
+
+	for ( var i = 0; i < count_available_users; i++ )
+		if ( select_available_users.options[ i ].selected )
+		{
+			select_users.appendChild( select_available_users.options[ i-- ] );
+			count_available_users--;
+		}
+
+	/*
 	for (i = 0 ; i < count_available_users ; i++) {
 		if (select_available_users.options[i].selected)	{
@@ -195,4 +203,5 @@
 		select_users.outerHTML = select_users.outerHTML;
 	}
+	*/
 }
 
Index: trunk/calendar/templates/default/edit.tpl
===================================================================
--- trunk/calendar/templates/default/edit.tpl	(revision 1154)
+++ trunk/calendar/templates/default/edit.tpl	(revision 2802)
@@ -15,9 +15,23 @@
 		Window1=window.open('{accounts_link}',"Search","width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes");
 	}
+	function send_form( )
+	{
+		var participants;
+
+		if ( ( participants = document.getElementById( 'user_list_in' ) ) )
+			for ( var i = 0; i < participants.length; i++ )
+				participants.options[ i ].selected = false;
+
+		if ( ( participants = document.getElementById( 'user_list' ) ) )
+			for ( var i = 0; i < participants.length; i++ )
+				participants.options[ i ].selected = true;
+
+		return ExpressoLivre.form( arguments[ 0 ].parentNode.removeChild( arguments[ 0 ] ) );
+	}
 </script>
 <center>
 <font color="#000000" face="{font}">
 
-<form action="{action_url}" method="post" name="app_form">
+<form action="{action_url}" method="post" name="app_form" onsubmit="return send_form( this );">
 {common_hidden}
 <table id="editFormTable" border="0" width="90%"   class="prefTable">
