// 회원 가입시 금지할 도메인을 입력 하세요
var invalidaddress=new Array()
invalidaddress[0]="daum"
/*invalidaddress[1]="kebi"
invalidaddress[2]="yahoo"
invalidaddress[3]="hanmail"
*/
var testresults

function checkemail(str){
	var invalidcheck=0;
	var filter=/^[_a-zA-Z0-9-\.]+@[\.a-zA-Z0-9-]+\.[a-zA-Z]+$/;
		if (filter.test(str)){
		var tempstring=str.split("@")
		tempstring=tempstring[1].split(".")
		for (i=0;i<invalidaddress.length;i++){
		if (tempstring[0]==invalidaddress[i])
		invalidcheck=1
	}
	if (invalidcheck!=1)
		testresults=true
	else{
		alert("사용 금지된 메일주소를 입력하셨습니다.")
		document.frm1.m_mail.value = "";
		testresults=false
	}
	}else{
		alert("E-mail 주소를 정확히 입력해 주시기 바랍니다.")
		document.frm1.m_mail.value = "";
		testresults=false
	}
		return (testresults)
	}

function checkbae(str){
	var emailStr = str.value
	if (document.layers||document.getElementById||document.all)
		return checkemail(emailStr)
	else
		return true
}
	
	function check_email(str){
	emailStr = str.value
	if(emailStr != "") {
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var firstChars=validChars
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom="(" + firstChars + validChars + "*" + ")"
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
			alert("E-mail 주소를 정확히 입력해 주시기 바랍니다.");
			str.focus();
			return false;
			}
		}
	}
	
	function inputbirth(){
		if (document.frm1.mc_item_birthdayP.value == "1"){
			var b_temp1, b_temp2, b_temp3;

			b_temp1 = document.frm1.m_ssn1.value.substring(0,2);	
			b_temp2 = document.frm1.m_ssn1.value.substring(2,4);
			b_temp3 = document.frm1.m_ssn1.value.substring(4,6);

			if( b_temp1 < 30 ) {
			 document.frm1.m_birthday1.value = "20" + b_temp1; 
			}
			else { 
			 document.frm1.m_birthday1.value="19" + b_temp1; 
			}
			document.frm1.m_birthday2.value = b_temp2;
			document.frm1.m_birthday3.value = b_temp3;
		}
	}

// 생년월일 자동입력
function auto_birth(){
	if (document.frm1.mc_item_birthdayI.value = "1"){
		var inText = document.frm1.m_ssn1.value;
		if (inText.length == 6){
			document.frm1.m_birthday1.value = "19" + inText.substring(0, 2);
			document.frm1.m_birthday2.value = inText.substring(2, 4);
			document.frm1.m_birthday3.value = inText.substring(4, 6);
		}
	}
}

