
	var cur_id="";
	function changeCategory(id_name)
	{
		if(cur_id!="")
		{
			document.getElementById(cur_id).style.display="";
			document.getElementById(cur_id+"_s").style.display="none";
			document.getElementById("sub_"+cur_id).className="submenu";
		}
		cur_id = id_name;
		document.getElementById(cur_id).style.display="none";
		document.getElementById(cur_id+"_s").style.display="";
		document.getElementById("sub_"+cur_id).className="submenu_s";
	}

	function swapImage(id_name, option)
	{
		if(id_name == cur_id)
			return;
		if(option == "on")
		{
			document.getElementById(id_name).style.display="none";
			document.getElementById(id_name+"_s").style.display="";
			document.getElementById("sub_"+id_name).className="submenu_s";
		}
		else
		{
			document.getElementById(id_name).style.display="";
			document.getElementById(id_name+"_s").style.display="none";
			document.getElementById("sub_"+id_name).className="submenu";
		}
	}

	function byteCheck(code){
	 var code_byte = 0;
		for (var inx = 0; inx < code.value.length; inx++) {
			var oneChar = escape(code.value.charAt(inx));
			if ( oneChar.length == 1 ) {
				code_byte ++;
			} else if (oneChar.indexOf("%u") != -1) {
				code_byte += 2;
			} else if (oneChar.indexOf("%") != -1) {
				code_byte += oneChar.length/3;
			}
		}
		return code_byte;
	}
	function isValid(input_idx, check)
	{//정규표현식 .test
		if(input_idx == "user_id")
		{
			var variable=document.general.user_id;
			document.general.param.value = "user_id";
			ch = variable.value.charAt(0);
			if(variable.value.length <3 || variable.value.length >20)
			{		
				document.getElementById("user_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">ID는 3~20자 사이만 입력 가능합니다.</font>";

				return false;
			}
			else
			{
				if(ch>=0 && ch<=9)
				{
					document.getElementById("user_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">ID의 첫글자는 영문자여야 합니다.</font>";
					return false;
				}
				for(i = 0; i<variable.value.length; i++)
				{
					ch = variable.value.charAt(i);
					if( (ch<'0' || ch >'9') && (ch <'a' || ch >'z') && (ch<'A' || ch>'Z') )
					{
						document.getElementById("user_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">ID는 숫자,영어 대소문자만 입력 가능합니다.</font>";
						return false;
					}
				}
			}	
		}
		else if(input_idx == "pw")
		{
			var variable=document.general.pw;
			document.general.param.value = "pw";
			if(variable.value.length <6 || variable.value.length >20)
			{
				document.getElementById("pw_td").innerHTML = "&nbsp;<font color=\"#c83c16\">비밀번호는 6~20자 사이만 입력 가능합니다.</font>";
				return false;
			}
		}
		else if(input_idx == "check_pw")
		{
			var variable=document.general.check_pw;
			document.general.param.value = "check_pw";
			if(variable.value.length <6 || variable.value.length >20)
			{
				document.getElementById("check_pw_td").innerHTML = "&nbsp;<font color=\"#c83c16\">비밀번호는 6~20자 사이만 입력 가능합니다.</font>";
				return false;
			}
		}
		else if(input_idx == "mail_id")
		{
			reg_mail_id = new RegExp("^[\\w\\-][\\w+\\-\\.]*[\\w\\-]$");
			
			var mail_id = document.general.mail_id;
			
			if(!reg_mail_id.test(mail_id.value))
			{
				document.getElementById("mail_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">E-mail ID가 잘못 되었습니다.</font>";
				return false;
			}
			else
				document.getElementById("mail_id_td").innerHTML = "";
			document.general.param.value = "mail_id";
		}
		else if(input_idx == "mail_domain")
		{
			reg_mail_domain = new RegExp("^[a-zA-Z0-9][\\w\\-]*(\\.[\\w\\-]+)*(\\.[a-zA-Z]{2,3})$");
			var mail_domain = document.general.mail_domain;

			if(!reg_mail_domain.test(mail_domain.value))
			{
				document.getElementById("mail_domain_td").innerHTML = "&nbsp;<font color=\"#c83c16\">E-mail domain이 잘못 되었습니다.</font>";
				return false;
			}
			else
				document.getElementById("mail_domain_td").innerHTML = "";
			
			return true;	//mail domain의 경우 따로 디비검색 할 필요 없으므로 이곳에서 종료
		}
		else if(input_idx == "nick_id")
		{
			var variable=document.general.nick_id;
			document.general.param.value = "nick_id";
			num = byteCheck(variable);
			if(num <4 || num >20)
			{
				document.getElementById("nick_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">닉네임은 한글로 2~10자 영어로 4~20자 사이만 입력 가능합니다.</font>";
				return false;
			}
			for(i = 0; i<variable.value.length; i++)
			{
				
				if( variable.value.charAt(i) ==' ' ||  variable.value.charCodeAt(i) == 12288)
				{
					document.getElementById("nick_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">공백은 허용이 안됩니다.</font>";
					return false;
				}
			}
		}
		else if(input_idx == "cur_pw")
		{
			var variable=document.general.cur_pw;
			document.general.param.value = "cur_pw";
			if(variable.value.length <6 || variable.value.length >20)
			{
				document.getElementById("cur_pw_td").innerHTML = "&nbsp;<font color=\"#c83c16\">비밀번호는 6~20자 사이만 입력 가능합니다.</font>";
				return false;
			}
		}
		else
		{
			alert("잘못된 경로로 접속 하셨습니다");
			return false;
		}
		if( check !=0)
			return true;
		var f= document.general;
		f.action="isValid_tr.php";
		f.submit();		
		//action에 tr할 주소 달기
		//submit 하기
	}

	function isValidFroModify(input_idx, check)
	{//정규표현식 .test
		if(input_idx == "pw")
		{
			var variable=document.general.pw;
			document.general.param.value = "pw";
			if(variable.value.length <6 || variable.value.length >20)
			{
				document.getElementById("pw_td").innerHTML = "&nbsp;<font color=\"#c83c16\">비밀번호는 6~20자 사이만 입력 가능합니다.</font>";
				return false;
			}
		}
		else if(input_idx == "check_pw")
		{
			var variable=document.general.check_pw;
			document.general.param.value = "check_pw";
			if(variable.value.length <6 || variable.value.length >20)
			{
				document.getElementById("check_pw_td").innerHTML = "&nbsp;<font color=\"#c83c16\">비밀번호는 6~20자 사이만 입력 가능합니다.</font>";
				return false;
			}
		}
		else if(input_idx == "mail_id")
		{
			reg_mail_id = new RegExp("^[\\w\\-][\\w+\\-\\.]*[\\w\\-]$");
			
			var mail_id = document.general.mail_id;
			
			if(!reg_mail_id.test(mail_id.value))
			{
				document.getElementById("mail_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">E-mail ID가 잘못 되었습니다.</font>";
				return false;
			}
			else
				document.getElementById("mail_id_td").innerHTML = "";
			document.general.param.value = "mail_id";
		}
		else if(input_idx == "mail_domain")
		{
			reg_mail_domain = new RegExp("^[a-zA-Z0-9][\\w\\-]*(\\.[\\w\\-]+)*(\\.[a-zA-Z]{2,3})$");
			var mail_domain = document.general.mail_domain;

			if(!reg_mail_domain.test(mail_domain.value))
			{
				document.getElementById("mail_domain_td").innerHTML = "&nbsp;<font color=\"#c83c16\">E-mail domain이 잘못 되었습니다.</font>";
				return false;
			}
			else
				document.getElementById("mail_domain_td").innerHTML = "";
			
			return true;	//mail domain의 경우 따로 디비검색 할 필요 없으므로 이곳에서 종료
		}
		else if(input_idx == "nick_id")
		{
			var variable=document.general.nick_id;
			document.general.param.value = "nick_id";
			num = byteCheck(variable);
			if(num <4 || num >20)
			{
				document.getElementById("nick_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">닉네임은 한글로 2~10자 영어로 4~20자 사이만 입력 가능합니다.</font>";
				return false;
			}
			for(i = 0; i<variable.value.length; i++)
			{
				
				if( variable.value.charAt(i) ==' ' ||  variable.value.charCodeAt(i) == 12288)
				{
					document.getElementById("nick_id_td").innerHTML = "&nbsp;<font color=\"#c83c16\">공백은 허용이 안됩니다.</font>";
					return false;
				}
			}
		}
		else
		{
			alert("잘못된 경로로 접속 하셨습니다");
			return false;
		}
		if( check !=0)
			return true;
		var f= document.general;
		f.type.value="modify";
		f.action="isValid_tr.php";
		f.submit();		
		//action에 tr할 주소 달기
		//submit 하기
	}

	function join_func()
	{
		if(isValid("user_id", 1) == false)
		{
			alert("아이디를 다시 입력해주세요");
			document.general.user_id.focus();
		}
		else if(isValid("pw", 1) == false)
		{
			alert("비밀번호를 다시 입력해주세요");
			document.general.pw.focus();
		}
		else if(isValid("check_pw", 1) == false)
		{
			alert("비밀번호 확인을 다시 입력해주세요");
			document.general.check_pw.focus();
		}
		else if(isValid("mail_id", 1) == false)
		{
			alert("이메일 아이디를 다시 입력해주세요");
			document.general.mail_id.focus();
		}
		else if(isValid("mail_domain", 1) == false)
		{
			alert("이메일 도메인을 다시 입력해주세요");
			document.general.mail_domain.focus();
		}
		else if(isValid("nick_id", 1) == false)
		{
			alert("닉네임을 다시 입력해주세요");
			document.general.nick_id.focus();
		}
		else if(document.general.service_agree.checked != true)
		{
			alert("서비스 이용약관에 동의하지 않으시면 회원 가입이 불가능합니다");
			document.general.service_agree.focus();
		}
		else if( document.general.private_info_agree.checked != true)
		{
			alert("개인정보 수집 및 이용안내에 동의하지 않으시면 회원 가입이 불가능합니다");
			document.general.private_info_agree.focus();
		}
		else // 모든 가입 양식에 문법적으로 이상이 없으면
		{
			var f=document.general;
			f.action = "join_tr.php";
			f.param.value="join";
			f.submit();
		}
	}

	function modify_func()
	{
		accept = true;
		if(document.getElementById("npw_name").innerHTML !="")
		{
			if(isValidFroModify("pw", 1) == false)
			{
				alert("새 비밀번호를 다시 입력해주세요");
				document.general.pw.focus();
				accept = false;
			}
			else if(isValidFroModify("check_pw", 1) == false)
			{
				alert("비밀번호 확인을 다시 입력해주세요");
				document.general.check_pw.focus();
				accept = false;
			}
		}
		else if(isValidFroModify("mail_id", 1) == false)
		{
			alert("이메일 아이디를 다시 입력해주세요");
			document.general.mail_id.focus();
			accept = false;
		}
		else if(isValidFroModify("mail_domain", 1) == false)
		{
			alert("이메일 도메인을 다시 입력해주세요");
			document.general.mail_domain.focus();
			accept = false;
		}
		else if(isValidFroModify("nick_id", 1) == false)
		{
			alert("닉네임을 다시 입력해주세요");
			document.general.nick_id.focus();
			accept = false;
		}
		if(accept == true) // 모든 가입 양식에 문법적으로 이상이 없으면
		{
			var f=document.general;
			f.action = "modify_tr.php";
			if(document.getElementById("npw_name").innerHTML =="")
				f.param.value="modify";
			else
				f.param.value="modifypw";
			f.submit();
		}
	}

	function showNewPW()
	{
		tdId = document.getElementById("npw_name");
		if(document.getElementById("npw_name_root").style.display=="none")
		{
			document.getElementById("npw_name_root").style.display="";
			document.getElementById("check_npw_name_root").style.display="";
			tdId.style["color"]="#525151";
			tdId.style["padding"]="20 0 20 10";
			tdId.style["borderBottom"]="1 solid #dadada";
			tdId.innerHTML = "<b>새 비밀번호</b>";
			tdId = document.getElementById("npw_attribute");
			tdId.style["borderBottom"]="1 solid #dadada";
			tdId.style["padding"]="0 0 0 7";
			tdId.innerHTML = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><input type="password" size="20" maxlength="20" name="pw" id="pw" onblur="javascript:isValidFroModify(\'pw\', 0);"></td><td id="pw_td"></td></tr><tr><td colspan="2">·비밀번호는 6~20자 사이로 이루어져야 합니다.</td></tr></table>';
			tdId = document.getElementById("check_npw_name");
			tdId.style["color"]="#525151";
			tdId.style["padding"]="20 0 20 10";
			tdId.style["borderBottom"]="1 solid #dadada";
			tdId.innerHTML = "<b>새 비밀번호 확인</b>";
			tdId = document.getElementById("check_npw_attribute");
			tdId.style["borderBottom"]="1 solid #dadada";
			tdId.style["padding"]="0 0 0 7";
			tdId.innerHTML = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><input type="password" size="20" maxlength="20" name="check_pw" id="check_pw" onblur="javascript:isValidFroModify(\'check_pw\', 0);"></td><td id="check_pw_td"></td></tr><tr><td colspan="2">·비밀번호를 한번 더 입력하십시오.</td></tr></table>';
		}
		else
		{
			document.getElementById("npw_name_root").style.display="none";
			document.getElementById("check_npw_name_root").style.display="none";
			tdId.style["color"]="";
			tdId.style["padding"]="";
			tdId.style["borderBottom"]="";
			tdId.innerHTML = "";
			tdId = document.getElementById("npw_attribute");
			tdId.style["borderBottom"]="";
			tdId.style["padding"]="";
			tdId.innerHTML = "";
			tdId = document.getElementById("check_npw_name");
			tdId.style["color"]="";
			tdId.style["padding"]="";
			tdId.style["borderBottom"]="";
			tdId.innerHTML = "";
			tdId = document.getElementById("check_npw_attribute");
			tdId.style["borderBottom"]="";
			tdId.style["padding"]="";
			tdId.innerHTML = "";
		}
	}