function GetBPL() { return "1"; }
function GetBPLWidth() { return 0; }
function GetBPLHeight() { return 0; }
function GetBPLTop() { return 0; }
function GetBPLLeft() { return 0; }

function hangulCheck(str) 
{
	for(i=0; i<str.length; i++) 
	{
		var a = str.charCodeAt(i);
		if (a > 128) 
		{
			alert('Ã·ºÎÇÏ½Ç ÀÌ¹ÌÁö´Â ÇÑ±Û¸íÀ» »ç¿ëÇÏ½Ç¼ö ¾ø½À´Ï´Ù. ¿µ¹®À¸·Î »ç¿ëÇØÁÖ¼¼¿ä.');
			return false;
		}	
	}
	return true;
}

function trim (strSource) 
{
	re = /^\s+|\s+$/g;
	return strSource.replace(re, '');
}

function ltrim (strSource) 
{
	re = /^\s+/g;
	return strSource.replace(re, '');
}

function rtrim (strSource) 
{
	re = /\s+$/g;
	return strSource.replace(re, '');
}

function loadmedia()
{
	var arrMediaList = document.all.tags("object");
	var i;

	for (i=0; i<arrMediaList.length; i++) 
	{
		if (arrMediaList[i].classid.toUpperCase() == "CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" && arrMediaList[i].rsr.length > 40) {
			arrMediaList[i].ShowStatusBar = "-1";
			if (arrMediaList[i].rau == "0") {
				arrMediaList[i].autostart = "0"
			} else {
				arrMediaList[i].autostart = "-1"
			}
			arrMediaList[i].filename = arrMediaList[i].rsr;
		}
	}
}

function EDT_ViewImage() 
{
	if (event.srcElement.tagName == "IMG") 
	{
		newOpen('/admin2/bbsMS/bbs_img_view.php?filePath=' + event.srcElement.src,'view','0','0','0','0','0','1','0','','');
//		window.open(event.srcElement.src, "", "directories=no,location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=yes");
	}
}

function ToggleEditorSize(bDirection,browserType) 
{
	if (!bDirection) 
	{
		if(browserType == "Editor")
		{
			document.all.editBox.height = document.all.editBox.height <= 400?document.all.editBox.height:parseInt(document.all.editBox.height)-200;
		}
		else
		{
			document.form1.content.rows = document.form1.content.rows-5;
		}
	}
	else 
	{
		if(browserType == "Editor")
		{
			document.all.editBox.height = document.all.editBox.height>=2000?document.all.editBox.height:parseInt(document.all.editBox.height) + 200;
		}
		else
		{
			document.form1.content.rows = document.form1.content.rows+5;
		}
	}
}

// Ã·ºÎÆÄÀÏ »èÁ¦ ¹× Á¤¸®
function removeAttach()
{
	var attachlist = document.getElementById("attachfilelist");
    if (attachlist.selectedIndex <= 0) { return; } // ¼±ÅÃµÈ°Ô ¾øÀ¸¸é
	attachlist.remove(attachlist.selectedIndex);   // ¼±ÅÃÇÑ ÆÄÀÏ ¸®½ºÆ®¿¡¼­ »èÁ¦
	putAttachFile();
}

function putAttachFile()
{
	var attachlist = document.getElementById("attachfilelist");
	var total = attachlist.options.length;			
	if (total > 1)
	{
		var oriFileNameArr = "";
		var newFileNameArr = "";

		for(i=0; i<total; i++)
		{
			if (attachlist.options[i].value != "") 
			{
				oriFileNameArr = oriFileNameArr + attachlist.options[i].text + "?";				// ¿À¸®Áö³¯ ÆÄÀÏ¸í
				newFileNameArr = newFileNameArr + attachlist.options[i].value + "?";		// »õ·Î¿î ÆÄÀÏ¸í
			}			
		}
	}
	else
	{
		oriFileNameArr = ""; 
		newFileNameArr = ""; 
	}
	document.form1.attachOriFileNameList.value = oriFileNameArr;			// ¿À¸®Áö³¯ ÆÄÀÏ¸í
	document.form1.attachFileNameList.value = newFileNameArr;			// »õ·Î¿î ÆÄÀÏ¸í
}
// Ã·ºÎÆÄÀÏ »èÁ¦ ¹× Á¤¸®

