<script type="text/javascript">
(function(){
	function checkPwdOld(password){
		if ("" == password){
			return E_PWD_OLD_BLANK;
		}

		return E_NONE;
	}

	function checkPwdNew(pwdNew, pwdCfm){
		var err = checkStrFormat(pwdNew);
		switch(err){
		case E_STRINGBLANK:
			return E_PWD_NEW_BLANK;
		case E_STRINGFORMAT:
			return E_PWD_NEW_ILLEGAL;
		}

		if (checkStrLen(pwdNew, 63, 5)){
			return E_PWD_NEW_LEN;
		}

		if (pwdNew != pwdCfm){
			return E_PWD_NEW_REPEAT_SAME;
		}

		return E_NONE;
	}

	function refreshPwd(){
		history.go(-1);
	}

	$("#Save").click(function(){
		var oldPwd = $("#PwdOld").val();
		var pwd = $("#PwdNew").val();
		var confirmPwd = $("#PwdCfm").val();

		if (handleError(checkPwdOld(oldPwd))){
			return;
		}

		if (handleError(checkPwdNew(pwd, confirmPwd))){
			return;
		}

		var oldpwdEncoded = new Base64().base64encode(oldPwd);
		var pwdEncoded = new Base64().base64encode(pwd);
		var data = {};
		data.old_password = oldpwdEncoded;
		data.new_password = pwdEncoded;

		apiModify(data, function(ret){
			var code = ret[ERR_CODE];
			handleError(code, showNote)?closeLoading():refreshPwd();
		});
	});
})();
</script>
<div class="head-con">
	<a href="javascript:history.go(-1);" class="head-btn-l"><i class="head-btn icon icon_back"></i></a>
	<h1 class="head-title">{%label.adminPwd%}</h1>
</div>
<div class="set-con below-head">
	<ul class="blank-bg"></ul>
	<ul class="set-con">
		<label class="desc-lbl desc-width">{%label.oldPwd%}</label>
		<li class="text-con">
				<input class="text ime-mode-n hover text-width" maxLength="63" id="PwdOld" value="" />
			<i class="tip icon-eye" data-value="0"></i>
		</li>
	</ul>
	<ul class="set-con">
		<label class="desc-lbl desc-width">{%label.newPwd%}</label>
		<li class="text-con">
				<input class="text ime-mode-n hover text-width" maxLength="63" id="PwdNew" value="" placeholder="{%label.pwdLenTip%}" />
			<i class="tip icon-eye" data-value="0"></i>
		</li>
	</ul>
	<ul class="set-con">
		<label class="desc-lbl desc-width">{%label.confirmNewPwd%}</label>
		<li class="text-con">
				<input class="text ime-mode-n hover text-width" maxLength="63" id="PwdCfm" value="" placeholder="{%label.pwdLenTip%}" />
			<i class="tip icon-eye" data-value="0"></i>
		</li>
	</ul>
	<ul class="blank-bg"></ul>
	<div class="err-note hidden">
		<i class="err-icon icon_remind_line"></i>
		<p class="note-str"></p>
	</div>
	<div class="btn-con">
		<input id="Save" class="btn" type="button" value="{%btn.save%}" />
	</div>
</div>