
var selectArea = null;
var color_target = "";

function init_editor() {
  editCtrl.document.designMode = "on";
  var html = "<html><head><script language='javascript'>document.domain = 'moneta.co.kr';</script></head><body></body></html>";
  editCtrl.document.open("text/html");
  editCtrl.document.write(html);
  editCtrl.document.close();
  editCtrl.document.body.style.fontFamily = "tahoma";
  editCtrl.document.body.style.fontSize = "9pt";
  editCtrl.document.onkeyup = showHtml;
  editCtrl.document.oncontextmenu = disableContext;
}



function disableContext() {
	return false;
}

function showHtml() {
	var html = editCtrl.document.body.innerHTML;
	document.frm.content.value = html;
}


function execCmd(cmd) {
	editCtrl.focus();
	selectArea = editCtrl.document.selection.createRange();

	if (selectArea != null)
		selectArea.select();
	
	if (cmd == "createlink") {
		editCtrl.focus();
		editCtrl.document.execCommand("createlink", 1);
	}
	else
		editCtrl.document.execCommand(cmd);

	showHtml();
}

function setFont(obj) {
	var font = obj.options[obj.selectedIndex].value;
	editCtrl.document.execCommand("FontName", null, font);

	showHtml();
}

function setFontSize(obj) {
	var size = obj.options[obj.selectedIndex].value;
	editCtrl.document.execCommand("FontSize", null, size);

	showHtml();
}

function setForeColor() {
	editCtrl.focus();
	selectArea = editCtrl.document.selection.createRange();

	document.all.foreColorTable.style.display = "";
	document.all.bgColorTable.style.display = "none";
}

function setBgColor() {
	editCtrl.focus();
	selectArea = editCtrl.document.selection.createRange();

	document.all.foreColorTable.style.display = "none";
	document.all.bgColorTable.style.display = "";
}

function dlg_setForeColor(color) {
	if (selectArea != null)
		selectArea.select();

	editCtrl.document.execCommand("forecolor", null, color);
	document.all.foreColorTable.style.display = "none";

	showHtml();
}

function dlg_setBackColor(color) {
	if (selectArea != null)
		selectArea.select();

	editCtrl.document.execCommand("backcolor", null, color);
	document.all.bgColorTable.style.display = "none";

	showHtml();
}

function dlg_insertImage(img) {
	editCtrl.focus();
	editCtrl.document.execCommand("insertimage", false, img);

	showHtml();
}

function dlg_insertMedia(tag) {
	editCtrl.focus();
	var sel = editCtrl.document.selection.createRange();
	sel.pasteHTML(tag);

	showHtml();
}
/*
function dlg_insertMedia() {
	var tag = '<embed src="mms://starlike.co.kr/vod/bdan_happybirthday.wmv" quality="high" autostart="true" loop="true" /></embed>';

	editCtrl.focus();
	var sel = editCtrl.document.selection.createRange();
	sel.pasteHTML(tag);

	showHtml();
}
*/

function insertImg() {
	window.open("/common/img_reg.asp", "img_dlg_window", "width=400,height=193");
}
/*

function insertMedia() {
	window.open("insert_media.php", "media_dlg_window", "width=300,height=163");
}
*/


