function send_check() 
{
	var f = document.WriteMail;

	if (!f.SUBJECT.value) {
		alert('Á¦¸ñÀÌ ÀÔ·ÂµÇÁö ¾Ê¾Ò½À´Ï´Ù.     ');
		f.SUBJECT.focus();
		return false;
	}
	if(f.HTML.value == 'HTML') {
		if (f.sourceview.checked)
		{
		var str = ContentIframe.document.body.innerText;
		document.WriteMail.CONTENT.value = str;
		}
		else {
		var tmp = ContentIframe.document.body.innerHTML;
		document.WriteMail.CONTENT.value = tmp.replace(/&lt;?/g, '<').replace(/&gt;?/g, '>').replace(/&quot;?/g, '"').replace(/&amp;?/g, '&');
		}
	}
	if (!f.CONTENT.value) {
		alert('³»¿ëÀÌ ÀÔ·ÂµÇÁö ¾Ê¾Ò½À´Ï´Ù.');
		//f.CONTENT.focus();
		return false;
	}
}

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 format(what, opt)
{
  if (opt == null) {
  ContentIframe.document.execCommand(what);
  }
  else {
  ContentIframe.document.execCommand(what,"", opt);
  }
  nowkong.selection = null;
}

function Edit_Start()
{
	var tag = "";
	nowkong = new kong();

	ContentIframe.document.open();
	ContentIframe.document.write(document.WriteMail.FORSAVE.value);
	ContentIframe.document.close();
	ContentIframe.document.designMode = 'on';
}

function tchange(clk, opt){
	var nowopened=0;
	if(document.all.colum.style.display!='none'){
		nowopened =1;
	}
	else {
		nowkong.SaveSelection();
	}
	if(document.WriteMail.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.WriteMail.backcolor);
		return;
	}
	if(clk == "backcol"){
		GetColor(document.WriteMail.bgcolor);
		return;
	}
	else if(clk == "fontcol"){
		GetColor(document.WriteMail.fontcolor);
		return;
	}
	else{
		format(clk, opt);
	}

	return true;
}

function htmlinside(){
	var eA = ContentIframe.document.selection.createRange();
	var aa = eA.parentElement();
	if(aa.tagName != "bd"){
		return;
	}
	eA.pasteHTML(eA.text);
	ContentIframe.focus();
}

function f_backcolor(color){
	document.WriteMail.backcolor.value = color;
	document.WriteMail.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:Arial;' topmargin=11 leftmargin=11>";
	ContentIframe.document.body.style.backgroundColor = '' + color + '';
}

function srcview(flag){
	
	if(flag){
		if (document.WriteMail.HTML.value == 'TEXT')
		{
			alert('\nTEXT ¸ðµå¿¡¼­´Â »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.        \n');
			document.WriteMail.sourceview.checked = false;
			return false;
		}
		document.WriteMail.bd_temp.value = ContentIframe.document.body.style.backgroundImage;
		document.WriteMail.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.WriteMail.bd_temp.value;
		ContentIframe.document.body.style.backgroundColor = document.WriteMail.bgcolor_temp.value;
		ContentIframe.focus();
	}
}



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

		document.getElementById("ContentDiv").style.position = "absolute";
		document.getElementById("ContentDiv").style.visibility = "hidden";

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

		document.getElementById("ContentDiv").style.position = "relative";
		document.getElementById("ContentDiv").style.visibility = "visible";
		document.WriteMail.CONTENT.style.position = "absolute";
		document.WriteMail.CONTENT.style.visibility = "hidden";
	}
}

function plus_width() {
	document.getElementById("ContentDiv").style.width = parseInt(document.getElementById("ContentDiv").style.width) + 30;
	document.WriteMail.CONTENT.style.width = parseInt(document.WriteMail.CONTENT.style.width) + 30;
}

function plus_height() {
	document.getElementById("ContentDiv").style.height = parseInt(document.getElementById("ContentDiv").style.height) + 100;
	document.WriteMail.CONTENT.style.height = parseInt(document.WriteMail.CONTENT.style.height) + 100;
}
function minus_width() {
	if (parseInt(document.getElementById("ContentDiv").style.width) > 670)
	{
	document.getElementById("ContentDiv").style.width = parseInt(document.getElementById("ContentDiv").style.width) - 30;
	document.WriteMail.CONTENT.style.width = parseInt(document.WriteMail.CONTENT.style.width) - 30;
	}
}

function minus_height() {
	if ( parseInt(document.getElementById("ContentDiv").style.height) > 330)
	{
	document.getElementById("ContentDiv").style.height = parseInt(document.getElementById("ContentDiv").style.height) - 100;
	document.WriteMail.CONTENT.style.height = parseInt(document.WriteMail.CONTENT.style.height) - 100;
	}
}

function aplus_size() {
	plus_width();
	plus_height();
}

function real_size() {
	document.getElementById("ContentDiv").style.width = 670;
	document.getElementById("ContentDiv").style.height = 330;
	document.WriteMail.CONTENT.style.width = 670;
	document.WriteMail.CONTENT.style.height = 330;
}

function ccview() {
	if(document.getElementById("cc").style.position == "absolute") {
	document.getElementById("cc").style.position = "relative";
	document.getElementById("cc").style.visibility = "visible";
	document.getElementById("bcc").style.position = "relative";
	document.getElementById("bcc").style.visibility = "visible";
	}
	else {
	document.getElementById("cc").style.position = "absolute";
	document.getElementById("cc").style.visibility = "hidden";
	document.getElementById("bcc").style.position = "absolute";
	document.getElementById("bcc").style.visibility = "hidden";
	}
}

