<div id="primary_header">
	<h1><?php print $this->translate('Calendar Settings')?></h1>
	<div id="back_button">
		<a href="#">
			<span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span>
		</a>
	</div>
</div>

<div id="back_button" class="savecontact">
	<a href="#">
		<span>
			<?php print $this->translate('Save Settings')?>
		</span>
	</a>
</div>


<div id="primary_content">
	<div id="primary_content_inner">
		<div id="Flash" class="flash_notice"><?php echo $this->translate('The settings have been updated'); ?></div>

		<form id="settingsForm" method="post" action="<?php echo $this->moduleBaseUrl ?>/settings/calendarsave">
			<input type="hidden" name="save" value="1" id="save" />
			<table class="settings" style="display:none;">

				<tr>
					<td class="label"><label for="CalDavView"><?php print $this->translate('Default View')?></label></td>
					<td>
						<select name="CalDavView" id='CalDavView'>
							<option <?php echo ($this->UserSettings['CalDavView'] == 'Day' ? 'selected=true' : ''); ?> value="Day"><?php echo $this->translate('Day') ?></option>
							<option <?php echo ($this->UserSettings['CalDavView'] == 'Week' ? 'selected=true' : ''); ?> value="Week"><?php echo $this->translate('Week') ?></option>
							<option <?php echo ($this->UserSettings['CalDavView'] == 'Month' ? 'selected=true' : ''); ?> value="Month"><?php echo $this->translate('Month') ?></option>
						</select>
						<small><?php print $this->translate('The default view to load when opening the calendar.')?></small>
					</td>
				</tr>
			</table>

			<div class='divider' style="display:none;" />

			<table class="settings">

				<tr>
					<td class="label"><label for="calDavUrl"><?php print $this->translate('CalDAV Server URL')?></label></td>
					<td>
						<input type="text" value="<?php echo $this->UserSettings['CalDavUrl'] ?>" name="calDavUrl" id="calDavUrl" />
						<small><?php print $this->translate('The URL for the CalDAV server that contains your calendar information')?></small>
					</td>
				</tr>
				<tr>
					<td class="label"><label for="CalDavType"><?php print $this->translate('CalDAV Server Type')?></label></td>
					<td>
						<small id ="caldavTypeText"><?php echo $this->caldavTypeText; ?></small>
						<small><?php print $this->translate('This is the automatically detected type of CalDAV server.')?></small>
					</td>
				</tr>
			</table>

			<div class='divider'/>

				<table class="settings">
					<tr>
						<td class="label"><label for="calDavAuth"><?php print $this->translate('External Authentication')?></label></td>
						<td>
							<input type="checkbox" id='auth' name="calDavAuth" <?php echo (@$this->UserSettings['CalDavUser'] != '' ? 'checked' : '') ?> value="auth"><small><?php print $this->translate('Select if the calendar server is installed on another machine requiring different login credentials to your current account.')?></small>
						</td>
					</tr>

					<tr>
						<td class="label"><label id='authlabel1' for="calDavUrlUser"><?php print $this->translate('Username')?></label></td>
						<td><input type="text" id='calDavUrlUser' name="calDavUrlUser" value="<?php echo $this->UserSettings['CalDavUser']; ?>"><small><?php print $this->translate('Specify the username of your calendar server account.')?></small></td>
					</tr>

					<tr>
						<td class="label"><label id='authlabel2' for="calDavUrlPass"><?php print $this->translate('Password')?></label></td>
						<td><input type="password" id='calDavUrlPass' name="calDavUrlPass" value="<?php echo $this->UserSettings['CalDavPass']; ?>"><small><?php print $this->translate('Specify the password of your calendar server account.')?></small></td>
					</tr>

				</table>
				<div class="bottomFormMainButtonArea" style="display:none;">
					<div id="back_button"><a href="#"><span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span></a></div>
				</div>
				<br />
				<br />
				<br />
				
			</div>
		</form>


	</div>

	<script type="text/javascript">
	$(function() 
	{

		function editauth()	
		{
		
			if($("#auth", "#calendar").attr('checked') == true)	
			{
			
				$("#authlabel1", "#calendar").fadeTo("slow", 1);
				$("#authlabel2", "#calendar").fadeTo("slow", 1);
				$("#calDavUrlUser", "#calendar").removeAttr("disabled");
				$("#calDavUrlPass", "#calendar").removeAttr("disabled");
				$("#calDavUrlUser", "#calendar").focus();
			
			} 
			else 
			{
			
				$("#authlabel1", "#calendar").fadeTo("fast", 0.5);
				$("#authlabel2", "#calendar").fadeTo("fast", 0.5);
				$("#calDavUrlUser", "#calendar").attr("disabled","disabled");
				$("#calDavUrlPass", "#calendar").attr("disabled","disabled");
				$("#save", "#calendar").focus();
			
			}
		
		}

		$('#settingsForm', '#calendar').submit(function() 
		{

			$('#back_button').fadeTo(100, 0.5);
			$("#Flash", "#calendar").hide();
			$.php($("#settingsForm", '#calendar').attr("action"),$("#settingsForm", "#calendar").serializeArray());
			return false;

		});

		$('#back_button a', '#calendar').bind("click", function() { return $('#settingsForm', '#calendar').submit()});

		$("#auth", "#calendar").change(function() { editauth() });
		$("#CalDavType option", '#calendar').removeAttr('selected');
		$("#CalDavType option[value=<?php echo $this->UserSettings['CalDavType'] ?>]", '#calendar').attr('selected', 'true');

		editauth();

		// Sliding Checkboxes
		$('#Settings :checkbox').iphoneStyle();
	
		$('.stronglastword').each( function() { $(this).stronglastword() });

	});
		
	</script>
