var tempX = 0;
var tempY = 0;
function selectBoxHidden(layer_id) 
    {
        //var ly = eval(layer_id);
        var ly = document.getElementById(layer_id);

        // 레이어 좌표
        var ly_left   = ly.offsetLeft;
        var ly_top    = ly.offsetTop;
        var ly_right  = ly.offsetLeft + ly.offsetWidth;
        var ly_bottom = ly.offsetTop + ly.offsetHeight;

        // 셀렉트박스의 좌표
        var el;

        for (i=0; i<document.forms.length; i++) {
            for (k=0; k<document.forms[i].length; k++) {
                el = document.forms[i].elements[k];    
                if (el.type == "select-one") {
                    var el_left = el_top = 0;
                    var obj = el;
                    if (obj.offsetParent) {
                        while (obj.offsetParent) {
                            el_left += obj.offsetLeft;
                            el_top  += obj.offsetTop;
                            obj = obj.offsetParent;
                        }
                    }
                    el_left   += el.clientLeft;
                    el_top    += el.clientTop;
                    el_right  = el_left + el.clientWidth;
                    el_bottom = el_top + el.clientHeight;

                    // 좌표를 따져 레이어가 셀렉트 박스를 침범했으면 셀렉트 박스를 hidden 시킴
                    if ( (el_left >= ly_left && el_top >= ly_top && el_left <= ly_right && el_top <= ly_bottom) || 
                         (el_right >= ly_left && el_right <= ly_right && el_top >= ly_top && el_top <= ly_bottom) ||
                         (el_left >= ly_left && el_bottom >= ly_top && el_right <= ly_right && el_bottom <= ly_bottom) ||
                         (el_left >= ly_left && el_left <= ly_right && el_bottom >= ly_top && el_bottom <= ly_bottom) ||
                         (el_top <= ly_bottom && el_left <= ly_left && el_right >= ly_right)
                        )
                        el.style.visibility = 'hidden';
                }
            }
        }
    }

    // 감추어진 셀렉트 박스를 모두 보이게 함
    function selectBoxVisible() 
    {
        for (i=0; i<document.forms.length; i++) 
        {
            for (k=0; k<document.forms[i].length; k++) 
            {
                el = document.forms[i].elements[k];    
                if (el.type == "select-one" && el.style.visibility == 'hidden')
                    el.style.visibility = 'visible';
            }
        }
    }
	 var last_id = null;
 function menu(id)
    {
        if (id != last_id)
        {
            if (last_id != null)
                document.getElementById(last_id).style.display = "none";
            document.getElementById(id).style.display = "block";
            last_id = id;
        }
        else
        {
            document.getElementById(id).style.display = "none";
            last_id = null;
        }
    }
function help(id, left, top)
{
    menu(id);

    var el_id = document.getElementById(id);

    //submenu = eval(name+".style");
    submenu = el_id.style;
    submenu.left = tempX - 50 + left;
    submenu.top  = tempY + 15 + top;

    selectBoxVisible();

    if (el_id.style.display != 'none')
        selectBoxHidden(id);
}
function checkSpace( str )
{
     if(str.search(/\s/) != -1){
     	return 1;
     }

     else {
         return 0;
     }
}


function isHangul(str) 
{
     var len;
     
     len = str.length;

     for (var i = 0; i < len; i++)  {
         if (str.charCodeAt(i) != 32 && (str.charCodeAt(i) < 44032 || str.charCodeAt(i) > 55203))
             return 0;
     }
     return 1;
}

       

function check_Jumin(juminSum)
{
	var juminSum = juminSum.toString();
     a = juminSum.substring(0, 1);
     b = juminSum.substring(1, 2);
     c = juminSum.substring(2, 3);
     d = juminSum.substring(3, 4);
     e = juminSum.substring(4, 5);
     f = juminSum.substring(5, 6);
     g = juminSum.substring(6, 7);
     h = juminSum.substring(7, 8);
     i = juminSum.substring(8, 9);
     j = juminSum.substring(9, 10);
     k = juminSum.substring(10, 11);
     l = juminSum.substring(11, 12);
     m = juminSum.substring(12, 13);
	 month = juminSum.substring(2,4);
	 day = juminSum.substring(4,6);
	 jumin1 = juminSum.substring(0, 7);
	 jumin2 = juminSum.substring(7, 13);

	 if(month <= 0 || month > 12) return 'N';
	 if(day <= 0 || day > 31) return 'N';

	 if(g > 4 || g == 0) return 'N';

	 if (isNaN(jumin1) || isNaN(jumin2))
	 {
		 return 'N';
	 }

     temp=a*2+b*3+c*4+d*5+e*6+f*7+g*8+h*9+i*2+j*3+k*4+l*5;
     temp=temp%11;
     temp=11-temp;
     temp=temp%10;
    
     if(temp == m)
        return 'Y';
     else
        return 'N'; 
}


