<!--
//
function chkForm(f)
{
	var i,currEl;
	for(i = 0; i < f.elements.length; i++)
	{
		currEl = f.elements[i];
		if (currEl.getAttribute("required") != null)
		{
			if(currEl.type.toUpperCase() == "TEXT" || currEl.tagName.toUpperCase() == "SELECT" || currEl.tagName.toUpperCase() == "TEXTAREA" ||currEl.type.toUpperCase() == "PASSWORD" ||currEl.type.toUpperCase() == "FILE" ||currEl.type.toUpperCase() == "HIDDEN")
			{
				if(!chkText(currEl,currEl.hname)) return false;
			}
			else if(currEl.type.toUpperCase() == "CHECKBOX")
			{
				if(!chkCheckbox(f, currEl,currEl.hname)) return false;
			}
			else if(currEl.type.toUpperCase() == "RADIO")
			{
				if(!chkRadio(f, currEl,currEl.hname)) return false;
			}
		}
		if(currEl.getAttribute("option") != null && currEl.value.length > 0)
		{
			if(!chkPatten(currEl,currEl.option,currEl.hname)) return false;
		}
		if(currEl.getAttribute("lengthchk") != null && currEl.value.length > 0)
		{
			if(!chkLength(currEl,currEl.lengthchk,currEl.hname)) return false;
		}
		if(currEl.getAttribute("lengthchk2") != null && currEl.value.length > 0)
		{
			if(!chkLength2(currEl,currEl.lengthchk2,currEl.hname)) return false;
		}
	}
	return true;
}

function chkPatten(field,patten,name)
{
	var regNum =/^[0-9]+$/;
	var regPhone =/^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/;
	var regPhone2 =/^[0-9]{2,3}[-]{0,1}[0-9]{3,4}[-]{0,1}[0-9]{4}$/;
	var regMobilePhone = /01[16789]-[0-9]{3,4}-[0-9]{4}/;
	var regMail =/^[_a-zA-Z0-9-]+@[._a-zA-Z0-9-]+\.[a-zA-Z]+$/;
	var regDomain =/^[.a-zA-Z가-힣0-9-]+.[a-zA-Z]+$/;
	var regAlpha =/^[a-zA-Z]+$/;
	var regHost =/^[a-zA-Z-]+$/;
	var regMailID =/^[_a-zA-Z0-9-]+$/;

	//-- 한글체크
	var regHangul =/[가-힣]/;

	//-- 한영체크
	var regHangulEng =/[가-힣a-zA-Z]/;

	//-- 한영숫자체크
	var regHanEngNum =/^[가-힣a-zA-Z0-9]+$/;

	//-- 한글체크
	var regHangulOnly =/^[가-힣]*$/;

	//-- 아이디체크   영문으로 시작 숫자결합 4자 ~ 16자(대,소문자,숫자)
	var regId = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_-]{3,15}$/;

	//-- 비밀번호체크 영문소문자와 숫자결합 4자 ~ 16자(소문자,숫자)
	var regPass = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_-]{3,15}$/;

	//-- 날짜체크 2003-06-12
	var regDate =/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
	var regAlphaNum =/[a-zA-Z0-9]/;
	patten = eval(patten);
	if(!patten.test(field.value))
	{
		alert(name + "\n\n항목의 형식이 올바르지 않습니다!");
		field.focus();
		return false;
	}
	return true;
}

function getLength(str)
{
	return (str.length + (escape(str) + "/%u").match(/%u/g).length-1);
}

function chkLength(field,length,name)
{
	if(getLength(field.value) > length)
	{
		alert(name + "\n\n영문,숫자 "+length+"자 , 한글 "+(length/2)+"자 이하로 입력을 제한합니다!"); 
		field.focus();
		return false;
	}
	return true;
}

function chkLength2(field,length,name)
{
	if(getLength(field.value) < length)
	{
		alert(name + "\n\n영문,숫자 "+length+"자 , 한글 "+(length/2)+"자 이상 입력해주세요!"); 
		field.focus();
		return false;
	}
	return true;
}

function chkText(field, name)
{
	if(field.value.length < 1)
	{
		alert(name);
		field.focus();
		return false;
	}
	return true;
}

function chkCheckbox(form, field, name)
{
	fieldname = eval(form.name+'.'+field.name);
	if (!fieldname.checked)
	{
		alert(name);
		field.focus();
		return false;
	}
	return true;
}

function chkRadio(form, field, name)
{
	fieldname = eval(form.name+'.'+field.name);
	for (i=0;i<fieldname.length;i++)
	{
		if (fieldname[i].checked) return true; 
	}
	alert(name);
	field.focus();
	return false;
}

function ViewImage(img,width,height)
{
	if(img) window.open("../Libs/ViewImage.php?img="+img,"ViewImageFrm","left=0,top=0,width="+width+",height="+height);
}

function WinOpen(url,id,param)
{
	window.open(url,id,param);
}

function encode_base64( what )
{
	var base64_encodetable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
	var result = "";
	var len = what.length;
	var x, y;
	var ptr = 0;

	while( len-- > 0 )
	{
		x = what.charCodeAt( ptr++ );
		result += base64_encodetable.charAt( ( x >> 2 ) & 63 );

		if( len-- <= 0 )
		{
			result += base64_encodetable.charAt( ( x << 4 ) & 63 );
			result += "==";
			break;
		}

		y = what.charCodeAt( ptr++ );
		result += base64_encodetable.charAt( ( ( x << 4 ) | ( ( y >> 4 ) & 15 ) ) & 63 );

		if ( len-- <= 0 )
		{
			result += base64_encodetable.charAt( ( y << 2 ) & 63 );
			result += "=";
			break;
		}

		x = what.charCodeAt( ptr++ );
		result += base64_encodetable.charAt( ( ( y << 2 ) | ( ( x >> 6 ) & 3 ) ) & 63 );
		result += base64_encodetable.charAt( x & 63 );
	}
	return result;
}

function ShowUserLayer(aEvent,NickName,BbsCode,UserID)
{
	var x = window.event ? window.event.clientX + document.documentElement.scrollLeft : aEvent.pageX;
	var y = window.event ? window.event.clientY + document.documentElement.scrollTop : aEvent.pageY;
	var NoteUrl = encode_base64('../common/NoteWrite.php?ReceiveID=' + UserID);
	var UserMenuText = "<table cellpadding='0' cellspacing='0' border='0'>";
	UserMenuText += "	<tr>";
	UserMenuText += "		<td>&nbsp;<img src='../images/icon2.gif' /><font onclick=\"location.href='./bbs.php?kids=list&BbsCode=" + BbsCode + "&s1=1&q=" + NickName + "'\" style='color:686666;cursor:pointer;size:11px;'>닉네임 검색<\/font><\/td>";
	UserMenuText += "	<\/tr>";
	UserMenuText += "<\/table>";
	if (UserID) document.getElementById('UserMenuText').innerHTML = UserMenuText;
	if (UserID) document.getElementById('UserLayer').style.top=y+"px";
	if (UserID) document.getElementById('UserLayer').style.left=x+"px";
	if (UserID) document.getElementById('UserLayer').style.display="block";
}
//-->