function popup(name,link,width,height,scroll)
{
	var top = (window.screen.height-height)/2;
	var left = (window.screen.width-width)/2;
	if ( scroll && scroll == 'y' ) {
	window.open( link , '' , 'top='+top+', left='+left+', width='+width+',height='+height+',scrollbars=yes,scrolling=yes,status=no,menubar=no,resizable=no');
	}
	else {
	window.open( link , '' , 'top='+top+', left='+left+', width='+width+',height='+height+',scrollbars=NO,scrolling=yes,status=no,menubar=no,resizable=no');
	}
}
function imgPopup(viewer, url, text)
{
	if ( text == null ) text='';
	popup('imgViewer',viewer+'?url='+url+'&text='+text,500,500,'y');
}
function imgResize(id, maxwidth)
{
	obj = document.getElementById(id);
	if ( obj == "undefined" )
	{
		return;
	}

	
	if ( obj.width > maxwidth)
	{
		obj.width = maxwidth;
	}

	return;
}

String.prototype.cut = function(len) {
		var str = this;
		var l = 0;
		for (var i=0; i<str.length; i++) {
				l += (str.charCodeAt(i) > 128) ? 2 : 1;
				if (l > len) return str.substring(0,i);
		}
		return str;
}
String.prototype.bytes = function() {
		var str = this;
		var l = 0;
		for (var i=0; i<str.length; i++) l += (str.charCodeAt(i) > 128) ? 2 : 1;
		return l;
}

var comment_maxlength = 400;

function comment_count(o1, o2)
{
	a = document.getElementById(o2);
	b = document.getElementById(o1);
	a.value = b.value.bytes();
	if ( a.value > comment_maxlength ) {
		alert(comment_maxlength+'ÀÚ ÀÌ»ó ±ÛÀ» ¾µ ¼ö ¾ø½À´Ï´Ù');
		b.value = b.value.cut(comment_maxlength);
		a.value = b.value.bytes();
	}
}
function comment_reset()
{
	if(document.comment.content.value == '³»¿ëÀº 400ÀÚ±îÁö ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.')
		document.comment.content.value = '';
}

function comment_write_check()
{
	if ( document.comment.name.value == "" ) {
		alert('ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.');
		document.comment.name.focus();
		return;
	}
	if ( document.comment.password.value == "" ) {
		alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
		document.comment.password.focus();
		return;
	}
	if ( document.comment.content.value == "" || document.comment.content.value == '³»¿ëÀº 400ÀÚ±îÁö ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.') {
		alert('±ÛÀ» ÀÔ·ÂÇÏ¼¼¿ä.');
		document.comment.content.focus();
		return;
	}
	document.comment.submit();
}

function view_comment_reple_show(id)
{
	obj = document.getElementById(id);
	if ( obj.style.display == "none" )
	{
		obj.style.display = "inline";
	}
	else {
		obj.style.display = "none";
	}
	return;
}