function validID( str )
{
     if( str == ""){
     	alert("아이디를 입력하세요.");
     	return 0;
     }

 
     if( checkSpace(str) != "" ) {
         alert("아이디에는 빈 공간 없어야 합니다.");
         return 0; 
     } 
     if( str.charAt(0) == '_') {
	 alert("아이디의 첫문자는 '_'로 시작할수 없습니다.");
	 return 0;
     }


	 var isID = /^[a-z0-9_-]{4,12}$/;
     if( !isID.test(str) )
	 {
         alert("아이디는 4~12자의 영문 소문자와 숫자,특수기호(_, -)만 사용할 수 있습니다."); 
         return 0; 
     }

	 return 1;
}


function validPWD( str )
{
     var cnt=0;
     if( str == ""){
     	alert("비밀번호를 입력하세요.");
     	return 0;
     }     

     var retVal = checkSpace( str );
     if( retVal != "") {
         alert("비밀번호는 빈공간 없이 연속된 영문 소문자와 숫자만 사용할 수 있습니다.");
         return 0;
     }
/*
     for( var i=0; i < str.length; ++i)
     {
         if( str.charAt(0) == str.substring( i, i+1 ) ) ++cnt;
     }  
     if( cnt == str.length ) {
         alert("한 문자로 연속된 비밀번호는 허용하지 않습니다.");
         return 0; 
     }

     var isPW = /^[a-zA-Z0-9^,&]{3,30}$/;
     if( !isPW.test(str) ) {
         alert("비밀번호는 3~30자의 영문과 숫자만 사용할 수 있습니다."); 
         return 0; 
     }
*/
     return 1;
}

function validEMAIL( str )
{

     if(str == ""){
     	alert("이메일 주소를 입력하세요.");
     	return 0;
     }
     var retVal = checkSpace( str );
     if( retVal != "") {
         alert("이메일 주소를 빈공간 없이 넣으세요.");
         return 0;
     }
 		  

    var arrMatch = str.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);
    if (arrMatch == null) {
        alert("이메일 형식이 잘못 되었습니다.");
        return 0;
    }
 
     return 1;
}

function validRandom(str){

	var string_val = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	var i;

	for (i=0; i< str.length; i++){
		if(string_val.indexOf(str.substring(i,i+1)) < 0){

			return 0;
		}
	}

	return 1;
}

function asclen(s)
{
	var i, len=0;
	for(i=0;i < s.length; i++) (s.charCodeAt(i) > 255)? len+=2:len++;
	return len;
}


function isValidNick(nickName){

	var ReservedWord = [
		"관리자", "야동", "야사", "야설", "에로", "와레즈", "음란", "음부", "자위", "자지", "운영자",
		"꼬추", "누드","몰카", "보지", "빠구리", "빠꾸리", "뽀르노", "사창가", "성감대", "성기",
		"섹스", "스팽킹","애무", "카섹", "컴섹", "클리토리스", "페니스", "포르노", "폰섹", "헨타이",
		"sex", "자살", "청부살인","청부폭력", "히로뽕", "마약", "비아그라", "엑스터시", "코카인",
		"갈보" ,"강간", "개년", "개놈","개새끼", "개세이", "개쉐이", "개자식", "개지랄", "노브라",
		"미친년", "미친뇬", "미친놈", "미친넘", "마스터베이션","뻐르노", "뻐르너", "스와핑", "시발넘",
		"시발년", "시발놈", "시벌", "씨발", "씨팔", "쌍넘","쌍년", "쌍놈", "씹새", "씹세", "씹쉐",
		"야캠", "야덩", "야겜", "야설", "야시시","가슴", "좆", "페티쉬", "페티시", "슴가"
	];

	if (nickName == "")
	{
		alert("사용자 필명(닉네임)을 입력하세요.");
		return false;
	}

	var len = asclen(nickName);
	if (len < 2)
	{
		alert("사용자 필명(닉네임)을 2자 이상 입력하세요.\r\n\r\n한글 한글자는 2자로 인식됩니다.");
		return false;
	}
	if (len > 12)
	{
		alert("사용자 필명(닉네임)을 12자 이내로 입력하세요.\r\n\r\n한글 한글자는 2자로 인식됩니다.");
		return false;
	}
	
	for (var i = 0; i < nickName.length; i++)
	{
		if (!nickNameCharCheck(nickName.charCodeAt(i)))
		{
			alert("사용자 필명(닉네임)에 사용할 수 없는 문자가 있습니다.\r\n\r\n사용자 필명(닉네임)은 1~6자의 한글, 2~12자의 영문대소문자, 숫자, '_' 만 가능합니다.");
			return false;
		}
	}
	

	var FilterNick = "";

	for (var i = 0; i < nickName.length; i++)
	{
		if ("_".indexOf(nickName.substring(i,i+1)) < 0) FilterNick = FilterNick + nickName.substring(i,i+1);
	}


	if(FilterNick == ""){
		alert("'_'만으로 구성된 사용자 필명(닉네임)은 사용하실 수 없습니다.");
		return false;
	}

	FilterNick = FilterNick.toLowerCase();
	
	for (var i = 0; i < ReservedWord.length; i++)
	{
		if (FilterNick.indexOf(ReservedWord[i]) >= 0){
			alert("사용자 필명(닉네임)으로 비속어는 사용하실 수 없습니다.");
			return false;
		}
	}

	return true;
}

