/* ¼ýÀÚ¸¸ ÀÔ·Â */
function onlyNumber(){
	if(((event.keyCode) < 48)||((event.keyCode) > 57))
	event.returnValue = false;
}

/* Æ¯Á¤¹®ÀÚ °Ë»ç */
function validText(str,type){
	
	if(str == "") return false;

	// type =1 :: Æ¯¼ö¹®ÀÚ¸¦ Á¦¿ÜÇÑ ¸ðµç¹®ÀÚ »ç¿ë°¡´É
	// type =2 :: ¿µ¹®,¼ýÀÚ,¾ð´õ¹Ù¸¸ »ç¿ë°¡´É
	// type =3 :: ¿µ¹®,¼ýÀÚ¸¸ »ç¿ë°¡´É
	// type =4 :: ¼ýÀÚ¸¸ »ç¿ë°¡´É
	var invalidChars = "``!@#$%^&*()+={}[]\'\":;\\/.<>?|-";

	if(type==1 || type==2 || type==3){
		for(i=0;i<invalidChars.length;i++) {
			badChar = invalidChars.charAt(i);
			if(str.indexOf(badChar,0)>-1){
				return false;
			}
		}
	}

	if(type==2){
		for(i=0; i<str.length; i++){
			vch = str.charAt(i).charCodeAt(0) ;
			if((!(vch >= 97 && vch <= 122) && !(vch >= 65 && vch <= 90) && !(vch >= 48 && vch <= 57) && (vch != 95))){
				return false;
			}
		}
	}

	if(type==3){
		for(i=0; i<str.length; i++){
			vch = str.charAt(i).charCodeAt(0) ;
			if(!(vch >= 97 && vch <= 122) && !(vch >= 65 && vch <= 90) && !(vch >= 48 && vch <= 57)){
				return false;
			}
		}
	}

	if(type==4){
		for(i=0; i<str.length; i++){
			vch = str.charAt(i).charCodeAt(0) ;
			if(!(vch >= 48 && vch <= 57)){
				return false;
			}
		}
	}

	return true;
}




/* ÁÖ¹Î¹øÈ£ Ã¼Å© */
function dcUserNum(){
	
	var form = document.myForm;
	var userNum1 = form.userNum1.value ;
	var userNum2 = form.userNum2.value ;
	if(validUserNum(userNum1, userNum2)){
	
		var loc = "/manager/member/checkUserNum.php?userNum1="+userNum1+"&userNum2="+userNum2;
		window.open(loc,'dcNum',"width=350,height=110");
	}else{

		alert("ÁÖ¹Î¹øÈ£¸¦ Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä");
		form.userNum1.focus();
		return false;
	}
}


/* ¾ÆÀÌµð Áßº¹°Ë»ç */
function dcID(){
	
	var form = document.myForm;
	var userID = form.userID.value ;
	if(userID==""){
		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		form.userID.focus();
		return false;
	}

	if(userID.length<3 || userID.length>15 || !validText(userID,3)){
		alert("¾ÆÀÌµð¸¦ Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä");
		form.userID.focus();
		return false;
	}
	window.open("/manager/member/checkUserId.php?userID="+userID,'dcID',"width=350,height=130");
}


/* ¿ìÆí¹øÈ£ °Ë»ö */
function zipSearch1(){
	window.open("/manager/member/checkZipCode.php",'zipSearch',"width=460,height=350,,scrollbars=yes");
}

