function pWcheck_show(query,uid,p,option)
{
	var x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX;
	var y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY;

	document.all.pacheck_layer.style.visibility = "visible";
	document.all.pacheck_layer.style.left = x - 100; 
	document.all.pacheck_layer.style.top = y - 80;
	document.pacheck_layer_form.query.value = query;
	document.pacheck_layer_form.uid.value = uid;
	document.pacheck_layer_form.p.value = p;
	document.pacheck_layer_form.option.value = option;
	document.pacheck_layer_form.dp.focus();
}
function passform_check(f)
{
	if (!f.dp.value)
	{
		alert('\nºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.             \n');
		f.dp.focus();
		return false;
	}
}
function upfile_lay_show()
{
	var x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX;
	var y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY;

	document.all.mk_up.style.visibility = "visible";
	document.all.mk_up.style.left = x - 350; 
	document.all.mk_up.style.top = y + 50;

	var f = document.WriteForm;
	var i;
	var j = 0;

	for ( i = 0; i < f.length; i++ )
	{
		if (f[i].name == 'upfile[]' && f[i].value != "http://" && f[i].value != "mms://")
		{
			j++;
		}
	}
	if (j == 0)
	{
		AddFile();
	}
}
function upfile_lay_hide()
{
	document.all.mk_up.style.visibility = "hidden";
	document.all.mk_up.style.left = -1000; 
	document.all.mk_up.style.top = 0;

	var f = document.WriteForm;
	var i,g;
	var j = 0;
	var k = 0;

	for ( i = 0; i < f.length; i++ )
	{
		if (f[i].name == 'upfile[]' && f[i].value != "http://" && f[i].value != "mms://")
		{	
			k++;
			if (f[i].value)
			{
				j++;
			}
		}
	}
	
	if (j)
	{
		upfile_insert();
	}
}