function nickNameCharCheck(chcode)
{
	if (chcode >= "가".charCodeAt(0) && chcode <= "힣".charCodeAt(0))
		return true;
	if (chcode == "_".charCodeAt(0))
		return true;
	if (chcode >= "A".charCodeAt(0) && chcode <= "Z".charCodeAt(0))
		return true;
	if (chcode >= "a".charCodeAt(0) && chcode <= "z".charCodeAt(0))
		return true;
	if (chcode >= "0".charCodeAt(0) && chcode <= "9".charCodeAt(0))
		return true;
	return false;
}



function quecheck(val){

	if(val.checked){
		document.all.que1.style.display = "none";
		document.all.que2.style.display = "inline";
		document.all.question2.focus();

	}else{
		document.all.que1.style.display = "inline";
		document.all.que2.style.display = "none";
		document.all.question2.value= "";

	}//if...
}

function validNum(str){

	var string_val = "1234567890";
	var i;

	for (i=0; i< str.length; i++){
		if(string_val.indexOf(str.substring(i,i+1)) < 0){

			return 0;
		}
	}

	return 1;
}

//시작

function onlyDigit(el) 
	{
		el.value = el.value.replace(/\D/g,'');
	}
function next(val,order){  

   number = val.elements[order].value;
   size = number.length;
   numFlag = Number(number);
   
	if(!numFlag && size > 0){
		alert('정확한 숫자를 넣어주십시오.');
		val.elements[order].select();
		val.elements[order].focus();
	return false;
	}//if...

   if( (order == 1) && (size == 6) ){
      val.elements[2].focus();
	  return true;
   }

   if(order == 2 && size > 0){
		if(number.substring(0,1) < 1 || number.substring(0,1) > 4){
			alert('정확한 주민등록번호를 입력하여 주십시오.');
         	val.elements[order].select();
         	val.elements[order].focus();
			return false;
		}
   }
}


function RealNameCheck()
{
     var thisForm = document.forms[0];
	 var str = thisForm.UserName.value;

     if(  (str == '') || (checkSpace(str) == 1) || (isHangul(str) == 0) ){
     	 alert("정확한 실명을 입력하여 주십시오.");
		 thisForm.UserName.focus();
     	 thisForm.UserName.select();    
         return false;	
     }     

     if(str.length > 10 ) {
         alert("이름은 7자까지만 사용하실 수 있습니다.");
         return false;
     }
     	
	if(thisForm.jumin1.value.length != 6){
         alert("유효한 주민등록번호가 아닙니다");
         thisForm.jumin1.focus();
         return false;
     }

	if( thisForm.jumin2.value.length != 7){
         alert("유효한 주민등록번호가 아닙니다");
         thisForm.jumin2.focus();
         return false;
     }


	var juminSum = (thisForm.jumin1.value + thisForm.jumin2.value);
    var rtnVal = check_Jumin(juminSum);

    if( rtnVal == 'N' ){
        alert("주민등록번호가 유효하지 않습니다.     \n\r\n\r다시 입력하여 주십시오.  ");
        thisForm.jumin1.focus();
        return false;
    }//if...

    thisForm.action = "./RealName.jsp"; 
    thisForm.submit();

}

