{template_user 'head.html'}

<div class="index-bg">
	<div class="container">
		<div class="section2">



			<div class="user-content-table-nav">
				<ul>
					<li><a href="{url('user/edit/table/user')}">{lang('edituserinfo')}</a></li>
					<li><a class="active" href="{url('user/changepassword')}">{lang('changepassword')}</a></li>
				</ul>
			</div>

			<div class="clearfix blank30"></div>

<script languagel="javascript">
    <!--
    function CheckForm()
    {
        if (document.myform.pwdconfirm.value!=document.myform.password.value)
        {
            alert("{lang('twicepassnosame')}")
            document.myform.password.value = ""
            document.myform.pwdconfirm.value = ""
            document.myform.password.focus()
            document.myform.password.select()
            return false
        }

        document.myform.submit.disabled=true;
    }
    //-->
</script>



<?php
if(hasflash()){
	$showmessage = showflash();
	if(strlen($showmessage)>200){ 
?>
<div id='message'><span style="color:red;float:left"><?php echo $showmessage; ?></span>
<span style="color:blue;float:right"><a href="#" onClick="javascript:turnoff('#message');">(×)</a></span></div><div class="blank20"></div>
<?php
    }else{
?>
<script type="text/javascript">
art.dialog({
		id:'messagebox',
		content:"<?php echo $showmessage; ?>",
		title:"{lang('prompted')}",
		time: 2,
		lock:true
	});
</script>
<?php
    }
}
?>

<form name=myform onsubmit="return CheckForm();" action="<?php echo uri();?>" method=post>

 <div class="clearfix form-group">
    <label>{lang('oldpassword')}</label>
    <input class="form-control" type="password" placeholder="{lang('oldpassword')}" value="" name="oldpassword">
  </div>

   <div class="clearfix form-group">
    <label>{lang('newpassword')}</label>
    <input class="form-control" id="password" type="password" placeholder="{lang('newpassword')}" value="" name="password">
	<div class="blank10"></div>
	<div class="ywz_zhuce_huixian" id='pwdLevel_1'> </div>
			<div class="ywz_zhuce_huixian" id='pwdLevel_2'> </div>
			<div class="ywz_zhuce_huixian" id='pwdLevel_3'> </div>
			<div class="ywz_zhuce_hongxianwenzi"> {lang('weak')}</div>
			<div class="ywz_zhuce_hongxianwenzi"> {lang('middle')}</div>
			<div class="ywz_zhuce_hongxianwenzi"> {lang('strong')}</div>
  </div>

   <div class="clearfix form-group">
    <label>{lang('againpassword')}</label>
    <input class="form-control" id="pwdconfirm" type="password" placeholder="{lang('againpassword')}" value="" name="pwdconfirm">
	<div class="blank10"></div>
	<div class="ywz_zhuce_huixian" id='pwdLevel_4'> </div>
			<div class="ywz_zhuce_huixian" id='pwdLevel_5'> </div>
			<div class="ywz_zhuce_huixian" id='pwdLevel_6'> </div>
			<div class="ywz_zhuce_hongxianwenzi"> {lang('weak')}</div>
			<div class="ywz_zhuce_hongxianwenzi"> {lang('middle')}</div>
			<div class="ywz_zhuce_hongxianwenzi"> {lang('strong')}</div>
  </div>

<div class="blank30"></div>
{lang('6_16_bits_consisting_of_letters_casesensitive_numbers_and_symbols')}
<div class="blank30"></div>
<input type=hidden value=1 name=dosubmit> 
<input class="btn btn-primary" type=submit value="{lang('edit')}" name="submit" style="margin-right:15px;">

<input class="btn btn-warning" type=reset value="{lang('clear')}" name="reset">
</form>

  </div>