/* °¡ÀÔÆû Ã¼Å© */
function joinCheck(form,type){

	if(type=="reg"){
		// ¾ÆÀÌµð °ü·Ã Ã¼Å©
		var userID = form.userID.value ;
		if(userID==""){
			alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
			form.userID.focus();
			return false;
		}
		if(userID.length<3 || userID.length>15 || !validText(userID,3)){
			alert("¾ÆÀÌµð¸¦ Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä");
			form.userID.focus();
			return false;
		}
		if(userID != form.idCheck.value){
			alert("¾ÆÀÌµð Áßº¹°Ë»ç¸¦ ÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
			form.userID.focus();
			return false;
		}


		// ºñ¹Ð¹øÈ£ °ü·Ã
		var userPass = form.userPass.value ;
		var userPass1 = form.userPass1.value;
		if(userPass=="" || userPass1==""){
			alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
			form.userPass.focus();
			return false;
		}
		if(userPass.length<6 || userPass.length>15){
			alert("ºñ¹Ð¹øÈ£¸¦ Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä");
			form.userPass.focus();
			return false;
		}
		if(userPass != userPass1){
			alert("ºñ¹Ð¹øÈ£¿Í ºñ¹Ð¹øÈ£ È®ÀÎÀÌ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
			form.userPass.focus();
			return false;
		}
		if(userPass1.length<6 || userPass1.length>15){
			alert("ºñ¹Ð¹øÈ£ È®ÀÎÀ» Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä");
			form.userPass1.focus();
			return false;
		}

	}



	// ÀÌ¸§ °Ë»ç
	if(form.userName.value == ""){
		alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä");
		form.userName.focus();
		return false;
	}

	
	// ÁÖ¹Î¹øÈ£ °ü·Ã
	var userNum1= form.userNum1.value ;
	var userNum2= form.userNum2.value ;
	if(userNum1.length!=6 || userNum2.length!=7 || !validUserNum(userNum1, userNum2)){
		alert("ÁÖ¹Î¹øÈ£¸¦ Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä");
		form.userNum1.focus();
		return false;
	}
	if(form.userNumCheck.value != userNum1+''+userNum2){
		alert("ÁÖ¹Î¹øÈ£ Áßº¹°Ë»ç¸¦ ÇÏ¼Å¾ßÇÕ´Ï´Ù.");
		form.userNum1.focus();
		return false;
	}
	

	// ÀÌ¸ÞÀÏ
	if(form.email.value=="" || !validEmail(form.email.value)){
		alert("ÀÌ¸ÞÀÏÀ» Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä");
		form.email.focus();
		return false;
	}


	// ÀüÈ­¹øÈ£
	var phone1 = form.phone1.options[form.phone1.selectedIndex].value;
	var phone2 = form.phone2.value;
	var phone3 = form.phone3.value;
	var isPhone = false;
	if(phone1!="" && phone2!="" && phone3!="") isPhone = true;


	// ÈÞ´ëÆù
	var mobile1 = form.mobile1.options[form.mobile1.selectedIndex].value;
	var mobile2 = form.mobile2.value;
	var mobile3 = form.mobile3.value;
	if(mobile1!="" && mobile2!="" && mobile3!="") isPhone = true;

	
	// ÀüÈ­/ÈÞ´ëÆù °Ë»ç
	if(!isPhone){
		alert("ÀüÈ­ ¹øÈ£³ª ÈÞ´ëÆù ¹øÈ£Áß ÇÑ°¡Áö´Â ÇÊ¼öÀÔ·Â ÀÔ´Ï´Ù.");
		return false;
	}


	// ¿ìÆí¹øÈ£
	var zip1 = form.zip1.value ;
	var zip2 = form.zip2.value ;
	if(zip1=="" || zip2==""){
		alert("¿ìÆí¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		form.zip1.focus();
		return false;
	} 
	if(form.address.value == ""){
		alert("ÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		form.address.focus();
		return false;
	}
	

	if(type=="reg"){
		// ¹«´Ü °¡ÀÔ ¹æÁöÄÚµå
		var rpcCode = form.rpcCode.value;
		if( rpcCode=="" || rpcCode.length!=6 || !validText(rpcCode)){
			alert("6ÀÚ¸®ÀÇ ÄÚµå¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
			form.rpcCode.focus();
			return false;
		}
	}

	return true;
}