function RealNameCheck2()
{
     var thisForm = document.forms[0];
	 var str = thisForm.UserName.value;

     if(  (str == '') || (checkSpace(str) == 1) || (isHangul(str) == 0) ){
     	 alert("정확한 실명을 입력하여 주십시오.");
		 thisForm.UserName.focus();
     	 thisForm.UserName.select();    
         return false;	
     }     

     if(str.length > 10 ) {
         alert("이름은 7자까지만 사용하실 수 있습니다.");
         return false;
     }
     	
	if(thisForm.jumin1.value.length != 6){
         alert("유효한 주민등록번호가 아닙니다");
         thisForm.jumin1.focus();
         return false;
     }

	if( thisForm.jumin2.value.length != 7){
         alert("유효한 주민등록번호가 아닙니다");
         thisForm.jumin2.focus();
         return false;
     }


	var juminSum = (thisForm.jumin1.value + thisForm.jumin2.value);
    var rtnVal = check_Jumin(juminSum);

    if( rtnVal == 'N' ){
        alert("주민등록번호가 유효하지 않습니다.     \n\r\n\r다시 입력하여 주십시오.  ");
        thisForm.jumin1.focus();
        return false;
    }//if...

    thisForm.action = "./RealName2.jsp"; 
    thisForm.submit();

}

function  checkID( val )
{
	var valUserID = val.value;

	if( valUserID.length < 1 )
	{
		alert("아이디를 입력하여 주십시오.");
		val.focus();
	}
	else
	{
		retVal = validID(valUserID);
		if( !retVal ){
			val.focus();
			return;
		} 

		var targetUrl = ("./id_search_run.jsp?id=" + valUserID ); 
		var Rwin = window.open(targetUrl, 'checkID', 'width=350,height=320,top=20,left=20,resizable=no,scrollbars=no,toolbar=no,menubar=no');
		Rwin.focus();
	}
}

function  checkMobile(val1,val2,val3 )
{

		if( ((val1 != "010") && (val1 != "011") && (val1 != "016") && (val1 != "017") && (val1 != "018") && (val1 != "019") ) || (val1.length != 3) || (val2.length < 1) || (val3.length < 1) ){

			alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			return;
		}else{

			var str = eval(val1)+eval(val2)+eval(val3)

			if(validNum(str) < 1){
				alert("정확한 휴대전화 번호를 입력하여 주십시오.");
				return;
			}

			var targetUrl = ("./confirm_mobile.jsp?Mobile1="+val1+"&Mobile2="+val2+"&Mobile3="+val3 ); 
			var Mwin = window.open(targetUrl, 'checkID', 'width=350,height=320,top=20,left=20,resizable=no,scrollbars=no,toolbar=no,menubar=no');
			Mwin.focus();
		}

}

function  checkMobile2(val1,val2,val3,val4)
{

		if( ((val1 != "010") && (val1 != "011") && (val1 != "016") && (val1 != "017") && (val1 != "018") && (val1 != "019") ) || (val1.length != 3) || (val2.length < 1) || (val3.length < 1) ){

			alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			return;
		}else{

			var str = eval(val1)+eval(val2)+eval(val3)

			if(validNum(str) < 1){
				alert("정확한 휴대전화 번호를 입력하여 주십시오.");
				return;
			}
			var str = val1+val2+val3;
			if(val4 == str){
				alert("등록된 휴대전화 번호와 같습니다.");
			}else{
				var targetUrl = ("./confirm_mobile.jsp?Mobile1="+val1+"&Mobile2="+val2+"&Mobile3="+val3 ); 
				var Mwin = window.open(targetUrl, 'checkID', 'width=350,height=370,top=20,left=20,resizable=no,scrollbars=no,toolbar=no,menubar=no');
				Mwin.focus();
			}//if...
		}//if...

}
function formcheck(){
		f_name=document.myform
		if( f_name.O_NAME.value=='' ){
		alert("이름를 입력하여 주십시오.");
		f_name.O_NAME.focus();
		return;
		}
		if( f_name.O_PHONE.value=='' ){
		alert("전화번호를 입력하여 주십시오.");
		f_name.O_PHONE.focus();
		return;
		}
		if( f_name.O_PHONE.value.length < 9 ){
		alert("정확한전화번호를 입력하여 주십시오.");
		f_name.O_PHONE.focus();
		return;
		}
		if( f_name.O_HPHONE.value=='' ){
		alert("휴대전화를 입력하여 주십시오.");
		f_name.O_HPHONE.focus();
		return;
		}
		if( f_name.O_HPHONE.value.length < 9 ){
		alert("정확한휴대번호를 입력하여 주십시오.");
		f_name.O_HPHONE.focus();
		return;
		}
		if( f_name.O_ZIPCODE.value=='' ){
		alert("우편번호를 입력하여 주십시오.");
		f_name.O_ZIPCODE.focus();
		return;
		}
		if( f_name.O_ADDR2.value=='' ){
		alert("주소를 입력하여 주십시오.");
		f_name.O_ADDR.focus();
		return;
		}
		if( f_name.O_ADDR3.value=='' ){
		alert("상세주소를 입력하여 주십시오.");
		f_name.O_ADDR3.focus();
		return;
		}
		if( f_name.O_GE.value=='' ){
		alert("연령을 입력하여 주십시오.");
		f_name.O_GE.focus();
		return;
		}
		if( f_name.O_MEMBER.value=='' ){
		alert("참여인원을 입력하여 주십시오.");
		f_name.O_MEMBER.focus();
		return;
		}
		if( f_name.O_MEMBER.value==0 ){
		alert("정확한참여인원을 입력하여 주십시오.");
		f_name.O_MEMBER.focus();
		return;
		}
		if( f_name.O_MAIL.value=='' ){
		alert("이메일주소를 입력하여 주십시오.");
		f_name.O_MAIL.focus();
		return;
		}
		if( f_name.O_NDATE.value=='' ){
		alert("투어참여일을 입력하여 주십시오.");
		f_name.O_NDATE.focus();
		return;
		}
		f_name.O_ADDR.value=f_name.O_ADDR2.value+f_name.O_ADDR3.value;
	
		f_name.submit();
}

