// JavaScript Document
<!--
var UnAvalNmChars = '0123456789 ';	//2006.10.11  / 공백,숫자는 회원가입정보 First Name, Last Name에 사용못함.
var Alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
var Digit = '1234567890'
var TelDigit = '-1234567890'
var Mail = "@.-_"	

var win1
var win2
var idcheck_clicked = "1"


function chkid(f) 
{
	if (Tcheck(f.userid, 'ID', Alpha + Digit , 6, 12)) return;	
	if (f.userid.value=="") {alert("\n Please enter your ID."); f.userid.focus();	return;}
		idcheck_clicked = "2"	 //2이면 아이디 체크를 누른 것이다. 		
		window.open('/member/id_confirm.jsp?userid='+f.userid.value,'iddup','width=350,height=348,left=300,top=200');
}

function Check() { 
	var total = 0; 
	for (var i = 0; i < f.user_interest.length; i++) { 
		if (eval("f.user_interest[" + i + "].checked") == true) { 
			total += 1; 
		} 
	} 
	if (total < 1){
		alert("You must choose at least one category."); 
		return false
	}
} 

function w_close(f) {
	if (f != null && !f.closed) 
		f.close();
}

function Tcheck(target, cmt, astr, lmin, lmax){
			 
		var i;
		var t = target.value;
		
		if (t.length < lmin || t.length > lmax) {
			if (lmin == lmax) alert(cmt + 'must ' + lmin + ' characters.')
			else alert(cmt + ' must be between ' + lmin + ' ~ ' + lmax + ' characters.')
			target.focus();
			return true
		}
		if (astr.length > 1) {
				for (i=0; i < t.length; i++)
					if(astr.indexOf(t.substring(i,i+1))<0) {
					alert('There is an unacceptable character contained in ' + cmt)
					target.focus();
					return true
				}
		}
		return false
}

		
// 회원가입시 First Name,Last Name은 영문자만 입력할 수 있도록 되어 있었으나 
// 숫자, 공백문자를 제외한 모든문자의 입력이 가능하도록 변경함.
function Tcheck01(target, cmt, astr, lmin, lmax){
			 
		var i;
		var t = target.value;
		
		if (t.length < lmin || t.length > lmax) {
			if (lmin == lmax) alert(cmt + 'must ' + lmin + ' characters.')
			else alert(cmt + ' must be between ' + lmin + ' ~ ' + lmax + ' characters.')
			target.focus();
			return true
		}
		if (astr.length > 1) {
				for (i=0; i < t.length; i++)
					if(astr.indexOf(t.substring(i,i+1))!=-1) {
					alert('There is an unacceptable character contained in ' + cmt)
					target.focus();
					return true
				}
		}
		return false
}		
		
		
function hanCheck(f) { 
	var x = f
	for(i=0;i<x.username.value.length;i++) { 
		var a=x.username.value.charCodeAt(i); 
		if (a < 129) { 
			alert('Please use Korean characters.'); 
			x.username.value=""; 
			x.username.focus(); 
			return true; 
		} 
	} 
} 

			

function email_chk(email)
{
	var t = email.value
	var ValidFlag = false
	var atCount = 0
	var SpecialFlag
	var atLoop
	var atChr
	var BadFlag
	var tAry1
	var UserName
	var DomainName

	if ( t.length > 0 && t.indexOf("@") > 0 && t.indexOf(".") > 0 ) {
		atCount = 0
		SpecialFlag = false

		for( atLoop=1; atLoop<=t.length; atLoop++ ) {
			atChr = t.substring( atLoop, atLoop+1 )
			if ( atChr == "@" ) atCount = atCount + 1

			if ( (atChr >= 32) && (atChr <= 44) ) SpecialFlag = true 
			if ( (atChr == 47) || (atChr == 96) || (atChr >= 123) ) SpecialFlag = true 
			if ( (atChr >= 58) && (atChr <= 63) ) SpecialFlag = true 
			if ( (atChr >= 91) && (atChr <= 94) ) SpecialFlag = true 
		}

		if ( ( atCount == 1 ) && (SpecialFlag == false ) ) {
			BadFlag = false
			tAry1 = t.split("@")
			UserName = tAry1[0]
			DomainName = tAry1[1]
			if ( (UserName.length <= 0 ) || (DomainName.length <= 0 ) ) BadFlag = true
			if ( DomainName.substring( 1, 2 ) == "." ) BadFlag = true
			if ( DomainName.substring( DomainName.length-1, DomainName.length) == "." ) BadFlag = true
			ValidFlag = true
		}
	}
	if ( BadFlag == true ) ValidFlag = false
	return ValidFlag
}




