<h2>Step 3: SMTP, LDAP and Admin Email Configuration</h2>
<p>In this step we will set the SMTP host for the sending of emails, configure the optional LDAP address book integration and set the admin's email address.</p>

<?php if($var['smtp_error']): ?>
<div class="error">
	<h3>Error</h3>
	<p>Could not connect to the specified SMTP server <em><?php echo $var['bad_smtp_host'] ?></em></p>
	<p><?php echo $var['smtp_error'] ?></p>
</div>
<?php endif; ?>

<form action="index.php" method="POST" name="myform">
	<input type="hidden" name="step" value="3"/>
<table>
<tr>
<td nowrap>
<table width="400">


		<?php if($var['smtp_error'] && !$var['smtp_auth_error']): ?>
		<tr class="error">
		<?php endif; ?>

		<?php if(!$var['smtp_error']): ?>
		<tr>
		<?php endif; ?>
			<td><label for="smtp_host">SMTP Host</label></td>
			<td><a href="javascript://" title="help" onClick="info('smtphost', event, 15000)">?</a>
			<input type="text" id="smtphost" name="smtphost" value="<?php echo $var['smtphost'] ?>" onFocus="info('smtphost', event, 15000)"></td>
		</tr>

		<tr>
			<td><label for="smtp_host">Use SMTP Authentication</label></td>
			<td><a href="javascript://" title="help" onClick="info('smtp_auth', event, 15000)">?</a>
			<input type="checkbox" name="smtp_auth" onclick="showsmtpauth(this)" onmouseover="info('smtp_auth', event, 15000)" <?php echo $var['smtp_auth_check'] ?>></td>
		</tr>

		<?php if($var['smtp_error'] && $var['smtp_auth_error']): ?>
		<tr class="error">
		<?php endif; ?>

		<?php if(!$var['smtp_auth_error']): ?>
		<tr id="smtpauthuser" style="display:none">
		<?php else: ?>
		<tr id="smtpauthuser">
		<?php endif; ?>
			<td><label for="smtp_host">SMTP Auth Username</label></td>
			<td><a href="javascript://" title="help" onClick="info('smtpauth_username', event, 15000)">?</a>
				<input type="text" name="smtpauth_username" value="<?php echo $var['smtpauth_username'] ?>" onFocus="info('smtpauth_username', event, 15000)"></td>
		</tr>

		<?php if($var['smtp_error'] && $var['smtp_auth_error']): ?>
		<tr class="error">
		<?php endif; ?>

		<?php if(!$var['smtp_auth_error']): ?>
		<tr id="smtpauthpass" style="display:none">
		<?php else: ?>
		<tr id="smtpauthpass">
		<?php endif; ?>
			<td><label for="smtp_host">SMTP Auth Password</label></td>
			<td><a href="javascript://" title="help" onClick="info('smtpauth_password', event, 15000)">?</a>
				<input type="password" id="smtpauth_password" name="smtpauth_password" value="<?php echo $var['smtpauth_password'] ?>" onFocus="info('smtpauth_password', event, 15000)"></td>
		</tr>
		
		<tr>
			<td><label for="smtp_host">Configure LDAP Address Book Integration</label></td>
			<td>
				<input type="checkbox" name="ldap_abook" onclick="showldap(this)" <?php echo $var['ldap_abook_check'] ?> />
			</td>
		</tr>
		
		<tr id="ldapserver" style="display:none">
			<td><label for="ldap_host">LDAP Server</label></td>
			<td>
				<input type="text" id="ldap_server" name="ldap_server" value="<?php echo $var['ldap_server'] ?>" />
			</td>
		</tr>
		<tr id="ldapbasedn" style="display:none">
			<td><label for="ldap_host">LDAP Base DN</label></td>
			<td>
				<input type="text" id="ldap_base_dn" name="ldap_base_dn" value="<?php echo $var['ldap_base_dn'] ?>" />
			</td>
		</tr>
		<tr id="ldappasswd" style="display:none">
			<td><label for="ldap_host">LDAP Password</label></td>
			<td>
				<input type="text" id="ldap_passwd" name="ldap_passwd" value="<?php echo $var['ldap_passwd'] ?>" />
			</td>
		</tr>
		
		<?php if($var['admin_email_error']): ?>
		<tr class="error">
			<td colspan="2">
				<span class="error">Invalid email address given</span>
			</td>
		</tr>
		<tr class="error">
		<?php else: ?>
		<tr>
		<?php endif; ?>
			<td><label for="admin_email">Admin Email</label></td>
			<td><a href="javascript://" title="help" onClick="info('admin_email', event, 15000)">?</a>
			<input type="text" name="admin_email" value="<?php echo $var['admin_email'] ?>" onFocus="info('admin_email', event, 15000)" id="adminemail"></td>
		</tr>
		<tr>
			<td colspan="2">
				<input type="checkbox" name="subscribe" value="1" checked /> <label for="subscribe">Signup to receive email updates of new versions and special Atmail announcements. Never disclosed to 3rd parties and No Spam!</label>
			</td>
		</tr>
		<tr>
			<td colspan="2"><input type="submit" name="submit" value="Continue &gt;&gt;"><p>&nbsp;</p><p>&nbsp;</p>
		</tr>
	</table>
	</td>
	 <td valign="top">

	    <div id="infobox">
	         <div id="helptext"></div>
	     </div>

	   </td>
	</tr>
	</table>
</form>

<script>

<?php if($var['smtp_error'] && !$var['smtp_auth_error']): ?>
document.getElementById('smtphost').focus();
<?php endif; ?>

<?php if($var['smtp_error'] && $var['smtp_auth_error']): ?>
document.getElementById('smtpauth_password').focus();
<?php endif; ?>

<?php if(!$var['smtp_error']): ?>
document.getElementById('adminemail').focus();
<?php endif; ?>

function showsmtpauth(obj) {
if(obj.checked)	{
	document.getElementById('smtpauthuser').style.display='';
	document.getElementById('smtpauthpass').style.display='';
} else {
	document.getElementById('smtpauthuser').style.display='none';
	document.getElementById('smtpauthpass').style.display='none';
	document.getElementById('smtpauth_username').value ='';
	document.getElementById('smtpauth_password').value ='';
}
}

function showldap(obj) {
if(obj.checked)	{
	document.getElementById('ldapserver').style.display='';
	document.getElementById('ldapbasedn').style.display='';
	document.getElementById('ldappasswd').style.display='';
} else {
	document.getElementById('ldapserver').style.display='none';
	document.getElementById('ldapbasedn').style.display='none';
	document.getElementById('ldappasswd').style.display='none';
	document.getElementById('ldap_server').value ='';
	document.getElementById('ldap_base_dn').value ='';
	document.getElementById('ldap_passwd').value ='';
}
}

</script>
