<div id="primary_header">
	<h1 class="admin"><?php echo $this->translate('Reboot Services') ?></h1>
</div>

<div id="rebootdialog" title="Restarting Network"></div>
<div id="primary_content">
	<div id="primary_content_inner">
		<div id="primary_content">
			<div id="primary_content_inner">
			<form id="formRestartServices" method="post">
				<input type="hidden" name="type" value="restart" />
				<table class="settings">

					<tr>
						<td class="label"><?php echo $this->translate('Restart Services') ?></td>
						<td>
							<input type="submit" name="Restart" value="Restart Services" />
							<small><?php echo $this->translate('Restart the Atmail services (SMTP, POP3/IMAP, Groupware, AV/Anti-Spam)') ?></small>
						</td>
					</tr>
			
				</table>
			</form>
		
			<div class="divider"></div>
		
			<form id="formReboot" method="post">
				<input type="hidden" name="type" value="reboot" />
				<table class="settings">
		
					<tr>
						<td class="label"><?php echo $this->translate('Reboot Server') ?></td>
						<td>
							<input type="submit" name="Reboot" value="Reboot Server" />
							<small><?php echo $this->translate('Reboot the Atmail appliance - Will take approximately 3 minutes to reboot fully') ?></small>
						</td>
					</tr>
			
				</table>
			</form>

			<div class="divider"></div>
		
			<form id="formShutdownServer" method="post">
				<input type="hidden" name="type" value="shutdown" />			
				<table class="settings">
		
					<tr>
						<td class="label"><?php echo $this->translate('Shutdown Server') ?></td>
						<td>
							<input type="submit" name="Shutdown" value="Shutdown" />
							<small><?php echo $this->translate('Shutdown the Atmail appliance') ?></small>
						</td>
					</tr>

				</table>
			</form>
		
			</form>
			</div>
		</div>
   	</div>
</div>

<script type="text/javascript">
	
	// bind to the form's submit event and cancel legacy submit
	var defaultFormAction = '<?php echo $this->appBaseUrl; ?>/admin/appliance/rebootsave'
	$('#formRestartServices', '#Appliance').submit(function()
	{
		
		$('#dialog').html("<?php echo addslashes($this->translate('Restarting Atmail services<br />Please standby.')) ?>");
		$("#dialog").dialog('open');
		$.php( defaultFormAction,$(this).serializeArray() );
		return false;

	});

	function tryReload() 
	{
		
		location.reload();
		
	}
		
	$('#formReboot', '#Appliance').submit(function()
	{

		$('#dialog').html('Restarting Server<br />Please <a href="<?php echo $this->appBaseUrl; ?>/admin">click here</a> if the page does not automatically refresh after 3 minutes.<br /><div id="countdown"></div>')
		$('#countdown').countdown({until: +180, layout: '%M%n %l%M, %S%n %l%S remaining.', onExpiry: tryReload});
		$("#dialog").dialog('open');
	    $.php(defaultFormAction,$(this).serializeArray());
		return false;

	});

	$('#formShutdownServer', '#Appliance').submit(function() 
	{
		
		$.php(defaultFormAction,$(this).serializeArray());
		return false;

	});

</script>