//-----------------------------------------------------------------------------------------///
function fsubmit(f){

	if(f.pact.value=="insert"){	
		if (f.userid.value =="") {
			alert("Please enter your ID.");
			f.userid.focus();	
			return false;
		}
		if (Tcheck(f.userid, 'ID', Alpha + Digit, 6, 12)) return false
	
		if (f.checkIdFlag.value=="") {
			alert("Please check to see if your ID already exists.");
			f.userid.focus();
			return false;
		}
	}
	
	if (f.username.value =="") {
		alert("Please enter your korean name.");
		f.username.focus();
		return false;
	}

	if (f.userpwd.value =="") {
		alert("Please enter your Password.");
		f.userpwd.focus();
		return false;
	}
	if (Tcheck(f.userpwd, 'Password', '', 6, 10)) return false
	
	if (f.user_re_pwd.value =="") {
		alert("Wrong password. Please retype your password.");
		f.user_re_pwd.focus();
		return false;
	}
	if (Tcheck(f.user_re_pwd, 'retype Password', '', 3, 10)) return false
	
	if (f.userpwd.value != f.user_re_pwd.value) {
		alert("Your password doesn't correspond with retyped password.");
		f.userpwd.focus();
		return false;
	}

	if (f.username_first.value =="") {
		alert("Please enter your First Name.");
		f.username_first.focus();
		return false;
	}
	if (Tcheck01(f.username_first, 'First Name', UnAvalNmChars, 2, 20)) return false
	if (f.username_last.value =="") {
		alert("Please enter your Last Name.");
		f.username_last.focus();
		return false;
	}
	if (Tcheck01(f.username_last, 'Last Name', UnAvalNmChars, 2, 20)) return false

	if (f.nation_code.value =="-1") {
		alert("Please choose your country.");
		f.nation_code.focus();
		return false
	}
	
	if (f.live_nation.value =="-1") {
		alert("Please choose your dwelling country.");
		f.live_nation.focus();
		return false
	}

	if (f.email.value =="") {
		alert("Please enter your E-mail address.");
		f.email.focus();
		return false
	}
	if (Tcheck(f.email, 'E-mail address', Alpha + Digit + Mail, 5, 30)) return false
	
	if (f.email.value.indexOf("@") + "" == "-1" || f.email.value.indexOf(".") + "" == "-1" ) 
	{ alert("\n Your e-mail has been sent to the wrong address."); f.email.focus(); return false;}	


	// user_interest by postcorea
	var count = 0;
	for( var i=0; i< f.chk.length ; i++)
    {
		if(f.chk[i].checked == true){
			count++;
			f.user_interest.value += f.chk[i].value;
		}		
	}
	
	if(count < 1) {
		alert("Please choose your interest at least one category.");
		//f.chk.focus();
		return false
	}

	f.birthday.value = f.user_birth_yy.value+f.user_birth_mm.value+f.user_birth_dd.value;
	
	f.action ="/member/registerok.jsp";	
	encryptForm01(f);
	f.submit;	
}

