<?php
/**
* @version 1.0.0
* @package RSEvents! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

defined('_JEXEC') or die('Restricted access');
?>
<script type="text/javascript">
function selectall() 
{
	for ( i=0; i<document.getElementById('EventRepeatAlso').options.length; i++)
	{	
	document.getElementById('EventRepeatAlso').options[i].selected = true;
	}
}

function submitbutton(task)
{
	var form = document.adminForm;
	
	if(task == 'cancel')
	{
		submitform(task);
	}
	else  
	{
		ret = true;
		if(form.EventRepeatNumber.value <= 0) { form.EventRepeatNumber.className = 'rserror'; ret=false; } else { form.EventRepeatNumber.className = '';  }	
		if(ret) 
		{
			selectall();
			submitform(task);
		}
	}
	return false;
	 
}

function addOption(from,to)
{
to.options[to.options.length] = new Option( from.value, from.value, false, false);
}

function removeOption(from)
{
	if (from.options.selectedIndex == -1) return false;
	for(i=from.length-1; i>=0;i--)
		if (from.options[i].selected)
			from.remove(from.options[i].index);
}

</script>
<style>
.rserror 
{
	border:1px solid red;
}
</style>
<form action="index.php" method="post" enctype="multipart/form-data" name="adminForm" id="adminForm">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
		<tr>
			<td valign="top">
				<table  class="adminform">
					<tr>
						<td width="200">
							<label for="recurency">
								<?php echo JText::_( 'RSE_ENABLE_REPEAT' ).':'; ?>
							</label>
						</td>
						<td>
							<?php echo JHTML::_('select.booleanlist','EventEnableRepeat','class="inputbox"',$this->data->EventEnableRepeat); ?>
						</td>
					</tr>
					<tr>
						<td width="200">
							<label for="repeat">
								<?php echo JText::_( 'RSE_REPEAT_METHOD' ).':'; ?>
							</label>
						</td>
						<td>
							<input type="text" name="EventRepeatNumber" value="<?php echo $this->data->EventRepeatNumber;?>" size="2" maxlength="2" /> &nbsp;&nbsp;<?php echo $this->lists['repeat']; ?>
						</td>
					</tr>
					<tr>
						<td width="200">
							<label for="until">
								<?php echo JText::_( 'RSE_REPEAT_UNTIL' ).':'; ?>
							</label>
						</td>
						<td>
							<?php echo JHTML::_('calendar', date('Y-m-d',empty($this->data->EventRepeatUntil) ? time() : $this->data->EventRepeatUntil), "EventRepeatUntil", "EventRepeatUntil"); ?>
						</td>
					</tr>
					<tr>
						<td width="200">
							<label for="EventRepeatAlso">
								<?php echo JText::_( 'RSE_REPEAT_ALSO' ).':'; ?>
							</label>
						</td>
						<td width="130">
							<?php echo $this->lists['repeatalso']; ?>
						</td>
						<td width="40">
							<input type="button" name="repeatbutton" value="&laquo;" onclick="addOption(document.getElementById('RepeatAlso'),document.getElementById('EventRepeatAlso'));"/><br/><br/>
							<input type="button" name="repeatbutton1" value="&raquo;" onclick="removeOption(document.getElementById('EventRepeatAlso'));"/>
						</td>
						<td>	
							<?php echo JHTML::_('calendar', date('Y-m-d'), "RepeatAlso", "RepeatAlso"); ?>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
<?php echo JHTML::_( 'form.token' ); ?>
<input type="hidden" name="option" value="com_rsevents" />
<input type="hidden" name="cid" value="<?php echo $this->data->IdEvent; ?>" />
<input type="hidden" name="IdEvent" value="<?php echo $this->data->IdEvent; ?>" />
<input type="hidden" name="controller" value="repeat" />
<input type="hidden" name="view" value="repeat" />
<input type="hidden" name="task" value="" />
</form>

<?php
//keep session alive while editing
JHTML::_('behavior.keepalive');
?>