<!--
clsEditor=function(){}
clsEditor.prototype={
	ms_ : navigator.appName !="Netscape",
	mode_ : 0,
	editor_ : new Object(),
	editorDiv_ : new Object(),
	htmlDiv_ : new Object(),
	textarea_ : new Object(),
	designDiv_ : new Object(),
	uploaddir_ : "",
	style_ : "",
	height_ : "",
	editorid_ : "ykEditor",
	areaid_ : "ykEditorIfrm",
	colorchart_ : "colorChart",
	uploadDiv_ : "editorImageUploadDiv",
	font_ : ["±¼¸²","µ¸¿ò","¹ÙÅÁ","±Ã¼­","Arial","Tahoma"],
	fsize_ : [2,3,4,5,6,7],
	skin : "",
	btn_ : [
		[28,"»õ±Û","n_editor.inidoc()"],
		[21,"ÀüÃ¼¼±ÅÃ","n_editor.htmledit('selectall')"],
		[12,"±½°Ô","n_editor.htmledit('bold')"],
		[13,"ÀÌÅÅ¸¯","n_editor.htmledit('italic')"],
		[14,"¾ð´õ¶óÀÎ","n_editor.htmledit('underline')"],
		[26,"Ãë¼Ò¼±","n_editor.htmledit('strikethrough')"],
		[29,"À§Ã·ÀÚ","n_editor.htmledit('subscript')"],
		[30,"¾Æ·¡Ã·ÀÚ","n_editor.htmledit('superscript')"],
		[24,"±ÛÀÚ»ö","n_editor.colorChart('forecolor',event)"],
		[27,"¹ÙÅÁ»ö","n_editor.colorChart('backcolor',event)"],
		[25,"°¡·Î¼±","n_editor.htmledit('inserthorizontalrule')"],
		[4,"ÁÂÃøÁ¤·Ä","n_editor.htmledit('justifyleft')"],
		[5,"Áß¾ÓÁ¤·Ä","n_editor.htmledit('justifycenter')"],
		[22,"ÀüÃ¼Á¤·Ä","n_editor.htmledit('justifyfull')"],
		[7,"Á¡Ç¥½Ã¸ñ·Ï","n_editor.htmledit('insertunorderedlist')"],
		[8,"¼ýÀÚ¸ñ·Ï","n_editor.htmledit('insertorderedlist')"],
		[11,"¸µÅ©","n_editor.htmledit('createlink')"],
		[20,"¸µÅ©Áö¿ì±â","n_editor.htmledit('unlink')"],
		[17,"Å×ÀÌºí¸¸µé±â","n_editor.createTable()"],
		[23,"ÀÌ¹ÌÁö|ÇÃ·¡½Ã|µ¿¿µ»ó","n_editor.insertImage(event)"]
	],
	color_ : ['#ffffff','#e5e4e4','#d9d8d8','#c0bdbd','#a7a4a4','#8e8a8b','#827e7f','#767173',
		'#333333','#000000','#fefcdf','#fef4c4','#feed9b','#fee573','#ffed43','#f6cc0b',
		'#e0b800','#c9a601','#ad8e00','#8c7301','#ffded3','#ffc4b0','#ff9d7d','#ff7a4e',
		'#ff6600','#e95d00','#d15502','#ba4b01','#a44201','#8d3901','#ffd2d0',
		'#ffbab7','#fe9a95','#ff7a73','#ff483f','#fe2419','#f10b00','#d40a00','#940000',
		'#6d201b','#ffdaed','#ffb7dc','#ffa1d1','#ff84c3','#ff57ac','#fd1289','#ec0078',
		'#d6006d','#bb005f','#9b014f','#fcd6fe','#fbbcff','#f9a1fe','#f784fe','#f564fe',
		'#f546ff','#f328ff','#d801e5','#c001cb','#8f0197','#e2f0fe','#c7e2fe','#add5fe',
		'#92c7fe','#6eb5ff','#48a2ff','#2690fe','#0162f4','#013add','#0021b0','#d3fdff',
		'#acfafd','#7cfaff','#4af7fe','#1de6fe','#01deff','#00cdec','#01b6de','#00a0c2',
		'#0084a0','#edffcf','#dffeaa','#d1fd88','#befa5a','#a8f32a','#8fd80a','#79c101',
		'#3fa701','#307f00','#156200','#d4c89f','#daad88','#c49578','#c2877e','#ac8295',
		'#c0a5c4','#969ac2','#92b7d7','#80adaf','#9ca53b'
	],
	ini : function(html,upload_dir,Height,skin)
	{
		this.skin=(parseInt(skin)>9) ? skin : "0"+skin;
		this.height_=Height ? Height+"px" : "200px";
		this.textarea_=document.getElementById("cont");
		this.textarea_.style.width="100%";
		this.textarea_.style.height=this.height_;
		if(html){
			var editor="";
			this.uploaddir_=upload_dir;
			this.editorDiv_=document.getElementById("ykEditor");
			var div=document.createElement("div");
			editor=	"<div id='"+this.uploadDiv_+"'"+
					" style='width:300px;padding:10px;position:absolute;"+
					"background:#f9f9f9;display:none;border:1px solid #e1e1e1;'"+
					" onmousedown=_clsMouse.dragstart(this)"+
					" onmouseup=_clsMouse.dragend() onmousemove=_clsMouse.drag()></div>\r\n"+
					"<div id='"+this.colorchart_+"' style='display:none;position:absolute'"+
					" onmousedown=_clsMouse.dragstart(this) onmouseup=_clsMouse.dragend()"+
					" onmousemove=_clsMouse.drag()></div>\r\n";
			div.innerHTML=editor;
			document.body.appendChild(div);
			if(html){
				editor = "<table>\r\n"+
						"<tr>\r\n"+
						"<td>&nbsp;</td>\r\n"+
						"<td id='"+this.editorid_+"_md' style='width:80px;background:#cccccc;"+
						"padding:3px 0;cursor:pointer;text-align:center;'"+
						" onclick=n_editor.mode(0)>µðÀÚÀÎ¸ðµå</td>\r\n"+
						"<td id='"+this.editorid_+"_md' style='width:80px;cursor:pointer;text-align:center'"+
						" onclick=n_editor.mode(1)>HTML¸ðµå</td>\r\n"+
						"</tr>\r\n"+
						"</table>\r\n";
				this.editorDiv_.innerHTML=editor;
			}
			this.designDiv_=document.createElement("div");
			this.designDiv_.id="designDiv";
			this.designDiv_.name="designDiv";
			editor="<div style='background-color:#eeeeee;border-top:1px solid #cccccc;padding:3px;'>\r\n"+
				"<table>\r\n"+
				"<tr>\r\n";
				for(var i=0;i<this.btn_.length;i++)
					editor +="<td style='padding:0'><img src='/_prozn/_skin"+this.skin+
					"/_image/f/f"+this.btn_[i][0]+
					".gif' width='22' height='22' alt='"+this.btn_[i][1]+
					"' onclick="+this.btn_[i][2]+" style='cursor:pointer'></td>\r\n";
				editor +="<td style='padding-left:5px;padding-right:2px;'>\r\n"+
				"<select name='fontname' id='fontname' onchange=n_editor.htmledit('fontname')>\r\n";
				for(var i=0;i<this.font_.length;i++)
					editor +="<option value='"+this.font_[i]+"'>"+this.font_[i]+"</option>\r\n";
				editor +="</select>\r\n"+
				"</td>\r\n"+
				"<td>\r\n"+
				"<select name='fontsize' id='fontsize' onchange=n_editor.htmledit('fontsize')>\r\n";
				for(var i=0;i<this.fsize_.length;i++)
					editor += "<option value='"+this.fsize_[i]+"'>"+this.fsize_[i]+"</option>\r\n";
				editor +="</select>\r\n"+
					"</td>\r\n";
				editor += "</tr>\r\n"+
					"</table>\r\n"+
					"</div>\r\n"+
					"<iframe id='"+this.areaid_+"' name='"+this.areaid_+"'"+
					" frameborder=0 framespacing=0 border=0"+
					" style='width:100%;height:"+this.height_+";margin:0;border:1px solid #cccccc'></iframe>\r\n";
			this.designDiv_.innerHTML=editor;
			this.editorDiv_.appendChild(this.designDiv_);
			this.style_="<style>\n"+
				"body,p,div,dl,table,td{margin:1px 0;font-family:Tahoma,±¼¸²;font-size:9pt;background:#FFFFFF;}\n"+
				"table{border-collapse:collapse;}\n"+
				"table td{border:1px dotted #cccccc;}\n"+
				"div{border:1px dotted #cccccc;}\n"+
				"dl{border:1px dotted #cccccc;}\n"+
				"ul{border:1px dotted #cccccc;}\n"+
				"ol{border:1px dotted #cccccc;}\n"+
				"img{border:0;}\n"+
				"embed{border:1px dotted #FF0080;}\n"+
				"</style>\n";
			this.editor_=document.getElementById(this.areaid_).contentWindow;
			this.editor_.document.open("text/html");
			this.editor_.document.writeln(this.style_);
			this.editor_.document.writeln(document.getElementById("cont").value);
			this.editor_.document.close();
			this.editor_.document.designMode = "on";
			this.createEditor();
		}else{
			this.mode_=1;
			this.textarea_.style.display="block";
		}
	},
	inidoc : function()
	{
		this.editor_=document.getElementById(this.areaid_).contentWindow;
		this.editor_.document.open("text/html");
		this.editor_.document.writeln(this.style_);
		this.editor_.document.close();
		this.editor_.document.designMode = "on";
	},
	createEditor : function()
	{
		var colorchart=document.getElementById(this.colorchart_);
		colorchart.style.position="absolute";
		colorchart.style.width="175px";
		colorchart.style.border="1px solid #e1e1e1";
		colorchart.style.backgroundColor="#f9f9f9";
		var chart="<input type='hidden' name='chart_type' id='chart_type' />\n"+
		"<div style='text-align:right;padding:5px 15px;'>"+
		"<input type=button value='x´Ý±â' onclick=document.getElementById('"+this.colorchart_+
		"').style.display='none'; onfocus=blur() class='b0' /></div>"+
		"<div style='padding:0 10px'>";
		for(var i=0;i<this.color_.length;i++){
			if((i%10)==0 && i>0) chart += "</div><div style='padding:0 10px'>";
			chart += "<span><input type=button style='border:0;width:15px;height:15px;background-color:"+
			this.color_[i]+
			";' onclick=n_editor.selectColor("+i+") onmouseover=\"n_editor.showColorCode("+i+
			");this.style.border='1px solid #000000';\""+
			" onmouseout=\"n_editor.showColorCode("+i+
			");this.style.border='1px';\"></span>";
		}
		chart +="</div>\n"+
		"<span id='selectcolor' style='color:#333333;padding-left:10px;'>&nbsp;</span>\n";
		colorchart.innerHTML=chart;
	},
	imageUploader : function()
	{
		var f="<iframe name='IfrHidden' style='display:none'></iframe>\n"+
			"<form method='post' action='/_prozn/_system/editor/_process_upload.php' "+
			"enctype='multipart/form-data' onsubmit='return n_editor.imageUploadchk(this);'>\n"+
			"<span style='white-space:nowrap'>\n"+
			"<input type=hidden name='upload_dir' id='upload_dir' value='"+this.uploaddir_+"'>\n"+
			"<input type='file' name='img_file' accept='image/jpg'"+
			" onchange=js_cls.preview(this,document.getElementById('nf_preview')) class='f0' />\n"+
			"<input type='submit' value='µî·Ï' onfocus=blur() class='b0' />\n"+
			"<input type='button' value='´Ý±â' onclick=document.getElementById('"+this.uploadDiv_+
			"').style.display='none'; onfocus=blur() class='b0' />\n"+
			"<div id='nf_preview' style='margin:5px 0;width:100%;"+
			"background:#ffffff;height:220px;border:1px solid #c8c8c8;'></div>\n"+
			"</span>\n"+
			"</form>";
		document.getElementById(this.uploadDiv_).innerHTML=f;
	},
	imageUploaderWin : function()
	{
		var win=js_cls.openwin("/_prozn/_system/editor/upload_form.php?uploaddir="+this.uploaddir_,360,245,0,0,"no","editor_uploadwin");
	},
	imageUploadchk : function(fm)
	{
		if(document.getElementById("nf_preview").innerHTML=="") {
			alert('¾÷·ÎµåÇÒ ÀÌ¹ÌÁö¸¦ ¼±ÅÃÇÏ¼¼¿ä.       ');
			return false;
		}
		fm.target="IfrHidden";
	},
	showColorCode : function(i)
	{
		document.getElementById("selectcolor").innerHTML=this.color_[i];
	},
	htmledit : function(execute)
	{
		if(execute == 'fontname' || execute == 'fontsize') {
			var obj=document.getElementById(execute);
			var val=obj.options[obj.selectedIndex].value;
			this.editor_.document.execCommand(execute,0,val);
		}else{
			this.editor_.document.execCommand(execute);
		}	
	},
	createTable : function()
	{
		this.editor_.focus();
		var table =js_cls.openModal('/_prozn/_system/editor/c_table.php',0,280,230);
		if (table != null){
			var sel = this.editor_.document.selection.createRange();
			sel.pasteHTML(table);
			sel.select();
		}
		this.editor_.focus();
	},
	selectColor : function(colorcode)
	{
		var ctype=document.getElementById("chart_type").value;
		var sel=this.editor_.document.selection.createRange();
		sel.execCommand(ctype,0,this.color_[colorcode]);
		document.getElementById(this.colorchart_).style.display="none";
	},
	colorChart : function(ctype,e)
	{
		var evt=e || window.event;
		if(this.ms_){
			var _x=evt.x;
			var _y=evt.y;
		}else{
			var _x=evt.pageX;
			var _y=evt.pageY;
		}
		var chartDiv=document.getElementById(this.colorchart_);
		if(this.ms_){
			chartDiv.style.pixelTop=document.body.scrollTop+_y;
			chartDiv.style.pixelLeft=document.body.scrollLeft+_x;
		}else{
			chartDiv.style.top=_y.toString()+"px";
			chartDiv.style.left=_x.toString()+"px";
		}
		chartDiv.style.display="block";
		document.getElementById("chart_type").value=ctype;
	},
	insertImage : function(e)
	{
		this.imageUploaderWin();
	},
	mode : function(val)
	{
		this.mode_=val;
		var obj=document.getElementsByName(this.editorid_+"_md");
		var obj_txt=document.getElementById("cont");
		var len=obj.length;
		for(i=0;i<len;i++) {
			if(i==val) {
				obj[i].style.background='#cccccc';
				if(val==1) 
					obj_txt.style.display="block";
				else 
					this.designDiv_.style.display="none";
			} else {
				obj[i].style.background="";
				obj[i].style.color="";
			}
		}
		if(val==1) {
			var innerhtml_=this.editor_.document.body.innerHTML;
			var oRegex = this.Regex = new Object() ;
			oRegex.BlocksOpener = /\<(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|TH|AREA|OPTION)[^\>]*\>/gi ;
			oRegex.BlocksCloser = /\<\/(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|TH|AREA|OPTION)[^\>]*\>/gi ;
			oRegex.NewLineTags	= /\<(BR|HR)[^\>]*\>/gi ;
			oRegex.MainTags = /\<\/?(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR)[^\>]*\>/gi ;
			oRegex.LineSplitter = /\s*\n+\s*/g ;
			oRegex.IncreaseIndent = /^\<(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ \/\>]/i ;
			oRegex.DecreaseIndent = /^\<\/(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ \>]/i ;
			oRegex.FormatIndentatorRemove = new RegExp( '^' + '    ') ;
			oRegex.ProtectedTags = /(<PRE[^>]*>)([\s\S]*?)(<\/PRE>)/gi ;
			innerhtml_=innerhtml_.replace( this.Regex.BlocksOpener, '\n$&' ) ;
			innerhtml_=innerhtml_.replace( this.Regex.BlocksCloser, '$&\n' ) ;
			innerhtml_=innerhtml_.replace( this.Regex.NewLineTags, '$&\n' ) ;
			innerhtml_=innerhtml_.replace( this.Regex.MainTags, '\n$&\n' ) ;
			FormatIndentator='    ' ;
			var sIndentation = '' ;
			var asLines = innerhtml_.split( this.Regex.LineSplitter ) ;
			innerhtml_ = '' ;
			for ( var i = 0 ; i < asLines.length ; i++ ){
				var sLine = asLines[i] ;
				if ( sLine.length == 0 )
					continue ;
				if ( this.Regex.DecreaseIndent.test( sLine ) )
					sIndentation = sIndentation.replace( this.Regex.FormatIndentatorRemove, '' ) ;
				innerhtml_ += sIndentation + sLine + '\n' ;
				if ( this.Regex.IncreaseIndent.test( sLine ) )
					sIndentation += FormatIndentator ;
			}
			obj_txt.value=innerhtml_;
			this.designDiv_.style.display="none";
			//this.textarea_.style.background="#F9F9F9";
			//this.textarea_.style.color="#333333";
			this.textarea_.style.display="block";
		} else {
			this.editor_.document.body.innerHTML="";
			this.editor_.document.body.innerHTML=obj_txt.value;
			this.textarea_.style.display="none";
			this.designDiv_.style.display="block";
		}
	},
	editorchk :function(fm)
	{
		if(fm.no_editor_chk){
			if(fm.no_editor_chk.value==1){
				if(this.mode_==0)
					fm["cont"].value=this.editor_.document.body.innerHTML;
				return true;
			}
		}else{
			if(this.mode_==1) {
				if (!fm["cont"].value) {
					alert('³»¿ëÀ» ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.     ');
					fm["cont"].focus();
					return false;
				}
				return true;
			} else {
				if(this.editor_.document.body.innerHTML=="") {
					alert('³»¿ëÀ» ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À.       ');
					return false;
				} else {
					fm["cont"].value=this.editor_.document.body.innerHTML;
					return true;
				}
			}
		}
	}
};

n_editor=new clsEditor();
//-->