// ÆÄÀÏÃ·ºÎÃ¢ ¶ç¿ì±â
function fileUpload(frmObj)
{
	var bbsID = frmObj.bbsID.value;
	var bbsClass = frmObj.bbsClassCheck.value;
	var nFileTotal = frmObj.attachfilelist.length;
	var bbsPdsTotal = frmObj.bbsPdsTotal.value;
	
	if (bbsID.length < 1 || bbsID == "")	{ alert("bbsID °ªÀÌ ¾ø½À´Ï´Ù."); return; }
	if (bbsClass.length < 1 || bbsClass == "")	{ alert("bbsClass °ªÀÌ ¾ø½À´Ï´Ù."); return; }

	if(bbsClass != "powerEditor")	// ÆÄ¿ö¿¡µðÅÍ´Â ÆÄÀÏÃ·ºÎ ¹«Á¦ÇÑ
	{
		if(parseInt(nFileTotal-1) >= parseInt(bbsPdsTotal)) { alert(bbsPdsTotal + "°³ ÀÌ»ó Ã·ºÎÇÏ½Ç¼ö ¾ø½À´Ï´Ù."); return; }
	}

	if (browserOs == "Editor")
	{
		var retVal = window.showModalDialog("/admin2/bbsMS/editor/fileUpload.htm",bbsID,"dialogHeight: 180px; dialogWidth: 440px; edge: Raised; center: Yes; scroll: no; help: No; resizable: No; status: No;");
		
		if(retVal)	 // ÆÄÀÏÀ» Ã·ºÎÇÑ°Ô ÀÖ´Ù¸é
		{
			if(retVal[0] != null && retVal[0] != "" && retVal[1] != null && retVal[1] != "" && retVal[2] != null && retVal[2] != "")
			{
				var attachFileNameList = frmObj.attachFileNameList.value;						// ºÎ¸ðÆûÀÇ È÷µçÇÊµå
				attachFileNameList = attachFileNameList + "?" + retVal[1];						// ÆÄÀÏ¸í ´õÇÏ±â
				frmObj.attachFileNameList.value = attachFileNameList;							// ´õÇÑ ÆÄÀÏ¸í ºÎ¸ðÃ¢ÀÇ È÷µçÇÊµå¿¡ ³Ö±â

				// ºÎ¸ðÆûÀÇ ÆÄÀÏÃ·ºÎ ¹Ú½º¿¡ Ãß°¡
				var total = frmObj.attachfilelist.options.length;
				var position = parseInt(total) + 1
				frmObj.attachfilelist.length = position;		
				frmObj.attachfilelist.options[total].text = retVal[0];
				frmObj.attachfilelist.options[total].value = retVal[1];	
			}
		}
	}
	else
	{
		newOpen('/admin2/bbsMS/editor/fileUpload_netscape.php?bbsID=' + bbsID,'fileUpload','440','180','0','0','0','0','0','0','','');
	}
}
// ÆÄÀÏÃ·ºÎÃ¢ ¶ç¿ì±â

function HandleLoad() 
{
	blnBodyLoaded = true;
	init();
}

function HTMLDecode(strHtml)
{
	var strRetVal = "";
	strRetVal = strHtml.replace(/&gt;/gi, ">");
	strRetVal = strRetVal.replace(/&lt;/gi, "<");
	strRetVal = strRetVal.replace(/&quot;/gi, "\"");
	strRetVal = strRetVal.replace(/&amp;/gi, "&");
	return strRetVal;
}

function setEditMode(sMode) { document.all.editBox.editmode = sMode; }

function HandleKeyDown(e)
{
	if (event.srcElement.name == "title") 
	{
		if (event.keyCode == 9 || event.keyCode == 13) 
		{
			document.all.editBox.focus();
			document.all.editBox.setFocus();
			return false;
		}
	}
	else if (event.keyCode == 13) 	{ event.keyCode = 9; }
	return true;
}

function init() 
{
	for (var i = 0; i < document.form1.elements.length; i++) 
	{
		if (document.form1.elements[i].type == "text" || document.form1.elements[i].type == "password") 
		{
			document.form1.elements[i].onkeydown = HandleKeyDown;
		}
	}
	document.all.editBox.displaybpl(GetBPL(), GetBPLWidth(), GetBPLHeight(), GetBPLTop(), GetBPLLeft());
	setTimeout("document.form1.title.focus()", 0);
}

// ext ¹è¿­¿¡ µé¾îÀÖ´Â ÆÄÀÏÈ®ÀåÀÚ¶õ °°Àº ÆÄÀÏÀÎÁö ¾Ë¾Æ³»±â 
function fileExtCheck(file,ext) 
{
	var flag = "Y";
	if (!file) return;
	if(!ext) return; 

	var extArray = ext.split(",");

	while (file.indexOf("\\") != -1)
	{
		file = file.slice(file.indexOf("\\") + 1);
		ext = file.slice(file.indexOf(".")+1).toLowerCase();

		for (var i = 0; i < extArray.length; i++) 
		{
			if (extArray[i] == ext)
			{
				flag = "N";
				break;
			} 
			if(flag == "N") break;
		}
	}
	return flag;
}