function member_join_check(){

// 약관을 사용하지 않으려면 아래 부분을 지워 주시기 바랍니다.
		if (document.frm1.login_name.value == ""){
			alert("이름을 입력해 주시기 바랍니다.");
			document.frm1.login_name.focus();
			return false;
		}	
		
		if (document.frm1.mc_item_ssnP.value == "1"){
			if (document.frm1.mode.value == "join"){
				if (document.frm1.m_ssn1.value == ""){
					alert("주민등록번호를 입력해 주시기 바랍니다.");
					document.frm1.m_ssn1.focus();
					return false;
				}

				if (document.frm1.m_ssn2.value == ""){
					alert("주민등록번호를 입력해 주시기 바랍니다.");
					document.frm1.m_ssn2.focus();
					return false;
				}		

				var chk =0
				var yy  = frm1.m_ssn1.value.substring(0,2)
				var mm  = frm1.m_ssn1.value.substring(2,4)
				var dd  = frm1.m_ssn1.value.substring(4,6)
				var sex = frm1.m_ssn2.value.substring(0,1)

				if ((frm1.m_ssn1.value.length!=6)||(yy <25||mm <1||mm>12||dd<1)){
						   alert ("주민등록번호를 바로 입력하여 주십시오.");
						   frm1.m_ssn1.focus();
						   return false;
						   }

				if ((sex != 1 && sex !=2 )||(frm1.m_ssn2.value.length != 7 )){
						   alert ("주민등록번호를 바로 입력하여 주십시오.");
						   frm1.m_ssn2.focus();
						   return false;
						   }

				for (var i = 0; i <=5 ; i++){ 
				chk = chk + ((i%8+2) * parseInt(frm1.m_ssn1.value.substring(i,i+1)))
				}

				for (var i = 6; i <=11 ; i++){ 
				chk = chk + ((i%8+2) * parseInt(frm1.m_ssn2.value.substring(i-6,i-5)))
				}
				chk = 11 - (chk %11)
				chk = chk % 10

				if (chk != frm1.m_ssn2.value.substring(6,7))
				{
					   alert ("유효하지 않은 주민등록번호입니다.");
					   frm1.m_ssn1.focus();
					   return false;
				}
			}
		}

		if(document.frm1.login_id.value == ""){
			alert("로그인 아이디를 입력해 주시기 바랍니다.");
			document.frm1.login_id.focus();
			return false;
		}

		if(document.frm1.login_id.value.length < 4){
			alert("로그인 아이디는 4자 이상이어야 합니다.");
			document.frm1.login_id.focus();
			return false;
		}

		if(document.frm1.login_pwd1.value == ""){
			alert("패스워드를 입력해 주시기 바랍니다.");
			document.frm1.login_pwd1.focus();
			return false;
		}

		if(document.frm1.login_pwd1.value.length < 4){
			alert("패스워드는 4자 이상으로 입력해 주시기 바랍니다.");
			document.frm1.login_pwd1.focus();
			return false;
		}

		if(document.frm1.login_pwd2.value == ""){
			alert("패스워드를 확인해 주시기 바랍니다.");
			document.frm1.login_pwd2.focus();
			return false;
		}

		if (document.frm1.login_pwd1.value != document.frm1.login_pwd2.value){
			alert("입력한 비밀번호와 확인 비밀번호가 일치하지 않습니다.");
			document.frm1.login_pwd2.focus();
			return false;
		}

		if (document.frm1.mc_item_birthdayP.value == "1"){
			if (document.frm1.m_birthday1.value == ""){
				alert("생년월일을 입력해 주시기 바랍니다.");
				document.frm1.m_birthday1.focus();
				return false;
			}

			if (document.frm1.m_birthday2.value == ""){
				alert("생년월일을 입력해 주시기 바랍니다.");
				document.frm1.m_birthday2.focus();
				return false;
			}
		
			if (document.frm1.m_birthday3.value == ""){
				alert("생년월일을 입력해 주시기 바랍니다.");
				document.frm1.m_birthday3.focus();
				return false;
			}
		}
		
		
		
		 if (check_date(document.frm1.m_birthday1.value,document.frm1.m_birthday2.value, document.frm1.m_birthday3.value) != 0 )
		 	{
		 		alert("생년월일을 정확히 입력해  주시기 바랍니다.");
				document.frm1.m_birthday1.focus();
				return false;
		 	} else
		 	{
		 		if ( document.frm1.m_birthday2.value.length == 1 )
		 			document.frm1.m_birthday2.value = "0" + document.frm1.m_birthday2.value			;
		 		if ( document.frm1.m_birthday3.value.length == 1 )
		 			document.frm1.m_birthday3.value = "0" + document.frm1.m_birthday3.value			
		 	}
		 	
		
	
		if (document.frm1.mc_item_nickP.value == "1"){
			if (document.frm1.m_nick.value == ""){
				alert("별명 또는 별칭을 입력해 주시기 바랍니다.");
				document.frm1.m_nick.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_icqP.value == "1"){
			if (document.frm1.m_icq.value == ""){
				alert("ICQ 번호를 입력해 주시기 바랍니다.");
				document.frm1.m_icq.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_msnP.value == "1"){
			if (document.frm1.m_msn.value == ""){
				alert("MSN 메신져 주소를 입력해 주시기 바랍니다.");
				document.frm1.m_msn.focus();
				return false;
			}
		}
	
		if (document.frm1.mc_item_homepageP.value == "1"){
			if (document.frm1.m_homepage.value == ""){
				alert("홈페이지 주소를 입력해 주시기 바랍니다.");
				document.frm1.m_homepage.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_home_addrP.value == "1"){
			if (document.frm1.m_homepost1.value == "" || document.frm1.m_homepost1.value == ""){
				alert("우편번호 찾기 버튼으로 우편번호를 검색해 주시기 바랍니다.");
				document.frm1.m_homeaddr.focus();
				return false;
			}
			
			if (document.frm1.m_homeaddr.value == "" ){
				alert("자택 주소를 입력해 주시기 바랍니다.");
				document.frm1.m_homeaddr.focus();
				return false;
			}

			if (document.frm1.m_homeaddr.value == document.frm1.m_homeaddr2.value){
				alert("동 이하 부분을 입력해 주시기 바랍니다.");
				document.frm1.m_homeaddr.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_home_telP.value == "1"){
			if (document.frm1.m_hometel1.value == ""){
				alert("자택 전화번호를 선택해 주시기 바랍니다.");
				document.frm1.m_hometel1.focus();
				return false;
			}

			if (document.frm1.m_hometel2.value == ""){
				alert("자택 전화번호를 입력해 주시기 바랍니다.");
				document.frm1.m_hometel2.focus();
				return false;
			}

			if (document.frm1.m_hometel3.value == ""){
				alert("자택 전화번호를 입력해 주시기 바랍니다.");
				document.frm1.m_hometel3.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_office_addrP.value == "1"){
			if (document.frm1.m_officepost1.value == "" || document.frm1.m_officepost1.value == ""){
				alert("우편번호 찾기 버튼으로 우편번호를 검색해 주시기 바랍니다.");
				document.frm1.m_officepost1.focus();
				return false;
			}
			
			if (document.frm1.m_officeaddr.value == ""){
				alert("회사 주소를 입력해 주시기 바랍니다.");
				document.frm1.m_officeaddr.focus();
				return false;
			}

			if (document.frm1.m_officeaddr.value == document.frm1.m_officeaddr2.value){
				alert("동 이하 부분을 입력해 주시기 바랍니다.");
				document.frm1.m_officeaddr.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_office_telP.value == "1"){
			if (document.frm1.m_officetel1.value == ""){
				alert("회사 전화번호를 입력해 주시기 바랍니다.");
				document.frm1.m_officetel1.focus();
				return false;
			}

			if (document.frm1.m_officetel2.value == ""){
				alert("회사 전화번호를 입력해 주시기 바랍니다.");
				document.frm1.m_officetel2.focus();
				return false;
			}
		
			if (document.frm1.m_officetel3.value == ""){
				alert("회사 전화번호를 입력해 주시기 바랍니다.");
				document.frm1.m_officetel3.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_handphoneP.value == "1"){
			if (document.frm1.m_handphone1.value == ""){
				alert("핸드폰 번호를 선택해 주시기 바랍니다.");
				document.frm1.m_handphone1.focus();
				return false;
			}

			if (document.frm1.m_handphone2.value == ""){
				alert("핸드폰 번호를 입력해 주시기 바랍니다.");
				document.frm1.m_handphone2.focus();
				return false;
			}

			if (document.frm1.m_handphone3.value == ""){
				alert("핸드폰 번호를 입력해 주시기 바랍니다.");
				document.frm1.m_handphone3.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_jobP.value == "1"){
			if (document.frm1.m_job.value == "0"){
				alert("직업을 선택해 주시기 바랍니다.");
				document.frm1.m_job.focus();
				return false;
			}

			if (document.frm1.m_job_level.value == "0"){
				alert("직급을 선택해 주시기 바랍니다.");
				document.frm1.m_job_level.focus();
				return false;
			}
		}
		
		if (document.frm1.m_mail_01.value == ""){
			alert("메일주소를 입력해 주시기 바랍니다.");
			document.frm1.m_mail_01.focus();
			return false;
		}
		
		if (document.frm1.m_mail_02.value == ""){
			alert("메일주소를 선택해 주시기 바랍니다.");
			document.frm1.m_mail_02.focus();
			return false;
		}	

		if (document.frm1.m_mail_02.value == "1"){
			
			if (document.frm1.m_mail_03.value == ""){
				alert("메일주소를 입력해 주시기 바랍니다.");
				document.frm1.m_mail_03.focus();
				return false;
			}
		}	

		if (document.frm1.mc_item_hobbyP.value == "1"){
			if (document.frm1.m_hobby.value == ""){
				alert("취미를 입력해 주시기 바랍니다.");
				document.frm1.m_hobby.focus();
				return false;
			}
		}		

		if (document.frm1.mc_item_marryP.value == "1"){
			if (document.frm1.m_marry_value.value == "1"){
				if (document.frm1.m_marrydate1.value == ""){
					alert("결혼을 하셨다면 결혼 기념일을 입력해 주시기 바랍니다.");
					document.frm1.m_marrydate1.focus();
					return false;
				}

				if (document.frm1.m_marrydate2.value == ""){
					alert("결혼을 하셨다면 결혼 기념일을 입력해 주시기 바랍니다.");
					document.frm1.m_marrydate2.focus();
					return false;
				}

				if (document.frm1.m_marrydate3.value == ""){
					alert("결혼을 하셨다면 결혼 기념일을 입력해 주시기 바랍니다.");
					document.frm1.m_marrydate3.focus();
					return false;
				}		
			}		
		}

		if (document.frm1.mc_item_how_registP.value == "1"){
			if (document.frm1.m_how_regist.value == "0"){
				alert("가입동기를 선택해 주시기 바랍니다.");
				document.frm1.m_how_regist.focus();
				return false;
			}
		}

		if (document.frm1.mc_item_memoP.value == "1"){
			if (document.frm1.m_memo.value == ""){
				alert("자기소개 또는 기타 하고 싶은말을 기재해 주시기 바랍니다.");
				document.frm1.m_memo.focus();
				return false;
			}
		}

	}

	function find_id(){
		if(document.frm1.login_id.value == ""){
			alert("아이디를 입력해 주세요");
			document.frm1.login_id.focus();
			return false;
		}

		find_id_url = "find_id.asp?search_id=" + document.frm1.login_id.value + "&group_name=" + document.frm1.group_name.value;
		new_win(find_id_url,'find_id','450','280','0')
	}


	function find_post(str){
		find_post_url = "/08_member/find_post.asp?mode=" + str;
		new_win2(find_post_url,'find_post','570','280','0','yes')
	}

	function marry_check(str){
		document.frm1.m_marry_value.value = str;
	}

	// 영문과 숫자만 입력 가능하게 하는 스크립트..
	function onlyEng(objtext1) {
		var inText = objtext1.value;
		var ret;

		for (var i = 0; i < inText.length; i++) {
			ret = inText.charCodeAt(i);
			if ((ret > 122) || (ret < 48) || (ret > 57 && ret < 65) || (ret > 90 && ret < 97)) {
				alert("영문자와 숫자만을 입력하세요");
				objtext1.value = "";
				objtext1.focus();
				return false;
			}
		}
		return true;
	}

	// 숫자만 입력 가능하게 하는 스크립트..
	function onlynum(objtext1){
		var inText = objtext1.value;
		var ret;

		for (var i = 0; i < inText.length; i++) {
		    ret = inText.charCodeAt(i);
			if (!((ret > 47) && (ret < 58)))  {
				alert("숫자만 입력 가능합니다.");
				objtext1.value = "";
				objtext1.focus();
				return false;
			}
		}
		return true;
	}

	// 새창 띄우기 스크립트
	function new_win(filename,p_name,s_width,s_height,s_scrol)
	{
		x = screen.width;
		y = screen.height;
		wid = (x / 2) - (s_width / 2);
		hei = (y / 2) - (s_height / 2);

	   window.open(filename, p_name, "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=" + s_scrol + ",width=" + s_width + ",height=" + s_height + ",top=" + hei + ",left=" + wid ); 
	}

	function new_win2(filename,p_name,s_width,s_height,s_scrol)
	{
		x = screen.width;
		y = screen.height;
		wid = (x / 2) - (s_width / 2);
		hei = (y / 2) - (s_height / 2);

	   window.open(filename, p_name, "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=yes,width=" + s_width + ",height=" + s_height + ",top=" + hei + ",left=" + wid ); 
	}

	// 메모 리스트 이동 스크립트
	function memo_list(str1, str2){
		if (str1 == "1"){
			document.frm1.action = "member_memo.asp?mode=" + str1 + "&group_name=" + str2;
		}else{
			document.frm1.action = "member_memo2.asp?mode=" + str1 + "&group_name=" + str2;
		}
		document.frm1.submit();
	}

	// 메모 전체 선택 / 해제 스크립트
	function memo_checkall(obj, recordCount){
		if(recordCount != 0){
			var cntBox = obj.check.length-1;
			for(var i = 0; i <= cntBox; i++) {
				if (obj.check[i].checked == false){
					obj.check[i].checked=true;
				}
				else{
					obj.check[i].checked=false;
				}
			}
		}
	}

	// 메모 삭제 스크립트
	function memo_del(mode,page,dm,group_name){
		var i, j=0, k=0;
		for(i=0;i<document.frm1.length;i++) {
		if(document.frm1[i].checked)
		k++;
		}
		if (k<1){
			alert("삭제하실 메모를 선택해 주시기 바랍니다.");
			return false;
		}

		if(confirm("선택한 메모를 삭제하시겠습니까?")){
			document.frm1.action = "member_memo_exec.asp?exec=delete&mode=" + mode + "&page=" + page + "&dm=" + dm + "&group_name=" + group_name;
			document.frm1.submit();
			return true;
		}
		return false;
	}

	// 메모 본문 보기시 삭제 스크립트
	function memo_del2(mode,page,num,group_name){
		if (mode == "1"){
			var dm = "2";
		}else{
			var dm = "4";
		}

		if(confirm("선택한 메모를 삭제하시겠습니까?")){
			document.frm1.action = "member_memo_exec.asp?exec=delete&mode=" + mode + "&page=" + page + "&dm=" + dm + "&num=" + num + "&group_name=" + group_name;
			document.frm1.submit();
			return true;
		}
		return false;
	}

	// 답장 메모 보내기
	function reple_memo(to_login_id, group_name){
		var url = "member_memo_write.asp?to_login_id=" + to_login_id + "&group_name=" + group_name; 
		new_win(url,'member_memo_write','292','370','0');
	}

	// 메모 쓰기 체크
	function member_memo_write_check(){
		if(document.frm1.to_login_id.value == ""){
			alert("받는 사람 아이디를 입력해 주시기 바랍니다.");
			document.frm1.to_login_id.focus();
			return false;
		}

		if(document.frm1.subject.value == ""){
			alert("메모 제목을 입력해 주시기 바랍니다.");
			document.frm1.subject.focus();
			return false;
		}

		if(document.frm1.content.value == ""){
			alert("메모 내용을 입력해 주시기 바랍니다.");
			document.frm1.content.focus();
			return false;
		}

		if(document.frm1.to_login_id.value == document.frm1.from_login_id.value){
			alert("본인에게는 메모를 보낼 수 없습니다.");
			document.frm1.to_login_id.focus();
			return false;
		}

		document.frm1.action = "member_memo_exec.asp?exec=add"
		document.frm1.submit();
	}

	function go_memo_list(group_name){
		document.frm1.action = "member_memo.asp?group_name=" + group_name;
		document.frm1.submit();
	}

	function  name_img_add(){
		if(document.frm1.markname1.value==""){
			alert("등록할 이미지를 선택해 주시기 바랍니다.");
			document.frm1.markname1.focus();
			return false;
		}

		document.frm1.action = "member_mark_ok.asp?login_id=" + document.frm1.login_id.value + "&group_name=" + document.frm1.group_name.value + "&mode=add"
		document.frm1.submit();
	}

	function mark_img_add(){
		if(document.frm1.markname2.value==""){
			alert("등록할 이미지를 선택해 주시기 바랍니다.");
			document.frm1.markname2.focus();
			return false;
		}

		document.frm1.action = "member_mark_ok.asp?login_id=" + document.frm1.login_id.value + "&group_name=" + document.frm1.group_name.value + "&mode=add"
		document.frm1.submit();
	}

	function name_img_del(str){
		if(confirm("선택된 이름 이미지를 삭제하시겠습니까?")){
			frm1.action = "member_mark_del.asp?login_id=" + document.frm1.login_id.value + "&group_name=" + document.frm1.group_name.value + "&mode=name"
			frm1.submit();
			return true;
		}
		return false;
	}

	function mark_img_del(str){
		if(confirm("선택된 마크 이미지를 삭제하시겠습니까?")){
			frm1.action = "member_mark_del.asp?login_id=" + document.frm1.login_id.value + "&group_name=" + document.frm1.group_name.value + "&mode=mark"
			frm1.submit();
			return true;
		}
		return false;
	}

	function mark_windows_close(){
		self.close();
	}
	
	
	function gogogo() {
	var ri = check_date(document.all.year.value,document.all.month.value,document.all.day.value)
	if (ri == 0) {
		alert('정상적인 형식');
	} else if (ri == 1) {
		alert('년(?)이 잘못 되었습니다');
	} else if (ri == 2) {
		alert('월이 잘못 되었습니다');
	} else if (ri == 3) {
		alert('일이 잘못 되었습니다');
	}
}


function check_date(year, month, day) {
		var dat_option = year % 4;
		year = parseInt(year, 10);
		month = parseInt(month, 10);
		day = parseInt(day, 10);
		
		if (isNaN(year) == true) { return 1; }
		if (year < 1901) { return 1; }
		
		if (isNaN(month) == true) { return 2; }
		if (isNaN(day) == true) { return 3; }
		if (day < 1 || day > 31) { return 3; }
		
		if (month == 2) {
			if (((dat_option == 0) && (day > 29)) || ((dat_option != 0) && (day > 28)) ) { return 3; }
		} else if ((month == 4) ||
							(month == 6) ||
							(month == 9) ||
							(month == 11)) {
			if (day > 30) { return 3; }
		} else if ((month == 1) ||
							(month == 3) ||
							(month == 5) ||
							(month == 7) ||
							(month == 8) ||
							(month == 10) ||
							(month == 12)) {
			if (day > 31) { return 3; }			
		} else {
			return 2;
		}
		
		return 0;
	}
	
	
	
