
var edit_mode="HTML";	// ¿¡µðÅÍ ¸ðµå(HTML/TEXT)
var select_obj;				// ·¹ÀÌ¾î

// ¸¶¿ì½º ¿À¹ö½Ã.. //
function btn_overed(obj)
{
	if(edit_mode=="TEXT") return;
	if(obj.className=="btn"){ obj.className="btn_over"}
}

// ¸¶¿ì½º ¶°³¯¶§.. //
function btn_outed(obj)
{
	if(edit_mode=="TEXT") return;

	if(obj.className=="btn_over"){ obj.className="btn"}
}

// ½ºÅ¸ÀÏ Àû¿ë //
function apply_format(obj,style)
{
	if(edit_mode=="TEXT") return;

	contentFrm.focus();
	//onBtnMousePressed(objName);	// ¼öÁ¤ÇÊ¿ä
	apply_HTML(style);
}

// html Àû¿ë //
function apply_HTML(excute,values)
{
	if(edit_mode=="TEXT") return;

	if(values==null)
	{
		contentFrm.document.execCommand(excute);
	}
	else
	{
		contentFrm.document.execCommand(excute,"",values);
	}
}


// ÆùÆ® »çÀÌÁî º¯°æ
function chgFontSize()
{
	if(edit_mode=="TEXT") return;
	contentFrm.focus();

	var SelectFontSize;
	SelectFontSize =document.Form.cmFontSize.options[document.Form.cmFontSize.selectedIndex].value;
	apply_HTML('fontsize',SelectFontSize);
	document.Form.cmFontSize.selectedIndex=0;
}

// ÆùÆ® º¯°æ
function chgFontFace()
{
	if(edit_mode=="TEXT") return;
	contentFrm.focus();

	var SelectFontFace;
	SelectFontFace = document.Form.cmFontFace.options[document.Form.cmFontFace.selectedIndex].value;
	apply_HTML('fontname',SelectFontFace);
	document.Form.cmFontFace.selectedIndex=0;
}

// Á¤·Ä
function apply_align(style)
{
	if(edit_mode=="TEXT") return;
	contentFrm.focus();

	apply_HTML(style);
}

// ±âº» Ä¿¸Çµå
function apply_command(style)
{
	if(edit_mode=="TEXT") return;
	contentFrm.focus();

	apply_HTML(style);
}

// ¿ÀºêÁ§Æ® ¸µÅ© °É±â
function show_make_object()
{
	if(edit_mode=="TEXT") return;
	contentFrm.focus();

	var MakeObject = showModalDialog("makeObjectLink.html",0, "dialogWidth:600px; dialogHeight:270px;  resizable: no; help: no; status: no; scroll: no;");
	if (MakeObject != null)
	{
		var sel = contentFrm.document.selection.createRange();
		sel.pasteHTML(MakeObject);
		sel.select();
	}
}
// ÀÌ¹ÌÁö »ðÀÔÇÏ±â
function show_insert_img()
{
	if(edit_mode=="TEXT") return;
	contentFrm.focus();

	window.open('ChoisImage.html','chois_img','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=450,z-lock=yes');
}

// Å×ÀÌºí ¸¸µé±â
function show_make_table()
{
	if(edit_mode=="TEXT") return;
	contentFrm.focus();

	var MakeTable = showModalDialog("makeTable.html",0, "dialogWidth:380px; dialogHeight:270px;  resizable: no; help: no; status: no; scroll: no;");
	if (MakeTable != null)
	{
		var sel = contentFrm.document.selection.createRange();
		sel.pasteHTML(MakeTable);
		sel.select();
	}
}

// ÆùÆ® Ä®¶ó ¼±ÅÃ //
function show_font_color(color_style) {
	if(edit_mode=="TEXT") return;
	
	var color = showModalDialog("ChoisColor.html", color_style, "dialogWidth:190px; dialogHeight:210px; center=yes; screenTop=yes; scroll=no; status=no; help=no; resizable: no; help: no;");
	contentFrm.focus();

	if (color != null)
	{
		if( color_style=='ForeColor' )
			apply_HTML("ForeColor",color);
		else if( color_style=='BackColor' )
			apply_HTML("BackColor",color);
	}
}

// ÅØ½ºÆ® ¸ðµå º¯°æ
function exchage_edit_mode(mode)
{
	if( mode=="HTML" )
	{
		if(edit_mode == 'HTML') return;
		document.all.imgSource.src='img/btn_source_over.gif';
		document.all.imgHtml.src='img/btn_html.gif';

		edit_mode="HTML";
		contentFrm.document.body.innerHTML=tagFrm.value;
		divContentFrm.style.display="";
		divTagFrm.style.display="none";
		contentFrm.focus();
	}
	else if( mode=="TEXT" )
	{
		if(edit_mode == 'TEXT') return;
		document.all.imgSource.src='img/btn_source.gif';
		document.all.imgHtml.src='img/btn_html_over.gif';

		edit_mode="TEXT";
		tagFrm.value=contentFrm.document.body.innerHTML;
		divContentFrm.style.display="none";
		divTagFrm.style.display="";
		tagFrm.focus();
	}
}


var myHeight = 600;
var isResizable = true;

function show_preview() {

	var form = document.frmPreview;

	if(edit_mode == "TEXT"){
		alert("HTML ¿¡µðÅÍ ¸ðµå¿¡¼­¸¸ »ç¿ëÇÏ½Ç¼ö ÀÖ½À´Ï´Ù.");
		return;
	}
	parent.onOK();
	var temp = contentFrm.document.body.innerHTML;
	form.contents.value = temp;

	if(!form.contents.value)
	{
		alert("¹Ì¸®º¸±â ÇÒ ³»¿ëÀÌ ¾ø½À´Ï´Ù.");
		return;
	}
	_target = form.target;
	_colon = _target.indexOf(":");

	if(_colon != -1) {
		form.target = _target.substring(0,_colon);
		form.args = _target.substring(_colon+1);
	} else if(typeof(form.args)=="undefined") {
		form.args = "";
	}

	if(form.args.indexOf("{")!=-1) {
		_args = form.args.split("{");
		form.args = _args[0];

		for(var i = 1; i < _args.length;i++) {
			_args[i] = _args[i].split("}");
			form.args += eval(_args[i][0]) + _args[i][1];
	   }
	}

	form.args = form.args.replace(/ /g,"");
	_win = window.open('',form.target,form.args);

	if(typeof(focus)=="function")
		_win.focus();

	form.submit();
}
