/**
 * @author hooriza (ajaxUI team)
 */
 
(function(className) {

	SPS[className] = $Class({
		
		_o : null,

		$init : function(sEl) {

			var oEl = $(sEl);
			
			var o = this._o = {};
			o.frm = SPS.getParentForm(oEl);
			o.password = $$('input[name=password]', oEl)[0];
			o.rePasswd = $$('input[name=repasswd]', oEl)[0];
			
			o.pwdSafe = $$('.pwdsafe', oEl)[0];
			o.pwdMatch = $$('.pwdmatch', oEl)[0];

			o.submit = $$('.edit_per_btn a', oEl)[0];
			
			this._bindEvents();
			
		},
		
		_bindEvents : function() {
			
			var o = this._o;
			
			// 비밀번호 입력 중 확인
			$Fn(function(oEvent) {
				this._checkPasswordSafe();
				this._checkPasswordMatch();
			}).owner(this).attach(o.password, 'keyup');

			// '비밀번호 재입력' 입력 중 확인
			$Fn(function(oEvent) {
				this._checkPasswordMatch();
			}).owner(this).attach(o.rePasswd, 'keyup');
			
			this._checkPasswordSafe();
			this._checkPasswordMatch();
			
		},
		
		_checkPasswordSafe : function() {
			
			var o = this._o;
			$Element(o.pwdSafe)[o.password.value.length < 6 ? 'hide' : 'show']();
			
		},
		
		_checkPasswordMatch : function() {
			
			var o = this._o;
			var bFlag = (o.rePasswd.value.length > 0) && (o.rePasswd.value == o.password.value);
			
			$Element(o.pwdMatch)[bFlag ? 'show' : 'hide']();
			
		}

	});

})('ct_128_01');