function formcheck2(){
		f_name=document.myform
		if( f_name.O_NAME.value=='' ){
		alert("이름를 입력하여 주십시오.");
		f_name.O_NAME.focus();
		return;
		}
		if( f_name.O_COMPANY.value=='' ){
		alert("연락처를 입력하여 주십시오.");
		f_name.O_COMPANY.focus();
		return;
		}
		if( f_name.O_COMPANY.value.length < 9 ){
		alert("연락처를 입력하여 주십시오.");
		f_name.O_COMPANY.focus();
		return;
		}
		if( f_name.O_ZIPCODE.value=='' ){
		alert("우편번호를 입력하여 주십시오.");
		f_name.O_ZIPCODE.focus();
		return;
		}
		if( f_name.O_ADDR.value=='' ){
		alert("주소를 입력하여 주십시오.");
		f_name.O_ADDR.focus();
		return;
		}
		if( f_name.O_HPHONE.value=='' ){
		alert("나머지주소를 입력하여 주십시오.");
		f_name.O_HPHONE.focus();
		return;
		}
//		if( f_name.O_HOMEPAGE.value=='' ){
//		alert("이메일주소를 입력하여 주십시오.");
//		f_name.O_HOMEPAGE.focus();
//		return;
//		}
		
		f_name.submit();
}
function submitJoin(){

	if( document.insert.id.value.length < 1 ){
		alert("아이디를 입력하여 주십시오.");
		document.insert.id.focus();
		return;
	}

	if( document.insert.flag.value != 1){
     	 alert("사용자 아이디 중복검사를 확인하여 주십시오.");
         return;	
	}

	var nick = document.insert.nickName.value;
	if (!isValidNick(nick))
	{
		 document.insert.nickName.focus();
     	 document.insert.nickName.select(); 
		return;
	}

     if( document.insert.repwd.value == "" ) {
         alert("비밀번호 확인을 입력하세요.");
         document.insert.repwd.focus();
         return;
     }
     else {
         retVal = validPWD(document.insert.repwd.value);
         if( !retVal ) return;
     } 
     if( document.insert.pwd.value != document.insert.repwd.value ) {
         alert("비밀번호가 일치하지 않습니다.");
         document.insert.pwd.select();
         return;
     }


	if(document.insert.queChecker.checked){

		if( document.insert.question2.value == "" ) {
			 alert("비밀번호 재발급을 위한 질문을 직접 입력하세요.");
			 document.insert.question2.focus();
			 return;
		 }

	}else{

		if( document.insert.question1.options[document.insert.question1.selectedIndex].value == 0 ) {
			 alert("비밀번호 재발급을 위한 질문을 선택하세요.");
			 document.insert.question1.focus();
			 return;
		 }
	}


     if( document.insert.reqeustion.value == "" ) {
         alert("비밀번호 재발급을 위한 답을 입력하세요.");
         document.insert.reqeustion.focus();
         return;
     }


     if( document.insert.email.value == "" ) {
         alert("이메일 주소를 입력하세요.");
         document.insert.email.focus();
         return;
     }
     else {
         retVal = validEMAIL(document.insert.email.value);
         if( !retVal ) {
             document.insert.email.select();
             document.insert.email.focus();
             return;
         }
     }


     if( (document.insert.phone1.value).length > 0) {
         retVal = validRandom(document.insert.phone1.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone1.select();
             document.insert.phone1.focus();
             return;
         }
     }

     if( (document.insert.phone2.value).length > 0) {
         retVal = validRandom(document.insert.phone2.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone2.select();
             document.insert.phone2.focus();
             return;
         }
     }


     if( (document.insert.phone3.value).length > 0) {
         retVal = validRandom(document.insert.phone3.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone3.select();
             document.insert.phone3.focus();
             return;
         }
     }

	var phoneSum = eval(document.insert.mobile1.value) + eval(document.insert.mobile2.value) + eval(document.insert.mobile3.value);

	if(phoneSum.length > 0){

		 if( document.insert.mobileflag.value != 1 ) {
			 alert("휴대전화 중복확인을 검사하여 주십시오.");
			 document.insert.mobile1.focus();
			 return;
		}

		 if( document.insert.mobile1.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile1.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile1.value);
			if( !retVal ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile1.select();
			 document.insert.mobile1.focus();
			 return;
			}
		 }

		 if( document.insert.mobile2.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile2.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile2.value);
			if( !retVal ) {
			 alert("정확한 정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile2.select();
			 document.insert.mobile2.focus();
			 return;
			}
		 }


		 if( document.insert.mobile3.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile3.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile3.value);
			if( !retVal ) {
			 alert("정확한 정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile3.select();
			 document.insert.mobile3.focus();
			 return;
			}
		 }

	}


     if( document.insert.randomCount.value == "" ) {
         alert("자동가입방지 코드를 입력하세요.");
         document.insert.randomCount.focus();
         return;
     }else {

         retVal = validRandom(document.insert.randomCount.value);
         if( !retVal ) {
			 alert("자동가입방지 코드는 영문 대문자와 숫자로 구성되어 있습니다.");
             document.insert.randomCount.select();
             document.insert.randomCount.focus();
             return;
         }
     }

      document.insert.action = "join_run.jsp";
      document.insert.submit();

}

