function check_form(forms){
	var i ;
	for(i = 0;i < forms.length;i++){
		//null check
		if (forms[i].mandatory == "1"){
			if ("undefined" != typeof (forms[i].mandatory) && forms[i].value == ""){
				if (forms[i].type == "text" || forms[i].type == "textarea" || forms[i].type == "password"){
					if (forms[i].msg == "Confirm new password") {
						alert("Please confirm new password");
					}
					else {
						alert("Please enter "+forms[i].msg);
					}
				}
				else if (forms[i].type == "select-one" || forms[i].type == "select-multiple"){
					alert("Please select "+forms[i].msg);
				}
				else if(forms[i].type == "file"){
					alert("Please select attached file at "+forms[i].msg);
				}
				forms[i].focus();
				return false;
			}
			else{
				if(forms[i].type == "file"){
					if(!isHangul(forms[i])){
						alert("You cannot use symbol and Korean file name at "+forms[i]);
					
						forms[i].focus();
						return false;
					}	
			 	}
			}
		}
		//file check(??? check ?? mandatory value ? "2"? ???.)
		if(forms[i].mandatory == "2"){
			if ("undefined" != typeof (forms[i].mandatory) && forms[i].value != ""){
				if(!isHangul(forms[i])){
					alert("You cannot use symbol and Korean file name at "+forms[i].msg);
					
					forms[i].focus();
					return false;
				}	
			}
		}
	}
	return true;
}


// ???? ?? ??
function isHangul(str){
	////////////////////////
	// ???? ? ?????? 
	////////////////////////
	var strTemp = str.value;
	////////////// ?? ?? /////////////////////////
	var rcp_test = strTemp.indexOf("(");
	var rcp_test1 = strTemp.indexOf(")");
    var rcp_test2 = strTemp.indexOf(" ");
   
	var rcp_value = false ; 

	if(rcp_test  > 0)
		rcp_value = true ; 
	if(rcp_test1  > 0)
		rcp_value = true ; 
	if(rcp_test2  > 0)
		rcp_value = true ; 
	//////////////////////////////////////////////////////////
	var idx = 0;
	while(idx !=-1){
//		alert("idx:"+idx);
		idx = strTemp.lastIndexOf("\\");
		if(idx > 0)
			strTemp = strTemp.substring(idx+1,strTemp.length);
//			alert("strTemp:"+strTemp);
	}
	var c;          
	for(i=0;i< strTemp.length;i++){               
		c=strTemp.charAt(i);
//		alert("c:"+c);
		if(((c<'!'||'~'<c))&&c!=' ')     return false;
	}
	/////////////////////????/////////////////////////
//	alert("rcp_value:"+rcp_value);
//	if (rcp_value){
//		return true;
//	} else {
//		return false;
//	}
	return true;
}

//????? ????.
function date_set(){
	var now   = new Date();
	var year  = now.getYear();
	var month = now.getMonth();
	month = parseInt(month)+1;
	var day   = now.getDate();
	var hour  = now.getHours()
	var min   = now.getMinutes();
	var sec   = now.getSeconds();

	if (year < 2000) year = year + 1900;
	if (month<=9) month="0"+month;
	if (day<=9) day="0"+day;
	if (hour<=9) hour="0"+hour;
	if (min<=9) min="0"+min;
	if (sec<=9) sec="0"+sec;
	document.nutri.dtm.value = year+"-"+month+"-"+day+" "+hour+":"+min+":"+sec;
}


//????? ????.(2??? int ??? ????.)
function date_set2(){
	var now   = new Date();
	var year  = now.getYear();
	var month = now.getMonth();
	month = parseInt(month)+1;
	var day   = now.getDate();
	var hour  = now.getHours()
	var min   = now.getMinutes();
	var sec   = now.getSeconds();

	if (year < 2000) year = year + 1900;
	if (month<=9) month="0"+month;
	if (day<=9) day="0"+day;
	if (hour<=9) hour="0"+hour;
	if (min<=9) min="0"+min;
	if (sec<=9) sec="0"+sec;
	document.nutri.dtm.value = year+"-"+month+"-"+day+" "+hour+":"+min+":"+sec;
	document.nutri.dtm2.value = year+"-"+month+"-"+day+" "+hour+":"+min+":"+sec;

}

function set_radio(obj, value)
{
	if ("object" == typeof(obj))
	{
		if (obj.length)
		{
			for(i = 0;i < obj.length;i++)
			{
				if (obj[i].value == value)
				{
					obj[i].checked = true;
					break;
				}	
			}
		}
		else
		{
			if (obj.value == value)
			{
				obj.checked = true;	
			}
		}
	}	
}

function set_select(obj, value)
{
	

	if (typeof(obj) == "object")
	{
		
		for(i = 0;i < obj.options.length;i++)
		{
			if (obj.options[i].value == value)
			{
				
				obj.options[i].selected = true;
				return true;
			}	
		}	
	}
	
	return false;
}

