function fn_pop_login(siteCode, isPopup) {
	var frm = document.form1;

	var loc1 = screen.availWidth;
	var loc2 = screen.availHeight;

	var popWidth = 810;
	var popHeight = 670;

	win=window.open("","","status=0,menubar=0,scrollbars=1,resizable=1,width="+popWidth+",height="+popHeight+",align=left,left="+(loc1-popWidth)/2+",top="+(loc2-popHeight)/2);

	win.location="/common/member/login/memLoginMain.jsp?pSiteCode="+siteCode+"&isPopup="+isPopup;
}

function fn_pop_join(siteCode) {
	var frm = document.form1;

	var loc1 = screen.availWidth;
	var loc2 = screen.availHeight;

	var popWidth = 810;
	var popHeight = 670;

	win=window.open("","","status=0,menubar=0,scrollbars=1,resizable=1,width="+popWidth+",height="+popHeight+",align=left,left="+(loc1-popWidth)/2+",top="+(loc2-popHeight)/2);

	win.location="/common/member/join/memJoinConfirm.jsp?pSiteCode="+siteCode;
}

function fn_pop_search(siteCode) {
	var frm = document.form1;

	var loc1 = screen.availWidth;
	var loc2 = screen.availHeight;

	var popWidth = 810;
	var popHeight = 670;

	win=window.open("","","status=0,menubar=0,scrollbars=1,resizable=1,width="+popWidth+",height="+popHeight+",align=left,left="+(loc1-popWidth)/2+",top="+(loc2-popHeight)/2);

	win.location="/common/member/search/memSearchView.jsp?pSiteCode="+siteCode;
}

function fn_pop_change() {
	var frm = document.form1;

	var loc1 = screen.availWidth;
	var loc2 = screen.availHeight;

	var popWidth = 810;
	var popHeight = 670;

	win=window.open("","","status=0,menubar=0,scrollbars=1,resizable=1,width="+popWidth+",height="+popHeight+",align=left,left="+(loc1-popWidth)/2+",top="+(loc2-popHeight)/2);

	win.location="/common/member/change/memChangeLogin.jsp";
}

function fn_pop_withdraw() {
	var frm = document.form1;

	var loc1 = screen.availWidth;
	var loc2 = screen.availHeight;

	var popWidth = 810;
	var popHeight = 670;

	win=window.open("","","status=0,menubar=0,scrollbars=1,resizable=1,width="+popWidth+",height="+popHeight+",align=left,left="+(loc1-popWidth)/2+",top="+(loc2-popHeight)/2);

	win.location = "/common/member/withdraw/memWithdrawEdit.jsp";
}

function fn_go_pop_join() {
	document.location.href = "/common/member/join/memJoinConfirm.jsp";
}

function fn_go_pop_login() {
	document.location.href = "/common/member/login/memLoginMain.jsp";
}

function fn_go_pop_search() {
	document.location.href = "/common/member/search/memSearchView.jsp";
}

function fn_go_pop_change() {
	document.location.href = "/common/member/change/memChangeLogin.jsp";
}

function fn_go_pop_change_add(type) {
	if(type == 1) {
		document.location.href = "/common/member/change/memChangeEduEdit.jsp";
	} else if(type == 2) {
		document.location.href = "/common/member/change/memChangeReadEdit.jsp";
	} else if(type == 3) {
		document.location.href = "/common/member/change/memChangeCoachEdit.jsp";
	}
}

function fn_go_pop_passwd() {
	document.location.href = "/common/member/passwd/memPasswdEdit.jsp";
}

function fn_go_pop_service() {
	document.location.href = "/common/member/joinservice/memJoinserviceView.jsp";
}

function fn_pop_service(siteCode) {

	var loc1 = screen.availWidth;
	var loc2 = screen.availHeight;

	var popWidth = 810;
	var popHeight = 670;

	win=window.open("","","status=0,menubar=0,scrollbars=1,resizable=1,width="+popWidth+",height="+popHeight+",align=left,left="+(loc1-popWidth)/2+",top="+(loc2-popHeight)/2);

	win.location="/common/member/joinservice/memJoinserviceView.jsp?pSiteCode="+siteCode;
}

function fn_go_pop_withdraw() {
	document.location.href = "/common/member/withdraw/memWithdrawEdit.jsp";
}