function submitReset(){

	document.insert.id.value = "";
	document.insert.flag.value = "0";
	document.insert.nickName.value = "";
	document.insert.pwd.value = "";
	document.insert.repwd.value = "";
	document.insert.queChecker.checked = false;
	document.all.que1.style.display = "inline";
	document.all.que2.style.display = "none";
	document.all.question2.value= "";
	document.insert.reqeustion.value = "";
	document.insert.email.value = "";
	document.insert.phone1.value = "";
	document.insert.phone2.value = "";
	document.insert.phone3.value = "";
	document.insert.randomCount.value = "";
	document.insert.id.focus();

return;
}


function IDSearch1()
{
    var thisForm = document.forms[0];
	var str = thisForm.UserName.value;
	var strYear = thisForm.year.value;
	var strMonth = thisForm.month.value;
	var strDay = thisForm.day.value;

    if(  (str == '') || (checkSpace(str) == 1) || (isHangul(str) == 0) ){
     	 alert("정확한 실명을 입력하여 주십시오.");
		 thisForm.UserName.focus();
     	 thisForm.UserName.select();    
         return;
    }     

	if(strYear.length != 4){
     	 alert("년자리수는 4자리의 숫자로 입력하여 주십시오.");
		 thisForm.year.focus();
     	 thisForm.year.select();    
         return;
	}else{

		if(validNum(strYear) < 1){
			alert("생년월일은 숫자로 구성되어야 합니다.");
			 thisForm.year.focus();
			 thisForm.year.select();
			return;
		}
	}

	if(validNum(strMonth) < 1){
		alert("생년월일은 숫자로 구성되어야 합니다.");
		 thisForm.month.focus();
		 thisForm.month.select();
		return;
	}

	if(validNum(strDay) < 1){
		alert("생년월일은 숫자로 구성되어야 합니다.");
		 thisForm.day.focus();
		 thisForm.day.select();
		return;
	}

    thisForm.action = "./id_search_run.jsp"; 
	thisForm.mode.value = "1";
    thisForm.submit();
}

function IDSearch2()
{
    var thisForm = document.forms[0];
	var str = thisForm.handphone.value;

    if(  (str == '') || (checkSpace(str) == 1)){
     	 alert("정확한 핸드폰번호를 입력하여 주십시오.");
		 thisForm.handphone.focus();
     	 thisForm.handphone.select();    
         return;
    }
	else if(str.length < 10){
     	 alert("입력하신 핸드폰번호가 짧습니다.");
		 thisForm.handphone.focus();
     	 thisForm.handphone.select();    
         return;
    }

    thisForm.action = "./id_search_run.jsp"; 
	thisForm.mode.value = "2";
    thisForm.submit();
}


