<div id="primary_header">
	<h1><?php print $this->translate('Accounts Settings')?></h1>
</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>
		
		<br />
		<div id="relay-table" class="contactSettings">
			<?php echo $this->render('settings/accountslist.phtml'); ?>
		</div>
		

		<div class="divider"/>
		
		<form id="settingsForm" method="post" action="<?php echo $this->moduleBaseUrl ?>/settings/externalaccountsave">
			<input type="hidden" name="save" value="1" />
			<table class='settings' id='carddav'>
			
				<tr>
					<td class="label"></td>
					<td>
						<strong><?php echo $this->translate('Specify a server and type to add to your Webmail application.') ?></strong>
						<small><?php echo $this->translate('This creates an connection to an external addressbook or calendar server for data.') ?></small>
					</td>
				</tr>
								
				<tr>
					<td class="label"><?php print $this->translate('Server Type')?></td>
					<td>
						<select name="protocol" id='protocol'>
							<option value=""><?php print $this->translate('Select'); ?></option>
							<option value="<?php echo CALDAV_SERVER; ?>">CalDAV</option>
							<option value="<?php echo CARDDAV_SERVER; ?>">CardDAV</option>
							<option value="<?php echo SIP_SERVER; ?>">SIP</option>
							<option value="<?php echo SMS_SERVER; ?>">SMS</option>
						</select>
						<small><?php print $this->translate('Specify the server type')?></small>
					</td>
				</tr>

				</table>
				
				<?php echo $this->render('settings/wizard_caldav.phtml'); ?>
				<?php echo $this->render('settings/wizard_carddav.phtml'); ?>
				<?php echo $this->render('settings/wizard_sip.phtml'); ?>

				<div class="divider"/>
				
				<table class='settings' id='' style="margin-top: 5px;">
				
				<tr id="addAction" style="display:none;">
					<td class="label"></td>
					<td>
						<div id="add_contact_action" class="contacts-add">
							<a href="#">
								<span class="stronglastword"><?php echo $this->translate('Add Account') ?></span>
							</a>
						</div>
					</td>
				</tr>
				
				</table>
			
				
			
			
			</form>

		</div>

<script type="text/javascript">	
	$(function() 
	{
		$('#protocol', '#accounts').bind('change', function() {
			if($(this).val() == '')
			{
				$('.wizard', '#accounts').hide();
				$('#addAction', '#accounts').hide();
				return;
			}
			if($('.wizard', '#accounts').length)
			{
				wizard_to_run = $(this).val();
				$('.wizard', '#accounts').hide();
				$('#wizard_' + wizard_to_run, '#accounts').stop(true, true).show();
			}
			else
			{
				$('#wizard_' + $(this).val(), '#accounts').show();
			}

			$('#addAction', '#accounts').show();
			if (typeof window['clear_wizard_' + $(this).val()] == "function")
			{
				(window['clear_wizard_' + $(this).val()])();
			}
			
		});
		$('#add_contact_action a', '#accounts').bind("click", function()
		{ 
			$("#Flash", "#accounts").hide();
			$.php($("#settingsForm", '#accounts').attr("action"),$("#settingsForm", "#accounts").serializeArray());
		});
		$('.stronglastword', "#accounts").each( function() { $(this).stronglastword() });		
	});
	
</script>