function check_radio_form(obj)
{
	var checkItem = 0;
	
	if (typeof(obj) != "object")
	{
		return false;	
	}
	
	if (obj)
	{
		
		if (obj.length)
		{
			for(i = 0; i < obj.length;i++)
			{
				if (obj[i].checked)	checkItem++;
			}
		} 
		else 
		{
			if (obj.checked)
			{
				checkItem++;
			}
		}

		if (checkItem == 0)
		{
			return false;
		} 
		else 
		{
			return true;
		}
	} 
	else 
	{
		return false;
	}
}

function get_radio_value(obj)
{
	var value;
	
	if (typeof(obj) != "object")
	{
		return "";	
	}
	
	if (obj)
	{
		if (obj.length)
		{
			for(i = 0; i < obj.length;i++)
			{
				if (obj[i].checked) 
				{
					value = obj[i].value;
					return value;	
				}
			}
		} 
		else 
		{
			if (obj.checked)
			{
				value = obj.value;
			}
		}
	} 
	return value;
}

function check_all_true(obj)
{
	check_all (obj, true);
}

function check_all_false(obj)
{
	check_all (obj, false);
}

function check_all(obj, bool)
{
	if (typeof(obj) != "object")
	{
		return;
	}

	if (obj.length)
	{	
		for (i = 0;i < obj.length;i++) 
		{
				obj[i].checked = bool;
		}
	}
	else
	{
		obj.checked = bool;	
	}
}

function select_all(obj, bool)
{
	if (typeof(obj) != "object")
	{
		return;
	}

	if (obj.length)
	{	
		for (i = 0;i < obj.length;i++) 
		{
				obj[i].selected = bool;
		}
	}
	else
	{
		obj.selected = bool;	
	}
}

function check_with_all(obj, forms, tobj)
{
	var cast_obj = null;
	var result = false;
	
	if (typeof(obj) != "object")
	{
		return false;
	}

	if (obj.length)
	{	
		for (i = 0;i < obj.length;i++) 
		{
			if (obj[i].checked == true)
			{
				cast_obj = eval("forms."+tobj+obj[i].value);
				if (cast_obj.value == "")
				{
					alert("Please enter "+cast_obj.id);
					cast_obj.focus();
					return false;
				}
				result = true;
			}
		}
	}
	else
	{
		if (obj.checked == true)
		{
			cast_obj = eval("forms."+tobj+obj.value);
			if (cast_obj.value == "")
			{
				alert("Please enter "+cast_obj.id);
				cast_obj.focus();
				return false;
			}
			result = true;
		}
	}
	
	return result;
}

function check_with_all_int(obj, forms, tobj)
{
	var cast_obj = null;
	var result = 0;
	
	if (typeof(obj) != "object")
	{
		return result;
	}

	if (obj.length)
	{	
		for (i = 0;i < obj.length;i++) 
		{
			if (obj[i].checked == true)
			{
				cast_obj = eval("forms."+tobj+obj[i].value);
				if (cast_obj.value == "")
				{
					alert("Please enter "+cast_obj.id);
					cast_obj.focus();
					return 0;
				}
				result++;
			}
		}
	}
	else
	{
		if (obj.checked == true)
		{
			cast_obj = eval("forms."+tobj+obj.value);
			if (cast_obj.value == "")
			{
				alert("Please enter "+cast_obj.id);
				cast_obj.focus();
				return 0;
			}
			result++;
		}
	}
	
	return result;
}

function showMsg(obj, message)
{
	if (typeof(obj) == "object")
	{
		alert(message);
		obj.focus();
	}
	return false;
}

var ImgFileFormat = new Array(".gif", ".jpg");
var MovFileFormat = new Array(".avi", ".mpeg", ".wmv", ".rm", ".mov", ".asf");

function check_img_file_format(file) 
{
	if (!file) return;
	
	while (file.indexOf("\\") != -1)
	{
		file = file.slice(file.indexOf("\\") + 1);
		ext  = file.slice(file.indexOf(".")).toLowerCase();
		for (var i = 0; i < ImgFileFormat.length; i++) 
		{
			if (ImgFileFormat[i] == ext) 
			{
				return true;
			}
		}
	}
	
	return false;
}

function check_mov_file_format(file) 
{
	if (!file) return;
	
	while (file.indexOf("\\") != -1)
	{
		file = file.slice(file.indexOf("\\") + 1);
		ext  = file.slice(file.indexOf(".")).toLowerCase();
		for (var i = 0; i < MovFileFormat.length; i++) 
		{
			if (MovFileFormat[i] == ext) 
			{
				return true;
			}
		}
	}
	
	return false;
}

