<?php if (!isset($this->global['mobilecssStyle']) || empty($this->global['mobilecssStyle'])) $this->global['mobilecssStyle'] = "original"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html class="ui-mobile" xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta name="viewport" content="width=290; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
		<title><?php print $this->global['brandname'] . ' ' . generateVersionString($this->version) . ' - ' . $this->translate('Login Page') ?></title>
		<link rel="stylesheet" type="text/css" href="<?php echo $this->siteBaseUrl; ?>css/jquery.ui.dialog.css" />
		<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/lang.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen"/>
		<link rel="stylesheet" type="text/css" href="<?php echo $this->siteBaseUrl ?>css/mobile/jquery.mobile-1.1.0.min.css" media="screen, print"/>
	    <link rel="stylesheet" type="text/css" href="<?php echo $this->siteBaseUrl ?>css/mobile/mobile.css" media="screen, print"/>
		<link rel="stylesheet" type="text/css" href="<?php echo $this->siteBaseUrl ?>css/mobile/themes/<?php echo $this->global['mobilecssStyle'] ?>/mobile.css" media="screen, print"/>
		<?php if (file_exists(APP_ROOT . "css/mobile/themes/". $this->global['mobilecssStyle'] . "/highdensity.css")): ?>
		<link rel="stylesheet" media="only screen and (-webkit-min-device-pixel-ratio: 2)" type="text/css" href="<?php echo $this->siteBaseUrl ?>css/mobile/themes/<?php echo $this->global['mobilecssStyle'] ?>/highdensity.css" media="screen, print"/>
		<?php endif; ?>
	</head>
		<!-- login page js translations -->
		<script type="text/javascript">
		function jsTranslate(englishString)
		{

			if( jsTranslateHash[englishString] !== undefined && jsTranslateHash[englishString].length > 0 ) return jsTranslateHash[englishString]
			else return englishString
		}
		
		//Add translation strings here for strings that have to be inside .js files (currently not configured to be parsed by php engine)
		jsTranslateHash = {
			"A popup-blocker is enabled on your browser.<br>To correctly view the WebMail application, you must allow popup windows from the URL of the site." : "<?php echo addslashes($this->translate("A popup-blocker is enabled on your browser.<br>To correctly view the WebMail application, you must allow popup windows from the URL of the site.")) ?>", 
		};
		</script>
		<!-- jQuery -->
		<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/xp.js"></script>
		<script type="text/javascript" src="<?php echo $this->siteBaseUrl; ?>js/browsercheck.js"></script>
		
		<!-- Fav icon -->
		<link rel="shortcut icon" href="<?php echo $this->siteBaseUrl ?>images/themes/<?php echo $this->global['mobilecssStyle'] ?>/favicon.ico?<?php echo Zend_registry::get('config')->global['version'] ?>" type="image/x-icon" />

		<script type="text/javascript">
		var Expand;

		// Reload to the master frame if we are inside a frameset
		if (parent.frames[1]) top.window.location=self.location;

		// Get list of local domains as a JS array 
	    <?php echo $this->localDomainsJsArray(); ?>

		$(function() {

		// Focus on the email field to start, make it easy to start downloading profile
		$("INPUT#email").focus();
		
		$("#loginPage").bind('submit', function() {
			email = $("#email").val();
			emailArgs = email.split('@');
			$("input[name=emailName]").val(emailArgs[0]);
			
			if( !emailArgs[1] ) {
				$("input[name=emailDomain]").val( $("input[name=emailDomainDefault]").val() );
				
			} else {
				$("input[name=emailDomain]").val(emailArgs[1]);				
			}

			document.body.style.cursor = 'wait';
		});
		 
		$("#dialog").dialog({ 
			autoOpen: false, 
			height: 70,
			modal: true, 
			overlay: { 
			opacity: 0.5, 
			background: "white" 
			},
			resizable: false,
			closeOnEscape: false,  
			width: 270
		});
		
		$('#email').focus();

		<?php if($this->errorMsg) : ?>
			alert("<?php echo $this->errorMsg; ?>");
		<?php endif ?>

		});
		</script>

	</head>
	<body id="bg" class="ui-mobile-viewport ui-overlay-c <?php echo $this->defaultUserSettings['Language'] ?>">
		
		<div id="dialog" style="display:none;">

		<br>
		<center>
		<div id='loading'>
		<h1 class='loading-text'><img class='loadingimg' src='<?php echo $this->siteBaseUrl ?>images/25.gif' width='28' height='28'/><span class='loading'><strong><?php echo $this->translate('Loading...') ?></strong></span></h1>
		</div>
		</center>

		</div>
				
		<?php if(isset($this->error)) :?>
			<center>
			<table width='600'>
				<tr>
				<td>
				<div id="licence-error"><img class="regerror" src="<?php echo $this->siteBaseUrl ?>images/icons/error.png"/><span>
				<?php echo 'Error: ' . $this->error ?>	
				</span>
				</div>
				</td>
				</tr>
			</table>
			</center>
		<?php endif ?>

		<?php if(isset($this->message)) :?>
			<center>
			<table width='600'>
				<tr>
				<td>
				<div id="licence-error"><img class="regerror" src="<?php echo $this->siteBaseUrl ?>images/icons/error.png"/><span>
				<?php echo $this->message ?>	
				</span>
				</div>
				</td>
				</tr>
			</table>
			</center>
		<?php endif ?>
		
		<div id="ios_profile" style="min-height: 319px; padding-top: 40px; border: medium none;" class="ui-page ui-body-c ui-page-header-fixed ui-page-active">

			<div class="ui-header ui-bar-l ui-header-fixed slidedown ui-fixed-hidden">
				<div class="logo"></div>
			</div>

			<div class="main ui-content">
		        <div class="ui-content">
					<p style="text-align:center; margin-bottom: 20px;">Enter your email and password to provision your device with email, contacts and calendar.</p>
					<form class="login-form" action="<?php echo $this->moduleBaseUrl; ?>/auth/processlogin?iosprofile" name="loginPage" id="loginPage" method="post">
						<input type='hidden' name='emailName' value=''/>
						<input type='hidden' name='emailDomain' value=''/>
						<input type='hidden' name='emailDomainDefault' value='<?php echo $this->config->dovecot['default_domain'] ?>'/>
						<input type='hidden' name='cssStyle' value='<?php echo $this->cssStyle ?>'/>
						<input type='hidden' name='requestedServer' />
		                <fieldset>
							<input id="email" class="login-input ui-input-text ui-body-c ui-corner-all ui-shadow-inset" type="email" name="email" tabindex="1" value="<?php if ($e = @$_GET['email']) echo $this->escape($e); ?>" placeholder="Email"/>
		                    <input class="login-input ui-input-text ui-body-c ui-corner-all ui-shadow-inset" type="password" name="password" id="password" tabindex="2"  value="" placeholder="Password"/>
		
		<div class="ui-btn ui-btn-inline ui-shadow ui-btn-corner-all ui-fullsize ui-btn-up-b"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text"><?php print $this->translate('Get My iOS Profile') ?></span><input class="ui-btn ui-btn-inline ui-shadow ui-btn-corner-all ui-btn-hidden ui-btn-up-b" type="submit" value="" /></div>
		                </fieldset>
		            </form>

				</div>
		    </div><!-- /content -->
		</div>
						
		<div id="foot">
			<a href="http://www.atmail.com/" target="_blank"><?php echo $this->translate('Powered by Atmail') . " " . generateVersionString($this->version) ?></a>
		</div>
	</body>
</html>