function submitJoin2(){

	var nick = document.insert.nickName.value;
	if (!isValidNick(nick))
	{
		 document.insert.nickName.focus();
     	 document.insert.nickName.select(); 
		return;
	}

     if( document.insert.repwd.value == "" ) {
         alert("비밀번호 확인을 입력하세요.");
         document.insert.repwd.focus();
         return;
     }
     else {
         retVal = validPWD(document.insert.repwd.value);
         if( !retVal ) return;
     } 
     if( document.insert.pwd.value != document.insert.repwd.value ) {
         alert("비밀번호가 일치하지 않습니다.");
         document.insert.pwd.select();
         return;
     }

	if(document.insert.queChecker.checked){

		if( document.insert.question2.value == "" ) {
			 alert("비밀번호 재발급을 위한 질문을 직접 입력하세요.");
			 document.insert.question2.focus();
			 return;
		 }

	}else{

		if( document.insert.question1.options[document.insert.question1.selectedIndex].value == 0 ) {
			 alert("비밀번호 재발급을 위한 질문을 선택하세요.");
			 document.insert.question1.focus();
			 return;
		 }
	}

     if( document.insert.reqeustion.value == "" ) {
         alert("비밀번호 재발급을 위한 답을 입력하세요.");
         document.insert.reqeustion.focus();
         return;
     }


     if( document.insert.email.value == "" ) {
         alert("이메일 주소를 입력하세요.");
         document.insert.email.focus();
         return;
     }
     else {
         retVal = validEMAIL(document.insert.email.value);
         if( !retVal ) {
             document.insert.email.select();
             document.insert.email.focus();
             return;
         }
     }


     if( (document.insert.phone1.value).length > 0) {
         retVal = validRandom(document.insert.phone1.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone1.select();
             document.insert.phone1.focus();
             return;
         }
     }

     if( (document.insert.phone2.value).length > 0) {
         retVal = validRandom(document.insert.phone2.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone2.select();
             document.insert.phone2.focus();
             return;
         }
     }


     if( (document.insert.phone3.value).length > 0) {
         retVal = validRandom(document.insert.phone3.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone3.select();
             document.insert.phone3.focus();
             return;
         }
     }

	var phoneSum = eval(document.insert.mobile1.value) + eval(document.insert.mobile2.value) + eval(document.insert.mobile3.value);

	if(phoneSum.length > 0){

		 if( document.insert.mobileflag.value != 1 ) {
			 alert("휴대전화 중복확인을 검사하여 주십시오.");
			 document.insert.mobile1.focus();
			 return;
		}

		 if( document.insert.mobile1.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile1.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile1.value);
			if( !retVal ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile1.select();
			 document.insert.mobile1.focus();
			 return;
			}
		 }

		 if( document.insert.mobile2.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile2.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile2.value);
			if( !retVal ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile2.select();
			 document.insert.mobile2.focus();
			 return;
			}
		 }


		 if( document.insert.mobile3.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile3.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile3.value);
			if( !retVal ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile3.select();
			 document.insert.mobile3.focus();
			 return;
			}
		 }
	}


     if( document.insert.randomCount.value == "" ) {
         alert("자동가입방지 코드를 입력하세요.");
         document.insert.randomCount.focus();
         return;
     }else {

         retVal = validRandom(document.insert.randomCount.value);
         if( !retVal ) {
			 alert("자동가입방지 코드는 영문 대문자와 숫자로 구성되어 있습니다.");
             document.insert.randomCount.select();
             document.insert.randomCount.focus();
             return;
         }
     }

      document.insert.action = "join_run2.jsp";
      document.insert.submit();

}

function submitReset2(){

	document.insert.nickName.value = "";
	document.insert.pre_jumin1.value = "";
	document.insert.pwd.value = "";
	document.insert.repwd.value = "";
	document.insert.queChecker.checked = false;
	document.all.que1.style.display = "inline";
	document.all.que2.style.display = "none";
	document.all.question2.value= "";
	document.insert.reqeustion.value = "";
	document.insert.email.value = "";
	document.insert.phone1.value = "";
	document.insert.phone2.value = "";
	document.insert.phone3.value = "";
	document.insert.randomCount.value = "";
	//document.insert.id.focus();

return;
}

