<div id="primary_header">
	<h1><?php print $this->translate('ActiveSync&reg; Service')?></h1>
</div>

<div id="primary_content">
	<div id="primary_content_inner">
<?php 	$w4m70Yt2hYUduM2r0lrrIuY0zgKG4A3vvftl4NbbCWfW = ((Zend_Registry::get('w4m70Yt0hYUduM2r2lrrIuY0bgKG4A3vvftl4NbzCWfW') & 256) != 0); ?>
<?php if($this->licenseExpired ==1): ?>
		<div id="licence-error"><img src="<?php echo $this->siteBaseUrl; ?>/images/icons/error.png" class="regerror"><span>Your license expired on <?php echo $this->expiry ?>, you have till <?php echo date('jS F Y', strtotime("+7 days", strtotime($this->expiry))) ?> to renew or ActiveSync will cease to work. <a href="https://secure.atmail.com/store/index.php/index/renewalinfo?clientId=<?php echo Zend_Registry::get("config")->reg['downloadId'] ?>" target="_blank">Renew Now</a></span></div>
<?php else :?>
		<div id="licence-error" class='display: none;'><span></span></div>
<?php endif; ?>
	<div id="Flash" class="flash_notice"><?php print $this->translate('The settings have been updated') ?></div>
<?php if( !$this->licenseExpired && $this->pushReady && $w4m70Yt2hYUduM2r0lrrIuY0zgKG4A3vvftl4NbbCWfW ) : ?>
	<div id="excluded" href='<?php echo $this->moduleBaseUrl ?>/users/excludedlink'></div>
<?php endif; ?>
		<form id="settingsForm" method="post" action="<?php echo $this->moduleBaseUrl ?>/services/activesyncsave">
			<input type="hidden" name="save" value="1" />
			<table class="settings">
				<tbody>
					<tr>
					<td class="label"><?php print $this->translate('Enable ActiveSync&reg; Service')?></td>
					<td>
						<input name="fields[PushSupport]" type='hidden' value="0"/>
						<input id="fieldsPushSupport" name="fields[PushSupport]" type="checkbox" class="iphoneStyle" value="1"<?php echo ($this->pushReady&&$this->groupDefault['PushSupport']&&$w4m70Yt2hYUduM2r0lrrIuY0zgKG4A3vvftl4NbbCWfW)?' checked':'' ?>>
						<small><?php print $this->translate('Enable Microsoft&reg; Exchange ActiveSync&reg; Service. Server for push calendaring, contacts, and email functions.')?> <?php print $this->translate('(This setting has a global effect on the system.)')?></small>
					</td>
				</tr>
				
				<tr>
					<td class="label"><label class="settings_label"><?php print $this->translate('Cache Lifespan')?></label></td>
					<td class="tdstyle">
						<div class="styled-select">
						        <span class="arrow"></span>
						<select id="ActiveSyncCacheLifespan" name="global[ActiveSyncCacheLifespan]">
							<option value="7"><?php echo $this->translate("1 week") ?></option>
							<option value="14"><?php echo $this->translate("2 weeks") ?></option>
							<option value="30"><?php echo $this->translate("1 month") ?></option>
							<option value="60"><?php echo $this->translate("2 months") ?></option>
							<option value="90"><?php echo $this->translate("3 months") ?></option>
						</select>
						</div>
						<small><?php print $this->translate('Lifespan for the ActiveSync&reg; data cache. The cache will be periodically cleared of all data older than the value given here.')?></small>
					</td>
				</tr>
				<tr>
					<td class="label"><label class="settings_label"><?php print $this->translate('Timeout')?></label></td>
					<td>
						<input class="large" name="global[ActiveSyncTimeout]" type="text" id="ActiveSyncTimeout" value="<?php echo $this->global['ActiveSyncTimeout']; ?>" />
						<small><?php print $this->translate('The timeout value for detecting changes during a long poll query. A lower value will make Active Sync more responsive at the expense of increased server load.')?></small>
					</td>
				</tr>
				<tr>
					<td class="label"><label class="settings_label"><?php print $this->translate('Tar Pit Maximum')?></label></td>
					<td>
						<input class="large" name="global[ActiveSyncTarpit]" type="text" id="ActiveSyncTarpit" value="<?php echo $this->global['ActiveSyncTarpit']; ?>" />
						<small><?php print $this->translate('During the long-poll cycle, you can optionally move timeout values to a maximum value. "0" to disable.')?></small>
					</td>
				</tr>
				<tr>
					<td class="label"><label class="settings_label"><?php print $this->translate('Tar Pit Multiplier')?></label></td>
					<td>
						<input class="large" name="global[ActiveSyncTarpitMultiplier]" type="text" id="ActiveSyncTarpitMultiplier" value="<?php echo $this->global['ActiveSyncTarpitMultiplier']; ?>" />
						<small><?php print $this->translate('The amount to increase the timeout each time a long poll cycle if Tar Pit Maximum is non-zero.')?></small>
					</td>
				</tr>
				</tbody>
			</table>
		</form>
		
		<div class="divider"></div>
		
		<div id="back_button">
			<a href="#">
				<span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span>
			</a>
		</div>
	</div>
</div>

<script type="text/javascript">
$( function()
{
	var tabId = '#Active_Sync';
	perform_service_common_binds(tabId);

<?php if( !($w4m70Yt2hYUduM2r0lrrIuY0zgKG4A3vvftl4NbbCWfW) ) : ?>
	$(".settings", tabId).fadeTo(0, 0.5)
	$("#fieldsPushSupport", tabId).attr("disabled","true")
	$("#licence-error SPAN").html("No license that includes Activesync was found on your server. Purchase a license that includes ActiveSync via the <a href='http://upgrade.atmail.com/?DownloadID=<?php echo Zend_Registry::get('config')->reg['downloadId'] ?>' target='_blank'>Atmail store</a> to enable PUSH support.");
<?php elseif( !$this->pushReady ) : ?>
		$(".settings", tabId).fadeTo(0, 0.5)
		$("#fieldsPushSupport", tabId).attr("disabled","true")
		$("#licence-error SPAN").html("PUSH support not enabled. Check module installed and PHP dependencies satisfied");
<?php elseif(!$this->licenseExpired): ?>
	$("DIV#licence-error").hide();
	$('#back_button', tabId).show();
<?php endif; ?>
	
	$("#ActiveSyncCacheLifespan option[value='<?php echo $this->global['ActiveSyncCacheLifespan']?>']").attr("selected", "selected");

	$("#fieldsPushSupport", tabId).change( function() { enableSettingsBox($("#fieldsPushSupport", tabId)); });
	enableSettingsBox($("#fieldsPushSupport", tabId));
})

</script>
