function imgInput(n,t) {
	var ref = "imgUpload.html?uid="+n+"&TB="+t;
	window.open(ref, "ZipWin", "width=500, height=400, status=no, scrollbars=yes");
}


function f_backcolor(color){
	document.WriteForm.backcolor.value = color;
	document.WriteForm.FORSAVE.value = "<STYLE>P {margin-top:2px;margin-bottom:2px;font-size:9pt;}</STYLE><BODY oncontextmenu='return false;' BGCOLOR='"+color+"' style='font-size:11pt; font-family:±¼¸²;' topmargin=11 leftmargin=11>";
	ContentIframe.document.body.style.backgroundColor = '' + color + '';
}

function format(what, opt)
{
  if (opt == null) {
  ContentIframe.document.execCommand(what);
  }
  else {
  ContentIframe.document.execCommand(what,"", opt);
  }
  nowkong.selection = null;
}

function tchange(clk, opt){
	if (document.WriteForm.HTML.value == 'TEXT')
	{
		alert('\nTEXT ¸ðµå¿¡¼­´Â »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.        \n');
		return false;
	}

	var nowopened=0;
	if(document.all.colum.style.display!='none'){
		nowopened =1;
	}
	else {
		nowkong.SaveSelection();
	}
	if(document.WriteForm.sourceview.checked){
		alert('Á÷Á¢ÄÚµù Ã¼Å©¸¦ ÇØÁ¦ÇÏ°í »ç¿ëÇÏ¼¼¿ä');
		return;
	}

	nowkong.RestoreSelection();
	if(nowkong.selection){
		var aa = nowkong.selection.parentElement();
		if(aa.style.topmargin != "12px"){
			ContentIframe.focus();
		}
	}
	if (clk == "bgcol")
	{
		GetColor(document.WriteForm.backcolor);
		return;
	}
	if(clk == "backcol"){
		GetColor(document.WriteForm.bgcolor);
		return;
	}
	else if(clk == "fontcol"){
		GetColor(document.WriteForm.fontcolor);
		return;
	}
	else{
		format(clk, opt);
	}

	return true;
}
function plus_width() {
	if (parseInt(document.getElementById("ContentDiv").style.width) < 650)
	{
		document.getElementById("ContentDiv").style.width = 650;
		document.WriteForm.CONTENT.style.width = 650;
	}
	else {
		document.getElementById("ContentDiv").style.width = parseInt(document.getElementById("ContentDiv").style.width) + 30;
		document.WriteForm.CONTENT.style.width = parseInt(document.WriteForm.CONTENT.style.width) + 30;
	}
}
function minus_width() {
	if (parseInt(document.getElementById("ContentDiv").style.width) > 650)
	{
	document.getElementById("ContentDiv").style.width = parseInt(document.getElementById("ContentDiv").style.width) - 30;
	document.WriteForm.CONTENT.style.width = parseInt(document.WriteForm.CONTENT.style.width) - 30;
	}
}
function plus_height() {
	document.getElementById("ContentDiv").style.height = parseInt(document.getElementById("ContentDiv").style.height) + 100;	
	document.WriteForm.CONTENT.style.height = parseInt(document.WriteForm.CONTENT.style.height) + 100;
}
function minus_height() {
	if ( parseInt(document.getElementById("ContentDiv").style.height) > 330)
	{
	document.getElementById("ContentDiv").style.height = parseInt(document.getElementById("ContentDiv").style.height) - 100;
	document.WriteForm.CONTENT.style.height = parseInt(document.WriteForm.CONTENT.style.height) - 100;
	}
}
function aplus_size() {
	plus_width();
	plus_height();
}
function real_size() {
	document.getElementById("ContentDiv").style.width = "100%";
	document.getElementById("ContentDiv").style.height = 330;
	document.WriteForm.CONTENT.style.width = "100%";
	document.WriteForm.CONTENT.style.height = 330;
}
function srcview(flag){
	
	if(flag){
		if (document.WriteForm.HTML.value == 'TEXT')
		{
			alert('\nTEXT ¸ðµå¿¡¼­´Â »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.\n');
			document.WriteForm.sourceview.checked = false;
			return false;
		}

		document.WriteForm.bd_temp.value = ContentIframe.document.body.style.backgroundImage;
		document.WriteForm.bgcolor_temp.value = ContentIframe.document.body.style.backgroundColor;
		var tmp = ContentIframe.document.body.innerHTML;
		ContentIframe.document.body.innerText = tmp;
		ContentIframe.document.body.style.backgroundImage = '';
		ContentIframe.document.body.style.backgroundColor = '';
		ContentIframe.focus();
	}
	else{
		var tmp = ContentIframe.document.body.innerText;
		ContentIframe.document.body.innerHTML = tmp;
		ContentIframe.document.body.style.backgroundImage = document.WriteForm.bd_temp.value;
		ContentIframe.document.body.style.backgroundColor = document.WriteForm.bgcolor_temp.value;
		ContentIframe.focus();
	}
}

