	var innerHeader = "<style>P {margin-top:2px;margin-bottom:2px;} \nbody {font-size:9pt; font-family:±¼¸²;}</style>\n";

	function ready_edit(){
		NowSpace = new Space();

		KnEditor.document.designMode="On"

		KnEditor.document.open();
		KnEditor.document.write(innerHeader);
		KnEditor.document.close();
	}

	function cmdExec(cmd, opt){
		NowSpace.RestoreSelection();
		
		var tt = KnEditor.document.selection.createRange();
				
		if (sector_1.chk == '1'){
			alert('HTML, ¹Ì¸®º¸±â »óÅÂ¿¡¼­´Â ¼öÁ¤À» ÇÏ½Ç¼ö°¡ ¾ø½À´Ï´Ù.');
		}else{
			NowSpace.RestoreSelection();
		
			if (opt==null){
				KnEditor.document.execCommand(cmd);
			}else{
				KnEditor.document.execCommand(cmd,"",opt);
			}
		}
	}

	function changeColor(cmd, opt){
		ColorBox.style.visibility = 'hidden';
		cmdExec(cmd, opt);
	}
	
	function cmdHrInput(){
		if (sector_1.chk == '1'){
			alert('HTML, ¹Ì¸®º¸±â »óÅÂ¿¡¼­´Â ¼öÁ¤À» ÇÏ½Ç¼ö°¡ ¾ø½À´Ï´Ù.');
		}else{
		
				NowSpace.RestoreSelection();
		
				if(NowSpace.selection){
					var aa = NowSpace.selection.parentElement();
					if(aa.style.topmargin != "12px"){
						KnEditor.focus();
					}
				}
	
			var KnEditorCtrl = KnEditor.document.selection.createRange();
				KnEditorCtrl.pasteHTML("<hr>");
		}
	}
	
	function cmdImageLink(){
		divLayerOFF();
		
		var linkURL = img_url.value;
		

		NowSpace.RestoreSelection();
		
		if(NowSpace.selection){
			var aa = NowSpace.selection.parentElement();
			if(aa.style.topmargin != "12px"){
				KnEditor.focus();
			}
		}
		var KnEditorCtrl = KnEditor.document.selection.createRange();
		KnEditorCtrl.pasteHTML("<IMG src='"+linkURL+"'>");
		
	
	}	function Space(){
		this.selection    = null;
		this.selection2    = null;
		this.RestoreSelection = Space_RestoreSelection;
		this.SaveSelection  = Space_SaveSelection;
		this.GetSelection  = Space_GetSelection;
	}

	function Space_RestoreSelection() {
		if (this.selection) {
			this.selection.select();
		}
	}

	function Space_GetSelection() {
		var oSelected = this.selection;
		if (!oSelected) {
			oSelelected = KnEditor.document.selection.createRange();
			oSelelected.type = KnEditor.document.selection.type;
		}
		return oSelected;
	}

	function Space_SaveSelection() {
		NowSpace.selection = KnEditor.document.selection.createRange();
		NowSpace.selection.type = KnEditor.document.selection.type;
	}

	function ShowColorBox(posX, posY, cmd){
		
		if (sector_1.chk == '1'){
			alert('HTML, ¹Ì¸®º¸±â »óÅÂ¿¡¼­´Â ¼öÁ¤À» ÇÏ½Ç¼ö°¡ ¾ø½À´Ï´Ù.');
		}else{
			if (ColorBox.style.visibility != 'visible'){
				ColorBox.innerHTML = tagColor(cmd);
				ColorBox.style.visibility = 'visible';
				ColorBox.style.left = (posX - 12);
				ColorBox.style.top = (posY + 30);
			}else{
				divLayerOFF();
			}
		}
	}
	
	function tagColor(cmd){
		var colortone = new Array(15);
			colortone[0] = new Array('#000000','#ffffff','#008000','#800000','#ac8295','#808000','#000080','#800080','#808080','#c0c0c0');
			colortone[1] = new Array('#ffff00','#00ff00','#00ffff','#ff00ff','#ff0000','#0000ff','#008080','#ed8602','#0099ff','#9900ff');
			colortone[2] = new Array('#ffffff','#e5e4e4','#d9d8d8','#c0bdbd','#a7a4a4','#8e8a8b','#827e7f','#767173','#5c585a','#000000');
			colortone[3] = new Array('#fefcdf','#fef4c4','#feed9b','#fee573','#ffed43','#f6cc0b','#e0b800','#c9a601','#ad8e00','#8c7301');
			colortone[4] = new Array('#ffded3','#ffc4b0','#ff9d7d','#ff7a4e','#ff6600','#e95d00','#d15502','#ba4b01','#a44201','#8d3901');
			colortone[5] = new Array('#ffd2d0','#ffbab7','#fe9a95','#ff7a73','#ff483f','#fe2419','#f10b00','#d40a00','#940000','#6d201b');
			colortone[6] = new Array('#ffdaed','#ffb7dc','#ffa1d1','#ff84c3','#ff57ac','#fd1289','#ec0078','#d6006d','#bb005f','#9b014f');
			colortone[7] = new Array('#fcd6fe','#fbbcff','#f9a1fe','#f784fe','#f564fe','#f546ff','#f328ff','#d801e5','#c001cb','#8f0197');
			colortone[8] = new Array('#e2f0fe','#c7e2fe','#add5fe','#92c7fe','#6eb5ff','#48a2ff','#2690fe','#0162f4','#013add','#0021b0');
			colortone[9] = new Array('#d3fdff','#acfafd','#7cfaff','#4af7fe','#1de6fe','#01deff','#00cdec','#01b6de','#00a0c2','#0084a0');
			colortone[10] = new Array('#edffcf','#dffeaa','#d1fd88','#befa5a','#a8f32a','#8fd80a','#79c101','#3fa701','#307f00','#156200');
			colortone[11] = new Array('#d4c89f','#daad88','#c49578','#c2877e','#ac8295','#c0a5c4','#969ac2','#92b7d7','#80adaf','#9ca53b');

		var strHTML = "";
			strHTML = strHTML + "<table cellpadding=2 cellspacing=0 border=1 style='border-collapse: collapse' bgcolor='#FFFFFF'><tr><td><table cellpadding=0 cellspacing=0 border=0>";

			for (var i=0; i<11; i++){
				strHTML = strHTML + "<tr>";
				
				for(var j=0; j<10; j++){
					strHTML = strHTML + "<td onmouseover=this.style.backgroundColor='blue' onmouseout=this.style.backgroundColor='' class='hand' title='" + colortone[i][j] + "'><table cellpadding=0 cellspacing=1 border=0><tr><td bgcolor='" + colortone[i][j] + "' onclick='changeColor(\"" + cmd + "\", \"" + colortone[i][j] + "\");' width=10 height=10></td></tr></table></td>";
				}   
				strHTML = strHTML + "</tr>";
			}
			strHTML = strHTML + "</table></td></tr></table>";
			
			return strHTML;
	}
	
	function divLayerOFF(){
	
		try{
			ColorBox.style.visibility = 'hidden';
			imgLinkBox.style.visibility = 'hidden';
		}catch(e){}
	}
	
		
	function ShowImgLinkBox(posX, posY,cmd){
		
		if (sector_1.chk == '1'){
			alert('HTML, ¹Ì¸®º¸±â »óÅÂ¿¡¼­´Â ¼öÁ¤À» ÇÏ½Ç¼ö°¡ ¾ø½À´Ï´Ù.');
		}else{
			if (imgLinkBox.style.visibility != 'visible'){
				imgLinkBox.innerHTML = urlLinkInput();
				imgLinkBox.style.visibility = 'visible';
				imgLinkBox.style.left = (posX - 12);
				imgLinkBox.style.top = (posY + 12);
			
				img_url.focus();
				img_url.select();
			}else{
				divLayerOFF();
			}
		}
	}
	
	function urlLinkInput(cmd){
		
		if (cmd=='' || cmd=='undefined' || cmd==null){
			cmd='http://';
		}
		
		var strHTML = "";
			strHTML = strHTML + "<table border='1' cellspacing='0' width='300' style='border-collapse: collapse' bordercolor='#0A246A' cellpadding='5'><tr><td width='100%' bgcolor='#ffffff'><span style='font-size: 9pt'>ÀÎÅÍ³Ý »ó¿¡ ¿Ã·ÁÁø ÀÌ¹ÌÁö¸¸ °¡´É ÇÕ´Ï´Ù.<br>";
			strHTML = strHTML + "»ðÀÔÇÒ ÀÌ¹ÌÁöÀÇ ÀÎÅÍ³ÝÁÖ¼Ò(URL)À» ³Ö¾î ÁÖ¼¼¿ä.<br><font color='red'>¡º<b>http://</b>¡»¸¦ ²À¾²¼¼¿ä.<br><input type='text' name='img_url' size='30' class='808080_input' value='"+ cmd +"'><br><a style='cursor:hand' OnClick='cmdImageLink();'>[Ãß°¡]</a> <a style='cursor:hand' OnClick='divLayerOFF();'>[Ãë¼Ò]</a></span></td></tr></table>";
			
		return strHTML;
	}


	function button_over(btn_obj){
			btn_obj.style.borderBottom = "buttonshadow solid 1px";
			btn_obj.style.borderLeft = "buttonhighlight solid 1px";
			btn_obj.style.borderRight = "buttonshadow solid 1px";
			btn_obj.style.borderTop = "buttonhighlight solid 1px";
	}

	function button_out(btn_obj){
			btn_obj.style.borderColor = "threedface";
			btn_obj.style.border="0px";
	}

	function button_down(btn_obj){
			btn_obj.style.borderBottom = "buttonhighlight solid 1px";
			btn_obj.style.borderLeft = "buttonshadow solid 1px";
			btn_obj.style.borderRight = "buttonhighlight solid 1px";
			btn_obj.style.borderTop = "buttonshadow solid 1px";
	}
	
	function button_up(btn_obj){
			btn_obj.style.borderBottom = "buttonshadow solid 1px";
			btn_obj.style.borderLeft = "buttonhighlight solid 1px";
			btn_obj.style.borderRight = "buttonshadow solid 1px";
			btn_obj.style.borderTop = "buttonhighlight solid 1px";
			btn_obj = null; 
	}
	
	
	function select_btn(obj, order, sector){
		
		var cname;
		var chk = obj.chk;
		
		if (order=='over'){
			if (chk=='0'){
				cname='bt_btn_over';
			}else{
				cname='';
			}
		}else if(order=='out'){
			if (chk=='0'){
				cname='bt_btn_out';
			}else{
				cname='';
			}
		}else if(order=='click'){
			edit_default.className = 'bt_btn_out';
			edit_default.chk = '0';
			edit_html.className = 'bt_btn_out';
			edit_html.chk = '0';
			edit_preview.className = 'bt_btn_out';
			edit_preview.chk = '0';
			
			obj.chk=1;
			cname='bt_btn_click';
			
			if(sector==1){
					sector_1.style.display = 'block';
					sector_2.style.display = 'none';
				
				if (sector_1.chk != 0){
					sector_1.chk = 0;
					sector_2.chk = 0;
					KnEditor.document.body.innerHTML = KnEditor.document.body.innerText;
				}
				
				KnEditor.focus();
			}else if(sector==2){
					sector_1.style.display = 'block';
					sector_2.style.display = 'none';
				
				if (sector_1.chk != 1){
					KnEditor.document.body.innerText = KnEditor.document.body.innerHTML;
					sector_1.chk = 1;
					sector_2.chk = 0;
				}
				
				KnEditor.focus();
			}else if(sector==3){
				if (sector_2.chk != 1){
					sector_1.style.display = 'none';
					sector_2.style.display = 'block';
				
					if (sector_1.chk==0){
						sector_1.chk = 0;
						preview.document.open();
							preview.document.writeln("\n<html>\n<head>\n"+innerHeader+"</head>\n<body>\n");
							preview.document.writeln(KnEditor.document.body.innerHTML);
						preview.document.close("</body>\n</html>\n");
					}else{
						sector_1.chk = 1;
						preview.document.open();
							preview.document.writeln("\n<html>\n<head>\n"+innerHeader+"</head>\n<body>\n");
							preview.document.writeln(KnEditor.document.body.innerText);
							preview.document.writeln("</body>\n</html>\n");
						preview.document.close();
					}
	
					sector_2.chk = 1;
				}
				preview.focus();
			}
		}
		
		if (cname!=''){
			obj.className = cname;
		}
	}
	function form_chk(){
		form_obj = document.forms[0];
		
		var KNEditor_value = KnEditor.document.body.innerHTML;
		
		if (KNEditor_value==''){
			alert('³»¿ëÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä...');
			KnEditor.focus();
		}else{		
			form_obj.submit();
		}
	}
	
	function form_reset(){
		KnEditor.document.body.innerHTML = '';
	}
	
	
	function Content_set(sss){
		KnEditor.document.body.innerHTML = sss;
	}

document.write("<div id='ColorBox' style='position:absolute;visibility:hidden;left:200;top:100;'></div>");
document.write("<div id='imgLinkBox' style='position:absolute;visibility:hidden;left:200;top:100;'></div>");
