var isHTMLMode=false
var bHeader = "<style>P {margin-top:2px;margin-bottom:2px;}</style>\n";
var ground = "";	
var sCHK=false ;
	
function onreadystatechange()
{
	idContent.document.designMode="On"
	initEditor();
}

function initEditor()
{
	idContent.document.open();
	idContent.document.write(bHeader);
	idContent.document.close();

	idContent.document.body.style.fontSize = "10pt";
	idContent.document.body.style.fontFamily = "±¼¸²";
}

function cmdExec(cmd,opt) 
{
	if (isHTMLMode){alert("[HTML]¸¦ ÇØÁ¦ÇØ¾ß¸¸ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");return;}
	
	//if (cmd=="InsertImage")
	//{
		idContent.document.execCommand(cmd,"",opt);
		idContent.focus();		
	//}
	
}


	
/*function setMode(bMode)
{
	var sTmp;
	isHTMLMode = bMode;
	if (isHTMLMode){sTmp=idContent.document.body.innerHTML;idContent.document.body.innerText=sTmp;} 
	else {sTmp=idContent.document.body.innerText;idContent.document.body.innerHTML=sTmp;}
	idContent.focus();
}*/


function HTML_CHANGE()
{

	if (isHTMLMode==false)
	{
		sTmp=idContent.document.body.innerHTML;idContent.document.body.innerText=sTmp;
		isHTMLMode=true;
	} 
	else 
	{
		sTmp=idContent.document.body.innerText;idContent.document.body.innerHTML=sTmp;
		isHTMLMode=false;
	}
	idContent.focus();
}


function button_over(eButton)
{
	/*eButton.style.borderBottom = "buttonshadow solid 1px";
	eButton.style.borderLeft = "buttonhighlight solid 1px";
	eButton.style.borderRight = "buttonshadow solid 1px";
	eButton.style.borderTop = "buttonhighlight solid 1px";*/
}
function button_out(eButton)
{
	eButton.style.borderColor = "#EFEFEF";
}
function button_down(eButton)
{
	/*eButton.style.borderBottom = "buttonhighlight solid 1px";
	eButton.style.borderLeft = "buttonshadow solid 1px";
	eButton.style.borderRight = "buttonhighlight solid 1px";
	eButton.style.borderTop = "buttonshadow solid 1px";*/
}
function button_up(eButton)
{
	/*eButton.style.borderBottom = "buttonshadow solid 1px";
	eButton.style.borderLeft = "buttonhighlight solid 1px";
	eButton.style.borderRight = "buttonshadow solid 1px";
	eButton.style.borderTop = "buttonhighlight solid 1px";
	eButton = null; */
}

function changeColor(wcolour) 
{
	document.all["pickfgcolour"].style.backgroundColor = '#' + wcolour;		
	document.all["colorbox"].style.visibility = 'hidden';	
	cmdExec("ForeColor",wcolour);	
}
	
function showColor(posX,posY,what)
{	
	e = window.event;		
	with (document.all["colorbox"])
	{			
		style.left = e.clientX+4;			
		style.top  = e.clientY-18;			

		/*style.left = e.mouseX+4;			
		style.top  = e.mouseY-18;	*/

		style.visibility = 'visible';		
	}
	
	ground = what;
}

function createLink()
{
	if (isHTMLMode){alert("[HTML]¸¦ ÇØÁ¦ÇØ¾ß¸¸ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");return;}
	cmdExec("CreateLink");
}

function insertImage()
{
	if (isHTMLMode){alert("[HTML]¸¦ ÇØÁ¦ÇØ¾ß¸¸ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");return;}

	window.open("/NEWSADMIN/lib/popEditor_UPLOAD.asp","","width=350,height=200,status=no")
	
	//var sImgSrc=prompt("", "");
	//if(sImgSrc!=null) cmdExec("InsertImage",sImgSrc);
}

function Save() 
{
	if (isHTMLMode){alert("[HTML]¸¦ ÇØÁ¦ÇØ¾ß¸¸ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");return;}
	var sImgTag = idContent.document.body.all.tags("IMG");
	var oImg;
	for (var i = sImgTag.length - 1; i >= 0; i--) 
		{
		oImg = sImgTag[i];
		}
}

function on_submint()
{
		var Content = "\n<html>\n<head>\n" + bHeader + "</head>\n<body>\n" + idContent.document.body.innerHTML + "</body>\n</html>\n";
		document.form.R_Content.value = Content
		window.document.form.submit();
}