function han_check(strObj) { //ÇÑ±Û Ã¼Å©

	var strValue = strObj.value;
	var intCode = 0;

	for (i = 0; i < strValue.length; i++) {

		var intCode = strValue.charCodeAt(i)
		var strChar = strValue.substr(i,1).toUpperCase()

		intCode = parseInt(intCode)

		if ((strChar < "0" || strChar > "9") && (strChar < "A" || strChar > "Z") && ((intCode > 255) || (intCode < 0))) {
			return false;
		}
	}
	return true;
}

function space_check(strObj) { //°ø¹éÃ¼Å©

	var strValue = strObj.value;
	var intCode = 0;

	for (i = 0; i < strValue.length; i++) {
		var intCode = strValue.charCodeAt(i)
		var retChar = strValue.substr(i,1).toUpperCase()
		intCode = parseInt(intCode)
		if (retChar == " " )	return false;
	}
	return true;
}

function num_check(strObj) { // ¼ýÀÚ¸¸ Çã¿ë

	var strValue = strObj.value;
	var intCode = 0;

	for (i = 0; i < strValue.length; i++) {

		var intCode = strValue.charCodeAt(i)
		var strChar = strValue.substr(i,1).toUpperCase()

		intCode = parseInt(intCode)

		if ((strChar < "0" || strChar > "9") ){
			return false;
		}
	}
	return true;
}

function at_check(strObj) { // E-Mail Ã¼Å©


	var strValue = strObj.value;
	var intCode = 0;
	var flag =0;

	for (i = 0; i < strValue.length; i++) {

		var intCode = strValue.charCodeAt(i)
		var strChar = strValue.substr(i,1).toUpperCase()

		intCode = parseInt(intCode)

		if( strChar == "@" ) {
			flag +=1;
		}
		if( strChar == "." ) {
		  	flag +=1;
		}
	}

	if( flag < 2 )	return false;
	return true;
}


function moveNext(varControl, varNext)
{
	if(varControl.value.length == varControl.maxLength)
	{
	varNext.focus();
	varNext.select();
	}
}

function event(){
		if (confirm("¾à°ü¿¡ µ¿ÀÇÇÏ¼Å¾ß °¡ÀÔÀÌ ½ÂÀÎµË´Ï´Ù.")){
				location.href="sub08_1a.asp"}
				else{location.href="/index.asp"}
		}


function kname_check(form) {
	if(form.kname.value.length == 0) {
		alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.");
		form.kname.focus();
		return false;
	}
	return	true;
}


