/*
[ 첨부 ] - 글쓴이 : 지우 [ 감사합니다. ]
http://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=48766&sca=&sfl=wr_subject%7C%7Cwr_content&stx=%C0%A7%C1%F6%C0%A8&sop=and


// : 추가작업 [ 업로드작업 ]
작업자 : Netk
*/
// : 만약 이 함수를 두번 부르게 되면 위지윅이 2개가 나오기 때문에 이렇게 했음.
if(!wysiwyg) {
	var wysiwyg = function() {

		//~~~~~~~~~~~~~~~~~~~~~~~~
		// 전역변수
		this.textareaName = new Array(); //type이 "editor"인 textarea 배열
		this.replace = domain+'wysiwyg/';
		this.temp_photo = new Array(); // 이미지 모음 - 예) temp_photo[content1][0] = [aa.gif, 하하.gif, 0.1]; (content1:name명, aa.gif:업로드이미지, 하하.gif:원본이미지명, 0.1:이미지크기)
		this.max_photo_count = 20;
		this.temp_photo_size = 0;
		//~~~~~~~~~~~~~~~~~~~~~~~~


		// : 테스트테스트 왜 {}로 하면 값이 더 늘어나는가..ㅠ
		this.testtest = function() {
			var ddd = {'a':{'a':['에이','A'],'b':['비','B']},'b':{'c':['에이','C'],'d':['비','D']}};
			for(x in ddd) {
				alert(x+"@"+ddd[x]);
			}
		};


		// : 기타 함수
		// : type값 : photo:이미지
		this.etc_func = function(type, num) {
			var textarea = this.textareaName[num];
			switch(type) {
				// : 이미지 업로드 창 열기
				case "photo":
					window.open(this.replace+'upload_box.php?num='+num+"&textarea="+textarea, 'wysiwyg_upload', 'width=500,height=500,status=yes,scrollbars=yes');
					break;
			}
		};

		// : 위지윅 업로드된거 선택하기
		this.photo_select = function(el) {
			var check = el.getAttribute("check");
			switch(check) {
				case "yes":
					el.style.border = '2px solid #000000';
					el.setAttribute("check","no");
					break;
				default:
					el.style.border = '2px solid red';
					el.setAttribute("check","yes");
					break;
			}
		};


		// : 업로드갯수와 업로드사이즈 값 계산
		// : obj의 값, sizeTag나 countTag의 객체값은 이 함수 사용시 불러와야합니다. [ 현재값인지 opener값인지, parent값인지, 현재페이지인지 모르기 때문 ]
		this.photo_size_count_calc = function(obj, sizeTag, countTag) {
			var photo_size_total = 0;
			var count = 0;
			while(count<obj.length) {
				photo_size_total += obj[count][2]*100;
				count++;
			}
			sizeTag.innerHTML = photo_size_total/100;
			countTag.innerHTML = obj.length;
		};


		// : 위지윅 업로드후 업로드페이지에 붙이기 [ 사이즈계산및 업로드갯수도 나타냅니다. ]
		this.photo_regist_after = function(num, msg, text, size) {
			var photo_size_total = 0;
			var photo_replace = document.getElementById("photo_replace");
			var use_photo_count = document.getElementById("use_photo_count");
			var use_photo_size = document.getElementById("use_photo_size");
			use_photo_size.innerHTML = '';

			if(!wysiwyg.temp_photo[num]) wysiwyg.temp_photo[num] = new Array();
			var count = wysiwyg.temp_photo[num].length;
			wysiwyg.temp_photo[num][count] = [msg, text, size];

			wysiwyg.photo_size_count_calc(wysiwyg.temp_photo[num], use_photo_size, use_photo_count);
			photo_replace.innerHTML += '<img src="'+this.replace+'attach_temp/'+msg+'" width="100" height="80" style="border:2px solid #000000;margin:2px" id="photo_view[]" name="photo_view[]" onClick="wysiwyg.photo_select(this)" check="no">';
		};


		// : 위지윅에 업로드된 이미지 삭제하기. [ 업로드박스에서만 사용하는 기능입니다. ]
		this.upload_delete = function(num) {
			var photo_view = document.getElementsByName('photo_view[]');
			var count = 0;
			var count2 = 0;
			while(count<photo_view.length) {
				var check = photo_view[count].getAttribute("check");
				if(check=='yes') count2++;
				count++;
			}

			if(!photo_view || photo_view.length<=0) {
				alert("업로드된 이미지가 있어야 삭제가 가능합니다.");
				return;
			}

			if(count2<=0) {
				alert("삭제할 이미지를 선택해주시기 바랍니다.");
				return;
			}

			if(confirm("선택한 이미지를 삭제하시겠습니까?")) {
				var use_photo_count = document.getElementById("use_photo_count");
				var use_photo_size = document.getElementById("use_photo_size");
				var temp_photo = wysiwyg.temp_photo[num];
				var remove_tag = new Array();
				wysiwyg.temp_photo[num] = new Array();
				count = 0;
				count2 = 0;

				// : 이미지 배열속의 값 삭제하기
				while(count<photo_view.length) {
					check = photo_view[count].getAttribute("check");
					if(check=='yes') {
						remove_tag[count] = count;
					} else {
						wysiwyg.temp_photo[num][count2] = temp_photo[count];
						count2++;
					}
					count++;
				}

				// : 이미지 사라지게 하기
				count = 0;
				count2 = 0;
				while(count<remove_tag.length) {
					if(remove_tag[count]>=0) {
						photo_view[count2].parentNode.removeChild(photo_view[count2]);
						count2--;
					}
					count++;
					count2++;
				}

				// : 갯수와 사이즈 재조정
				wysiwyg.photo_size_count_calc(wysiwyg.temp_photo[num], use_photo_size, use_photo_count);
			}
		};


		// : 위지윅 이미지 붙이기
		this.photo_submit = function(num) {
			try{
				if(confirm("본문에 적용하시겠습니까?")) {
					var textarea = opener.wysiwyg.textareaName[num];
					var wysiwyg_upload_img = opener.document.getElementsByName("wysiwyg_upload_img[]");
					var wysiwyg_upload_text = opener.document.getElementsByName("wysiwyg_upload_text[]");
					var temp_photo = wysiwyg.temp_photo[num];
					var opener_content = opener.document.getElementById('iframe'+textarea).contentWindow;
					opener_content.focus();
					for(var i=0; i<temp_photo.length; i++) {
						if(temp_photo[i][0]) {
							var img_paste = '<div style="float:clean;"><img src="'+wysiwyg.replace+'attach_temp/'+temp_photo[i][0]+'" id="'+textarea+'_wysiwyg[]" name="'+textarea+'_wysiwyg[]"></div>';
							// : 익스명령어
							if(window.attachEvent) {
								var sText = opener_content.document.selection.createRange();
								opener_content.document.body.innerHTML += img_paste;
							// : 파이어폭스 명령어
							} else {
								var span = document.createElement("span");
								span.innerHTML = img_paste;
								opener_content.document.body.innerHTML += img_paste;
							}
							wysiwyg_upload_img[num].value += temp_photo[i][0]+'/';
							wysiwyg_upload_text[num].value += temp_photo[i][1]+'/';
						}
					}
					opener.wysiwyg.copyTohtml();
					//opener.wysiwyg.copyToeditor();
					window.close();
				}
				return false;
			} catch(e) {
				alert(e.message);
			}
		};


		//함수
		this.htmledit = function(excute, bool, value, num) {
			if(navigator.appName != "Microsoft Internet Explorer" && excute=="backcolor") excute = "hilitecolor";
			if(excute=="createlink") document.getElementById('iframe'+wysiwyg.textareaName[num]).contentWindow.document.execCommand(excute, bool);
			else document.getElementById('iframe'+wysiwyg.textareaName[num]).contentWindow.document.execCommand(excute, bool, value);
			document.getElementById('fontfaceLayer'+num).style.display = "none";
			document.getElementById('fontsizeLayer'+num).style.display = "none";
			document.getElementById('fgLayer'+num).style.display = "none";
			document.getElementById('bgLayer'+num).style.display = "none";
			document.getElementById('wyg_tablePyo'+num).style.display = "none";
			wysiwyg.copyTohtml();
			document.getElementById('iframe'+wysiwyg.textareaName[num]).contentWindow.focus();
		};


		this.viewLayer = function(el, num, layerId) {

			var _offset = jQuery(el).position();
			var x = _offset.left;
			var y = _offset.top;

			if(layerId) {
				var layerLeng = layerId.length;
				var numLeng = num.length;
				var layerName = layerId.substr(0, layerLeng-numLeng); 
				switch(layerName) {
					case "wyg_tablePyo":
						wysiwyg.table_pyo(num);
						break;
				}
			}

			document.getElementById('fontfaceLayer'+num).style.display = "none";
			document.getElementById('fontsizeLayer'+num).style.display = "none";
			document.getElementById('fgLayer'+num).style.display = "none";
			document.getElementById('bgLayer'+num).style.display = "none";
			document.getElementById('wyg_tablePyo'+num).style.display = "none";
			if(layerId) document.getElementById(layerId).style.display = "inline";
			if(layerId) document.getElementById(layerId).style.left = x+'px';
			if(layerId) document.getElementById(layerId).style.top = (y + 18)+'px';
			//if(layerId) document.getElementById(layerId).focus();
		};


		// : 기본값이 있을때 등록시 기본값그대로인경우 내용 삭제하기
		this.contentModify = function(el, num) {
			var editor_content = document.getElementsByName("editor_content[]");
			var textareaOrg = document.getElementsByName(this.textareaName[num])[0];
			var editor_content_count = textareaOrg.getAttribute("editor_content_count");
			var add_message = editor_content[editor_content_count].innerHTML;
			if(add_message==textareaOrg.value) {
				var doc = document.getElementById("iframe"+this.textareaName[num]).contentWindow.document;
				var docBody = doc.getElementsByTagName("body")[0];
				docBody.innerHTML = "";
			}
		}

		// : 내용 위지윅에 붙이기
		this.wyg_set_content = function(id, content) {
			var doc = document.getElementById("iframe"+id).contentWindow.document;
			var docBody = doc.getElementsByTagName("body")[0];
			docBody.innerHTML = content;
		}


		this.viewSource = function(elmId,elmName, num) {
			document.getElementById(elmId).style.display = "none";
			document.getElementsByName(elmName)[0].style.display = "inline";
			document.getElementById('viewSourceBtn'+num).style.display = "none";
			document.getElementById('viewEdirorBtn'+num).style.display = "inline";
			var textarea = document.getElementById(elmId).contentWindow.document.body.innerHTML.replace(/P>/mg,"BR> ");
			//var textarea = textarea.replace(/<BR>/mg,"");
			document.getElementsByName(elmName)[0].value = textarea.replace(/<\/BR>/mg,"<BR> ");
		};


		this.viewEdiror = function(elmId,elmName, num) {
			document.getElementById(elmId).style.display = "inline";
			document.getElementsByName(elmName)[0].style.display = "none";
			document.getElementById('viewSourceBtn'+num).style.display = "inline";
			document.getElementById('viewEdirorBtn'+num).style.display = "none";
			//document.getElementById(elmId).contentWindow.document.body.innerHTML = document.getElementsByName(elmName)[0].value.replace(/BR>/mg,"P>");
		};


		this.copyTohtml = function() {
			for (var i=0;i<wysiwyg.textareaName.length;i++){
				var textarea = document.getElementById('iframe'+wysiwyg.textareaName[i]).contentWindow.document.body.innerHTML.replace(/P>/mg,"BR> ");
				//var textarea = textarea.replace(/<BR>/mg,""); // - 
				document.getElementsByName(wysiwyg.textareaName[i])[0].value = textarea.replace(/<\/BR>/mg,"<BR> ");
			}
		};


		this.copyToeditor = function() {
			for (var i=0;i<wysiwyg.textareaName.length;i++){
				document.getElementById("iframe"+wysiwyg.textareaName[i]).contentWindow.document.body.innerHTML = document.getElementsByName(wysiwyg.textareaName[i])[0].value;
			}
		};


		// : 테이블 표 표현하기
		this.table_pyo = function(num) {
			var pyo_leng = [10, 10];
			var wyg_tablePyo = document.getElementById("wyg_tablePyo"+num);
			var table_is = wyg_tablePyo.getElementsByTagName("table");
			wysiwyg.table_pyo_mouseover(num, -1, -1);
			if(table_is.length>0) return;

			var tblObj = document.createElement("table");
			tblObj.className = "wyg_tablePyo_table";
			tblObj.border = "0";
			tblObj.style.width = "150px";
			tblObj.align = "center";
			tblObj.style.marginTop = "10px";
			tblObj.cellSpacing = "0";
			tblObj.cellPadding = "1";
			tblObj.bgColor = "#bbbbbb";

			for(var i=0; i<pyo_leng[0]; i++) {
				var tr = tblObj.insertRow(-1);
				tr.bgColor = "#ffffff";
				tr.align = "center";
				for(var j=0; j<pyo_leng[1]; j++) {
					var td = tr.insertCell(-1);
					td.className = "point_check";
					td.onmouseover = new Function("wysiwyg.table_pyo_mouseover("+num+", "+i+", "+j+");");
					td.onclick = new Function("wysiwyg.table_pyo_onclick("+num+", "+i+", "+j+");");
					td.style.width = "15px";
					td.style.height = "15px";
				}
			}

			var divObj = document.createElement("div");
			divObj.setAttribute("id", "wyg_tablePyo_div");
			divObj.setAttribute("name", "wyg_tablePyo_div");
			divObj.style.backgroundColor = "#ffffff";
			divObj.align = "center";
			divObj.style.height = "20px";

			wyg_tablePyo.appendChild(tblObj);
			wyg_tablePyo.appendChild(divObj);
		};

		// : 테이블 표 mouseover
		this.table_pyo_mouseover = function(num, i, j) {

			var wyg_tablePyo = document.getElementById("wyg_tablePyo"+num);
			var tableObj = wyg_tablePyo.getElementsByTagName("table")[0];
			if(tableObj) {
				var wyg_tablePyo_div = document.getElementById("wyg_tablePyo_div");
				var trObj = tableObj.getElementsByTagName("tr");
				var trLeng = trObj.length;
				var count = 0;
				for(var ii=0; ii<trLeng; ii++) {
					var tr = trObj[ii];
					var tdObj = tr.getElementsByTagName("td");
					var tdLeng = tdObj.length;
					for(var jj=0; jj<tdLeng; jj++) {
						var td = tdObj[jj];
						td.style.backgroundColor = (jj<=j && ii<=i) ? '#ccffff' : '';
					}
				}

				wyg_tablePyo_div.innerHTML = (j+1)+' X '+(i+1);
			}
		}

		this.table_pyo_onclick = function(num, i, j) {
			var divObj = document.createElement("div");
			var tblObj = document.createElement("table");
			tblObj.className = 'wyg_table_user_view';
			tblObj.border = "0";
			tblObj.style.width = "100%";
			tblObj.align = "center";
			tblObj.style.marginTop = "10px";
			tblObj.cellSpacing = "1";
			tblObj.cellPadding = "1";
			tblObj.bgColor = "#bbbbbb";

			for(var ii=0; ii<=i; ii++) {
				var tr = tblObj.insertRow(-1);
				tr.bgColor = "#ffffff";
				tr.align = "center";
				for(var jj=0; jj<=j; jj++) {
					var td = tr.insertCell(-1);
					td.style.height = "30px";
				}
			}
			divObj.appendChild(tblObj);

			var iframeObj = document.getElementById('iframe'+wysiwyg.textareaName[num]).contentWindow.document.body
			iframeObj.appendChild(divObj);

			wysiwyg.copyTohtml();
			document.getElementById('wyg_tablePyo'+num).style.display = "none";
		}


		// : 위지윅 수정시 내용에 담겨있던 이미지들 모음.
		this.update_before_img_check = function(text_value) {
			var img_arr = new Array();
			var text_value_arr = text_value.split(this.replace+'attach/');
			var len = text_value_arr.length;
			var count = 0;
			var chk_count = 0;
			do{
				var img_check = text_value_arr[count].indexOf('">');
				var img_value = text_value_arr[count].substr(0, img_check);
				if(img_check!=-1) {
					img_arr[chk_count] = img_value;
					chk_count++;
				}
				count++;
			}while(count<len);

			if(img_arr) return img_arr.join(",");
		};



		// : 위지윅 시작
		// : name값이 editor_content[]이게 있어야 기본정보를 담을 수 있습니다.
		// : editor_content의 키값은 textarea태그에 editor_content_count값과 맞을때만 적용됩니다.
		this.createELM = function() {

			var editor_content = document.getElementsByName("editor_content[]");
			var editor_content_len = editor_content.length;

			var left1 = (navigator.appName == "Microsoft Internet Explorer")?"13px":"9px"; //화면에 따라 약간씩 정해줘야해요..(IE:FireFox)
			var left2 = (navigator.appName == "Microsoft Internet Explorer")?"53px":"49px"; //화면에 따라 약간씩 정해줘야해요..(IE:FireFox)
			var left3 = (navigator.appName == "Microsoft Internet Explorer")?"179px":"175px"; //화면에 따라 약간씩 정해줘야해요..(IE:FireFox)
			var left4 = (navigator.appName == "Microsoft Internet Explorer")?"197px":"193px"; //화면에 따라 약간씩 정해줘야해요..(IE:FireFox)
			var c = 0;
			var textareaObj = document.getElementsByTagName('textarea');
			for (var i=0;i<textareaObj.length;i++){
				if(textareaObj[i].getAttribute("type")=="editor"){
					this.textareaName[c] = textareaObj[i].getAttribute("name");
					var editor_content_count = textareaObj[i].getAttribute("editor_content_count");
					if(editor_content_len>0 && editor_content_count) textareaObj[i].value = editor_content[editor_content_count].innerHTML;
					c++;
				}
			}

			for (var i=0;i<this.textareaName.length;i++){
				var textareaOrg = document.getElementsByName(this.textareaName[i])[0];
				var editor_content_count = textareaOrg.getAttribute("editor_content_count");
				
				//아이프레임생성
				var editorFrameObj = document.createElement("iframe");
				if(editor_content_len>0 && editor_content_count) editorFrameObj.onfocus = new Function("wysiwyg.contentModify(this, '"+i+"')");
				editorFrameObj.setAttribute("id","iframe"+this.textareaName[i]);
				editorFrameObj.setAttribute("scrolling","yes");
				editorFrameObj.setAttribute("frameBorder","no");
				editorFrameObj.setAttribute("wrap","virtual");
				editorFrameObj.style.width = textareaOrg.style.width;
				editorFrameObj.style.height = textareaOrg.style.height;
				editorFrameObj.style.border = "1px solid #D0D0D0";
				editorFrameObj.style.borderTop = "0px";
				editorFrameObj.frameborder = "0";
				editorFrameObj.onmouseover = new Function("wysiwyg.viewLayer(this, '"+i+"');");
				textareaOrg.parentNode.insertBefore(editorFrameObj,textareaOrg);

				var doc = document.getElementById("iframe"+this.textareaName[i]).contentWindow.document;
				doc.open(); 
				doc.write('<html><head>');
				doc.write('<link rel="stylesheet" type="text/css" href="'+this.replace+'wysiwyg.css?time=2"/>');
				doc.write('</head><body bgcolor="#FFFFFF">'+textareaOrg.value+'</body></html>'); 
				doc.close(); 
				doc.designMode = "on";
				textareaOrg.style.backgroundColor="#F0F0F0";
				textareaOrg.style.color="#336699";
				textareaOrg.style.fontSize="9pt";
				textareaOrg.style.fontFamily="Tahoma";
				textareaOrg.style.display="none";


				// : 이전에 등록된 위지윅 이미지 모음 [ 수정시에 사용합니다. ] - 이 함수 마지막에 이식해줍니다.
				// : 이걸 하는 이유는 내용 수정할때 이전에 저장된 위지윅 이미지가 없으면 삭제하기 위해서입니다.
				var before_img_value = this.update_before_img_check(textareaOrg.value);
				var before_img_divObj = document.createElement("div");
				var before_imgObj = document.createElement("input");
				before_imgObj.type = "hidden";
				before_imgObj.Name = "before_wysiwyg_image_"+this.textareaName[i];
				before_imgObj.value = before_img_value;
				before_img_divObj.appendChild(before_imgObj);


				// 이벤트 처리(내용 상호복제 부분)
				if(document.addEventListener){
					doc.addEventListener("mousedown", this.copyTohtml, false);
					doc.addEventListener("blur", this.copyTohtml, false);
					textareaOrg.addEventListener("mousedown", this.copyToeditor, false);
					textareaOrg.addEventListener("blur", this.copyToeditor, false);
				}else if(document.attachEvent){
					doc.attachEvent("onmousedown", this.copyTohtml, false);
					document.getElementById("iframe"+this.textareaName[i]).attachEvent("onblur", this.copyTohtml, false);
					textareaOrg.attachEvent("onmousedown", this.copyToeditor, false);
					textareaOrg.attachEvent("onblur", this.copyToeditor, false);
				}

				//도구테이블생성 -- [ wysiwyg_upload_~~]은 업로드이미지 값을 저장하기 위한 공간입니다.
				//position:absolute;margin-top:-32px;margin-left:-3px;
				var ctrlObj  = '<table width="'+textareaOrg.style.width+'" cellspacing="0" cellpadding="0" border="0" class="ml7 wyg_table_menu_table">';
				ctrlObj += ' <td height="27" style="border:0px;"> ';
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_fontface.gif\" class=\"vm\" border=\"0\" alt=\"글꼴\" onClick=\"wysiwyg.viewLayer(this, '"+i+"', 'fontfaceLayer"+i+"');\"> ";
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_fontsize.gif\" class=\"vm\" border=\"0\" alt=\"크기\" onClick=\"wysiwyg.viewLayer(this, '"+i+"', 'fontsizeLayer"+i+"');\"> ";
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_virtical.gif\" class=\"vm\"> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('bold', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_format_bold.gif\" class=\"vm\" border=\"0\" alt=\"두꺼운체\"></A> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('italic', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_format_italic.gif\" class=\"vm\" border=\"0\" alt=\"기울림체\"></A> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('underline', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_format_underline.gif\" class=\"vm\" border=\"0\" alt=\"밑줄\"></A> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('StrikeThrough', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_format_strike.gif\" class=\"vm\" border=\"0\" alt=\"취소선\"></A> ";
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_virtical.gif\" class=\"vm\"> ";
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_color_fg.gif\" class=\"vm\" border=\"0\" alt=\"글자색상\" onClick=\"wysiwyg.viewLayer(this, '"+i+"', 'fgLayer"+i+"');\"> ";
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_color_bg.gif\" class=\"vm\" border=\"0\" alt=\"글자색상\" onClick=\"wysiwyg.viewLayer(this, '"+i+"', 'bgLayer"+i+"');\"> ";
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_virtical.gif\" class=\"vm\"> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('justifyleft', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_align_left.gif\" class=\"vm\" border=\"0\" alt=\"좌측정렬\"></a> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('justifycenter', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_align_center.gif\" class=\"vm\" border=\"0\" alt=\"중심정렬\"></a> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('justifyright', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_align_right.gif\" class=\"vm\" border=\"0\" alt=\"우측정렬\"></a> ";
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_virtical.gif\" class=\"vm\"> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('insertorderedlist', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_list_number.gif\" class=\"vm\" border=\"0\" alt=\"숫자목록\"></a> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('insertunorderedlist', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_list_dot.gif\" class=\"vm\" border=\"0\" alt=\"점표시목록\"></a> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('outdent', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_format_outdent.gif\" class=\"vm\" border=\"0\" alt=\"들여쓰기줄이기\"></a> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('indent', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_format_indent.gif\" class=\"vm\" border=\"0\" alt=\"들여쓰기늘이기\"></a> ";
				ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_virtical.gif\" class=\"vm\"> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.etc_func('photo', '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_upload.gif\" border=\"0\" alt=\"이미지업로드\" class=\"vm\"></a> ";
				ctrlObj += " 	<A href=\"javascript:javascript:void(0)\"><img src=\""+this.replace+"editor_images/ed_pyo.gif\" border=\"0\" alt=\"표\" class=\"vm\" onClick=\"wysiwyg.viewLayer(this, '"+i+"', 'wyg_tablePyo"+i+"')\"></a> ";
				ctrlObj += " 	<A href=\"javascript:javascript:void(0)\"><img src=\""+this.replace+"editor_images/ed_link.gif\" border=\"0\" alt=\"링크\" class=\"vm\" onClick=\"wysiwyg.htmledit('createlink', false, '', '"+i+"')\"></a>";
				//ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('InsertHorizontalRule', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_hr.gif\" class=\"vm\" border=\"0\" alt=\"한줄넣기\"></a> ";
				//ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_virtical.gif\" class=\"vm\"> ";
				ctrlObj += " 	<A href=\"javascript:wysiwyg.htmledit('removeformat', false, null, '"+i+"');\"><img src=\""+this.replace+"editor_images/ed_reset.gif\" class=\"vm\" border=\"0\" alt=\"태그제거\"></a> ";
				//ctrlObj += " 	<img src=\""+this.replace+"editor_images/ed_virtical.gif\" class=\"vm\"> ";
				ctrlObj += " 	<img id=\"viewEdirorBtn"+i+"\" src=\""+this.replace+"editor_images/ed_editor.gif\" class=\"vm\" border=\"0\" alt=\"편집화면\" style=\"display:none\" onClick=\"wysiwyg.viewEdiror('iframe"+this.textareaName[i]+"','"+this.textareaName[i]+"', '"+i+"');\"> ";
				ctrlObj += " 	<img id=\"viewSourceBtn"+i+"\" src=\""+this.replace+"editor_images/ed_html.gif\" class=\"vm\" border=\"0\" alt=\"소스보기\" style=\"display:inline\" onClick=\"wysiwyg.viewSource('iframe"+this.textareaName[i]+"','"+this.textareaName[i]+"', '"+i+"');\"> ";
				//ctrlObj += " 	<br> ";
				ctrlObj += " 	<div id=\"fontfaceLayer"+i+"\" style=\"position:absolute; width:70px; border:1px solid #999999; left:"+left1+"; display:none;\"> ";
				ctrlObj += " 		<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bgcolor=\"#ffffff\"> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, '돋움', '"+i+"');\">돋움</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, '굴림', '"+i+"');\">굴림</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, '바탕', '"+i+"');\">바탕</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, '궁서', '"+i+"');\">궁서</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, 'Malgun Gothic', '"+i+"');\">맑은고딕</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, 'Arial', '"+i+"');\">Arial</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, 'Tahoma', '"+i+"');\">Tahoma</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, 'Verdana', '"+i+"');\">Verdana</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontname', false, 'Time', '"+i+"');\">Time</td></tr> ";
				ctrlObj += " 		</table> ";
				ctrlObj += " 	</div> ";
				ctrlObj += " 	<div id=\"fontsizeLayer"+i+"\" style=\"position:absolute; width:38px; border:1px solid #999999; left:"+left2+"; display:none;\"> ";
				ctrlObj += " 		<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bgcolor=\"#ffffff\"> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontsize', false, 1, '"+i+"');\">1</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontsize', false, 2, '"+i+"');\">2</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontsize', false, 3, '"+i+"');\">3</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontsize', false, 4, '"+i+"');\">4</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontsize', false, 5, '"+i+"');\">5</td></tr> ";
				ctrlObj += " 		<tr onmouseover=\"this.style.backgroundColor='#E0E0E0'\" onmouseout=\"this.style.backgroundColor=''\"><td style=\"border:0px;padding-left:3px;\" onmousedown=\"wysiwyg.htmledit('fontsize', false, 6, '"+i+"');\">6</td></tr> ";
				ctrlObj += " 		</table> ";
				ctrlObj += " 	</div> ";
				ctrlObj += " 	<div id=\"fgLayer"+i+"\" style=\"position:absolute; width:160px; height:75px; border:1px solid #999999; left:"+left3+"; display:none;\"> ";
				ctrlObj += " 		<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bgcolor=\"#ffffff\"> ";
				ctrlObj += " 		<td style='border:0px;'> ";
				ctrlObj += " 			<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" bordercolor=\"#000000\" style=\"border-collapse:collapse; margin:7px;\"> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FE1100\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FE1100', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FE4C24\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FE4C24', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FE875A\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FE875A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FECDA7\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FECDA7', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#040967\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#040967', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#2D328D\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#2D328D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#44499A\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#44499A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#686EB8\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#686EB8', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#669900\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#669900', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#66CC00\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#66CC00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#99FF00\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#99FF00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FF99FF\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FF99FF', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#6E0017\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#6E0017', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#7B243D\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#7B243D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#834C6B\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#834C6B', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#66FFFF\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#66FFFF', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#006BD4\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#006BD4', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#0087E1\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#0087E1', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#37B7FE\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#37B7FE', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#A7DEFE\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#A7DEFE', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FFCC00\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FFCC00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FFFF00\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FFFF00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FEFE9F\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FEFE9F', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FEFED0\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FEFED0', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#4E003D\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#4E003D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#6D2262\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#6D2262', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#926594\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#926594', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#C2A9C5\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#C2A9C5', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#005557\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#005557', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#03747B\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#03747B', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#579D9F\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#579D9F', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#A2C6CC\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#A2C6CC', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FF6600\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FF6600', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FF9933\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FF9933', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FECD8A\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FECD8A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FEE2B0\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FEE2B0', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#1B0B73\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#1B0B73', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#4C379D\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#4C379D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#876EBA\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#876EBA', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#BBBAEF\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#BBBAEF', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#008E37\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#008E37', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#26B168\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#26B168', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#47BE80\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#47BE80', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#76D3A2\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#76D3A2', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#B31C00\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#B31C00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#B03F21\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#B03F21', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#AE623A\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#AE623A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#AC6E54\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#AC6E54', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FEFEFE\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#FEFEFE', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#E6E6E6\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#E6E6E6', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#CDCDCD\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#CDCDCD', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#B4B4B4\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#B4B4B4', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#A8A8A8\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#A8A8A8', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#8D8D8D\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#8D8D8D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#747474\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#747474', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#595959\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#595959', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#4B4B4B\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#4B4B4B', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#303030\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#303030', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#0A0A0A\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#0A0A0A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#000000\" onmousedown=\"wysiwyg.htmledit('forecolor', false, '#000000', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			</table> ";
				ctrlObj += " 			</td> ";
				ctrlObj += " 		</table> ";
				ctrlObj += " 	</div> ";
				ctrlObj += " 	<div id=\"bgLayer"+i+"\" style=\"position:absolute; width:160px; height:75px; border:1px solid #999999; left:"+left4+"; display:none;\"> ";
				ctrlObj += " 		<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bgcolor=\"#ffffff\"> ";
				ctrlObj += " 		<td style='border:0px;'> ";
				ctrlObj += " 			<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" bordercolor=\"#000000\" style=\"border-collapse:collapse; margin:7px;\"> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FE1100\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FE1100', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FE4C24\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FE4C24', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FE875A\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FE875A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FECDA7\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FECDA7', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#040967\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#040967', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#2D328D\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#2D328D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#44499A\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#44499A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#686EB8\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#686EB8', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#669900\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#669900', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#66CC00\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#66CC00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#99FF00\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#99FF00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FF99FF\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FF99FF', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#6E0017\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#6E0017', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#7B243D\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#7B243D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#834C6B\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#834C6B', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#66FFFF\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#66FFFF', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#006BD4\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#006BD4', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#0087E1\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#0087E1', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#37B7FE\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#37B7FE', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#A7DEFE\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#A7DEFE', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FFCC00\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FFCC00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FFFF00\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FFFF00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FEFE9F\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FEFE9F', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FEFED0\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FEFED0', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#4E003D\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#4E003D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#6D2262\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#6D2262', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#926594\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#926594', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#C2A9C5\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#C2A9C5', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#005557\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#005557', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#03747B\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#03747B', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#579D9F\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#579D9F', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#A2C6CC\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#A2C6CC', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FF6600\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FF6600', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FF9933\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FF9933', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FECD8A\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FECD8A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FEE2B0\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FEE2B0', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#1B0B73\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#1B0B73', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#4C379D\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#4C379D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#876EBA\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#876EBA', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#BBBAEF\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#BBBAEF', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#008E37\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#008E37', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#26B168\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#26B168', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#47BE80\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#47BE80', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#76D3A2\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#76D3A2', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#B31C00\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#B31C00', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#B03F21\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#B03F21', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#AE623A\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#AE623A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#AC6E54\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#AC6E54', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			<tr height=\"11\"> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#FEFEFE\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#FEFEFE', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#E6E6E6\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#E6E6E6', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#CDCDCD\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#CDCDCD', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#B4B4B4\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#B4B4B4', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#A8A8A8\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#A8A8A8', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#8D8D8D\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#8D8D8D', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#747474\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#747474', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#595959\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#595959', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#4B4B4B\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#4B4B4B', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#303030\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#303030', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#0A0A0A\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#0A0A0A', '"+i+"');\"></td> ";
				ctrlObj += " 			<td style='border:0px;' width=\"11\" bgcolor=\"#000000\" onmousedown=\"wysiwyg.htmledit('backcolor', false, '#000000', '"+i+"');\"></td> ";
				ctrlObj += " 			</tr> ";
				ctrlObj += " 			</table> ";
				ctrlObj += " 			</td> ";
				ctrlObj += " 		</table> ";
				ctrlObj += " 	</div> ";
				ctrlObj += " 	<div id=\"wyg_tablePyo"+i+"\" style=\"position:absolute; width:170px; height:185px; border:1px solid #999999; background-color:#ffffff; left:"+left4+"; display:none;\"> ";
				ctrlObj += " 	</div> ";
				ctrlObj += " </td> ";
				ctrlObj += ' <td><input type="hidden" name="wysiwyg_upload_name[]" id="wysiwyg_upload_name[]" value="'+this.textareaName[i]+'"><input type="hidden" name="wysiwyg_upload_img[]" id="wysiwyg_upload_img[]" value=""><input type="hidden" name="wysiwyg_upload_text[]" id="wysiwyg_upload_text[]" value=""></div></td> ';
				//ctrlObj += " <td align=\"right\"><a href=\"javascript:PreView('"+i+"')\"><img src=\"images/btn_preview.gif\" class=\"vm\" border=\"0\" align=\"right\"></a></td> ";
				ctrlObj += " </table> ";

				var tableObj = document.createElement("table");
				tableObj.cellSpacing = 0;
				tableObj.cellPadding = 0;
				tableObj.border = 0;

				tableObj.className = "tbl_editor";
				tableObj.style.width = textareaOrg.style.width;
				tableObj.style.backgroundColor = "#eeeeee";
				tableObj.style.border = "1px solid #a6a6a6";
				if(document.all){
					var trObj = tableObj.insertRow();
					var tdObj = trObj.insertCell(); 
				}else{
					var trObj = document.createElement('tr'); 
					var tdObj = document.createElement('td');
				}
					
					tableObj.setAttribute("id","td"+this.textareaName[i]);
				if(!document.all){
					trObj.appendChild(tdObj);
					tableObj.appendChild(trObj);
				}
				editorFrameObj.parentNode.insertBefore(tableObj,editorFrameObj);
				tdObj.innerHTML = ctrlObj+before_img_divObj.innerHTML;
				//document.getElementById("asdf").innerText = tdObj.innerHTML;
			}
		};

		// : 저장하기.
		this.submit = function(el) {
			// : P테그를 br테그로 변경하기
			var count = 0;
			while(count<this.textareaName.length) {
				var ifname = 'iframe'+this.textareaName[count];
				var name = this.textareaName[count];
				if(document.getElementById(ifname).style.display!='none') {
					var textarea = document.getElementById(ifname).contentWindow.document.body.innerHTML.replace(/<P>/mg,"");
					document.getElementsByName(name)[0].value = textarea.replace(/<\/P>/mg, "<BR> ");
					document.getElementsByName(name)[0].value = document.getElementsByName(name)[0].value.replace(/<IMG id=content_wysiwyg\[\]/mg, ' <IMG id=content_wysiwyg[]');
				}
				//if(!upload_result) return false;
				count++;
			}
			return true;
		};


		// : 첨부파일 있는지 체크하기
		this.attach_is = function(name, txt, fname) {
			var form = document.forms[fname];
			var wysiwyg_upload_name = document.getElementsByName("wysiwyg_upload_name[]");
			var obj = eval('form.'+name);
			if(obj.innerHTML.indexOf(name+'_wysiwyg[]')==-1) {
				alert("게시물을 올리기 위해서는 "+txt+"에 이미지를 추가해야합니다.");
				return false;
			}
			return true;
		};
	}

	var wysiwyg = new wysiwyg();

	//함수 끝
	if(window.addEventListener) window.addEventListener("load", function() { wysiwyg.createELM(); }, false);
	else if(window.attachEvent) window.attachEvent("onload", function() { wysiwyg.createELM(); });
}
