/*
 * account.js
 * This document contains the basic operation of the user registration
 */


/*
 * Check the existence of members
 */
function checkNewName(){
	var email = $('#ue_N').val();
	if(email=='' || (/^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,5}$/i).exec(email)==null) {
		$("#result").html('電子メールの形式が修正されていません');
		$('#result').css('color', '#AA0033');
		return false;
	}
	$('#result').html('正しい');
	document.getElementById('sbnext').disabled = false;
	$('#result').css('color', '#008000');

	$.ajax({
		url: url+"/Member/checkAccount/email/"+email,
		dataType: 'json',
		success: function(response){
			$("#result").html(response.msg);
			if(response.type=='1'){
				document.getElementById('sbnext').disabled = true;
			}else if(response.type=='0'){
				document.getElementById('sbnext').disabled = false;
			}
			
		}
	});
	return true;
}

/*
 * Check the password is correct
 */
function checkNewPwd(){
	var pwd = $('#up_N').val();
	if(pwd=='' || (/^\S{6,16}$/i).exec(pwd)==null) {
		$('#pwdresult').html('不適切なパスワードの形式');
		$('#pwdresult').css('color', '#AA0033');
		return false;
	} else {
		$('#pwdresult').html('正しい');
		$('#pwdresult').css('color', '#008000');
		return true;
	}
}
function checkPwdAgain(){
	if(!($('#up_N').val())) {
		$('#nn').show();
		$('#yy').hide();
		return false;
	}
	if($('#up_N').val() == $('#pwd_chk').val()) {
		$('#yy').show();
		$('#nn').hide();
		return true;
	} else {
		$('#nn').show();
		$('#yy').hide();
		return false;
	}
}

/*
 * Submit information
 */
function submitValues() {
	var b1 = checkNewName();
	var b2 = checkNewPwd();
	var b3 = checkPwdAgain();
	var b4 = $('#agreed').attr('checked');

	if(b1 && b2 && b3 && b4) {
		document.forms['form11'].submit();
	} else {
		return false;
	}
}

function chkreemail(){
	var mail=$("#ue_N").attr("value");
	var remail=$("#ue_cN").attr("value");
	if(mail==remail&&mail.length>1){
		$("#suss").html('<img style="padding:3px 0px;" src=__PUBLIC__/Rmtco/images/success.png>');
        $("#erro").html('');
	}else{
		$("#erro").html('<img style="vertical-align: middle;padding:3px 0px;"  src="__PUBLIC__/Rmtco/images/error.png" /><font color="red">同一のメールアドレスを入力して下さい。</font>');
	    $("#suss").html('');
		}
}
