$(document).ready(function(){
	
	$("#idcheckbtn").click(function() {
		if($("input[name=userid]").val() ==""){
			alert('아이디를 입력바랍니다');
			document.form_agree.userid.focus();
		}else{

			 $.post("id_check.html", {
				id: $("input[name=userid]").val()
			 },
			function(data){
				//$("#idcheck").html(data);
				if(data == "fail"){
					$("#check_id").val("no");
					$("#idcheck").html("<span style=\"color:#FF0000\">존재하는 아이디 입니다.</span>");
				}else{
					$("#check_id").val("yes");
					$("#idcheck").html("<span style=\"color:#00AA00\">사용 가능한 아이디 입니다.</span>");
				}
			});

		}
	});

});

function change_chkValue(stype)
{
    document.getElementById(stype).value = '0';
}

// 로그인체크
function login_check()
{
	var theForm = document.form01;
	if( trim(theForm.user_id.value) =="" )
	{
		alert('아이디를 입력바랍니다');
		theForm.user_id.focus();
		return false;
	}	
	if( trim(theForm.user_pass.value) =="" )
	{
		alert('비밀번호를 입력바랍니다');
		theForm.user_pass.focus();
		return false;
	}	
	return true;
}


// 회원 약관 동의
function member_agree()
{

   var f = document.form01;

	if( !f.magreeYn1.checked )
	{
		alert( '이용약관에 동의하셔야 합니다.' );
		f.magreeYn1.focus();
		return false;
	}

	if( !f.magreeYn2.checked )
	{
		alert( '개인정보취급방침에 동의하셔야 합니다.' );
		f.magreeYn2.focus();
		return false;
	}

	return true;

}


