
function addattachFile(src) {
	var f = getFirstParentByTagAndClassName(src, 'form', null);
	var files = f.elements['attach[]'];

	if (files.length>=board_config.attach['max']) {
		alert('Ã·ºÎÆÄÀÏÀº ÃÖ´ë '+board_config.attach['max']+'°³±îÁö¸¸ µî·ÏÇÒ ¼ö ÀÖ½À´Ï´Ù.');
		return false;
	}

	var ol = $('attach_files');
	var li = getFirstElementByTagAndClassName('li', 'new_attach', ol);
	if (li==null) {
		alert('Ã·ºÎÆÄÀÏÀ» ´õÀÌ»ó Ãß°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.');
		return false;
	}
	var newLI = LI({'class':'new_attach'}, null );
	newLI.innerHTML = li.innerHTML;
	appendChildNodes(ol, newLI);

	return false;
}

function delattachFile(src) {
	var f = getFirstParentByTagAndClassName(src, 'form', null);
	var files = f.elements['attach[]'];

	if (typeof(files.length)=='undefined' || files.length <= 1) {
		alert('»èÁ¦ÇÒ ¼ö ¾ø½À´Ï´Ù.');
		return false;
	}

	if (files.length<=board_config.attach['min']) {
		alert('Ã·ºÎÆÄÀÏÀº ÃÖ¼Ò '+board_config.attach['min']+'°³ ÀÌ»ó µî·ÏÇØ¾ß ÇÕ´Ï´Ù.');
		return false;
	}

	var li = getFirstParentByTagAndClassName(src, 'li', null);
	var ol = getFirstParentByTagAndClassName(li, 'ol', null);

	removeElement(li);
	return false;
}

function addLink(src) {
	var f = getFirstParentByTagAndClassName(src, 'form', null);
	var lnks = f.elements['link[]'];

	if (lnks.length>=board_config.link['max']) {
		alert('¸µÅ©ÁÖ¼Ò´Â ÃÖ´ë '+board_config.link['max']+'°³±îÁö¸¸ µî·ÏÇÒ ¼ö ÀÖ½À´Ï´Ù.');
		return false;
	}

	var ol = $('attach_links');
	var li = getFirstElementByTagAndClassName('li', 'new_link', ol);
	if (li==null) {
		alert('¸µÅ©ÁÖ¼Ò¸¦ ´õÀÌ»ó Ãß°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.');
		return false;
	}
	var newLI = LI({'class':'new_link'}, null );
	newLI.innerHTML = li.innerHTML;
	appendChildNodes(ol, newLI);
	return false;
}

function delLink(src) {
	var f = getFirstParentByTagAndClassName(src, 'form', null);
	var lnks = f.elements['link[]'];

	if (typeof(lnks.length)=='undefined' || lnks.length <= 1) {
		alert('»èÁ¦ÇÒ ¼ö ¾ø½À´Ï´Ù.');
		return false;
	}

	if (lnks.length <= board_config.link['min']) {
		alert('¸µÅ©ÁÖ¼Ò´Â ÃÖ¼Ò '+board_config.link['min']+'°³ ÀÌ»ó µî·ÏÇØ¾ß ÇÕ´Ï´Ù.');
		return false;
	}

	var li = getFirstParentByTagAndClassName(src, 'li', null);
	var ol = getFirstParentByTagAndClassName(li, 'ol', null);

	removeElement(li);
	return false;
}

function checkWriteForm(f) {
	if (!AtAtForm.check(f)) {
		return false;
	}

	if (typeof(board_config)=='undefined') {
		return true;
	}
	for ( attr in board_config ) {
		if (attr in board_config && board_config[attr]['required']==true) {
			if (f.elements[attr]!=null && ( f.elements[attr].value==null || f.elements[attr].value.trim().length==0 )) {
				alert(board_config[attr]['msg']);
				f.elements[attr].focus();
				return false;
			}
		}
	}

	if (board_config['link']['min']>0) {
		// ÃÖ¼Ò ¸µÅ©ÁÖ¼Ò ¼ö °ËÁõ
		var lnks = getSelected(f, 'link[]');
		if (lnks.length < board_config['link']['min']) {
			alert(board_config['link']['msg']);
			// f.elements['link[]'][files.length].focus();
			return false;
		}
	}

	if (board_config['attach']['min']>0) {
		// ÃÖ¼Ò Ã·ºÎ ÆÄÀÏ ¼ö °ËÁõ
		var files = getSelected(f, 'attach[]');
		if (files.length < board_config['attach']['min']) {
			alert(board_config['attach']['msg']);
			// f.elements['attach[]'][files.length].focus();
			return false;
		}
	}
}

function checkCommentForm(f) {
	if (!AtAtForm.check(f)) {
		return false;
	}

	return true;
}

function replyComment(src, no) {
	var f = getFirstParentByTagAndClassName(src, 'form', null);
	f.co_no.value = no;
	
	var tr = getFirstParentByTagAndClassName(src, 'tr', null);
	var div = $('comment_reply_div');

	if (div==null) {
		return true;
	}
	div = removeElement(div);

	appendChildNodes(tr.cells[1], div);
	showElement(div);

	Highlight(div);

	if (f.elements['name'])
		f.elements['name'].focus();
	else
		f.content.focus();
	return false;
}
















