//made by ys@lastcom.pe.kr

//ÃÊ±âÈ­
function init() {
	TextEditor.document.onmousedown = new Function("TextEditorEvent()");
	iText = TextEditor;
	iText.document.designMode = "On";
	TextEditView.style.display="inline";
	initEditor();
	bLoad = true;
}

//±âÁ¸±ÛÀ» ºÒ·¯¿Í¼­ ÆíÁý
function Edit(){
	init();
	TextEditView.style.display="inline";
	TextEditor.document.body.innerHTML =writeform.tmpContent.value;
}

//ÃÊ±âÈ­¸é ½ºÅ¸ÀÏ ¼³Á¤
function initEditor() {
//	var bHeader = "<style>P {margin-top:3px;margin-bottom:3px;margin-left:3;margin-right;3}</style>\n";
	iText.document.open();
//	iText.document.writeform(bHeader);
	iText.document.close();
	iText.document.body.style.fontSize = "9pt";
	iText.document.body.style.fontFamily = "±¼¸²";
}

function TextEditorEvent(){
if (TextEditor.event.button==2){

	var oSource = TextEditor.event.srcElement ;
    if (!oSource.isTextEdit) 
        oSource = TextEditor.event.srcElement.parentTextEdit;

		var strValue = TextEditor.event.srcElement.tagName; //¼±ÅÃµÈ ºÎºÐÀÇ ÅÂ±× Á¾·ù
    if ((strValue == "IMG" || strValue == "HR") && oSource != null) {

        var oTextRange = oSource.createTextRange();
     }

		var selectedRange = TextEditor.document.selection.createRange();
		var edValue = selectedRange.htmlText;

	var strX = TextEditor.event.x;
	var strY = TextEditor.event.y+180;

	if (strValue == "IMG") 
		strH = "180px";
	else if (strValue == "HR" || strValue == "TABLE")
		strH = "135px";
	else
		strH = "340px";

	var strParam = "dialogLeft:" + strX + ";dialogTop:" + strY + ";"
	strParam = strParam + "center:no;dialogWidth:150px; dialogHeight:" + strH + ";status:0;scroll:0; help:0;unadorned:yes;"
	}
}

/*¼öÁ¤ µÈ ºÎºÐ */
//action event
function check(param){
	if(document.writeform.html_check[0].checked){
		document.writeform.content.value = TextEditor.document.body.innerHTML;
		if( !document.writeform.content.value ){
			alert( "³»¿ëÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä!^^");
			TextEditor.document.body.focus();
			return;
		}
	}else{
		document.writeform.content.value = document.writeform.html_body.value;
			if( !document.writeform.content.value ){
			alert( "³»¿ëÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä!^^");
			document.writeform.html_body.focus();
			return;
		}
	}
	document.writeform.method='post';
	document.writeform.action=param;
	document.writeform.submit();
//	document.writeform.enctype='multipart/form-data';
}


//since 2002/03/17
function paste(param){
	TextEditor.focus();
	var sel = TextEditor.document.selection;
	if (sel!=null) {
		var rng = sel.createRange();
	    if (rng!=null)
		    rng.pasteHTML(param);
	}
}

//since 2002.4.20
function layer_change(hidden_key,view_key){
	if(hidden_key == "html_layer")
		TextEditor.document.body.innerHTML = document.writeform.html_body.value;
	else
		document.writeform.html_body.value = TextEditor.document.body.innerHTML;
		document.all[hidden_key].style.display = "none";
		document.all[view_key].style.display = "block";
}
/*¼öÁ¤ µÈ ºÎºÐ */

function ButtonUp(param) {
	param.style.border="1px outset";
	param.style.background="#D4D4D4";
}

function ButtonOut(param) {
	param.style.border="";
	param.style.background="";

}
function MenuOver(param) {
	param.style.fontColor="white";
	param.style.backgroundColor="navy";
}

function MenuOut(param) {
	param.style.fontcolor="white";
	param.style.backgroundColor="#C0C0C0";
}


function block_style(o, cmd) {
	var ed=TextEditor.document.selection.createRange();
	ed.execCommand(cmd, false, o.value);
}


function SelectionCommand(Btn, cmd) {
	TextEditor.focus();
	var EdRange=TextEditor.document.selection.createRange();
	EdRange.execCommand(cmd);
}

/*
function ChFontColor(param,cmd){
	var ed
	ed = TextEditor.document.selection.createRange();
	ed.execCommand(cmd, false, param);
}*/
/** modified by neoburi-Inkuk*/

function ChFontColor(cmd){
	var ed
	var value = showModalDialog( "/include/include/selcolor.htm",
                             "",
                             "font-family:Verdana; font-size:12;dialogWidth:30em; dialogHeight:25em;status:no;help:no;self-close:no" );
	if( value != null ){
		ed = TextEditor.document.selection.createRange();
		ed.execCommand(cmd, true, value);
	}
	TextEditor.document.body.focus();
}

function OpenWin(URL) {
	var str;
	var scrWidth = (screen.availWidth / 2 ) - 200;
	var scrHeight = (screen.availHeight / 2) - 150;
	str="'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,";
	str=str+"width=400";
	str=str+",height=300',top="+scrHeight+",left="+scrWidth;
	wopen = window.open(URL,'remote',str);
}