function writer_check(form) {
	if(form.writer.value.length == 0) {
		alert("ÇÊ¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		form.writer.focus();
		return false;
	}
	return	true;
}



function check_ResidentNO(obj1,obj2)  //ÁÖ¹Î¹øÈ£ Ã¼Å©
{

	var str_f_num = obj1.value;
	var str_l_num = obj2.value;

	var i3=0
	for (var i=0;i<str_f_num.length;i++)
	{
		var ch1 = str_f_num.substring(i,i+1);
		if (ch1<'0' || ch1>'9') { i3=i3+1 }
	}
	if ((str_f_num == '') || ( i3 != 0 ))
	{
		return false;
	}

	var i4=0
	for (var i=0;i<str_l_num.length;i++)
	{
		var ch1 = str_l_num.substring(i,i+1);
		if (ch1<'0' || ch1>'9') { i4=i4+1 }
	}
	if ((str_l_num == '') || ( i4 != 0 ))
	{
		return false;
	}

	if(str_f_num.substring(0,1) < 0)
	{
		return false;
	}

	if(str_l_num.substring(0,1) > 2)
	{
		return false;
	}

	if((str_f_num.length > 7) || (str_l_num.length > 8))
	{
		return false;
	}

	if ((str_f_num == '72') || ( str_l_num == '18'))
	{
		return false;
	}

	var f1=str_f_num.substring(0,1)
	var f2=str_f_num.substring(1,2)
	var f3=str_f_num.substring(2,3)
	var f4=str_f_num.substring(3,4)
	var f5=str_f_num.substring(4,5)
	var f6=str_f_num.substring(5,6)
	var hap=f1*2+f2*3+f3*4+f4*5+f5*6+f6*7
	var l1=str_l_num.substring(0,1)
	var l2=str_l_num.substring(1,2)
	var l3=str_l_num.substring(2,3)
	var l4=str_l_num.substring(3,4)
	var l5=str_l_num.substring(4,5)
	var l6=str_l_num.substring(5,6)
	var l7=str_l_num.substring(6,7)
	hap=hap+l1*8+l2*9+l3*2+l4*3+l5*4+l6*5
	hap=hap%11
	hap=11-hap
	hap=hap%10
	if (hap != l7)
	{
		return false;
	}
  return true;
}

function jumin_check(form) {
	if(check_ResidentNO(form.jumin1,form.jumin2)==false) {
		alert("ÁÖ¹Î¹øÈ£°¡ Æ²¸®°Å³ª ÀÔ·ÂÇÏÁö ¾Ê¾Ò½À´Ï´Ù.");
		form.jumin1.value = "";
		form.jumin2.value = "";

		form.jumin1.focus();

		return false;
	}
	return	true;
}
function id_org_check(form) {
	if(form.m_id.value.length == 0) {
		alert("ID¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		form.m_id.focus();
		return false;
	}
	return	true;
}

function pass_check(form) {
	if(!space_check(form.password1)){
		alert("ºñ¹Ð ¹øÈ£¿¡ ½ºÆäÀÌ½º¸¦ ³ÖÀ¸½Ã¸é ¾ÈµË´Ï´Ù.");
		form.password1.focus();
		return false;
	}
	if(form.password1.value.length < 4 || form.password1.value.length > 20){
		alert("ºñ¹Ð ¹øÈ£´Â 4ÀÚ¿¡¼­ 20ÀÚ »çÀÌ·Î ÀÔ·ÂÇÏ¼¼¿ä.");
		form.password1.focus();
		return false;
	}
	if(form.password1.value != form.password2.value) {
		alert("ºñ¹Ð¹øÈ£¶õ°ú ºñ¹Ð¹øÈ£ È®ÀÎ¶õÀÌ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù");
		form.password2.value = "";
		form.password2.focus();
		return false;
	}
    return true;
}

function hasCheckedRadio(input) {
    if (input.length > 1) {
        for (var inx = 0; inx < input.length; inx++) {
            if (input[inx].checked) return true;
        }
    } else {
        if (input.checked) return true;
    }
    return false;
}

function email_check(form) {
	if(form.email.value.length == 0) {
		alert("E-mailÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		form.email.focus();
		return false;
	}
	if(!han_check(form.email)) {
		alert("EmailÀÔ·Â½Ã ÇÑ±ÛÀº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
		form.email.focus();
		return false;
	}
	if(form.email.value.length != 0){
		if(!at_check(form.email)){
			alert("EmailÇü½ÄÀ» ÁöÄÑÁÖ¼¼¿ä.");
			form.email.focus();
			return false;
		}
	}
	return	true;
}

function email_check1(form) {
	if(form.m_id.value.length == 0) {
		alert("E-mailÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		form.m_id.focus();
		return false;
	}
	if(!han_check(form.m_id)) {
		alert("EmailÀÔ·Â½Ã ÇÑ±ÛÀº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
		form.m_id.focus();
		return false;
	}
	if(form.m_id.value.length != 0){
		if(!at_check(form.m_id)){
			alert("EmailÇü½ÄÀ» ÁöÄÑÁÖ¼¼¿ä.");
			form.m_id.focus();
			return false;
		}
	}
	return	true;
}


function address_check(form) {
	if(form.post1.value.length == 0 || form.post2.value.length == 0){
		alert("¿ìÆí¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		form.post1.focus();
		return false;
	}
	if(form.addr.value.length == 0 ) {
		alert("ÁÖ¼Ò¸¦ Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä.");
		form.addr.focus();
		return false;
	}
	if(!num_check(form.post1)){
		alert("¿ìÆí¹øÈ£´Â ¼ýÀÚ¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.");
		form.post1.value = "";
		form.post2.value = "";
		form.post1.focus();
		return false;
	}
	if(!num_check(form.post2)){
		alert("¿ìÆí¹øÈ£´Â ¼ýÀÚ¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.");
		form.post1.value = "";
		form.post2.value = "";
		form.post1.focus();
		return false;
	}
	return	true;
}

function tel_check(form) {
	if(form.h_tel.value.length == 0) {
		alert("ÀüÈ­¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		form.h_tel.focus();
		return false;
	}
	return	true;
}

function content_check(form) {
	if(form.content.value.length == 0) {
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		form.content.focus();
		return false;
	}
	return	true;
}
function search_check(form) {
	if(form.search_key.value.length == 0) {
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		form.search_key.focus();
		return false;
	}
	return	true;
}

function org_name_check(form) {
	if(form.org_name.value.length == 0) {
		alert("¼Ò¼Ó/´ÜÃ¼¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		form.org_name.focus();
		return false;
	}
	return	true;
}

function contract_check(input){
	if(hasCheckedRadio(input) == false){
		alert("°è¾à ±â°£À» Ã¼Å© ÇÏ¼¼¿ä");
		return false;
	}
	return true;
}

function svcnm_check(input){
	if(hasCheckedRadio(input) == false){
		alert("°áÁ¦¹æ¹ýÀ» Ã¼Å© ÇÏ¼¼¿ä");
		return false;
	}
	return true;
}


function member_check(form) {

	if(email_check1(form) == false) return false;
	//if(id_check(form) == false) return false;
	if(pass_check(form) == false) return false;
	if(kname_check(form) == false) return false;
	//if(jumin_check(form) == false) return false;
	if(org_name_check(form) == false) return false;
	//if(address_check(form) == false) return false;
	if(tel_check(form) == false) return false;

	if(form.poll_chk[1].checked  == true){
		if(form.sel_cnslt_type.options[0].selected == true){
			alert("Á÷¾÷À» ¼±ÅÃÇÏ¼¼¿ä.");
			form.sel_cnslt_type.focus();
			return false;
		}else{
			if(form.sel_cnslt_code.options[0].selected == true){
				alert("¼¼ºÎÁ÷¾÷À» ¼±ÅÃÇÏ¼¼¿ä.");
				form.sel_cnslt_code.focus();
				return false;
			}
		}
	}

	if(hasCheckedRadio(form.contract_period) == false){
		alert("°áÁ¦±Ý¾×À» Ã¼Å© ÇÏ¼¼¿ä");
		return false;
	}

	if(hasCheckedRadio(form.svcnm) == false){
		alert("°áÁ¦¹æ¹ýÀ» Ã¼Å© ÇÏ¼¼¿ä");
		return false;
	}
/*	if(hasCheckedRadio(form.order_type) == false){
		alert("½ÅÃ» ±¸ºÐÀ» Ã¼Å© ÇÏ¼¼¿ä");
		return false;
	}
*/

	var WinWidth = 620; // °áÁ¦Ã¢ ³ÐÀÌ
	var WinHeight = 400; // °áÁ¦Ã¢ ³ôÀÌ
	var x=screen.width/2-WinWidth/2; //°áÁ¦Ã¢À» È­¸é Áß¾ÓÀ¸·Î À§Ä¡
	var y=screen.height/2-WinHeight/2;
	winopen = window.open('','gopay','left='+ x +',top='+ y +',width='+ WinWidth +', height='+ WinHeight +' , menubar=no, scrollvars=no, staus=no, resizable=no, titlebar=no, toolbar=no, hotkey=0,closeable=no');
	if(!winopen.opener) winopen.opener=self;
	form.action='pay.html'; // °áÁ¦ ÇÁ·Î±×·¥ URL
	form.target='gopay';
	form.submit();
	//return true;
}

function member_event_check(form) {

	if(email_check1(form) == false) return false;
	//if(id_check(form) == false) return false;
	if(pass_check(form) == false) return false;
	if(kname_check(form) == false) return false;
	if(jumin_check(form) == false) return false;
	if(org_name_check(form) == false) return false;
	if(address_check(form) == false) return false;
	if(tel_check(form) == false) return false;
	//if(email_check(form) == false) return false;

	if(form.poll_chk[1].checked  == true){
		if(form.sel_cnslt_type.options[0].selected == true){
			alert("Á÷¾÷À» ¼±ÅÃÇÏ¼¼¿ä.");
			form.sel_cnslt_type.focus();
			return false;
		}else{
			if(form.sel_cnslt_code.options[0].selected == true){
				alert("¼¼ºÎÁ÷¾÷À» ¼±ÅÃÇÏ¼¼¿ä.");
				form.sel_cnslt_code.focus();
				return false;
			}
		}
	}
	/*
	if(hasCheckedRadio(form.contract_period) == false){
		alert("°áÁ¦±Ý¾×À» Ã¼Å© ÇÏ¼¼¿ä");
		return false;
	}
	*/

	if(hasCheckedRadio(form.svcnm) == false){
		alert("°áÁ¦¹æ¹ýÀ» Ã¼Å© ÇÏ¼¼¿ä");
		return false;
	}
/*	if(hasCheckedRadio(form.order_type) == false){
		alert("½ÅÃ» ±¸ºÐÀ» Ã¼Å© ÇÏ¼¼¿ä");
		return false;
	}

	if(form.contract_period[0].checked == true){
		form.amt.value=2400000;
	}
	if(form.contract_period[1].checked == true){
		form.amt.value=1500000;
	}
	if(form.contract_period[2].checked == true){
		form.amt.value=300000;
	}
*/
	var WinWidth = 620; // °áÁ¦Ã¢ ³ÐÀÌ
	var WinHeight = 400; // °áÁ¦Ã¢ ³ôÀÌ
	var x=screen.width/2-WinWidth/2; //°áÁ¦Ã¢À» È­¸é Áß¾ÓÀ¸·Î À§Ä¡
	var y=screen.height/2-WinHeight/2;
	winopen = window.open('','gopay','left='+ x +',top='+ y +',width='+ WinWidth +', height='+ WinHeight +' , menubar=no, scrollvars=no, staus=no, resizable=no, titlebar=no, toolbar=no, hotkey=0,closeable=no');
	if(!winopen.opener) winopen.opener=self;
	form.action='pay_event.html'; // °áÁ¦ ÇÁ·Î±×·¥ URL
	form.target='gopay';
	form.submit();
	//return true;
}


function member_check2(form) {
	if(email_check1(form) == false) return false;
	if(pass_check(form) == false) return false;
	if(kname_check(form) == false) return false;
	//if(jumin_check(form) == false) return false;
	if(org_name_check(form) == false) return false;
	//if(address_check(form) == false) return false;
	if(tel_check(form) == false) return false;
	//if(email_check(form) == false) return false;
	/*
	if(!han_check(form.org_recommend)) {
		alert("ÃßÃµÀÎID´Â E-mail ÀÔ´Ï´Ù. \n\nÇÑ±ÛÀº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
		form.org_recommend.focus();
		return false;
	}
	if(form.org_recommend.value.length != 0){
		if(!at_check(form.org_recommend)){
			alert("ÃßÃµÀÎID´Â E-mailÀÔ´Ï´Ù.\n\nEmailÇü½ÄÀ» ÁöÄÑÁÖ¼¼¿ä.");
			form.org_recommend.focus();
			return false;
		}
	}
	*/
	
	if(form.poll_chk[1].checked  == true){
		if(form.sel_cnslt_type.options[0].selected == true){
			alert("Á÷¾÷À» ¼±ÅÃÇÏ¼¼¿ä.");
			form.sel_cnslt_type.focus();
			return false;
		}else{
			if(form.sel_cnslt_code.options[0].selected == true){
				alert("¼¼ºÎÁ÷¾÷À» ¼±ÅÃÇÏ¼¼¿ä.");
				form.sel_cnslt_code.focus();
				return false;
			}
		}
	
	}
	
	form.submit();
	//return true;
}

function member_check3(form) {
	if(email_check1(form) == false) return false;
	if(kname_check(form) == false) return false;
//	if(jumin_check(form) == false) return false;
	if(org_name_check(form) == false) return false;
	if(address_check(form) == false) return false;
	if(tel_check(form) == false) return false;

	/*if(form.poll_chk[0].checked  == true){
		if(form.sel_cnslt_type.options[0].selected == true){
			alert("Á÷¾÷À» ¼±ÅÃÇÏ¼¼¿ä.");
			form.sel_cnslt_type.focus();
			return false;
		}else{
			if(form.sel_cnslt_code.options[0].selected == true){
				alert("¼¼ºÎÁ÷¾÷À» ¼±ÅÃÇÏ¼¼¿ä.");
				form.sel_cnslt_code.focus();
				return false;
			}
		}
	}*/

	form.submit();
	//return true;
}

function member_edit_check(form) {
//	if(id_check(form) == false) return false;
	if(pass_check(form) == false) return false;
	if(kname_check(form) == false) return false;
	if(org_name_check(form) == false) return false;
	//if(jumin_check(form) == false) return false;
	if(address_check(form) == false) return false;
	if(tel_check(form) == false) return false;
	if(email_check(form) == false) return false;

	form.submit();
	//return true;
}


function checkField(form) {
//	if(id_check(form) == false) return false;
//	if(pass_check(form) == false) return false;
	if(kname_check(form) == false) return false;
	if(jumin_check(form) == false) return false;
	if(address_check(form) == false) return false;
	if(tel_check(form) == false) return false;
	if(email_check(form) == false) return false;
	form.submit();
	//return true;
}

function id_check(form) {

	if(form.m_id.value.length == 0) {
		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		form.m_id.focus();
		return false;
	}
	if(form.m_id.value.length < 3 || form.m_id.value.length > 20) {
		alert("È¸¿øID´Â 3ÀÚÀÌ»ó 20ÀÚ ÀÌÇÏ·Î ¿µ¹®°ú ¼ýÀÚ¸¦ ÀÌ¿ëÇÏ¿© ¸¸µå¼¼¿ä.");
		form.m_id.focus();
		return false;
	}
	if (han_check(form.m_id) == false) {
		alert("¾ÆÀÌµð´Â ¿µ¹®À¸·Î ÀÔ·ÂÇÏ¼¼¿ä.");
		form.m_id.focus();
		return false;
	}
	return true;
}


function mail_send_check(form) {
	if(kname_check(form) == false) return false;
	if(email_check(form) == false) return false;
	if(content_check(form) == false) return false;
	form.submit();
}

function search_ck(form) {
	if(search_check(form) == false) return false;
	form.submit();
}



function fnamewindow(form){
	if(writer_check(form) == true){
		form.jumin1.focus();
		var namewindow = window.open('writer_find.asp?writer=' + form.writer.value,'namewindow','width=400,height=180');
		namewindow.focus();
	}
}


function fidwindow(form){
	//if(id_check(form) == true){
		form.password1.focus();
		var idwindow = window.open('/sub06/id_find.html?id=' + form.m_id.value,'idwindow','width=400,height=180');
		idwindow.focus();
	//}
}
function fidwindow1(form){
	//if(id_check(form) == true){
		var idwindow = window.open('/sub06/id_find.html?id=' + form.m_id.value,'idwindow','width=400,height=180');
		idwindow.focus();
	//}
}

function fpostwindow(form){
	form.addr.focus();
	var postwindow = window.open('/sub06/post.html','postwin','width=400,height=200');
	postwindow.focus();
}


function join_check(input){
	if(hasCheckedRadio(input) == false){
		alert("È¸¿øÀ» ¼±ÅÃÇÏ¼¼¿ä");
		return false;
	}
	return true;
}


function joinChk(form) {
	if(join_check(form.standby) == false) return false;
	form.submit();
}

function payFunc(form){
	var pay_point = parseInt(form.pay_point.value);
	var tot_price = parseInt(form.tot_price.value);

	if(pay_point != tot_price){
		if(hasCheckedRadio(form.svcnm) == false){
			alert("°áÁ¦¹æ¹ýÀ» Ã¼Å© ÇÏ¼¼¿ä");
			return false;
		}
	}

	if(pay_point == tot_price){
		form.action = "buy.html";
	}else{
		form.action = "pay.html";
	}
	form.submit();

}




	function init_screen() {

		form = document.form2

		form.r_bs_trade_type[0].checked = true;

		get_cnslt_code();
	}

	function get_cnslt_code(){

		form = document.form2
		del_cnslt_code();

		var cnslt_code = form.sel_cnslt_type.value;

		add_option = new Option("¼±ÅÃ", "", true);

		form.sel_cnslt_code.options[0] = add_option;

		if(eval("form.cnslt_manage_value"+cnslt_code+".length") > 0){
			idx = eval("form.cnslt_manage_value"+cnslt_code+".length") ;
		}else if(eval("form.cnslt_manage_value"+cnslt_code+".value")){
			idx = 1;
		}

		for (i=0; i<idx; i++) {

			if(form.sel_cnslt_code.length > 0){
				j = form.sel_cnslt_code.length ;
			}else if(form.sel_cnslt_code.value){
				j = 1;
			}

			if (idx > 1)
			{
				sel_name = eval("form.cnslt_manage_value"+cnslt_code+"["+i+"].value");
				sel_value = eval("form.cnslt_manage_code"+cnslt_code+"["+i+"].value");
			}else{
				sel_name = eval("form.cnslt_manage_value"+cnslt_code+".value");
				sel_value = eval("form.cnslt_manage_code"+cnslt_code+".value");
			}
			add_option = new Option(sel_name, sel_value, true);
			form.sel_cnslt_code.options[j] = add_option;
		}
	}

	function del_cnslt_code(){

		form = document.form2;


		for ( i = form.sel_cnslt_code.length - 1 ; i >= 0 ; i-- )
		{
			form.sel_cnslt_code[i] = null;

		}
	}


function idfindFunc(){
	window.open("/login/idpw_find.html","idfindfunc", "width=400, height=230, resizable=no, location=0");
}

function money_ck(){

	var pay_point = parseInt(order.pay_point.value);
	var tot_price = parseInt(order.tot_price.value);
  var my_point = parseInt(order.my_point.value);

	if(!pay_point) pay_point = 0;

  if(pay_point!=0 && my_point < pay_point){
		alert('»ç¿ë°¡´ÉÇÑ Æ÷ÀÎÆ®¸¦ ÃÊ°úÇÏ¼Ì½À´Ï´Ù.');
	  order.pay_point.value = 0;
		return;
  }

	if(tot_price < pay_point){
		alert('±¸¸Å±Ý¾×º¸´Ù Àû¿ë Æ÷ÀÎÆ®°¡ Å®´Ï´Ù.');
	  order.pay_point.value = 0;
		return;
	}

/*
  if( order.pay_point.value >= order.my_point.value ){
	  order.pay_point.value = 	order.my_point.value;
  }
*/

  var val1 = tot_price - pay_point;
  var val2 = " Çö±Ý+ Æ÷ÀÎÆ® => " + val1 + " ¿ø + "  + pay_point +" point";
  order.amt.value = val1;
  order.amt1.value = val2;

}


function Check_Number(){
 	if ((event.keyCode<48)||(event.keyCode>57)){
  		alert("¼ýÀÚ¸¸ ÀÔ·ÂÀÌ Çã¿ëµË´Ï´Ù.");
  		event.returnValue=false;
 	}
}