var browser_type;

if(navigator.userAgent.indexOf('MSIE') == -1) browser_type = 'NS';
else browser_type = 'IE';

function MM_preloadImages() { //v3.0
  var d=document; if (d.images){ if (!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if (!d) d=document; if ((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if (!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if (!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if (!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu_window(targ,selObj,restore){ //v3.0
	if (selObj.value == '') return;
	window.open(selObj.options[selObj.selectedIndex].value, 'window_quick', 'top=0,left=0,width=900,height=700,resizable=yes,scrollbars=yes,menubar=yes');
	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	if (selObj.value == '') return;
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_showHideBoards() { //v6.0
  var i,p,v,obj,args=MM_showHideBoards.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='block')?'block':(v=='none')?'none':v; }
    obj.display=v; }
}

function show_layer(lname, flag) {
	layer = (navigator.appName == 'Netscape') ? document.layers[lname] : document.all[lname];
	if (typeof(layer) == 'undefined' || lname == '') return;
	if (navigator.appName == 'Netscape') layer.visibility = (flag == 0) ? 'show' : 'hide';
	else layer.style.visibility = (flag == 0) ? 'visible' : 'hidden';
}

// screenX ´Â ¸ð´ÏÅÍÈ­¸é ¿ÞÂÊ»ó´Ü ±âÁØ ¸¶¿ì½º X ÁÂÇ¥, clientX(NS:pageX) ´Â ÇöÀç Ã¢ ±âÁØ ¿ÞÂÊ »ó´Ü ±âÁØ X ÁÂÇ¥°ª
function open_window_mouse(ref, x_control, y_control, width, height, name) {
	x_owm = (event.pageX) ? event.pageX : event.screenX;
	y_owm = (event.pageY) ? event.pageY : event.screenY;
	if (typeof(x_control) == "number") x_owm = x_owm + x_control;
	if (typeof(y_control) == "number") y_owm = y_owm + y_control;
	if (name == '') name = 'OWM';
	window.open(ref,name,'width=' + width + ',height=' + height + ',status=no,resizable=yes,scrollbars=yes,top=' + y_owm + ',left=' + x_owm + '').focus();
}

function open_window(ref, left, top, width, height, name) {
	if (name == '') name = 'OW';
	window.open(ref,name,'width=' + width + ',height=' + height + ',status=no,resizable=yes,scrollbars=yes,top=' + top + ',left=' + left + '').focus();
}

//name : °´Ã¼ÀÌ¸§, len: ÃÖ´ë±æÀÌ, gb: ÀÔ·Â¿©ºÎÃ¼Å©
function chkTxarea(obj, len, gb, obj_print_len_box) {
	j = k = 0;
	tempStr = tempStr2 = '';
	//obj.value = trim(obj.value);
	for(i = 0; i < obj.value.length; i++  )	{
		tempStr = obj.value.charCodeAt(i);
		tempStr2 = tempStr.toString();
		if (tempStr2.length >= 5) j++;		//ÇÑ±Û
		else k++;												//¿µ¹®
	}
	ln = k+(j*2);
	if (gb == "D" && ln == 0) {
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		obj.focus();
		obj.select();
		return false;
	}
	if (obj_print_len_box != '') obj_print_len_box.value = ln;
	if (ln > len) {
		alert(len+"Byte ÀÌ³»·Î ÀÔ·ÂÇÏ¼¼¿ä. (ÇöÀç "+ ln +" Byte)");
		obj.focus();
		return false;
	} else {
		if (obj_print_len_box != '') obj_print_len_box.value = ln;
		return true;
	}
}

function coloring_box(obj, color) {
	if (color == '') color = "#EDFBFF;";
	obj.style.background = color;
}

function focus_msg(obj, msg, color) {
	if (msg != '') alert(msg);
	if (color != '') coloring_box(obj, color);
	obj.focus();
}

function ck_number(obj) {
	x = no_comma(obj.value);
	if (isNaN(x)) {
		alert("¼ýÀÚ¸¸ ÀÔ·Â ÇÏ¼¼¿ä.");
		obj.value = obj.defaultValue;
		obj.focus();
	} else {
		obj.value = number_format(x);
	}
}

function ck_number_1(obj) {
	x = obj.value;
	if (isNaN(x)) {
		alert("¼ýÀÚ¸¸ ÀÔ·Â ÇÏ¼¼¿ä.");
		obj.value = obj.defaultValue;
		obj.focus();
	}
}

// , ¸¦ ¾ø¾Ø´Ù.
function no_comma(data) {
	var tmp = '';
	var comma = ',';
	var i;
	for (i=0; i<data.length; i++) {
		if (data.charAt(i) != comma) tmp += data.charAt(i);
	}
	return tmp;
}

function number_format(data) {
	data = new String(data);
	var tmp = '';
	var number = '';
	var cutlen = 3;
	var comma = ',';
	var i;
	len = data.length;
	mod = (len % cutlen);
	k = cutlen - mod;
	for (i=0; i<data.length; i++) {
		number = number + data.charAt(i);
		if (i < data.length - 1) {
			k++;
			if ((k % cutlen) == 0) {
				number = number + comma;
				k = 0;
			}
		}
	}
	return number;
}

function check_number(value, min, max) {
	reg_express = new RegExp('^[0-9]{' + min + ',' + max + '}$');
	if (!reg_express.test(value)) return false;
}

function check_digit(checkval) {
	val = new String(checkval);
	len = val.length;
	for (idx=0; idx<len; idx++) {
		if (val.charAt(idx) != '0' && val.charAt(idx) != '1' && val.charAt(idx) != '2' && val.charAt(idx) != '3' && val.charAt(idx) != '4' && val.charAt(idx) != '5' && val.charAt(idx) != '6' && val.charAt(idx) != '7' && val.charAt(idx) != '8' && val.charAt(idx) != '9' )  return false;
	}
	return true;
}

function social_no_chk(socialno) {
	if ( socialno.length != 13 ) return false;
	lastid	= parseFloat(socialno.substring(12,13));
	value0 	= parseFloat(socialno.substring(0,1))	* 2;
	value1 	= parseFloat(socialno.substring(1,2))	* 3;
	value2 	= parseFloat(socialno.substring(2,3))	* 4;
	value3 	= parseFloat(socialno.substring(3,4))	* 5;
	value4 	= parseFloat(socialno.substring(4,5))	* 6;
	value5 	= parseFloat(socialno.substring(5,6))	* 7;
	value6 	= parseFloat(socialno.substring(6,7))	* 8;
	value7 	= parseFloat(socialno.substring(7,8))	* 9;
	value8 	= parseFloat(socialno.substring(8,9))	* 2;
	value9 	= parseFloat(socialno.substring(9,10))  * 3;
	value10	= parseFloat(socialno.substring(10,11)) * 4;
	value11	= parseFloat(socialno.substring(11,12)) * 5;
	value12 = 0;
	value12 = value0+value1+value2+value3+value4+value5+value6+value7+value8+value9+value10+value11+value12;
	li_mod = value12 % 11;
	li_minus = 11 - li_mod;
	li_last = li_minus % 10;
	if (li_last != lastid) return false;
 	return true;
}

function multi_select(form, new_name, name, divider) {
	multi_value = divider;
	T_name = eval("form." + name);
	T_new_name = eval("form." + new_name);
	select_flag = 0;						
	for (var i=0; i<T_new_name.length; i++) {
		if (T_new_name.options[i].selected && T_new_name.options[i].value != '') {
			multi_value += T_new_name.options[i].value + divider;
			select_flag = 1;
		}
	}
	if (select_flag == 1) T_name.value = multi_value;
	else T_name.value = '';
}
function multi_check(form, new_name, name, divider) {
	multi_value = divider;
	frm_els = form.elements;
	cnt = frm_els.length ;
	nm_cnt = new_name.length;
	select_flag = 0;
	for (i=0; i<cnt; i++) {
		if (frm_els[i].type == 'checkbox' && frm_els[i].name.substring(0, nm_cnt) == new_name) {
			if (frm_els[i].disabled != true && frm_els[i].checked && frm_els[i].value != '') multi_value += frm_els[i].value + divider;
			else continue;
			select_flag = 1;
		}
	}
	T_name = eval("form." + name);
	if (select_flag == 1) T_name.value = multi_value;
	else T_name.value = '';
}

function submit_radio_check(form, name) {
	frm_els = document.getElementsByName(name);
	cnt = frm_els.length ;
	select_flag = 0;
	for (i_radio_check=0; i_radio_check<cnt; i_radio_check++) {
		if (frm_els[i_radio_check].checked) select_flag = 1;
	}
	return select_flag;
}

// Æû³»ºÎ °´Ã¼Áß Á¦¿ÜÇÑ °Íµé¸¸ »©°í ¸ðµÎ ºñÈ°¼º ½ÃÅ´ (GET ¹æ½ÄÀÇ °Ë»ö¿¡¼­ °Ë»ö¿¡ È°¿ëµÉ ÀÔ·Â»óÀÚ¸¸ À¯ÁöÇÒ¶§ È°¿ëµÊ)
function disabled_except_obj(form, except_head, excepts) {
	frm_els = form.elements;
	cnt = frm_els.length;
	cnt_except_head = except_head.length;
	for (i=0; i<cnt; i++) {
		flag = 'Y';
		for (j=0; j<excepts.length; j++) {																					// Á¦¿Ü¸ñ·Ï Ã³¸®
			if (frm_els[i].name == excepts[j]) {
				flag = 'N';
				break;
			}
		}
		if (frm_els[i].name.substring(0, cnt_except_head) == except_head) {		// Á¦¿Ü Çì´õÃ³¸®
			flag = 'N';
			continue;
		}
		if (flag == 'Y') frm_els[i].disabled = true;
	}
}

// ´Ù¼öÀÇ Ã¼Å©»óÀÚ°¡ Ã¼Å©µÇ¾ú´ÂÁö ¿©ºÎ (°³¼ö¸®ÅÏ)
function submit_multi_checkbox(checkbox_name) {
	obj_checkbox = document.getElementsByName(checkbox_name);
	cnt = obj_checkbox.length;
	flag = 0;
	for (i=0; i<cnt; i++) {
		if (obj_checkbox[i].checked) flag++;
	}
	return flag;
}

function get_radio_value(obj) {
	if (typeof(obj) == 'undefined') return;
	cnt = obj.length;
	if (cnt > 1) {
		for (i=0; i<cnt; ++i) {
			if (obj[i].checked) return obj[i].value;
		}
	} else {
		if (obj.checked) return obj.value;
	}
}

function callColorPicker(tmpx, tmpy, d, e, str_btn, str_input) {
	var x = (e.screenX) ? e.screenX : document.body.scrollLeft+event.clientX;
	var y = (e.screenY) ? e.screenY : document.body.scrollTop+event.clientY;
	x = x + tmpx;
	y = y + tmpy;
	showColorPicker(x, y, d, str_btn, str_input);
	return;
}

function showColorPicker(x, y, d, str_btn, str_input) {
	var Selcol = showModalDialog('/designer/include/js/palbas.nwz','','font-family:Verdana; font-size:12; dialogWidth:202px; dialogHeight:190px; dialogLeft:' + x + 'px; dialogTop:' + y + 'px; status:no; help:no; scroll:no'); 
	if (Selcol != '') {
		var valid_color = /[0-9a-fA-F]{6}/;
		if (! valid_color.test (Selcol)) return;
		if (d == 1) {
			//c1 = Selcol;
			btn = eval(str_btn);
			input_box = eval(str_input);
			btn.style.backgroundColor = Selcol;
			input_box.style.backgroundColor = Selcol;
			input_box.value = Selcol; 
		}
	}
	return;
}

// ÁöÁ¤ÇÑ id °ªÀÌ ¼³Á¤µÈ ¿¤¸®¸ÕÆ®¸¦ º¸ÀÌ°Ô ¶Ç´Â º¸ÀÌÁö ¾Ê°Ô ÇÏ´Â ÇÔ¼ö
// È°¿ë : enable_child_id('FIRSTTABLE', document.getElementsByTagName('table'), '')
function enable_child_id(parent_id, layer_child, excepts, reverse) {
	if (typeof(excepts) == "undefined") excepts = '';											// Á¦¿Ü¸ñ·ÏÀÌ ¾øÀ¸¸é ³Î.
	if (typeof(parent_id) != "undefined") enables = parent_id.split('_');	// ¼±ÅÃµÈ ÀÔ·Â»óÀÚÀÇ id °ªÀ¸·Î º¸¿©ÁÙ ·¹ÀÌ¾î µéÀ» ¹è¿­·Î ÀúÀå
	else enables = '';
	for (i=0; i<layer_child.length; i++) {																		// ³Ñ¾î¿Â ·¹ÀÌ¾î °³¼ö¸¸Å­ ¹Ýº¹
		if (layer_child[i].id == '') continue;																		// ¾ÆÀÌµð°¡ ¾øÀ¸¸é °Ç³Ê¶Ü.
		T_flag_excepts = 'N';
		for (k=0; k<excepts.length; k++) {																	// Á¦¿Ü¸ñ·Ï Ã³¸®
			if (layer_child[i].id == excepts[k]) {
				T_flag_excepts = 'Y';
				break;
			}
		}
		if (T_flag_excepts == 'Y') continue;
		T_flag = 'N';
		for(j=0; j<enables.length; j++) {																		// º¸¿©ÁÙ id °ªµé¸¸Å­ ¹Ýº¹
			if (enables[j] == layer_child[i].id) {																// ·¹ÀÌ¾î id ¿Í µ¿ÀÏ ÇÏ¸é Ãâ·Â ¾Æ´Ï¸é Ãâ·Â¾ÈÇÔ.
				T_flag = 'Y';
				break;
			}
		}
		if (reverse != 'Y') {
			if (T_flag == 'Y') layer_child[i].style.display = 'block';
			else layer_child[i].style.display = 'none';
		} else{
			if (T_flag == 'Y') layer_child[i].style.display = 'none';
			else layer_child[i].style.display = 'block';
		}
	}
}

function disable_child_radio(parent_id, obj_child) {
	enables = parent_id.split('_');
	for (i=0; i<obj_child.length; i++) {		// ÇÏÀ§ ¶óµð¿À °³¼ö¸¸Å­ ¹Ýº¹
		T_flag = 'N';
		for(j=0; j<enables.length; j++) {	// ¼±ÅÃ(»óÀ§)µÈ ÀÔ·Â»óÀÚÀÇ ¾ÆÀÌµð¸¦ _ ·Î ºÐ¸®(¾ÆÀÌµð °ª¿¡ È°¼ºÈ­ ½ÃÅ³ ÇÏÀ§ ¶óµð¿ÀÀÇ °ªÀÌ _ ±¸ºÐÀÚ·Î ¼³Á¤µÇ¾î ÀÖ¾î¾ßÇÔ)
			if (enables[j] == obj_child[i].value) {
				T_flag = 'Y';
				break;
			}
		}
		if (T_flag == 'Y') obj_child[i].disabled = false;
		else  obj_child[i].disabled = true;
	}
}

function deletePrevCate(form, obj) {	// »óÀ§ Ä«Å×°í¸®°¡ º¯°æµÉ¶§ ÇÏÀ§ Ä«Å×°í¸® ¸®½ºÆ®¸¦ »èÁ¦ÇÏ´Â ÇÔ¼ö
	var optionCount = eval('document.createInsiteForm.categoryList_' + depth + '.length');	// Á¦°ÅÇØ¾ßÇÒ selectÀÇ option ÅÂ±×ÀÇ ¼ö¸¦ ¾ò¾î¿Â´Ù.
	for (var i=0; i<optionCount; i++) {
		eval('document.createInsiteForm.categoryList_' + depth + '.remove(0)');	// ¸ðµç option ÅÂ±×¸¦ Á¦°ÅÇÑ´Ù.
	}
}

function select_category_1(form, obj_name, obj_parent, form_name, category_2_title) {		// »óÀ§ Ä«Å×°í¸® ¸®½ºÆ®ÀÇ Ç×¸ñÀ» ¼±ÅÃÇÒ¶§ ÇÏÀ§ Ä«Å×°í¸® Ç×¸ñÀ» º¸¿©ÁÖ´Â ÇÔ¼ö
	obj = eval('form.' + obj_name);
	optionCount = obj.length;																																		// Á¦°ÅÇØ¾ßÇÒ selectÀÇ option ÅÂ±×ÀÇ ¼ö¸¦ ¾ò¾î¿Â´Ù.
	for (i=0; i<optionCount; i++) obj.remove(0);																								// ¸ðµç option ÅÂ±×¸¦ Á¦°ÅÇÑ´Ù.
	newOption = document.createElement('OPTION');																					// Ãâ·ÂÇÒ option ¿ä¼Ò¸¦ ¸¸µç´Ù.
	newOption.text = category_2_title;																													// text ±¸¼º
	newOption.value = '';																																				// value ±¸¼º
	obj.add(newOption);																																				// ÇöÀç ¼±ÅÃµÈ Ä«Å×°í¸® ¸®½ºÆ®ÀÇ ´ÙÀ½ ¸®½ºÆ®¿¡ ¸¸µé¾îÁø option ¿ä¼Ò¸¦ Ãß°¡ÇÑ´Ù.
	if (obj_parent.value == '') return false;
	temp1 = obj_parent.selectedIndex;
	temp2 = obj_parent.options[temp1].value;
	SELECTOPTION = eval('option_name_' + form_name + '_' + temp2);
	SELECTVALUE = eval('option_value_' + form_name + '_' + temp2);
	for (var k=0; k<SELECTVALUE.length; k++) {																								// »õ·Î ³ªÅ¸³¯ ÇÏÀ§ Ä«Å×°í¸® ¸ñ·Ï¼ö¸¸Å­ ¹Ýº¹
		newOption = document.createElement('OPTION');																				// Ãâ·ÂÇÒ option ¿ä¼Ò¸¦ ¸¸µç´Ù.
		newOption.text = SELECTOPTION[k];																											// text ±¸¼º
		newOption.value = SELECTVALUE[k];																											// value ±¸¼º			
		obj.add(newOption);																																			// ÇöÀç ¼±ÅÃµÈ Ä«Å×°í¸® ¸®½ºÆ®ÀÇ ´ÙÀ½ ¸®½ºÆ®¿¡ ¸¸µé¾îÁø option ¿ä¼Ò¸¦ Ãß°¡ÇÑ´Ù.
	}
}

// ¸¶¿ì½º Å¬¸¯½Ã ·¹ÀÌ¾î ¸Þ´º ÆîÃÄÁö°Ô ÇÏ´Â ÇÔ¼ö (¾Æ·¡2°³)
var select_obj;
function open_mouse_layer(name, status, left_move, top_move) {
	var obj = document.all[name];
	if (status == 'visible') {
		if (select_obj) {
			select_obj.style.visibility = 'hidden';
			select_obj = null;
		}
		select_obj = obj;
		var x = (event.pageX) ? event.pageX : document.body.scrollLeft+event.clientX;
		var y = (event.pageY) ? event.pageY : document.body.scrollTop+event.clientY;								
		obj.style.left = x + left_move;
		obj.style.top = y + top_move;
	} else {
		select_obj = null;		
	}
	obj.style.visibility = status;
}

function get_layer_tag(name, layer_contents, width, height) {
	layer_header = "<div id='" + name + "' align='center' valign='middle' style='width=" + width + ";height=" + height + ";visibility:hidden; position:absolute; left:0; top:0; z-index:1'>";
	layer_footer = "</div>";
	document.writeln(layer_header+layer_contents+layer_footer);
}

// ÁöÁ¤µÈ ¿ÀºêÁ§Æ®ÀÇ left positon À» ¾òÀ½
function find_pos_x(obj){
	curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

// ÁöÁ¤µÈ ¿ÀºêÁ§Æ®ÀÇ top positon À» ¾òÀ½
function find_pos_y(obj) {
	curtop = 0;
	if (obj.offsetParent){
		while(obj.offsetParent){
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

// ¿òÁ÷ÀÌ´Â ·¹ÀÌ¾î Ã³¸®
var moving_layer_zindex = 20;
function drag_layer(drag_type, evt, divName) {
	if (divName) {
		obj_moving_layer = document.getElementById(divName);
		if(obj_moving_layer.style.position != 'absolute'){
			obj_moving_layer.style.left = find_pos_x(obj_moving_layer);
			obj_moving_layer.style.top = find_pos_y(obj_moving_layer);
			obj_moving_layer.style.position = 'absolute';
		}
		obj_moving_layer.style.zIndex = ++moving_layer_zindex;
	} else {
		return;
	}
	moving_start = 1;
	moving_start_x = (browser_type == 'NS') ? evt.pageX : event.clientX;
	moving_start_y = (browser_type == 'NS') ? evt.pageY : event.clientY;

	if (drag_type < 1) {																																		// µå·¡±×
		temp1 = parseInt(obj_moving_layer.style.left);
		temp2 = parseInt(obj_moving_layer.style.top);
		document.onmousemove = moving_layer;
	} else{																																									// Ã¢ Å©±âÁ¶Àý
		iwindoWidth = parseInt(TntiwindowTable.width); // °¡·Î
		iwindoHeight = parseInt(TntiwindowTable.height); // ¼¼·Î
		document.onmousemove = resizing_layer;
	}
}
function moving_layer() {
	if (moving_start == 1){
		if (browser_type == 'NS') {
			obj_moving_layer.style.left = temp1+evt.pageX-moving_start_x;
			obj_moving_layer.style.top = temp2+evt.pageY-moving_start_y;
		} else {
			obj_moving_layer.style.left = temp1+event.clientX-moving_start_x;
			obj_moving_layer.style.top = temp2+event.clientY-moving_start_y;
		}
		return false;
	}
}
function stop_layer() {
	moving_start = 0;
}

/*
*±â´É:Æ¯Á¤ ¹®ÀÚ º¯È¯
*@param text:¿øº» ¹®ÀÚ
*@param oldstr:Ã£´Â¹®ÀÚ
*@param newstr:´ëÃ¼ÇÏ´Â ¹®ÀÚ
*@return º¯È¯µÈ ¹®ÀÚ¿­
*/
function str_replace(text, oldstr, newstr) {
	cnt = text.length;
	retValue = "";
	for(i=0; i < cnt; i++){
		if (text.charAt(i) == oldstr) retValue += newstr;
		else retValue += text.charAt(i);
	}
	return retValue;
}

function image_preview(form, obj_file, obj_name_img, width, height) {
	obj_image = eval("form." + obj_name_img);
	obj_image.src = obj_file.value;
	if (width != '') obj_image.width = width;
	if (height != '') obj_image.height = height;
}

// Æ¯Á¤ ÀÔ·Â»óÀÚ¸¦ Ã¼Å©»óÅÂ¿¡ µû¶ó È°¼º ¶Ç´Â ¾²±â°¡´É À¸·Î º¯°æÇÏ´Â ÇÔ¼ö
// header_cnt Ã¼Å©»óÀÚ name ¾Õ¿¡ ¾²ÀÌ´Â Çì´õ ±ÛÀÚ¼ö, Çì´õ ÀÌÈÄÀÇ name °ªÀº ´ë»ó ÀÔ·Â»óÀÚ¸í°ú µ¿ÀÏÇØ¾ßÇÔ.
function chk_box_enable(form, obj, header_cnt, mode) {
	obj_name = obj.name;
	obj_name_cnt = obj_name.length;
	obj_target_name = obj_name.substring(header_cnt, obj_name_cnt);
	obj_target = eval('form.' + obj_target_name);
	if (obj.checked == true) {		// Ã¼Å©µÈ°æ¿ì
		if (mode == 'D') {					// ºñÈ°¼º ¸ðµå
			obj_target.disabled = false;
			obj_target.style.background = 'ffffff';
		} else {										// ÀÐ±âÀü¿ë ¸ðµå
			obj_target.readOnly = false;
			//obj_target.style.background = 'ffffff';
		}
	} else {
		if (mode == 'D') {					// ºñÈ°¼º ¸ðµå
			obj_target.disabled = true;
			obj_target.style.background = 'fafafa';
		} else {										// ÀÐ±âÀü¿ë ¸ðµå
			obj_target.readOnly = true;
			//obj_target.style.background = 'fefefe';
		}
	}
}

// ³¯Â¥ ¹üÀ§ Çü½ÄÀÌ ¸Â´ÂÁö È®ÀÎ
function verify_date_term(form, str) {
	if (str == '') return true;
	reg_express = new RegExp('^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})~([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$');
	if (!reg_express.test(str)) {
		alert('±â°£ ÁöÁ¤ Çü½ÄÀÌ ¸ÂÁö ¾Ê½À´Ï´Ù.');
		form.reset();
		return false;
	} else {
		return true;
	}
}

////////////////////////////////////////////////////
// ÀÔ·ÂÇÊµå¿¡ °ø¹éÀÌ ÀÖ´ÂÁö Ã¼Å©
var errmsg = '';
var errfld = '';
var submit_is_ing = 'N';

// ÇÊµå °Ë»ç
function check_field(fld, msg, color_ok, color_error, msg_method) {
	if (color_ok == '') color_ok = "#FFFFFF";
	if (color_error == '') color_error = "#CCFF99";
	if ((fld.value = trim(fld.value)) == '') return error_field(fld, msg, color_error, msg_method);
	else fld.style.background = color_ok;
	return;
}

// ÇÊµå ¿À·ù Ç¥½Ã
function error_field(fld, msg, color, msg_method) {
	if (color == '') color = "#CCFF99";
	if (errfld == '') errfld = fld;
	fld.style.background = color;
	if (msg != '') {
		if (msg_method == 'P') {
			alert(msg);
			if (errfld.type == 'text' || errfld.type == 'textarea' || errfld.type == 'select' || errfld.type == 'password') errfld.focus();
			errfld = '';
			return false;
		} else {
			errmsg += msg + "\n";
		}
	}
}

// ÀüÈ­¹øÈ£, ÈÞ´ëÆù°ú °°ÀÌ ¿©·¯ ÇÊµå°ªÀ» ±³Â÷ °Ë»çÇÒ ¶§ »ç¿ë
//objs = new Array();
//objs[0] = [form.od_b_tel_1, form.od_b_tel_2, form.od_b_tel_3];
//objs[1] = [form.od_b_hp_1, form.od_b_hp_2, form.od_b_hp_3];
//check_field_array(objs, '¹ÞÀ¸½Ã´Â ºÐÀÇ ÀüÈ­ ¶Ç´Â ÈÞ´ëÆù ¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.', '', '');	
function check_field_array(objs, msg, color_ok, color_error, msg_method) {
	if (color_ok == '') color_ok = "#FFFFFF";
	if (color_error == '') color_error = "#CCFF99";
	flag_i = false;
	for (i=0; i<objs.length; i++) {
		flag_j = false;
		for (j=0; j<objs[i].length; j++) {
			if (objs[i][j].disabled == false && objs[i][j].value == '') {								// 2Â÷ ¿ÀºêÁ§Æ®¿¡ °ø¹é°ªÀÌ ÀÖ´Â »óÅÂ(¿¡·¯)
				flag_j = true;
				break;
			}
		}
		if (flag_j == false) flag_i = true;																						// °ø¹é°ªÀÌ ¾ø´Â°æ¿ì (Åë°ú)
	}
	if (flag_i == false) {																													// 2Â÷ ¿ÀºêÁ§Æ® ±×·ì ¸ðµÎ°¡ ¹®Á¦°¡ ÀÖ´Â °æ¿ì
		for (i=0; i<objs.length; i++) {
			flag_j = false;
			for (j=0; j<objs[i].length; j++) {
				if (errfld == '') errfld = objs[i][j];																				// Æ÷Ä¿½ºµÉ ÇÊµå
				objs[i][j].style.background = color_error;
			}
		}
		error_field(errfld, msg, color_error, msg_method);
		/*//if (msg != '') errmsg += msg + "\n";
		if (msg != '') {
			alert(msg);
			if (errfld.type == 'text' || errfld.type == 'textarea' || errfld.type == 'select' || errfld.type == 'password') errfld.focus();
			errfld = '';
			return false;
		}
		*/
	} else {
		for (i=0; i<objs.length; i++) {
			flag_j = false;
			for (j=0; j<objs[i].length; j++) {
				objs[i][j].style.background = color_ok;
			}
		}
	}
}

// ¸ðµç Å¸ÀÔÀÇ °´Ã¼¸¦ ´ë»óÀ¸·Î, °ªÀÌ ÀÔ·ÂµÇ°Å³ª ¼±ÅÃµÇ¾ú´ÂÁö È®ÀÎ ÇÏ´Â ÇÔ¼ö
// ÀÔ·ÂÀÌ ¾ÈµÇ¾úÀ¸¸é ¹è°æ»öÀ» º¯°æÇÔ
// È÷µç ÀÔ·Â»óÀÚ´Â ¿¬°áµÇ´Â ¼±ÅÃ»óÀÚµéÀÌ ÀÖ´ÂÁö È®ÀÎ
function chk_obj_input(form_name, obj_name, chg_color, res_color, obj_err_msg) {
	is_empty = 'N';
	form = eval('document.' + form_name);
	obj = eval('form.' + obj_name);
	if (!obj) {
		alert('Á¸ÀçÇÏÁö ¾Ê´Â ÀÔ·Â»óÀÚ¸¦ ÇÊ¼ö ÀÔ·ÂÇ×¸ñÀ¸·Î ¼±ÅÃÇÏ¼Ì½À´Ï´Ù.\r\n\r\nÇÊµå¸í : ' + obj_name + ' ¸¦ È®ÀÎÇØ ÁÖ¼¼¿ä');
		return false;
	}
	if (chg_color == '') chg_color = "#CCFF99";
	if (res_color == '') res_color = "#FFFFFF";
	
	switch (obj.type) {
		case 'text' :
		case 'password' :
		case 'file' :
			if (obj.value == '') {
				if (chg_color != '') obj.style.background = chg_color;
				is_empty = 'Y';
			} else {
				if (res_color != '') obj.style.background = res_color;
			}
		break;
		case 'textarea' :
			if (obj.value == '') {
				if (chg_color != '') obj.style.background = chg_color;
				is_empty = 'Y';
			} else {
				if (res_color != '') obj.style.background = res_color;
			}			
		break;
		case 'select-one' :
			if (obj.value == '') {
				if (chg_color != '') obj.style.background = chg_color;
				is_empty = 'Y';
			} else {
				if (res_color != '') obj.style.background = res_color;
			}
		break;
		case 'select-multiple' :																															// ¸ÖÆ¼ÄÞº¸
			if (obj.value == '') {
				if (chg_color != '') obj.style.background = chg_color;
				is_empty = 'Y';
			} else {
				if (res_color != '') obj.style.background = res_color;
			}
		break;
		case 'radio' :
			if (obj.checked == false) {
				if (chg_color != '') obj.style.background = chg_color;
				is_empty = 'Y';
			} else {
				if (res_color != '') obj.style.background = res_color;
			}
		break;
		case 'checkbox' :
			if (obj.checked == false) {
				if (chg_color != '') obj.style.background = chg_color;
				is_empty = 'Y';
			} else {
				if (res_color != '') obj.style.background = res_color;
			}
		break;
		case undefined :																																			// ¸ÖÆ¼¶óµð¿À
			if (obj.length != undefined) {
				if (submit_radio_check(form, obj_name, 'radio') == 0) {
					if (chg_color != '') for (i=0; i<obj.length ; i++) obj[i].style.background = chg_color;
					is_empty = 'Y';
				} else {
					if (res_color != '') for (i=0; i<obj.length ; i++) obj[i].style.background = res_color;
				}
			}
		break;
		case 'hidden' :
			HM = eval('form.' + obj_name + '_multi');
			if (HM != undefined) {																														// ¸ÖÆ¼ÄÞº¸ ¿¬°á
				if (obj.value == '') {
					if (chg_color != '') HM.style.background = chg_color;	
					is_empty = 'Y';
				}
			} else {
				HM_name = obj_name + '_multi[]';
				obj_checkbox = document.getElementsByName(HM_name);
				if (obj_checkbox.length > 0) {																									// ¸ÖÆ¼Ã¼Å© ¿¬°á
					if (obj.value == '') {
						if (chg_color != '') for (i=0; i<obj_checkbox.length ; i++) obj_checkbox[i].style.background = chg_color;
						is_empty = 'Y';
					} else {
						if (res_color != '') for (i=0; i<obj_checkbox.length ; i++) obj_checkbox[i].style.background = res_color;
					}
				}
			}
		break;
		default :																																						// È®ÀÎ ¾ÈµÇ´Â °´Ã¼ÀÎ°æ¿ì
		break;
	}
	if (is_empty == 'Y') {	 																																// ºó°ªÀÌ¸é
		if (errfld == '') errfld = obj;																													// Ã¹¹øÂ° °´Ã¼¸¸ ÀúÀå
		if (obj_err_msg != '') {																															// ÁöÁ¤µÈ ¿¡·¯ ¸Þ½ÃÁö°¡ ÀÖÀ¸¸é ¹Ù·Î ÁßÁö
			alert(obj_err_msg);
			if ((errfld.type == 'text' || errfld.type == 'textarea' || errfld.type == 'select' || errfld.type == 'password') && (errfld.style.display != 'none')) errfld.focus();
			errfld = '';
			return false;
		}
	}
}

function trim(s) {
	var t = '';
	var from_pos = to_pos = 0;
	for (i=0; i<s.length; i++) {
		if (s.charAt(i) == ' ') {
			continue;
		} else  {
			from_pos = i;
			break;
		}
	}
	for (i=s.length; i>=0; i--) {
		if (s.charAt(i-1) == ' ') {
			continue;
		} else {
			to_pos = i;
			break;
		}
	}	
	t = s.substring(from_pos, to_pos);
	return t;
}

// E-Mail °Ë»ç
function email_check(email) {
    if (email.value.search(/(\S+)@(\S+)\.(\S+)/) == -1) return false;
    else return true;
}

// ÁÖ¹Îµî·Ï¹øÈ£ °Ë»ç
function jumin_check(j1, j2) {
	if (j1.value.length<6 || j2.value.length<7) return false;
	var sum_1 = 0;
	var sum_2 = 0;
	var at=0;
	var juminno= j1.value + j2.value;
	sum_1 = (juminno.charAt(0)*2)+
						(juminno.charAt(1)*3)+
						(juminno.charAt(2)*4)+
						(juminno.charAt(3)*5)+
						(juminno.charAt(4)*6)+
						(juminno.charAt(5)*7)+
						(juminno.charAt(6)*8)+
						(juminno.charAt(7)*9)+
						(juminno.charAt(8)*2)+
						(juminno.charAt(9)*3)+
						(juminno.charAt(10)*4)+
						(juminno.charAt(11)*5);
	sum_2=sum_1%11;
	if (sum_2 == 0) {
		at = 10;
	} else {
		if (sum_2 == 1) at = 11;
		else at = sum_2;
	}
	att = 11 - at;
	if (juminno.charAt(12) != att) return false;
	return true
}

// ÄíÅ° ÀÔ·Â
function set_cookie(name, value, expirehours) {
	var today = new Date();
	today.setTime(today.getTime() + (60*60*1000*expirehours));
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
}

// ÄíÅ° ¾òÀ½
function get_cookie(name) {
	var find_sw = false;
	var start, end;
	var i = 0;
	for (i=0; i<= document.cookie.length; i++) {
		start = i;
		end = start + name.length;
		if (document.cookie.substring(start, end) == name) {
			find_sw = true
			break
		}
	}
	if (find_sw == true) {
	start = end + 1;
	end = document.cookie.indexOf(";", start);
	if (end < start) end = document.cookie.length;
		return document.cookie.substring(start, end);
	}
	return '';
}

// ÄíÅ° Áö¿ò
function delete_cookie(name) {
	var today = new Date();
	today.setTime(today.getTime() - 1);
	var value = get_cookie(name);
	if (value != '') document.cookie = name + "=" + value + "; path=/; expires=" + today.toGMTString();
}

// °°Àº ·¹ÄÚµå¿¡ ÀÖ´Â ÀÔ·Â°ªÀ» º¯°æ ¶Ç´Â Ã¼Å© ÇÏ´Â ÇÔ¼ö
function chg_same_idx_obj(obj_source_name, obj_target_name, idx, mode) {
	obj_source = document.getElementsByName(obj_source_name);
	obj_target = document.getElementsByName(obj_target_name);
	switch (mode) {
		case 'V' :
			obj_target[idx].value = obj_source[idx].value;
		break;
		case 'C' :
			obj_target[idx].checked = true;
		break;
	}
}

// ¼±ÅÃ(Ã¼Å©)µÈ ·¹ÄÚµå ÀÌ¿ÜÀÇ ·¹ÄÚµåÀÇ ÀÔ·Â»óÀÚ¸¦ ºñÈ°¼ºÈ­ ½ÃÅ°´Â ÇÔ¼ö
function disable_other_idx_obj(checkbox_name, target_boxs) {
	obj_checkbox = document.getElementsByName(checkbox_name);
	cnt = obj_checkbox.length;
	cnt_target_boxs = target_boxs.length;
	for (i=0; i<cnt_target_boxs; i++) {
		obj_taret_box = document.getElementsByName(target_boxs[i]);
		cnt_obj_target_box = obj_taret_box.length;
		for (j=0; j<cnt_obj_target_box; j++) {
			obj_taret_box[j].disabled = false;
			if (obj_checkbox[j].checked == true) continue;
			obj_taret_box[j].disabled = true;
		}
	}
}

// ¸ñ·ÏµîÀÇ ´ÙÁß Ã¼Å©»óÀÚ¸¦ ÀÏ°ý¼±ÅÃ, ¹ÝÀü, ¼±ÅÃÃë¼Ò ÇÏ´Â ÇÔ¼ö
function chg_checkbox_state(checkbox_name, mode) {
	obj_checkbox = document.getElementsByName(checkbox_name);
	cnt = obj_checkbox.length;
	for (i=0; i<cnt; i++) {
		switch (mode) {
			case 'C' :
				obj_checkbox[i].checked = true;
			break;
			case 'N' :
				obj_checkbox[i].checked = false;
			break;
			case 'R' :
				if (obj_checkbox[i].checked == false) obj_checkbox[i].checked = true;
				else obj_checkbox[i].checked = false;
			break;
		}
	}
}

function chk_sell_enabled(obj, obj_target_name, index) {
	obj_target = document.getElementsByName(obj_target_name);
	if (obj.checked == true) obj_target[index].value = 'Y';
	else obj_target[index].value = '';
}

// º¸°ü¿ë
/*
text, textarea »óÀÚÀÇ Ä¿¼­À§Ä¡¿¡ ¹®ÀÚ¿­À» ³Ö´Â ÇÔ¼ö
function save_current_pos(objTextArea) {
	if (objTextArea.createTextRange) objTextArea.currentPos = document.selection.createRange().duplicate();
}
function input_special_char(text) {
	objTextArea = document.$form_name.subject;
	if (objTextArea.createTextRange && objTextArea.currentPos) {
		var currentPos = objTextArea.currentPos;
		currentPos.text = currentPos.text.charAt(currentPos.text.length - 1) == ' ' ? text + ' ' : text;
	} else {
		objTextArea.value  = text;
	}
}
*/