function submitJoin3(){


	var nick = document.insert.nickName.value;
	if (!isValidNick(nick))
	{
		 document.insert.nickName.focus();
     	 document.insert.nickName.select(); 
		return;
	}

     if( document.insert.repwd.value == "" ) {
         alert("비밀번호 확인을 입력하세요.");
         document.insert.repwd.focus();
         return;
     }
     else {
         retVal = validPWD(document.insert.repwd.value);
         if( !retVal ) return;
     } 
     if( document.insert.pwd.value != document.insert.repwd.value ) {
         alert("비밀번호가 일치하지 않습니다.");
         document.insert.pwd.select();
         return;
     }


	if(document.insert.queChecker.checked){

		if( document.insert.question2.value == "" ) {
			 alert("비밀번호 재발급을 위한 질문을 직접 입력하세요.");
			 document.insert.question2.focus();
			 return;
		 }

	}else{

		if( document.insert.question1.options[document.insert.question1.selectedIndex].value == 0 ) {
			 alert("비밀번호 재발급을 위한 질문을 선택하세요.");
			 document.insert.question1.focus();
			 return;
		 }
	}


     if( document.insert.reqeustion.value == "" ) {
         alert("비밀번호 재발급을 위한 답을 입력하세요.");
         document.insert.reqeustion.focus();
         return;
     }


     if( document.insert.email.value == "" ) {
         alert("이메일 주소를 입력하세요.");
         document.insert.email.focus();
         return;
     }
     else {
         retVal = validEMAIL(document.insert.email.value);
         if( !retVal ) {
             document.insert.email.select();
             document.insert.email.focus();
             return;
         }
     }


     if( (document.insert.phone1.value).length > 0) {
         retVal = validRandom(document.insert.phone1.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone1.select();
             document.insert.phone1.focus();
             return;
         }
     }

     if( (document.insert.phone2.value).length > 0) {
         retVal = validRandom(document.insert.phone2.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone2.select();
             document.insert.phone2.focus();
             return;
         }
     }


     if( (document.insert.phone3.value).length > 0) {
         retVal = validRandom(document.insert.phone3.value);
         if( !retVal ) {
			 alert("정확한 전화번호를 입력하여 주십시오.");
             document.insert.phone3.select();
             document.insert.phone3.focus();
             return;
         }
     }

	var phoneSum = eval(document.insert.mobile1.value) + eval(document.insert.mobile2.value) + eval(document.insert.mobile3.value);

	if(phoneSum.length > 0){

		 if( document.insert.mobile2.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile2.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile2.value);
			if( !retVal ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile2.select();
			 document.insert.mobile2.focus();
			 return;
			}
		 }

		 if( document.insert.mobile1.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile1.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile1.value);
			if( !retVal ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile1.select();
			 document.insert.mobile1.focus();
			 return;
			}
		 }

		 if( document.insert.mobile3.value == "" ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile3.focus();
			 return;
		 }else{

			retVal = validRandom(document.insert.mobile3.value);
			if( !retVal ) {
			 alert("정확한 휴대전화 번호를 입력하여 주십시오.");
			 document.insert.mobile3.select();
			 document.insert.mobile3.focus();
			 return;
			}
		 }

		var str = document.insert.mobile1.value + document.insert.mobile2.value + document.insert.mobile3.value;
		if(document.insert.old.value == str) document.insert.mobileflag.value = 1;

		 if( document.insert.mobileflag.value != 1 ) {
			 alert("휴대전화 중복확인을 검사하여 주십시오.");
			 document.insert.mobile1.focus();
			 return;
		}

	}


     if( document.insert.randomCount.value == "" ) {
         alert("자동가입방지 코드를 입력하세요.");
         document.insert.randomCount.focus();
         return;
     }else {

         retVal = validRandom(document.insert.randomCount.value);
         if( !retVal ) {
			 alert("자동가입방지 코드는 영문 대문자와 숫자로 구성되어 있습니다.");
             document.insert.randomCount.select();
             document.insert.randomCount.focus();
             return;
         }
     }

      document.insert.action = "join_run3.jsp";
      document.insert.submit();

}

/***********************************************************************
 *  recieve Only number
 ***********************************************************************/
function checkNum2(name)
{
	if (window.event.keyCode == 8 || window.event.keyCode == 9 || window.event.keyCode == 13 ||window.event.keyCode == 37 || window.event.keyCode == 39 || window.event.keyCode == 46)
	{
		//just pass
	}
	else if ( ((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) || ((window.event.keyCode >= 96) && (window.event.keyCode <= 105)) )
	{
		//just pass
	}
	else
	{
		 window.event.returnValue = false;
	}
}

function setSelected(name, checkvalue)
{
	for(var selecti=0; selecti < name.length; selecti++)
	{
		if(name[selecti].value == checkvalue)
		{
			name[selecti].selected = true;
			break;
		}
	}
}