<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $this->translate('Webmail Signup') ?></title>
	
	<link rel="stylesheet" type="text/css" href="<?php echo $this->siteBaseUrl . 'css/login/' . strtolower($this->cssStyle) ?>.css" />
	
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/jquery-1.3.2.min.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/ui/jquery-ui-1.7.2.custom.min.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.jcacher-1.0.0.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.php.pack.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl; ?>js/browsercheck.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/atmail/mail/mail.js?<?php echo Zend_registry::get('config')->global['version'] ?>"></script>
	
</head>

<body id="bg" class="signup">

			<div id="logo"></div>
		<div id="Flash"></div>
		<div id="container-signup">
			<div class="login-txt">
								<p><?php echo $this->translate('Signup')?></p>
							</div>
	
			<?php if( !$this->signupAllowed) : ?>
			<h1 class="signup"><?php echo $this->translate('Signup not enabled') ?></h1>
			<h2 class="signup-text"><?php echo $this->translate('The signup page is not available') ?></h2>
			<?php else: ?>
			<h1 class="signup"><?php echo $this->translate('Email Details') ?></h1>
			<h2 class="signup-text"><?php echo $this->translate('Please select a username and which domain-name to create your new email-account. When creating an account, choose a password with at least 5 characters for optimal security.') ?></h2>

			<!-- Begin Form -->
			<form class="signupForm" id="signupForm" action="<?php echo $this->moduleBaseUrl ?>signup/signupprocess" method="post">
				<table class="signup">
					<tr>
						<td>
							<label class="email"><?php print $this->translate('Email Name') ?>:</label>
						</td>
						<td>
							<input id="username" class="input-email" type="text" name="username" />
						</td>	
						<td><label class="at">@</label></td>
						<td>
							<select id="hostname" class="email" name="hostname">
								<option value="" selected><?php echo $this->translate('Select domain') ?></option>
<?php 							foreach( $this->domains as $domain ) : ?>
								<option value="<?php echo $domain['DomainName'] ?>"><?php echo $domain['DomainName'] ?></option>