function fsubmitA(f){
	
	if (f.userpwd.value =="") {
		alert("Please enter your Password.");
		f.userpwd.focus();
		return false;
	}
	if (Tcheck(f.userpwd, 'Password', '', 3, 10)) return false
	
	if (f.user_re_pwd.value =="") {
		alert("Wrong password. Please retype your password.");
		f.user_re_pwd.focus();
		return false;
	}
	if (Tcheck(f.user_re_pwd, 'retype Password', '', 3, 10)) return false
	
	if (f.userpwd.value != f.user_re_pwd.value) {
		alert("Your password doesn't correspond with retyped password.");
		f.userpwd.focus();
		return false;
	}




	if (f.username_first.value =="") {
		alert("Please enter your Name.");
		f.username_first.focus();
		return false;
	}
	if (Tcheck(f.username_first, 'Last Name', Alpha, 2, 20)) return false
	if (f.username_last.value =="") {
		alert("Please enter your Last Name.");
		f.username_last.focus();
		return false;
	}
	if (Tcheck(f.username_last, 'Last Name', Alpha, 2, 20)) return false
	if (f.username.value != ""){	
		if (hanCheck(f)) return false
	}

	
	if (f.user_birth_yy.value =="") {
		alert("Please enter your birth year.");
		f.user_birth_yy.focus();
		return false;
	}
	
	if (f.user_birth_mm.value =="") {
		alert("Please enter your birth month.");
		f.user_birth_mm.focus();
		return false;
	}
	
	if (f.user_birth_dd.value =="") {
		alert("Please enter your birth day.");
		f.user_birth_dd.focus();
		return false;
	}

	if (f.email.value =="") {
		alert("Please enter your E-mail address.");
		f.email.focus();
		return false
	}
	if (Tcheck(f.email, 'E-mail address', Alpha + Digit + Mail, 5, 30)) return false

	
	if (f.email.value.indexOf("@") + "" == "-1" || f.email.value.indexOf(".") + "" == "-1" ) 
	{ alert("\n Your e-mail has been sent to the wrong address."); f.email.focus(); return false;}
	
	if (f.nation_code.value =="-1") {
		alert("Please input your nation code.");
		f.nation_code.focus();
		return false
	}
	
	if (f.live_nation.value =="-1") {
		alert("Please choose your live nation code.");
		f.live_nation.focus();
		return false
	}

	/*
	if (f.addr.value =="") {
		alert("Please input your address.");
		f.addr.focus();
		return false
	}
	*/
	/*
	if ((eval("f.user_interest1.checked") != true) && (eval("f.user_interest2.checked") != true) && (eval("f.user_interest3.checked") != true) && (eval("f.user_interest4.checked") != true) && (eval("f.user_interest5.checked") != true) && (eval("f.user_interest6.checked") != true) && (eval("f.user_interest7.checked") != true)) {
		alert("Please choose your interest at least one category.");
		f.user_interest1.focus();
		return false
	}*/
	
	var interest = "";
	if (eval(f.user_interest1.checked)) { interest += f.user_interest1.value; } 
	if (eval(f.user_interest2.checked)) { interest += f.user_interest2.value; } 
	if (eval(f.user_interest3.checked)) { interest += f.user_interest3.value; } 
	if (eval(f.user_interest4.checked)) { interest += f.user_interest4.value; } 
	if (eval(f.user_interest5.checked)) { interest += f.user_interest5.value; } 
	if (eval(f.user_interest6.checked)) { interest += f.user_interest6.value; } 
	if (eval(f.user_interest7.checked)) { interest += f.user_interest7.value; } 
	if (eval(f.user_interest8.checked)) { interest += f.user_interest8.value; } 
	f.user_interest.value = interest;
	
	if(interest=="")
	{
		alert("Please choose your interest at least one category.");
		f.user_interest1.focus();
		return false;
	}
	
	f.birthday.value = f.user_birth_yy.value+f.user_birth_mm.value+f.user_birth_dd.value;
	f.action ="registerok.jsp?gotoPage="+f.gotoPage.value;
	f.submit;	
}



function check_submit_click() {
	idcheck_clicked = "1";
}	

// 관리자 페이지 MemberList.jsp 검색 Form 유효성 체크
function searchValidCheck(){
  if(!SearchForm.searchOption.value){
    alert("검색조건을 선택해주세요.");
    SearchForm.searchOption.focus();
    return false;
  }
  if(!SearchForm.searchValue.value){
    alert("검색내용을 입력해주세요.");
    SearchForm.searchValue.focus();
    return false;
  }
  return true;
}
-->