function fn_search_company() {
	var win = window.open('/common/member/common/company/comCompanySrch.jsp','company','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,top=30,left=30,copyhistory=0,width=485,height=490') 
	
	return;	
}

function fn_check_id(userId) {
	var frm = document.form1;
	
	if(trim(frm.pUserId.value) < 1) {
		alert(JS_MSG_CHK_243);
		frm.pUserId.focus();
		return;

	} else if(getBytes(frm.pUserId.value) < 4) {			
		alert(JS_MSG_CHK_242);
		frm.pUserId.focus();
		return;

	} 

	var isCheck = false;
	
	// Æ¯¼ö ¹®ÀÚ check
	for (var i = 0; i < frm.pUserId.value.length; i++) {
		if(isEtc(frm.pUserId.value.charAt(i))) {
			isCheck = true;
		}
	}

	if(isCheck) {			
		alert(JS_MSG_COMMON_101);
		frm.pUserId.focus();
		return;
	}

	var win = window.open('/common/member/common/check/comUserIdDuplChk.jsp?pUserId='+userId+'' ,'userIdDulpChk','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,top=30,left=30,copyhistory=0,width=468,height=350');

	return;	
}

function fn_zip() {
	var strzip = window.open('/common/member/common/zip/comZip.jsp','zip','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,top=30,left=30,copyhistory=0,width=485,height=490') 
	
	return;	
}

function fn_zip2() {
	var strzip = window.open('/common/member/common/zip/comZip2.jsp','zip','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,top=30,left=30,copyhistory=0,width=485,height=490') 
	
	return;	
}

function fn_zip3() {
	var strzip = window.open('/common/member/common/zip/comZip3.jsp','zip','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,top=30,left=30,copyhistory=0,width=485,height=490') 
	
	return;	
}

function CheckPassword(strPwd) {
	var upw =strPwd;
	if(!/^[a-zA-Z0-9]{5,20}$/.test(upw)){ 
		alert('ºñ¹Ð¹øÈ£´Â ¼ýÀÚ¿Í ¿µ¹®ÀÚ Á¶ÇÕÀ¸·Î 6~10ÀÚ¸®¸¦ »ç¿ëÇØ¾ß ÇÕ´Ï´Ù.'); 
		return false;
	}
	var chk_num = upw.search(/[0-9]/g); 
	var chk_eng = upw.search(/[a-z]/ig); 

	if(chk_num < 0 || chk_eng < 0){ 
		alert('ºñ¹Ð¹øÈ£´Â ¼ýÀÚ¿Í ¿µ¹®ÀÚ¸¦ È¥¿ëÇÏ¿©¾ß ÇÕ´Ï´Ù.'); 
		return false;
	}
/*
	if(/(\w)\1\1\1/.test(upw)){
		alert('ºñ¹Ð¹øÈ£¿¡ °°Àº ¹®ÀÚ¸¦ 4¹ø ÀÌ»ó »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.'); 
		return false;
	}
*/
	  return true;

}

