<!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" />
<meta http-equiv="X-UA-Compatible" content="<?php echo X_UA_COMPATIBLE; ?>" />
<title><?php echo $this->page_title; ?></title>
<base href="<?php echo get_setting('base_url');?>/<?php echo GET_INDEX_SCRIPT; ?>" />
<?php if (is_array($this->_import_js_files)) { ?>
<?php foreach ($this->_import_js_files AS $import_js) { ?>
<script src="<?php echo $import_js; ?>?v=<?php echo GET_VERSION_BUILD; ?>" type="text/javascript"></script>
<?php } ?>
<?php } ?>
<link href="<?php echo GET_STATIC_URL; ?>/admin/css/default/admin_login.css?v=<?php echo GET_VERSION_BUILD; ?>" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	var GET_INDEX_SCRIPT = '<?php echo GET_INDEX_SCRIPT; ?>';
	var GET_BASE_URL = '<?php echo get_setting('base_url'); ?>/<?php echo rtrim(GET_INDEX_SCRIPT, '/'); ?>';
	var GET_USER_ID = <?php echo $this->user_id; ?>;
</script>
</head>
<body>
<div class="install">
  <p class="install_head"><span class="default_logo"></span></p>
  <div class="install_contents">
    <div class="default_error" id="notification"><h3 id="not_cont">Please enter E-mail / Username, password</h3></div>
    <form id="login_form" onsubmit="return false" action="admin/login_process_ajax/" method="post">
		<?php if($_GET['url']){ ?>
			<input type="hidden" name="url" value="<?php echo $_GET['url']; ?>">
		<?php } ?>
      <ul class="install_ul">
        <li>
          <label class="label">E-mail:</label>
		  <?php if($this->user_info){ ?>
        <span class="txt_color"><?php echo $this->user_info['email']; ?></span>
        <input class="default_textt" value="<?php echo $this->user_info['email']; ?>" type="hidden" name="username" id="username"/>
        <?php }else{ ?>
        <input class="default_text" type="text" name="username" id="username" />
        <?php } ?>
          </li>
        <li>
          <label class="label">Password:</label>
		    <input class="default_text" type="password" name="password" value="" id="password" onkeydown="if (event.keyCode == 13) { document.getElementById('login_submit').click(); };"/>
        </li>
        <?php if(get_setting('admin_login_seccode') == 'Y'){ ?>
        <li>
          <label class="label">Verification code:</label>
		    <input class="default_text" style="width:60px;" type="text" name="seccode_verify" value="" id="seccode_verify" onkeydown="if (event.keyCode == 13) { document.getElementById('login_submit').click(); };"/> &nbsp; <img src="" onclick="this.src = GET_BASE_URL + '/account/captcha/?' + Math.floor(Math.random() * 10000);" id="seccode" style="vertical-align:middle" /> <a href="javascript:void(0);" onclick="$('#seccode').click();">Click image to change</a>
        </li>
        <?php } ?>
        <li  class="install_n"><a id="login_submit" class="default_install" href="javascript:;" onclick="ajax_post($('#login_form'), _login_post_processer);">Login</a></li>
      </ul>
    </form>
  </div>
</div>


<script type="text/javascript">

$(document).ready(function () {
	$('#seccode').click();
});

function _login_post_processer(result)
{
	if (result.errno == "-1")
	{
		$("#notification").removeClass("information").addClass("error");
		$("#not_cont").html(result.err);
	}
	else if(result.errno=="1")
	{
		if(result.rsm.url != undefined)
		{
			window.location.href = result.rsm.url;
		}
		else
		{
			window.location.href = GET_BASE_URL + '/admin/';
		}
	}
}
</script>

<?php TPL::output('global/debuger.tpl.htm'); ?>
</body>
</html>