function getUfileName(str)
{
	var str_array = (str.substring(0,5) != "http:" && str.substring(0,4) != "mms:") ? str.split("\\") : str.split('/');
	return str_array[str_array.length - 1];
}
function getFileExt(file)
{
	var file_array = file.split(".");
	return file_array[file_array.length - 1].substring(0,3);
}
function upfile_insert()
{
	var f = document.WriteForm;
	var i;
	var j = 0;
	var k = 0;
	var ext;
	var str = "<TABLE CELLSPACING=0 CELLPADDING=0 WIDTH=100%>";

	for ( i = 0; i < f.length; i++ )
	{
		if (f[i].name == 'upfile[]')
		{
			k++;
			if (f[i].value && f[i].value != "http://" && f[i].value != "mms://")
			{
				j++;
				ext = getFileExt(getUfileName(f[i].value));
				str += "<TR HEIGHT=20><TD>";
				str += "<IMG SRC='../../image/file/" + ext + ".gif' ALIGN=absmiddle> ";
				str += getUfileName(f[i].value);
				if (f[i].value.substring(0,5) != "http:" && f[i].value.substring(0,4) != "mms:") {
				str += (ext == "htm" || ext == "php" || ext == "asp" || ext == "cgi" || ext == "jsp" || ext == "pl") ? " <FONT COLOR='RED'>(Ã·ºÎºÒ°¡)</FONT>" : "";
				}
				str += "</TD><TD ALIGN=RIGHT><IMG SRC='../image/tmp_del.gif' STYLE='cursor:hand;' onclick='dellForm("+ k +");'>&nbsp;&nbsp;</TD></TR>";
			}
		}
	}
	
	str += "</TABLE>";

	if (j)
	{
		document.all.UpfileLay_tr.style.display = "block";
		document.all.UpfileLay_tr.style.height	 = j * 23;
		UpfileIframe.document.body.innerHTML = str;

/*
		document.all.mk_up.style.visibility = "hidden";
		document.all.mk_up.style.left = -1000; 
		document.all.mk_up.style.top = 0;
*/
	}
	else {
		alert('\nÆÄÀÏÀ» Ã·ºÎÇÏ½Å ÈÄ ¾÷·Îµå¹öÆ°À» Å¬¸¯ÇØ ÁÖ¼¼¿ä.           \n');
		return false;
	}
}
function write_preview()
{
	var f = document.WriteForm;

	chtml = f.HTML.value;

    if(f.HTML.value == 'HTML') {
		if (f.sourceview.checked)
		{
		var str = ContentIframe.document.body.innerText;
		}
		else {
		var str = ContentIframe.document.body.innerHTML;
		//document.WriteForm.CONTENT.value = tmp.replace(/&lt;?/g, '<').replace(/&gt;?/g, '>').replace(/&quot;?/g, '"').replace(/&amp;?/g, '&');
		}
	}
	if (!str)
	{
		alert('\n³»¿ëÀÌ ÀÔ·ÂµÇÁö ¾Ê¾Ò½À´Ï´Ù.           \n');
		return false;
	}
	window.open('./bbs/lib/write_preview.php?cthml=' + chtml + '&content_name='+str ,'pre_win','width=730,height=650,scrollbars=yes');
}
function upfile_delete(table,uid,dfile,dp,p,option)
{
	if (!confirm('\nÁ¤¸»·Î ¼±ÅÃÇÏ½Å Ã·ºÎÆÄÀÏÀ» Á¦¿ÜÇÏ½Ã°Ú½À´Ï±î?               \n'))
	{
		return;
	}
	location.href = "./bbs.php?action=upfile_delete&table="+table+"&uid="+uid+"&dfile="+dfile+"&dp="+dp+"&p="+p+""+option;
}
function opfile_delete(table,uid,dfile,p_uid,p,opg,option)
{
	if (!confirm('\nÁ¤¸»·Î ¼±ÅÃÇÏ½Å Ã·ºÎÆÄÀÏÀ» Á¦¿ÜÇÏ½Ã°Ú½À´Ï±î?               \n'))
	{
		return;
	}
	location.href = "./bbs.php?backgo=op&action=upfile_delete&table="+table+"&uid="+uid+"&dfile="+dfile+"&parent_uid="+p_uid+"&p="+p+"&opg="+opg+""+option;
}
function font_plus()
{
	var fontsize = document.all.bbs_content_layer.style.fontSize.replace("pt", "");

	if (parseInt(fontsize) < 20)
	{
		document.all.bbs_content_layer.style.fontSize = parseInt(fontsize) + 1 + "pt";
	}
}
function font_minus()
{
	var fontsize = document.all.bbs_content_layer.style.fontSize.replace("pt", "");

	if (parseInt(fontsize) > 6)
	{
		document.all.bbs_content_layer.style.fontSize = parseInt(fontsize) - 1 + "pt";
	}
}
function font_normal()
{
	document.all.num_not_content.style.display = "block";
	document.all.num_yes_content.style.display = "none";
}
function font_num()
{
	document.all.num_not_content.style.display = "none";
	document.all.num_yes_content.style.display = "block";
}
function opi_check()
{
	var f = document.WriteForm;
	if (!f.root.value)
	{
		if (!f.RP_NAME.value)
		{
			alert('\nÀÌ¸§À» ÀÔ·ÂÇØ ÁÖ¼¼¿ä.             \n');
			f.RP_NAME.focus();
			return false;
		}
	}
	if (!f.RP_CONTENT.value)
	{
		alert('\nÄÚ¸àÆ®¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.             \n');
		f.RP_CONTENT.focus();
		return false;
	}
	if (!confirm('\nÁ¤¸»·Î ÄÚ¸àÆ®¸¦ µî·ÏÇÏ½Ã°Ú½À´Ï±î?             \n'))
	{
		return false;
	}
}
function op_del(table,uid,p,opg,p_uid,option)
{
	if(!confirm('\nÁ¤¸»·Î »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?              \n'))
	{
		return false;
	}
	location.href = './bbs.php?action=opinion_delete&table=' + table + '&uid=' + uid + '&p=' + p + '&opg=' + opg + '&parent_uid='+ p_uid+""+option;
}
function op_mod(table,uid,p,opg,p_uid,option)
{
	
	location.href = './bbs.php?table=' + table + '&query=view&uid=' + p_uid + '&p=' + p + '&opg=' + opg + '&o_uid='+ uid + option + "#opg"+ uid ;
}
function op_mod_submit(table,uid,p,opg,p_uid,option)
{  f = table;
   if(!confirm('\nÁ¤¸»·Î ¼öÁ¤ÇÏ½Ã°Ú½À´Ï±î?              \n'))
	{
		return false;
	}
  
   f.query.value = "";

   f.submit();

	
}
function sorry_op()
{
	alert('\nÈ¸¿ø·Î±×ÀÎÀ» ÇØÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.                 \n');
	return false;
}
function multi_check()
{
	var f = document.bbs_list;
	var i;
	
	for (i = 0; i < f.length; i++)
	{
		if (f[i].name.substring(0,6) == "multi_")
		{
			f[i].checked = !f[i].checked;
		}
	}
}
function multi_del()
{
	var f = document.bbs_list;
	var i;
	var chk = 0;
	
	for (i = 0; i < f.length; i++)
	{
		if (f[i].name.substring(0,6) == "multi_" && f[i].checked == true)
		{
			chk++;
		}
	}
	if (!chk)
	{
		alert('\n°Ô½Ã¹°ÀÌ ¼±ÅÃµÇÁö ¾Ê¾Ò½À´Ï´Ù.             \n');
		return false;
	}
	if (!confirm('\nÁ¤¸»·Î ¼±ÅÃµÈ °Ô½Ã¹°À» ¸ðµÎ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?              \n'))
	{
		return false;
	}
	f.query.value = "multi_d";
	f.submit();
}
function multi_view()
{
	var f = document.bbs_list;
	var i;
	var chk = 0;
	
	for (i = 0; i < f.length; i++)
	{
		if (f[i].name.substring(0,6) == "multi_" && f[i].checked == true)
		{
			chk++;
		}
	}
	if (!chk)
	{
		alert('\n°Ô½Ã¹°ÀÌ ¼±ÅÃµÇÁö ¾Ê¾Ò½À´Ï´Ù.             \n');
		return false;
	}
	f.query.value = "multi_v";
	f.submit();
}
function down_check(name)
{
	alert('\nÁË¼ÛÇÕ´Ï´Ù.\n\n'+ name +'´Ô²²¼­´Â ´Ù¿î·Îµå ±ÇÇÑÀÌ ¾ø½À´Ï´Ù.           \n');
	return false;
}
function down_layer(file_str,table,uid,type)
{
	var x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX;
	var y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY;

	document.all.upfile_lay.style.visibility = "visible";
	if (type != "movie") {
		document.all.upfile_lay.style.left = x + 20; 
		document.all.upfile_lay.style.top = y - 20;
	}
	else {
		document.all.upfile_lay.style.left = x + 100; 
		document.all.upfile_lay.style.top = y;
	}

	var file_exp = file_str.split(';');
	var file_num = file_exp.length;
	var i;
	var r_str = "";

	r_str += "<TABLE BACKGROUND='../image/filelist_tt.gif' WIDTH=100% CELLSPACING=0 CELLPADDING=0 BGCOLOR=EFEFEF>";
	r_str += "<TR HEIGHT=28>";
	r_str += "<TD><IMG SRC='../image/filelist_tt01.gif' align='absmiddle'>";
	r_str += "</TD><TD ALIGN='RIGHT'>";
	r_str += "<IMG SRC='../image/filelist_tt02.gif' alt='´Ý±â' onclick='down_layer_hide();' STYLE='cursor:hand;'></TD></TR>";
	r_str += "</TABLE>";

	r_str += "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 STYLE='font-size:9pt;'>";

	for (i = 0; i < file_num; i++)
	{
		if (file_exp[i])
		{
			var ext = getFileExt(getUfileName(file_exp[i]));

			if (type == "image") {
			   var image = (ext == 'gif' || ext == 'jpg' || ext == 'jpeg' || ext == 'bmp' || ext == 'png') ? true : false;
			   if (!image) continue;
			}
			if (type == "flash") {
			   var flash = (ext == 'swf') ? true : false;
			   if (!flash) continue;
			}
			if (type == "movie") {
			   var movie = (ext == 'asf' || ext == 'asx' || ext == 'mpg' || ext == 'mpeg' || ext == 'avi' || ext == 'wmv') ? true : false;
			   if (!movie) continue;
			}
			if (type == "sound") {
			   var sound = (ext == 'mp3' || ext == 'mid' || ext == 'wav') ? true : false;
			   if (!sound) continue;
			}

			r_str += "<TR HEIGHT=22 onMouseOver=\"mouse_over(this);\" onMouseOut=\"mouse_out(this);\"><TD nowrap>";
			r_str += "<A STYLE='cursor:hand;' onclick=\"getBbsDown('"+table+"','dat','"+uid+"','"+i+"');\">";
			r_str += "&nbsp;&nbsp;<IMG SRC='../../image/file/" + ext + ".gif' ALIGN=absmiddle> ";
			r_str += getUfileName(file_exp[i]);
			r_str += "</A>";
			r_str += "</TD></TR>";
		}
	}
	
	r_str += "</TABLE>";


	frames.upfile_lay.document.body.innerHTML = r_str;

	var gheight = frames.upfile_lay.document.body.scrollHeight;
	var gwidth = frames.upfile_lay.document.body.scrollWidth;
	document.all.upfile_lay.style.height = gheight;
	document.all.upfile_lay.style.width = (gwidth < 200) ? 200 : gwidth-20;
}
function media_image_view(que , str , table ,type)
{
	if (type != "sound")
	{
		var now_img  = document.all.upfile_img.src;
		var now_name = now_img.split('/');
		var now_num  = now_name.length;
		var now_src	 = now_name[now_num-1];

		var str_exp  = str.split(';');
		var str_num	 = str_exp.length;

		var movie_r  = now_img.split('movie=');
		var movie    = movie_r[1];
	}
	else {
		var now_img  = document.all.upfile_sound_lay.src;
		var now_name = now_img.split('/');
		var now_num  = now_name.length;
		var now_src	 = now_name[now_num-1];

		var str_exp  = str.split(';');
		var str_num	 = str_exp.length;

		var movie_r  = now_img.split('movie=');
		var movie    = movie_r[1];
	}


	var i;
	var j = 0;

	for(i = 0; i < str_num; i++)
	{
		if (type != "sound")
		{
			if (now_src == str_exp[i] || now_img == str_exp[i] || movie == str_exp[i])
			{
				j = i;
				break;
			}

		}
		else {
			if (document.all.upfile_tmp.value)
			{
				j = parseInt(document.all.upfile_tmp.value);
				break;
			}
			else {
				var sound_exp = str_exp[i].split('|');
				if (now_src == sound_exp[0] || now_img == sound_exp[0])
				{
					j = i;
					break;
				}
			}
		}
	}

	switch (que)
	{
		case "play" :
			if (type != "sound")
			{
				document.all.upfile_play.disabled = true;
				document.all.upfile_play.style.filter = "gray()";
				document.all.upfile_play.style.cursor = "none";
				document.all.upfile_stop.disabled = false;
				document.all.upfile_stop.style.filter = "";
				document.all.upfile_stop.style.cursor = "hand";
				document.all.upfile_tmp.style.display = "block";
				media_image_play(str , table , type);
			}
			else {
				document.all.upfile_play.disabled = true;
				document.all.upfile_play.style.filter = "gray()";
				document.all.upfile_play.style.cursor = "none";
				document.all.upfile_stop.disabled = false;
				document.all.upfile_stop.style.filter = "";
				document.all.upfile_stop.style.cursor = "hand";		
				
				var sound_exp = str_exp[j].split('|');
				var up_dir = (sound_exp[0].substring(0,5) != "http:" && sound_exp[0].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
				document.all.upfile_sound_lay.src = up_dir + sound_exp[0];
				eval("document.all.upfile_sound_img_"+ j).src = "./bbs/image/cd1.gif";
			}
		break;

		case "stop" :
			if (type != "sound")
			{
				document.all.upfile_play.disabled = false;
				document.all.upfile_play.style.filter = "";
				document.all.upfile_play.style.cursor = "hand";
				document.all.upfile_stop.disabled = true;
				document.all.upfile_stop.style.filter = "gray()";
				document.all.upfile_stop.style.cursor = "none";
				document.all.upfile_tmp.style.display = "none";
			}
			else {
				document.all.upfile_play.disabled = false;
				document.all.upfile_play.style.filter = "";
				document.all.upfile_play.style.cursor = "hand";
				document.all.upfile_stop.disabled = true;
				document.all.upfile_stop.style.filter = "gray()";
				document.all.upfile_stop.style.cursor = "none";
				document.all.upfile_tmp.value = j;
				document.all.upfile_sound_lay.src = "";

				for (j = 0; j < str_num-1; j++)
				{
					eval("document.all.upfile_sound_img_"+ j).src = eval("document.all.upfile_sound_tmp_"+ j).value;
				}
			}
		break;

		case "lskip" :
			if (type != "movie" && type != "sound")
			{
				if (j > 0)
				{
					var up_dir = (str_exp[j-1].substring(0,5) != "http:" && str_exp[j-1].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
					document.all.upfile_img.src = up_dir + str_exp[j-1];
				}
				else {
					var up_dir = (str_exp[str_num-2].substring(0,5) != "http:" && str_exp[str_num-2].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
					document.all.upfile_img.src = up_dir + str_exp[str_num-2];
				}
			}
			else if (type != "sound")
			{
				if (j > 0)
				{
					var up_type = (str_exp[j-1].substring(0,5) != "http:" && str_exp[j-1].substring(0,4) != "mms:") ? "up" : "link";
					document.all.upfile_img.src = "./bbs/lib/movie_blank.php?table="+table+"&type="+up_type+"&movie="+ str_exp[j-1];
				}
				else {
					var up_type = (str_exp[str_num-2].substring(0,5) != "http:" && str_exp[str_num-2].substring(0,4) != "mms:") ? "up" : "link";
					document.all.upfile_img.src = "./bbs/lib/movie_blank.php?table="+table+"&type="+up_type+"&movie="+ str_exp[str_num-2];
				}
			}
			else {
				if (j > 0)
				{
					var sound_exp = str_exp[j-1].split('|');
					var up_dir = (str_exp[j-1].substring(0,5) != "http:" && str_exp[j-1].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
					document.all.upfile_sound_lay.src = up_dir + sound_exp[0];
					eval("document.all.upfile_sound_img_"+ j).src = eval("document.all.upfile_sound_tmp_"+ j).value;
					eval("document.all.upfile_sound_img_"+ (j-1)).src = "./bbs/image/cd1.gif";
					document.all.upfile_tmp.value = j-1;
				}
				else {
					var sound_exp = str_exp[str_num-2].split('|');
					var up_dir = (str_exp[str_num-2].substring(0,5) != "http:" && str_exp[str_num-2].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
					document.all.upfile_sound_lay.src = up_dir + sound_exp[0];
					eval("document.all.upfile_sound_img_"+ 0).src = eval("document.all.upfile_sound_tmp_"+ 0).value;
					eval("document.all.upfile_sound_img_"+ (str_num-2)).src = "./bbs/image/cd1.gif";
					document.all.upfile_tmp.value = str_num-2;
				}
			}
		break;

		case "rskip" :
			if (type != "movie" && type != "sound")
			{
				if (j  < str_num-2)
				{
					var up_dir = (str_exp[j+1].substring(0,5) != "http:" && str_exp[j+1].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
					document.all.upfile_img.src = up_dir + str_exp[j+1];
				}
				else {
					var up_dir = (str_exp[0].substring(0,5) != "http:" && str_exp[0].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
					document.all.upfile_img.src = up_dir + str_exp[0];
				}
			}
			else if (type != "sound")
			{
				if (j  < str_num-2)
				{
					var up_type = (str_exp[j+1].substring(0,5) != "http:" && str_exp[j+1].substring(0,4) != "mms:") ? "up" : "link";
					document.all.upfile_img.src = "./bbs/lib/movie_blank.php?table="+table+"&type="+up_type+"&movie="+ str_exp[j+1];
				}
				else {
					var up_type = (str_exp[0].substring(0,5) != "http:" && str_exp[0].substring(0,4) != "mms:") ? "up" : "link";
					document.all.upfile_img.src = "./bbs/lib/movie_blank.php?table="+table+"&type="+up_type+"&movie="+ str_exp[0];
				}
			}
			else {
				if (j  < str_num-2)
				{
					var sound_exp = str_exp[j+1].split('|');
					var up_dir = (str_exp[j+1].substring(0,5) != "http:" && str_exp[j+1].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
					document.all.upfile_sound_lay.src = up_dir + sound_exp[0];
					eval("document.all.upfile_sound_img_"+ j).src = eval("document.all.upfile_sound_tmp_"+ j).value;
					eval("document.all.upfile_sound_img_"+ (j+1)).src = "./bbs/image/cd1.gif";
					document.all.upfile_tmp.value = j+1;
				}
				else {
					var sound_exp = str_exp[0].split('|');
					var up_dir = (str_exp[0].substring(0,5) != "http:" && str_exp[0].substring(0,4) != "mms:") ? "./bbs/table/" + table + "/upload/" : "";
					document.all.upfile_sound_lay.src = up_dir + sound_exp[0];
					eval("document.all.upfile_sound_img_"+ (str_num-2)).src = eval("document.all.upfile_sound_tmp_"+ (str_num-2)).value;
					eval("document.all.upfile_sound_img_"+ 0).src = "./bbs/image/cd1.gif";
					document.all.upfile_tmp.value = 0;
				}
			}
		break;

		case "zoom" :
		if (type == "movie")
		{
			window.open(now_img,'movie_win', 'width=600,height=400,scrollbars=no');
			return false;
		}
		else if (type == "flash")
		{
			window.open('./bbs/lib/flash_blank.php?movie='+now_img,'flash_win', 'width=600,height=400,scrollbars=no');
			return false;
		}
		else {
			upfile_win(now_img);
			return false;
		}
	}
}
function media_image_play(str , table ,type)
{
	var flag = document.all.upfile_tmp.style.display;
	var sec  = (type == "flash") ? 5000 : 2000;

	if (flag == 'block')
	{
		setTimeout("media_image_play('" + str + "' , '" + table + "' , '" + type + "')", sec);
		media_image_view('rskip' , str , table , type);
	}
}
function upfile_win(img)
{
	window.open('./bbs/lib/image_viewer.php?img=' + img , 'upfile_img_win' , 'width=100,height=100,scrollbars=yes');
}
function getSoundPlay(file,i,num)
{
	var j;
	
	for (j = 0; j < num; j++)
	{
		if (i == j)
		{
			eval("document.all.upfile_sound_img_"+ j).src = "./bbs/image/cd1.gif"; 
		}
		else {
			eval("document.all.upfile_sound_img_"+ j).src = eval("document.all.upfile_sound_tmp_"+ j).value;
		}
	}
	document.all.upfile_sound_lay.src = file;
	document.all.upfile_tmp.value = i;
}
function  getBbsAdmin(table,type)
{
	if (type == "logout")
	{
		window.open('./admin/include/ROOT_LOGOUT.php');
	}
	else {
		window.open('./admin/7_1_config.php?table=' + table , 'config_win' , 'width=650,height=650,scrollbars=yes');
	}
}