function fn_validate_member(frm) {

	if(trim(frm.pUserId.value) < 1) {			
		alert(JS_MSG_CHK_243);
		frm.pUserId.focus();
		return false;

	} else if(getBytes(frm.pUserId.value) < 4) {
		alert('¾ÆÀÌµð´Â 4ÀÚ ÀÌ»óÀÔ´Ï´Ù.');
		frm.pUserId.focus();
		return false;
	} 

	var isCheck = false;
	
	// Æ¯¼ö ¹®ÀÚ check
	for (var i = 0; i < frm.pUserId.value.length; i++) {
		if(isEtc(frm.pUserId.value.charAt(i))) {
			isCheck = true;
		}
	}

	if(isCheck) {			
		alert(JS_MSG_COMMON_101);
		frm.pUserId.focus();
		return false;
	}

	if(trim(frm.pPw.value) < 1) {
		alert(JS_MSG_CHK_179);
		frm.pPw.focus();
		return false;
	} 

	if(trim(frm.pPwConfirm.value) < 1) {
		alert(JS_MSG_CHK_181);
		frm.pPwConfirm.focus();
		return false;
	} 

	if(getBytes(frm.pPw.value) < 6) {			
		alert(JS_MSG_COMMON_102);
		frm.pPw.focus();
		return false;
	}

	if(getBytes(frm.pPwConfirm.value) < 6) {			
		alert(JS_MSG_COMMON_102);
		frm.pPwConfirm.focus();
		return false;
	}

	if(CheckPassword(frm.pPw.value) == false){
			return;
	}
	
	if(frm.pPw.value == frm.pUserId.value){
	  alert("È¸¿ø¾ÆÀÌµð¿Í ºñ¹Ð¹øÈ£´Â °°À» ¼ö ¾ø½À´Ï´Ù.");
	  frm.pPw.focus();
	  return false;
	}

	if(frm.pPw.value != frm.pPwConfirm.value) {
		alert(JS_MSG_CHK_180);
		frm.pPwConfirm.focus();
		return false;
	}

	if(trim(frm.pUserName.value) < 1) {					
		alert(JS_MSG_CHK_192);
		frm.pUserName.focus();
		return false;
	} 
		
	if(trim(frm.pIdNo1.value) < 1) {			
		alert("ÁÖ¹Î¹øÈ£ ¾Õ 6ÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		frm.pIdNo1.focus();
		return false;
	}

	if(trim(frm.pIdNo2.value) < 1) {			
		alert("ÁÖ¹Î¹øÈ£ µÚ 7ÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		frm.pIdNo2.focus();
		return false;
	}

	frm.pIdNo.value = frm.pIdNo1.value + frm.pIdNo2.value;

	if(getBytes(frm.pIdNo.value) < 13) {			
		alert(JS_MSG_CHK_293);
		return false;
	}

	if(frm.pZipCode1.value < 1) {			
		alert(JS_MSG_CHK_252);
		frm.pZipCode1.focus();
		return false;
	}

	if(frm.pZipCode2.value < 1) {
		alert(JS_MSG_CHK_252);
		frm.pZipCode2.focus();
		return false;
	} 

	frm.pZipCode.value = frm.pZipCode1.value + frm.pZipCode2.value;
		
	if(trim(frm.pAddr1.value) < 1) {
		alert(JS_MSG_CHK_294);
		frm.pAddr1.focus();
		return false;
	} 

	if(trim(frm.pAddr2.value) < 1) {			
		alert(JS_MSG_CHK_294);
		frm.pAddr2.focus();
		return false;
	} 

	if(trim(frm.pTelNo.value) < 1) {			
		alert(JS_MSG_CHK_271);
		frm.pTelNo.focus();
		return false;
	} else if(!isDigitOrBar(frm.pTelNo.value)) {			
		alert(JS_MSG_COMMON_108);
		frm.pTelNo.focus();
		return false;
	}

	if(frm.pMobileNo.value != "" && !isDigitOrBar(frm.pMobileNo.value)) {			
		alert(JS_MSG_COMMON_108);
		frm.pMobileNo.focus();
		return false;
	}

	if(trim(frm.pEmail.value) < 1) {			
		alert(JS_MSG_CHK_345);
		frm.pEmail.focus();
		return false;
	} 
	
	if(!fn_check_email(trim(frm.pEmail.value))) {
		alert("¿Ã¹Ù¸¥ ÀÌ¸ÞÀÏ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù");
		frm.pEmail.focus();
		return false;
	}

	return true;
}

function fn_validate_member2(frm) {

	if(trim(frm.pUserId.value) < 1) {			
		alert(JS_MSG_CHK_243);
		frm.pUserId.focus();
		return false;

	} else if(getBytes(frm.pUserId.value) < 4) {
		alert('¾ÆÀÌµð´Â 4ÀÚ ÀÌ»óÀÔ´Ï´Ù.');
		frm.pUserId.focus();
		return false;
	} 

	var isCheck = false;
	
	// Æ¯¼ö ¹®ÀÚ check
	for (var i = 0; i < frm.pUserId.value.length; i++) {
		if(isEtc(frm.pUserId.value.charAt(i))) {
			isCheck = true;
		}
	}

	if(isCheck) {			
		alert(JS_MSG_COMMON_101);
		frm.pUserId.focus();
		return false;
	}

	if(trim(frm.pPw.value) < 1) {
		alert(JS_MSG_CHK_179);
		frm.pPw.focus();
		return false;
	} 

	if(trim(frm.pPwConfirm.value) < 1) {
		alert(JS_MSG_CHK_181);
		frm.pPwConfirm.focus();
		return false;
	} 

	if(getBytes(frm.pPw.value) < 6) {			
		alert(JS_MSG_COMMON_102);
		frm.pPw.focus();
		return false;
	}

	if(getBytes(frm.pPwConfirm.value) < 6) {			
		alert(JS_MSG_COMMON_102);
		frm.pPwConfirm.focus();
		return false;
	}
	
	if(frm.pPw.value == frm.pUserId.value){
	  alert("È¸¿ø¾ÆÀÌµð¿Í ºñ¹Ð¹øÈ£´Â °°À» ¼ö ¾ø½À´Ï´Ù.");
	  frm.pPw.focus();
	  return false;
	}

	if(CheckPassword(frm.pPw.value) == false){
			return;
	}

	if(frm.pPw.value != frm.pPwConfirm.value) {
		alert(JS_MSG_CHK_180);
		frm.pPwConfirm.focus();
		return false;
	}

	if(trim(frm.pUserName.value) < 1) {					
		alert(JS_MSG_CHK_192);
		frm.pUserName.focus();
		return false;
	} 
/*		
	if(trim(frm.pIdNo1.value) < 1) {			
		alert("ÁÖ¹Î¹øÈ£ ¾Õ 6ÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		frm.pIdNo1.focus();
		return false;
	}

	if(trim(frm.pIdNo2.value) < 1) {			
		alert("ÁÖ¹Î¹øÈ£ µÚ 7ÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		frm.pIdNo2.focus();
		return false;
	}

	frm.pIdNo.value = frm.pIdNo1.value + frm.pIdNo2.value;
*/
	if(getBytes(frm.pIdNo.value) < 13) {			
		alert(JS_MSG_CHK_293);
		return false;
	}

	if(frm.pZipCode1.value < 1) {			
		alert(JS_MSG_CHK_252);
		frm.pZipCode1.focus();
		return false;
	}

	if(frm.pZipCode2.value < 1) {
		alert(JS_MSG_CHK_252);
		frm.pZipCode2.focus();
		return false;
	} 

	frm.pZipCode.value = frm.pZipCode1.value + frm.pZipCode2.value;
		
	if(trim(frm.pAddr1.value) < 1) {
		alert(JS_MSG_CHK_294);
		frm.pAddr1.focus();
		return false;
	} 

	if(trim(frm.pAddr2.value) < 1) {			
		alert(JS_MSG_CHK_294);
		frm.pAddr2.focus();
		return false;
	} 

	if(trim(frm.pTelNo.value) < 1) {			
		alert(JS_MSG_CHK_271);
		frm.pTelNo.focus();
		return false;
	} else if(!isDigitOrBar(frm.pTelNo.value)) {			
		alert(JS_MSG_COMMON_108);
		frm.pTelNo.focus();
		return false;
	}

	if(frm.pMobileNo.value != "" && !isDigitOrBar(frm.pMobileNo.value)) {			
		alert(JS_MSG_COMMON_108);
		frm.pMobileNo.focus();
		return false;
	}

	if(trim(frm.pEmail.value) < 1) {			
		alert(JS_MSG_CHK_345);
		frm.pEmail.focus();
		return false;
	} 
	
	if(!fn_check_email(trim(frm.pEmail.value))) {
		alert("¿Ã¹Ù¸¥ ÀÌ¸ÞÀÏ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù");
		frm.pEmail.focus();
		return false;
	}

	return true;
}

function fn_validate_member_update(frm) {

	if(trim(frm.pUserName.value) < 1) {					
		alert(JS_MSG_CHK_192);
		frm.pUserName.focus();
		return false;
	} 

	if(frm.pZipCode1.value < 1) {			
		alert(JS_MSG_CHK_252);
		frm.pZipCode1.focus();
		return false;
	}

	if(frm.pZipCode2.value < 1) {
		alert(JS_MSG_CHK_252);
		frm.pZipCode2.focus();
		return false;
	} 

	frm.pZipCode.value = frm.pZipCode1.value + frm.pZipCode2.value;
		
	if(trim(frm.pAddr1.value) < 1) {
		alert(JS_MSG_CHK_294);
		frm.pAddr1.focus();
		return false;
	} 

	if(trim(frm.pAddr2.value) < 1) {			
		alert(JS_MSG_CHK_294);
		frm.pAddr2.focus();
		return false;
	} 

	if(trim(frm.pTelNo.value) < 1) {			
		alert(JS_MSG_CHK_271);
		frm.pTelNo.focus();
		return false;
	} else if(!isDigitOrBar(frm.pTelNo.value)) {			
		alert(JS_MSG_COMMON_108);
		frm.pTelNo.focus();
		return false;
	}

	if(frm.pMobileNo.value != "" && !isDigitOrBar(frm.pMobileNo.value)) {			
		alert(JS_MSG_COMMON_108);
		frm.pMobileNo.focus();
		return false;
	}

	if(trim(frm.pEmail.value) < 1) {			
		alert(JS_MSG_CHK_345);
		frm.pEmail.focus();
		return false;
	} 

	if(!fn_check_email(trim(frm.pEmail.value))) {
		alert("¿Ã¹Ù¸¥ ÀÌ¸ÞÀÏ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù");
		frm.pEmail.focus();
		return false;
	}

	return true;
}

function fn_memo_open() {
	window.open("/common/memo/comMemoReceiveList.jsp", "MEMO", "width=500,height=500,scrollbars=no");
}

function fn_go_site(userId, siteCode, loginYn, currentUrl) {
	var url;

	if(siteCode == "01") {
		url = "http://www.readingcoach.co.kr";
	} else if(siteCode == "31") {
		url = "http://www.genture.co.kr";
	} else if(siteCode == "51") {
		url = "http://www.kyoboread.co.kr";
	} else if(siteCode == "91") {
		url = "http://www.ezpia.co.kr";
	}

	if(loginYn == "Y") {
		if(siteCode == "31") {
			url = url + "/common/member/gateway/gentureGateway.jsp?pSiteCode="+siteCode+"&pUserId="+userId+"&pLoginYn="+loginYn;
		} else {
			url = url + "/common/member/gateway/portalGateway.jsp?pSiteCode="+siteCode+"&pUserId="+userId+"&pLoginYn="+loginYn;
		}
	}

	if(currentUrl) {
		url = url + "&pCurrentUrl="+currentUrl;
	}

	var win = window.open(url, "_new");
}

function fn_go_site_popup(userId, siteCode, loginYn, currentUrl, userParam, top, left, width, height) {
	var url;

	if(siteCode == "01") {
		url = "http://www.readingcoach.co.kr";
	} else if(siteCode == "31") {
		url = "http://www.genture.co.kr";
	} else if(siteCode == "51") {
		url = "http://www.kyoboread.co.kr";
	} else if(siteCode == "91") {
		url = "http://www.ezpia.co.kr";
	}

	if(loginYn == "Y") {
		if(siteCode == "31") {
			url = url + "/common/member/gateway/gentureGateway.jsp?pSiteCode="+siteCode+"&pUserId="+userId+"&pLoginYn="+loginYn;
		} else {
			url = url + "/common/member/gateway/portalGateway.jsp?pSiteCode="+siteCode+"&pUserId="+userId+"&pLoginYn="+loginYn;
		}
	}

	if(currentUrl) {
		url = url + "&pCurrentUrl="+currentUrl;
	}
    
    url = url + "&pUserParam="+userParam;

	var win = window.open(url, '_new', 'top='+top+', left='+left+', width='+width+', height='+height+', menubar=no, toolbar=no, location=no, directories=no, resizable=yes, scrollbars=yes');
}


function fn_check_email(email) {

	if(email.indexOf("@")==-1) { 
		return false; 
	}

	if(email.indexOf(".")==-1) { 
		return false; 
	}

	for(i=0; i<email.length;i++) {

		if(!( (email.charAt(i)>='a' && email.charAt(i)<='z') || (email.charAt(i)>='A' && email.charAt(i)<='Z')
			|| (email.charAt(i)>='0' && email.charAt(i)<='9') || (email.charAt(i)=="-")
			|| (email.charAt(i)=="_") || (email.charAt(i)=="@")
			|| (email.charAt(i)==".") )) {

			return false;
		}
	}

	return true;
}