</div>
</div>



  
<script type="text/javascript">
	$('#password').focus(function () {
		$('#pwdLevel_1').attr('class', 'ywz_zhuce_hongxian');
		$('#password').keyup();
	});


	$('#password').keyup(function () {
		var __th = $(this);

		if (!__th.val()) {
			$('#pwd_tip').hide();
			$('#pwd_err').show();
			Primary(1);
			return;
		}
		if (__th.val().length < 6) {
			$('#pwd_tip').hide();
			$('#pwd_err').show();
			Weak(1);
			return;
		}
		var _r = checkPassword(__th);
		if (_r < 1) {
			$('#pwd_tip').hide();
			$('#pwd_err').show();
			Primary(1);
			return;
		}

		if (_r > 0 && _r < 2) {
			Weak(1);
		} else if (_r >= 2 && _r < 4) {
			Medium(1);
		} else if (_r >= 4) {
			Tough(1);
		}

		$('#pwd_tip').hide();
		$('#pwd_err').hide();
	});


	$('#pwdconfirm').focus(function () {
		$('#pwdLevel_4').attr('class', 'ywz_zhuce_hongxian');
		$('#password').keyup();
	});


	$('#pwdconfirm').keyup(function () {
		var __th = $(this);

		if (!__th.val()) {
			$('#pwd_tip').hide();
			$('#pwd_err').show();
			Primary(4);
			return;
		}
		if (__th.val().length < 6) {
			$('#pwd_tip').hide();
			$('#pwd_err').show();
			Weak(4);
			return;
		}
		var _r = checkPassword(__th);
		if (_r < 1) {
			$('#pwd_tip').hide();
			$('#pwd_err').show();
			Primary(4);
			return;
		}

		if (_r > 0 && _r < 2) {
			Weak(4);
		} else if (_r >= 2 && _r < 4) {
			Medium(4);
		} else if (_r >= 4) {
			Tough(4);
		}

		$('#pwd_tip').hide();
		$('#pwd_err').hide();
	});
 

	function Primary(id) {
		if(id==''){
			id=1;
		}
		$('#pwdLevel_'+id).attr('class', 'ywz_zhuce_huixian');
		$('#pwdLevel_'+(id+1)).attr('class', 'ywz_zhuce_huixian');
		$('#pwdLevel_'+(id+2)).attr('class', 'ywz_zhuce_huixian');
	}


	function Weak(id) {
		if(id==''){
			id=1;
		}
		$('#pwdLevel_'+id).attr('class', 'ywz_zhuce_hongxian');
		$('#pwdLevel_'+(id+1)).attr('class', 'ywz_zhuce_huixian');
		$('#pwdLevel_'+(id+2)).attr('class', 'ywz_zhuce_huixian');
	}

	function Medium(id) {
		if(id==''){
			id=1;
		}
		$('#pwdLevel_'+id).attr('class', 'ywz_zhuce_hongxian');
		$('#pwdLevel_'+(id+1)).attr('class', 'ywz_zhuce_hongxian2');
		$('#pwdLevel_'+(id+2)).attr('class', 'ywz_zhuce_huixian');
	}

	function Tough(id) {
		if(id==''){
			id=1;
		}
		$('#pwdLevel_'+id).attr('class', 'ywz_zhuce_hongxian');
		$('#pwdLevel_'+(id+1)).attr('class', 'ywz_zhuce_hongxian2');
		$('#pwdLevel_'+(id+2)).attr('class', 'ywz_zhuce_hongxian3');
	}




	function checkPassword(pwdinput) {
		var maths, smalls, bigs, corps, cat, num;
		var str = $(pwdinput).val()
		var len = str.length;

		var cat = /.{16}/g
		if (len == 0) return 1;
		if (len > 16) { $(pwdinput).val(str.match(cat)[0]); }
		cat = /.*[\u4e00-\u9fa5]+.*$/
		if (cat.test(str)) {
			return -1;
		}
		cat = /\d/;
		var maths = cat.test(str);
		cat = /[a-z]/;
		var smalls = cat.test(str);
		cat = /[A-Z]/;
		var bigs = cat.test(str);
		var corps = corpses(pwdinput);
		var num = maths + smalls + bigs + corps;

		if (len < 6) { return 1; }

		if (len >= 6 && len <= 8) {
			if (num == 1) return 1;
			if (num == 2 || num == 3) return 2;
			if (num == 4) return 3;
		}

		if (len > 8 && len <= 11) {
			if (num == 1) return 2;
			if (num == 2) return 3;
			if (num == 3) return 4;
			if (num == 4) return 5;
		}

		if (len > 11) {
			if (num == 1) return 3;
			if (num == 2) return 4;
			if (num > 2) return 5;
		}
	}

	function corpses(pwdinput) {
		var cat = /./g
		var str = $(pwdinput).val();
		var sz = str.match(cat)
		for (var i = 0; i < sz.length; i++) {
			cat = /\d/;
			maths_01 = cat.test(sz[i]);
			cat = /[a-z]/;
			smalls_01 = cat.test(sz[i]);
			cat = /[A-Z]/;
			bigs_01 = cat.test(sz[i]);
			if (!maths_01 && !smalls_01 && !bigs_01) { return true; }
		}
		return false;
	}
</script>
{template_user 'foot.html'}