function getCookie(varname) {
	varname += "=";
	startpos = document.cookie.indexOf(varname);
	if (startpos >= 0) {
		startpos += varname.length;
		endpos = document.cookie.indexOf(";", startpos);
		if (endpos == -1) endpos = document.cookie.length;
		return unescape(document.cookie.substring(startpos, endpos));
	}
}

function setCookie( value ) 
{ 
	document.cookie = "hide=" + escape( value ) + "; path=/; domain=; " ;
}

function CalendarWin(fld, len) {
	var CalendarW = window.showModalDialog("/super/include/calendar.html",0,"dialogHeight=270px;dialogWidth=366px;resizable:no;center:yes;help:no;status:no;scroll:no");
	if (typeof(CalendarW) != "undefined")
	{
		if (len == 8)
		{
			fld.value = CalendarW.substring(0, 8);
		}
		else
		{
			fld.value = CalendarW;
		}
	}
}

function write_up(width, bgcolor)
{
var round_up = "<table cellpadding=0 cellspacing=0 border=0 width='"+width+"' align=center>" +
				"<tr height=1>" +
				"    <td rowspan=4 width=1></td>" +
				"    <td rowspan=3 width=1></td>" +
				"    <td rowspan=2 width=1></td>" +
				"    <td width=2></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td width=2></td>" +
				"    <td rowspan=2 width=1></td>" +
				"    <td rowspan=3 width=1></td>" +
				"    <td rowspan=4 width=1></td>" +
				"</tr>" +
				"<tr height=1>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td bgcolor=#FFFFFF></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"</tr>" +
				"<tr height=1>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td colspan=3 bgcolor=#FFFFFF></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"</tr>" +
				"<tr height=2>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td colspan=5 bgcolor=#FFFFFF></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"</tr>" +
				"</table>";
	return round_up;
}

function write_down(width, bgcolor)
{
var round_down ="<table cellpadding=0 cellspacing=0 border=0 width='"+width+"' align=center>" +
				"<tr height=2>" +
				"    <td rowspan=4 width=1></td>" +
				"    <td width=1 bgcolor="+bgcolor+"></td>" +
				"    <td width=1 bgcolor=#FFFFFF></td>" +
				"    <td width=2 bgcolor=#FFFFFF></td>" +
				"    <td bgcolor=#FFFFFF></td>" +
				"    <td width=2 bgcolor=#FFFFFF></td>" +
				"    <td width=1 bgcolor=#FFFFFF></td>" +
				"    <td width=1 bgcolor="+bgcolor+"></td>" +
				"    <td rowspan=4 width=1></td>" +
				"</tr>" +
				"<tr height=1>" +
				"    <td rowspan=3></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td colspan=3 bgcolor=#FFFFFF></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td rowspan=3></td>" +
				"</tr>" +
				"<tr height=1>" +
				"    <td rowspan=2></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td bgcolor=#FFFFFF></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td rowspan=2></td>" +
				"</tr>" +
				"<tr height=1>" +
				"    <td></td>" +
				"    <td bgcolor="+bgcolor+"></td>" +
				"    <td></td>" +
				"</tr>" +
				"</table>";
	return round_down;
}

function commaSplit(srcNumber) {
	var txtNumber = '' + srcNumber;
	if (isNaN(txtNumber) || txtNumber == "") {
		alert("Please enter only number.");
		fieldName.select();
		fieldName.focus();
	} else {
		var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var arrNumber = txtNumber.split('.');
		arrNumber[0] += '.';
		do {
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
		} while (rxSplit.test(arrNumber[0]));
		
		if (arrNumber.length > 1) {
			return arrNumber.join('');
		} else {
			return arrNumber[0].split('.')[0];
		}
	}
}


	function toggle(frm){
		if(frm == null) return;

		if(frm.length == null) {
			if(frm.checked)frm.checked = false;
			else frm.checked = true;
		}
		if(frm[0].checked == true){
			for (i = 0; i < frm.length; i++) {
				frm[i].checked = false;
			}					
		}else{
			for (i = 0; i < frm.length; i++) {
				frm[i].checked = true;
			}					
		}
		return ;
	}


	function checkBoxToggle(formNames, fieldNames)
	{
		var check = false;

		var fields = eval('document.' + formNames + '.' + fieldNames);

		if(fields)
		{
			if(fields.length)
			{
				for(i=0; i<fields.length; i++)
				{
					if(fields[i].checked == false)
					{
						check = true;
						break;
					}
				}

				for(i=0; i<fields.length; i++)
				{
					if(fields[i].disabled == false)
						fields[i].checked = check;
				}
			}
			else
			{
				if(fields.checked == false)
					check = true;

				if(fields.disabled == false)
					fields.checked = check;
			}
		}
	}

//?????? : onKeypress="javascript:goNumCheck()"
	function goNumCheck(){
		if (event.keyCode < 45 || event.keyCode > 57) {
			alert("Please enter only number.");
			event.returnValue = false;
		}
	}