function edittext(){
	
	if(document.WriteForm.HTML.value == 'TEXT') {
		var conf = confirm("HTMLÈ¿°ú°¡ »ç¶óÁý´Ï´Ù. ½ÇÇàÇÏ½Ã°Ú½À´Ï±î?");
		if(!conf){
			document.WriteForm.HTML.value = "HTML";
			return;
		}

		document.getElementById("ContentDiv").style.display = "none";
		var str = ContentIframe.document.body.innerText;
		document.WriteForm.CONTENT.value = str;
		//document.WriteForm.CONTENT.value= str.replace(/&lt;?/g, '<').replace(/&gt;?/g, '>').replace(/&quot;?/g, '"').replace(/&amp;?/g, '&');
		document.WriteForm.CONTENT.style.display = "block";
	}
	else {
		var conf = confirm("HTMLÆíÁýÀ¸·Î ÀüÈ¯ÇÕ´Ï´Ù. ½ÇÇàÇÏ½Ã°Ú½À´Ï±î?");
		if(!conf){
			document.WriteForm.HTML.value = "TEXT";
			return;
		}

		document.getElementById("ContentDiv").style.display = "block";
		document.WriteForm.CONTENT.style.display = "none";
	}
}

function Edit_Start(html)
{
	var tag = "";
	nowkong = new kong();
	ContentIframe.document.open();
	ContentIframe.document.write(document.WriteForm.FORSAVE.value);
	ContentIframe.document.close();
	ContentIframe.document.designMode = 'on';
	if (html == "TEXT")
	{
		setTimeout("textstart()",10);
	}
}

function kong()
{
	this.selection    = null;
	this.selection2    = null;
	this.RestoreSelection = Kong_RestoreSelection;
	this.SaveSelection  = Kong_SaveSelection;
	this.GetSelection  = Kong_GetSelection;
}

function Kong_RestoreSelection() 
{
	if (this.selection) {
		this.selection.select();
	}
}

function Kong_GetSelection() 
{
	var oSel = this.selection;
	if (!oSel) {
		oSel = ContentIframe.document.selection.createRange();
		oSel.type = ContentIframe.document.selection.type;
	}
	return oSel;
}

function Kong_SaveSelection() 
{
	nowkong.selection = ContentIframe.document.selection.createRange();
	nowkong.selection.type = ContentIframe.document.selection.type;
}

function textstart(){
	document.getElementById("ContentDiv").style.display = "none";
	var str = ContentIframe.document.body.innerText;
	//document.WriteForm.CONTENT.value= str.replace(/&lt;?/g, '<').replace(/&gt;?/g, '>').replace(/&quot;?/g, '"').replace(/&amp;?/g, '&');
	document.WriteForm.CONTENT.value = str;
	document.WriteForm.CONTENT.style.display = "block";
}