/*** ºñ¹Ð±Û ÆË¾÷Ã¢ ***/
function popupSecret(obj,no)
{
	var popup = _ID('popupSecret');
	popup.style.top = get_objectTop(obj) + obj.offsetHeight;
	popup.style.left = get_objectLeft(obj);
	document.fmSecret.no.value = no;
	document.fmSecret.password.focus();
}
function ps_close()
{
	var popup = _ID('popupSecret');
	popup.style.left = -999;
}
function ps_submit()
{
	var popup = _ID('popupSecret');
	if (chkForm(document.fmSecret)) document.fmSecret.submit();
}

/*** º»¹® ÀÌ¹ÌÁö Å©±â ¸®»çÀÌÂ¡ ***/
function innerImgResize(id)
{
	var objContents = document.getElementById(id);
	var innerWidth = objContents.clientWidth;
	var img = objContents.getElementsByTagName('img');
	for (var i=0;i<img.length;i++){
		if (img[i].width>innerWidth){
			img[i].height = img[i].height * innerWidth / img[i].width;
			img[i].width = innerWidth;

			img[i].title = "¿øº» ÀÌ¹ÌÁöº¸±â";
			img[i].style.cursor = "pointer";
			img[i].onclick = function(){
				window.open("../board/popup.img.php?src=" + this.src,'','width=10,height=10');
			};
		}
	}
}

/*** ÄÚ¸àÆ® °ü·Ã ***/
var objComment;
function vComment(objnm,id,no)
{
	var obj = $('box_' + objnm);
	obj.style.display = (obj.style.display!="block") ? "block" : "none";
	if (obj.style.display=="none") return;
	
	objComment = objnm;
	printComment(objComment);
}

function printComment(objnm)
{
	if (arguments[1]){
		var fm = $('box_'+objnm).getElementsByTagName('form');
		fm[0].reset();
	}

	var div = objnm.split("_");
	var id = div.slice(0,div.length-1).join("_"); var no = div[div.length-1];
	var obj = $('cmt_' + objnm);

	new Ajax.Request('indb.php',{
		parameters:	'mode=ajaxComment&id=' + id + "&no=" + no,
		onComplete: showResponse
	});
	function showResponse(data)
	{
		obj.innerHTML = data.responseText;
	}
}

function chkFormComment(obj)
{
	objComment = obj.parentNode.getAttribute('id').replace("box_","");
	return chkForm(obj);
}

function chkFormCommentMod(obj)
{
	if (chkForm(obj)){
		//$('objComment').style.left = -999;
		return true;
	}
	return false;
}

function cmt_popup_close()
{
	$('objCommentPopup').style.left = -999;
}

function modComment(id,no)
{
	var obj = $('objCommentPopup');
	var w = 500;
	var h = 200;
	var frame = 20;

	var gap_w = w/frame;
	var gap_h = h/frame;

	var bodyW = document.body.clientWidth;
	var bodyH = document.body.clientHeight;

	obj.style.left = bodyW/2;
	obj.style.top = bodyH/2 + document.body.scrollTop;

	obj.innerHTML = "";

	obj.style.width = 0;
	obj.style.height = 0;
	//obj.className = "";

	function popupResize()
	{
		obj.style.left = obj.style.pixelLeft - gap_w/2;
		obj.style.top = obj.style.pixelTop - gap_h/2;
		obj.style.width = parseInt(obj.style.width) + gap_w;
		obj.style.height = parseInt(obj.style.height) + gap_h;
		if (parseInt(obj.style.width)>=w){
			clearTimeout(timer);
			setContents();
		} else timer = setTimeout(popupResize,1);		
	}
	popupResize();

	function setContents()
	{
		obj.innerHTML = $('innerCommentMod').innerHTML;
		//obj.className = "shadow";
		var f = obj.getElementsByTagName('form')[0];
		f.setAttribute("name","frmModComment");
		f.no.value = no;

		new Ajax.Request('indb.php',{
			parameters:	'mode=ajaxCommentMod&id=' + id + "&no=" + no,
			onComplete: showResponse
		});
		function showResponse(data)
		{
			var r = data.responseText;
			r = r.replace(/(\r\n|\r|\n)+/g,'<br>');
			r = eval('(' + r + ')');

			f.name.value = r.name;
			f.comment.value = r.comment.str_replace("<br>","\n");
			if (r.mid){
				$('objComment_name_box').innerHTML = r.name; 
				$('objComment_member').style.display = "block";
				$('objComment_guest').style.display = "none";
				f.password.disabled = true;
			} else {
				$('objComment_member').style.display = "none";
				$('objComment_guest').style.display = "block";
				f.password.disabled = false;
			}
		}
	}

}

function delComment(id,no)
{
	var obj = $('objCommentPopup');
	var w = 500;
	var h = 200;
	var frame = 20;

	var gap_w = w/frame;
	var gap_h = h/frame;

	var bodyW = document.body.clientWidth;
	var bodyH = document.body.clientHeight;

	obj.style.left = bodyW/2;
	obj.style.top = bodyH/2 + document.body.scrollTop;

	obj.innerHTML = "";

	obj.style.width = 0;
	obj.style.height = 0;
	//obj.className = "";

	function popupResize()
	{
		obj.style.left = obj.style.pixelLeft - gap_w/2;
		obj.style.top = obj.style.pixelTop - gap_h/2;
		obj.style.width = parseInt(obj.style.width) + gap_w;
		obj.style.height = parseInt(obj.style.height) + gap_h;
		if (parseInt(obj.style.width)>=w){
			clearTimeout(timer);
			setContents();
		} else timer = setTimeout(popupResize,1);		
	}
	popupResize();

	function setContents()
	{
		obj.innerHTML = $('innerCommentDel').innerHTML;
		
		var f = obj.getElementsByTagName('form')[0];
		f.setAttribute("name","frmDelComment");
		f.no.value = no;
	}

}

/*** °Ô½ÃÆÇ¸®½ºÆ®¿¡¼­ ÀÏ°ýÃ³¸® ***/
function boardChkDelete()
{
	if (isChked('chk[]','Á¤¸»·Î »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?')){
		var fm = document.frmList;
		fm.method = "POST";
		fm.mode.value = "delete";
		fm.action = "indb.php";
		fm.submit();
	}
}