<?php 							endforeach; ?>
							</select>
						</td>
					</tr>
					<tr>
						<td><label class="pass-confirm"><?php echo $this->translate('Password') ?>:</label></td>
						<td><input id="passwordfield"  class="input" type="password" name="Password" /></td>
						<td><label class="confirm"><?php echo $this->translate('Confirm Password') ?>:</label></td>
						<td><input id="passwordfield2"  class="input" type="password" name="Password2" /></td>
					</tr>
					<tr>
						<td><label class="pass-remind"><?php echo $this->translate('Password Reminder') ?>:</label></td>
						<td><input id="inputsign"  class="input" type="text" name="PasswordQuestion" /></td>
						<td></td>
						<td></td>
					</tr>
				</table>
                        
				<h1 class="signup"><?php echo $this->translate('Personal Details') ?></h1>
				<h2 class="signup-text"><?php echo $this->translate('Optionally specify your contact details to help us maintain your account. The full-name you provide will be used to address outgoing email-messages sent from your account.') ?></h2>

				<table class="signup">
					<tr>
						<td><label class="fname"><?php echo $this->translate('First Name') ?>:</label></td>
						<td><input id="firstname" class="input-email" type="text" name="UserFirstName" /></td>
						<td><label class="lname"><?php echo $this->translate('Last Name') ?>:</label></td>
						<td><input id="lastname" class="input-email" type="text" name="UserLastName" /></td>
					</tr>
				</table>

				<h1 class="signup"><?php echo $this->translate('Email Preferences') ?></h1>
				<h2 class="signup-text"><?php echo $this->translate('Select your WebMail interface and language preference for the interface. Depending on your web-browser capability/version you can select an interface to suite your requirements.') ?></h2>

				<table class="signup">
					<tr>
						<td><label class="plang"><?php echo $this->translate('Preferred Language') ?>:</label></td>
						<td>
							<select class="language" name="Language">
					  			<option value=""><?php print $this->translate('Default'); ?></option>
								<?php foreach( $this->availableLocales as $k => $v ) : ?>	
								<option value="<?php echo $k ?>"<?php echo ($this->defaultLanguage==$k?' selected':'') ?>><?php echo $v ?></option>
								<?php endforeach ?>
							</select>    
						</td>
					</tr>
				</table>

				<table class="signup">
					<tr id="LoginBtn">
						<td width="200">
							<input class="loginbtn <?php echo $this->cssStyle ?>" type="submit" value="<?php print $this->translate('Signup') ?>" /> 
						
						</td>
					</tr>
				</table>
				
				<table class="signup">
					<tr id="LoginBtn">
						<td>
								<input id="disclaimer" class="check-signup" type="checkbox" name="disclaimer" value="1" />
							<span class="disclaimer"><?php echo $this->translate('Before signing up for an account you have to agree to the Disclaimer') ?></span>
						</td>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div id="foot">
			<a href="http://www.atmail.com/" title="Linux email server" target="_blank"><?php echo $this->translate('Powered by Atmail') ?></a>
		</div>
		<?php endif; ?>

	<div style="display:none;">
		<form id="accountLoginForm" action="<?php echo $this->appBaseUrl ?>/mail/auth/processlogin" method="POST" >
			<input type="hidden" id="accountLoginEmailName" name="emailName" value="" />
			<input type="hidden" id="accountLoginPassword" name="password" value="" />
			<input type="hidden" id="accountLoginDomain" name="emailDomain" value="" />
			<input type="hidden" name="requestedServer" value="" />
		</form>
	</div>
	<script type="text/javascript">

	$( function()
	{
        php.errors.defaultCallBack = function (msg, params) 
		{
			$.localFlash(msg, 'error');
		}

		php.messages.defaultCallBack = function (msg, params) 
		{
			$.localFlash(msg, 'notice');
		}
		
		$.localFlash = function( message, type ) {
	
	    	if( type.toLowerCase() == 'notice' ) 
			{
				$('#Flash').removeClass('flash_notice_error');
				$('#Flash').addClass('flash_notice');
			}
			else
			{
				$('#Flash').removeClass('flash_notice');
				$('#Flash').addClass('flash_notice_error');
			}

			$('#Flash').html(message);
			$('#Flash').show();

			$('#Flash').unbind('click');
			$('#Flash').bind('click', function() { $(this).fadeOut(); });
			$('html, body').animate({scrollTop:0}, 'slow');
		}
				
		// bind to the form's submit event and cancel legacy submit 
		$('#signupForm').submit(function() {              
	    
		
			if( $('#username').attr('value') == '' )
			{
				
				$.localFlash('<?php echo str_replace( "'", "\'", $this->translate('Please enter desired email address.') ) ?>', 'error');
				$('#username').effect('highlight', {}, 1000);
				$('#username').focus();
				return false; 
				
			}
			
			if( $('#hostname').attr('value') == '' )
			{
				
				$.localFlash('<?php echo str_replace( "'", "\'", $this->translate('Select desired domain name for new account') ) ?>', 'error');
				$('#hostname').effect('highlight', {}, 1000);
				$('#hostname').focus();
				return false; 
				
			}
			
			if( $('#passwordfield').attr('value') == '' || $('#passwordfield').attr('value') != $('#passwordfield2').attr('value') )
			{
				
				$.localFlash('<?php echo str_replace( "'", "\'", $this->translate('Passwords do not match. Please re-enter Password and Confirm password.') ) ?>', 'error');
				$('#passwordfield').effect('highlight', {}, 1000);
				$('#passwordfield2').effect('highlight', {}, 1000);
				$('#passwordfield').focus();
				return false; 
				
			}
			
			if( $('#passwordfield').attr('value').length < 5 )
			{
				
				$.localFlash('<?php echo str_replace( "'", "\'", $this->translate('Password is too short. Please enter a longer password.') ) ?>', 'error');
				$('#passwordfield').effect('highlight', {}, 1000);
				$('#passwordfield2').effect('highlight', {}, 1000);
				$('#passwordfield').focus();
				return false; 
				
			}
			
			if( !$('#disclaimer').attr('checked') )
			{
				
				$.localFlash('<?php echo str_replace( "'", "\'", $this->translate('You must accept the disclaimer to proceed with signup.') ) ?>', 'error');
				$('#disclaimer').effect('highlight', {}, 1000);
				$('#disclaimer').focus();
				return false; 
				
			}
			
			$.localFlash('<?php echo str_replace( "'", "\'", $this->translate('Processing signup, please wait.') ) ?>', 'notice');
			$.php( $('#signupForm').attr('action'), $('#signupForm').serializeArray() );
			return false;
		}); 

	});

	</script>
</body>
</html>