// 회원 가입체크
function member_reg()
{
	var theForm = document.form_agree;
	if( trim(theForm.name.value) =="" )
	{
		alert('이름을 입력바랍니다');
		theForm.name.focus();
		return false;
	}	
	if( trim(theForm.userid.value) =="")
	{
		alert('아이디를 입력바랍니다');
		theForm.userid.focus();
		return false;
	}	
	if(theForm.check_id.value =="0"){
		alert('중복체크를 하시기 바랍니다.');
		theForm.userid.focus();
		return false;
	}
	if(theForm.check_id.value =="no"){
		alert('이미 존재하는 아이디입니다. 다시 입력바랍니다');
		theForm.userid.focus();
		return false;
	}
	if( trim(theForm.userpass.value) =="")
	{
		alert('비밀번호를 입력바랍니다');
		theForm.userpass.focus();
		return false;
	}	
	if( trim(theForm.userpass_re.value) =="")
	{
		alert('비밀번호확인을 입력바랍니다');
		theForm.userpass_re.focus();
		return false;
	}	
	if( trim(theForm.userpass.value) != trim(theForm.userpass_re.value) )
	{
		alert('비밀번호가 틀립니다 확인하여 입력바랍니다');
		theForm.userpass_re.focus();
		return false;
	}	
	if( trim(theForm.email.value) =="")
	{
		alert('이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( CheckMail(theForm.email.value) == false)
	{
		alert('올바른 이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( trim(theForm.mobile.value) =="")
	{
		alert('연락처를 입력바랍니다');
		theForm.mobile.focus();
		return false;
	}	
	return true;

}

// 회원 수정체크
function member_modify(){
	var theForm = document.form_agree;
	if( trim(theForm.userpass.value) =="")
	{
		alert('비밀번호를 입력바랍니다');
		theForm.userpass.focus();
		return false;
	}	
	if( trim(theForm.userpass_re.value) =="")
	{
		alert('비밀번호확인을 입력바랍니다');
		theForm.userpass_re.focus();
		return false;
	}	
	if( trim(theForm.userpass.value) != trim(theForm.userpass_re.value) )
	{
		alert('비밀번호가 틀립니다 확인하여 입력바랍니다');
		theForm.userpass_re.focus();
		return false;
	}	
	if( trim(theForm.email.value) =="")
	{
		alert('이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( CheckMail(theForm.email.value) == false)
	{
		alert('올바른 이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( trim(theForm.mobile.value) =="")
	{
		alert('연락처를 입력바랍니다');
		theForm.mobile.focus();
		return false;
	}	
	return true;

}


// 회원 탈퇴체크
function member_delete(){
	var theForm = document.form01;
	if( trim(theForm.userpass.value) =="")
	{
		alert('비밀번호를 입력바랍니다');
		theForm.userpass.focus();
		return false;
	}else{
		if(confirm('정말 탈퇴하시겠습니까?')) {
			return true;
		}
		return false;
	}

}


// 회원 가입 동의취소
function member_noagree(){
	location.href="./";
}

//메일링 가입신청
function mailing_join(){
	var theForm = document.form01;
	if( trim(theForm.name.value) =="" )
	{
		alert('이름을 입력바랍니다');
		theForm.name.focus();
		return false;
	}	
	if( trim(theForm.email.value) =="")
	{
		alert('이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( CheckMail(theForm.email.value) == false)
	{
		alert('올바른 이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( trim(theForm.residence.value) =="")
	{
		alert('거주지를 입력바랍니다');
		theForm.residence.focus();
		return false;
	}	
	return true;

}


//회원 아이디 찾기
function forget_id(){
	var theForm = document.form01;
	if( trim(theForm.mem_name.value) =="" )
	{
		alert('실명을 입력바랍니다');
		theForm.mem_name.focus();
		return false;
	}	
	if( trim(theForm.mem_email.value) =="")
	{
		alert('이메일을 입력바랍니다');
		theForm.mem_email.focus();
		return false;
	}	
	if( CheckMail(theForm.mem_email.value) == false)
	{
		alert('올바른 이메일을 입력바랍니다');
		theForm.mem_email.focus();
		return false;
	}	
	return true;

}


//회원 비번 찾기
function forget_pass(){
	var theForm = document.form02;
	if( trim(theForm.mem_id.value) =="" )
	{
		alert('아이디을 입력바랍니다');
		theForm.mem_id.focus();
		return false;
	}	
	if( trim(theForm.mem_email.value) =="")
	{
		alert('이메일을 입력바랍니다');
		theForm.mem_email.focus();
		return false;
	}	
	if( CheckMail(theForm.mem_email.value) == false)
	{
		alert('올바른 이메일을 입력바랍니다');
		theForm.mem_email.focus();
		return false;
	}	
	return true;

}

//수강신청
function educ_reg(){
	var theForm = document.form01;
	if( trim(theForm.korname.value) =="")
	{
		alert('한글이름을 입력바랍니다');
		theForm.korname.focus();
		return false;
	}	
	if( trim(theForm.engname.value) =="")
	{
		alert('영문이름을 입력바랍니다');
		theForm.engname.focus();
		return false;
	}	
	if( trim(theForm.zipcode01.value) =="")
	{
		alert('우편번호를 입력바랍니다');
		return false;
	}	
	if( trim(theForm.zipcode02.value) =="")
	{
		alert('우편번호를 입력바랍니다');
		return false;
	}		
	if( trim(theForm.address01.value) =="")
	{
		alert('주소를 입력바랍니다');
		theForm.address01.focus();
		return false;
	}	
	if( trim(theForm.address02.value) =="")
	{
		alert('주소를 입력바랍니다');
		theForm.address02.focus();
		return false;
	}		
	if( trim(theForm.mobile.value) =="")
	{
		alert('연락처를 입력바랍니다');
		theForm.mobile.focus();
		return false;
	}	
	if( trim(theForm.email.value) =="")
	{
		alert('이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( CheckMail(theForm.email.value) == false)
	{
		alert('올바른 이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( trim(theForm.mobile.value) =="")
	{
		alert('연락처를 입력바랍니다');
		theForm.mobile.focus();
		return false;
	}	
	return true;

}

//후원신청
function support_reg(){
	var theForm = document.form01;
	var types = 0;
	var banktype = 0;
	var bankday = 0;

	if( trim(theForm.name.value) =="")
	{
		alert('이름/기관명을 입력바랍니다');
		theForm.name.focus();
		return false;
	}	
	if( trim(theForm.email.value) =="")
	{
		alert('이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}	
	if( CheckMail(theForm.email.value) == false)
	{
		alert('올바른 이메일을 입력바랍니다');
		theForm.email.focus();
		return false;
	}		

	if( trim(theForm.address01.value) =="")
	{
		alert('주소를 입력바랍니다');
		return false;
	}	
	if( trim(theForm.address02.value) =="")
	{
		alert('주소를 입력바랍니다');
		theForm.address02.focus();
		return false;
	}		
	if( trim(theForm.mobile.value) =="")
	{
		alert('연락처를 입력바랍니다');
		theForm.mobile.focus();
		return false;
	}	
	for(i=0; i<theForm.type.length; i++){ 
        if(theForm.type[i].checked) {
			types = "1";
		}
    } 
	if( types == "0"  )
	{
		alert('후원방법을 선택바랍니다');
		return false;
	}	


	if(theForm.type[0].checked == true){   // 후원방법:정기후원방식
	
		if( trim(theForm.support_money.value) =="")
		{
			alert('후원액을 입력바랍니다');
			theForm.support_money.focus();
			return false;
		}	
	
		for(i=0; i<theForm.banktype.length; i++){ 
	        if(theForm.banktype[i].checked) {
				banktype = "1";
			}
	    } 
		if( banktype == "0"  )
		{
			alert('납입형태를 선택바랍니다');
			return false;
		}	
	
	
		if( trim(theForm.bankname.value) =="")
		{
			alert('출금은행을 입력바랍니다');
			theForm.bankname.focus();
			return false;
		}	
		if( trim(theForm.banknumber.value) =="")
		{
			alert('출금계좌를 입력바랍니다');
			theForm.banknumber.focus();
			return false;
		}	
		if( trim(theForm.bankowner.value) =="")
		{
			alert('예금주명을 입력바랍니다');
			theForm.bankowner.focus();
			return false;
		}	
		if( trim(theForm.bankjumin1.value) =="")
		{
			alert('예금주주민번호을 입력바랍니다');
			theForm.bankjumin1.focus();
			return false;
		}	
		if( trim(theForm.bankjumin2.value) =="")
		{
			alert('예금주 주민번호을 입력바랍니다');
			theForm.bankjumin2.focus();
			return false;
		}		
	
		for(i=0; i<theForm.bankday.length; i++){ 
	        if(theForm.bankday[i].checked) {
				bankday = "1";
			}
	    } 
		if( bankday == "0"  )
		{
			alert('출금일을 선택바랍니다');
			return false;
		}	
	
	}else{  // 후원방법:비정기후원방식
	
		if( trim(theForm.support_money.value) =="")
		{
			alert('후원액을 입력바랍니다');
			theForm.support_money.focus();
			return false;
		}	
	
		for(i=0; i<theForm.banktype.length; i++){ 
	        if(theForm.banktype[i].checked) {
				banktype = "1";
			}
	    } 
		if( banktype == "0"  )
		{
			alert('납입형태를 선택바랍니다');
			return false;
		}	
		
	}
	
	return true;

}


function checkpass(){
	var theForm = document.theform;

	if( trim(theForm.passwd.value) =="")
	{
		alert('비밀번호를 입력바랍니다');
		theForm.passwd.focus();
		return false;
	}	
	return true;
}
