﻿var header_html  = "<html>\n";
	header_html += "<head>\n";
	header_html += "<style type='text/css'>\n";
	header_html += "  body, tr, th, td { font-size:9pt; font-family:Tahoma,굴림; }\n";
	header_html += "  p { margin-top: 0px; margin-bottom: 0px; font-size:9pt; }\n";
	header_html += "</style>\n";
	header_html += "</head>\n";
	header_html += "<body leftmargin='0' topmargin='0' oncontextmenu='return false' onselectstart='return false' ondragstart='return false'>\n";
var content_html = "";
var footer_html  = "</body>\n";
	footer_html += "</html>\n";
var default_html = header_html + content_html + footer_html;
var isie=0; 
var browserName = navigator.appName;
var browserVersion = navigator.appVersion;
if(browserName=="Microsoft Internet Explorer" && browserVersion.substring(browserVersion.indexOf("MSIE")+5,browserVersion.indexOf("MSIE")+8)>=5.5) isie=1; 
else isie=0; 

//경로설정
imagesDir = "/Editor/Editorimages/";
UploadDir = "/upload/";
EditorDir = "/Editor/";


var edit_css = "<style type='text/css'>\n";
    edit_css += "A:link { color:#555555; text-decoration:none; font-size:9pt; } \n";
    edit_css += "A:visited { color:#555555; text-decoration:none; font-size:9pt; }\n";
    edit_css += "A:active { color:#4169e1; text-decoration:none; font-size:9pt; }\n";
    edit_css += "A:hover { color:#3333FF; text-decoration:none; font-size:9pt; }\n";
    edit_css += "body, table, tr, td, { font-size: 9pt; line-height: 14pt; font-family: 굴림; }\n";
    edit_css += "</style>";

document.write('<link rel="stylesheet" type="text/css" href="' +edit_css+ '">\n');

var Fonts = new Array();
	Fonts[0] = new Array("굴림","font-family:굴림;","");
	Fonts[1] = new Array("바탕","font-family:바탕;","");
	Fonts[2] = new Array("고딕","font-family:고딕;","");
	Fonts[3] = new Array("궁서","font-family:궁서;","");
	Fonts[4] = new Array("새굴림","font-family:새굴림;","");
	Fonts[5] = new Array("Arial","font-family:Arial;","");
	Fonts[6] = new Array("Arial Black","font-family:Arial Black;","");
	Fonts[7] = new Array("Courier New","font-family:Courier New;","");
	Fonts[8] = new Array("Tahoma","font-family:Tahoma;","");
	Fonts[9] = new Array("Times New Roman","font-family:Times New Roman;","");
	Fonts[10] = new Array("Verdana","font-family:Verdana;","");

var FontSizes = new Array();
	FontSizes[0]  = new Array("1","font-size:10px;","8pt");
	FontSizes[1]  = new Array("2","font-size:12px;","10pt");
	FontSizes[2]  = new Array("3","font-size:14px;","12pt");
	FontSizes[3]  = new Array("4","font-size:18px;","14pt");
	FontSizes[4]  = new Array("5","font-size:24px;","16pt");
	FontSizes[5]  = new Array("6","font-size:32px;","18pt");
	FontSizes[6]  = new Array("7","font-size:46px;","20pt");


var ColorTable = new Array();
	ColorTable[0]  = new Array("FFF4E2","FFFEE0","EEFAE4","F0F9E4","E6FAFB","E5EDFA","E4EEFA","F1E5F9","FCE5F5","FEE6E4","FDE5E3","FFF4E2");
	ColorTable[1]  = new Array("FEF7C3","FEF7C3","EBF6CC","D5F5CC","CDF5F5","D0E3F2","CFD5F7","E3CCF6","F6CDED","FCC5CA","FED5C3","FED5C3");
	ColorTable[2]  = new Array("FFE9A6","FDFBA6","E3F1B3","BEF0B3","B4F0F0","B3D5F1","B4BEF1","CFB1EF","EFB4E4","FEA4AE","FFC1A6","FFD5A5");
	ColorTable[3]  = new Array("FFE184","FFF987","D6EE9A","A3EB97","9BEBEA","9CC9EA","9AA9EE","C099EC","EB9BD6","FA8A96","FFAE88","FFC887");
	ColorTable[4]  = new Array("FFDA68","FFFA6A","CDE87F","94E682","82E6E4","84BAE6","8293E5","B282E6","E781CD","F86E7B","FF9A69","FEBA67");
	ColorTable[5]  = new Array("FED24B","FFFA6A","CEE97E","94E680","7AE6E8","82BBE6","8293E5","B282E6","E583CC","F86E7B","FF9A6A","FEBA69");
	ColorTable[6]  = new Array("FED24B","FFF94D","C5E465","7FE168","69E1E0","68AEE1","6A7CE2","A469E1","E169C3","FA5263","FE854C","FFAC4C");
	ColorTable[7]  = new Array("FFCB2D","FFF82C","BAE04D","6ADC50","50DCD9","3792D8","3650D9","8537D8","D637AE","F6182D","FE5D0F","FF8F0F");
	ColorTable[8]  = new Array("EFB400","F0E801","A2CB27","45C928","28C8C6","2784C7","2843C8","7527C9","C9279F","E90419","F04F01","F18000");
	ColorTable[9]  = new Array("D29D00","D2CB01","8DB31F","3EAE24","23AFAE","2373AE","243BAD","6723AE","AF238C","CB0617","D24500","D27100");
	ColorTable[10]  = new Array("967001","969101","658017","2B7D19","197D7B","19527F","192A7C","49197D","78105F","910512","973101","973101");
	ColorTable[11]  = new Array("594500","5A5600","3D4D0E","194B0E","0F4B49","0E304B","0F194C","2C0E4A","4A0F3B","58020B","591D01","5B3302");


var Zoom = new Array();
	Zoom[0]  = new Array("100","font-size:12px;font-family:굴림;","100%");
	Zoom[1]  = new Array("200","font-size:14px;font-family:굴림;","200%");
	Zoom[2]  = new Array("300","font-size:16px;font-family:굴림;","300%");
	Zoom[3]  = new Array("400","font-size:18px;font-family:굴림;","400%");
	Zoom[4]  = new Array("500","font-size:20px;font-family:굴림;","500%");

var Menu = new Array();
//	Menu[0] = new Array('New','new.jpg','새문서');//Refresh
	Menu[1] = new Array('Bold','text_bold.gif','굵게');	
	Menu[2] = new Array('Underline','text_line.gif','밑줄');
	Menu[3] = new Array('Italic','text_italic.gif','이탤릭체');
//	Menu[4] = new Array('Strikethrough','strike.jpg','중앙선');
	Menu[5] = new Array('Justifyleft','text_left.gif','왼쪽정렬');
	Menu[6] = new Array('Justifycenter','text_cen.gif','가운데정렬');
	Menu[7] = new Array('Justifyright','text_right.gif','오른쪽정렬');
//	Menu[8] = new Array('Outdent','indent_short.jpg','내어쓰기');
//	Menu[9] = new Array('Indent','indent_long.jpg','들여쓰기');	
//	Menu[10] = new Array('InsertOrderedList','num_list.jpg','번호달기');	
//	Menu[11] = new Array('InsertUnorderedList','list.jpg','글머리기호');	
	Menu[12] = new Array('CreateLink','btn_link.gif','링크첨부');
//	Menu[13] = new Array('HRline','line.jpg','분리선');
//	Menu[14] = new Array('Cut','cut.jpg','잘라내기');
//	Menu[15] = new Array('Copy','copy.jpg','복사하기');
//	Menu[16] = new Array('Paste','paste.jpg','붙여넣기');
//	Menu[17] = new Array('Undo','undo.jpg','뒤로');
//	Menu[18] = new Array('Redo','redo.jpg','앞으로');

var Now_Mode = 'Edit';

function HubEditorStart(TextareaID,Hub_Width, Hub_Height, Hub_Mode, Hub_Form){

	var ID = TextareaID;
	var Hub_Mode = Hub_Mode;
	var toolbar;
	var colortype1="F";
	var colortype2="B";

	toolbar ='<table border=0 cellpadding=0 cellspacing=0 width=100% height=100% align=left>';
	toolbar += '<tr><td align="left" height="44" valign="middle"><div id="EditorTool" style="display:none">';
	
	toolbar +='<img src="'+ imagesDir + 'source.jpg" id="HubEditor" onClick="ChangeType(this.id,\'' + ID + '\');" border="0" style="cursor:hand;" title="편집하기/소스보기">';
	
	if (Hub_Mode=="F") toolbar +='<img src="'+ imagesDir + 'btn_preview.gif" Align="AbsMiddle" id="View" onClick="ChangeType(this.id,\'' + ID + '\');" style="cursor:hand;" border="0" title="미리보기">';
	
	toolbar +='</div><div id ="EditorToolbar">';
	toolbar += '&nbsp;&nbsp;';
	toolbar += '<a href="Javascript:;" id="Layer" onClick="ShowLayer(this.id);"><img src="'+ imagesDir + 'font.gif" Align="AbsMiddle" border="0" style="cursor:hand;" title="글꼴선택"></a>';
	toolbar += '&nbsp;';
	toolbar += '<a href="Javascript:;" id="SizeLayer" onClick="ShowLayer(this.id);"><img src="'+ imagesDir + 'size.gif" Align="AbsMiddle" border="0" style="cursor:hand;" title="글자사이즈"></a>';
	toolbar += '&nbsp;&nbsp;&nbsp;&nbsp;';
	

	//if (Hub_Mode == "F") Menu.length = Menu.length; else Menu.length = "19";
	for (var i = 0; i <= 3;) {
		if (Menu[i]){
			 var MenuID = Menu[i][0];
			 var MenuIMG = Menu[i][1];
			 var MenuTitle = Menu[i][2];
			 toolbar += '<img src="'+ imagesDir + MenuIMG + '" Align="AbsMiddle" border="0" title="' + MenuTitle + '" onClick="execCmd(\''+ MenuID +'\',\'' + ID + '\');" style="cursor:hand;" >';
		}
	  i++;
    }
    
    toolbar += '&nbsp;&nbsp;&nbsp;';
    
    //if (Hub_Mode == "F") toolbar += '<a href="Javascript:;" id="ZoomLayer" onClick="ShowLayer(this.id);"><img src="'+ imagesDir + 'enlarge.gif" border="0" style="cursor:hand;" title="확대"></a>';
	if (Hub_Mode == "F"){ 
		toolbar +='<img src="'+ imagesDir + 'text_color.gif" Align="AbsMiddle" id="View" onClick="Color_Picker(\'' + ID + '\',\'' +colortype1+ '\');" border="0" style="cursor:hand;" title="글자색바꾸기">';		
		toolbar +='<img src="'+ imagesDir + 'text_bgcolor.gif" Align="AbsMiddle" id="View" onClick="Color_Picker(\'' + ID + '\',\'' +colortype2+ '\');" border="0" style="cursor:hand;" title="배경색바꾸기">';
	}
	
	toolbar += '&nbsp;&nbsp;&nbsp;&nbsp;';
	
	if (Hub_Mode == "F") Menu.length = Menu.length; else Menu.length = "19";
	for (var i = 4; i <= 7;) {
		if (Menu[i]){
			 var MenuID = Menu[i][0];
			 var MenuIMG = Menu[i][1];
			 var MenuTitle = Menu[i][2];
			 toolbar += '<img src="'+ imagesDir + MenuIMG + '" Align="AbsMiddle" border="0" title="' + MenuTitle + '" onClick="execCmd(\''+ MenuID +'\',\'' + ID + '\');" style="cursor:hand;" >';
		}
	  i++;
    }
    
    toolbar += '&nbsp;&nbsp;&nbsp;&nbsp;';
    
    if (Hub_Mode == "F") Menu.length = Menu.length; else Menu.length = "19";
	for (var i = 8; i <= Menu.length;) {
		if (Menu[i]){
			 var MenuID = Menu[i][0];
			 var MenuIMG = Menu[i][1];
			 var MenuTitle = Menu[i][2];
			 toolbar += '<img src="'+ imagesDir + MenuIMG + '" Align="AbsMiddle" border="0" title="' + MenuTitle + '" onClick="execCmd(\''+ MenuID +'\',\'' + ID + '\');" style="cursor:hand;" >';
		}
	  i++;
    }
    
    toolbar += '&nbsp;';
    
    if (Hub_Mode == "F"){ 
		toolbar +='<img src="'+ imagesDir + 'btn_img.gif" Align="AbsMiddle" id="View" onClick="Image_Insert(\'' + ID + '\',\'' + Hub_Form + '\');" border="0" style="cursor:hand;" title="이미지첨부">';
		//toolbar +='<img src="'+ imagesDir + 'flash.jpg" id="View" onClick="Flash_Insert(\'' + ID + '\');" border="0" style="cursor:hand;" title="플래쉬올리기">';
		//toolbar +='<img src="'+ imagesDir + 'movie.jpg" id="View" onClick="Media_Insert(\'' + ID + '\');" border="0" style="cursor:hand;" title="동영상올리기">';
		//toolbar +='<img src="'+ imagesDir + 'table.jpg" id="View" onClick="Table_Create(\'' + ID + '\');" border="0" style="cursor:hand;" title="테이블입력">';
	}
	toolbar += '&nbsp;';
	
	if (Hub_Mode=="F") toolbar +='<img src="'+ imagesDir + 'btn_preview.gif" Align="AbsMiddle" id="View" onClick="ChangeType(this.id,\'' + ID + '\');" style="cursor:hand;" border="0" title="미리보기">';
	toolbar += '&nbsp;';
	
	toolbar +='<img src="'+ imagesDir + 'source.jpg" id="HubEditor" Align="AbsMiddle" onClick="ChangeType(this.id,\'' + ID + '\');" border="0" style="cursor:hand;" title="편집하기/소스보기">';
	toolbar += '&nbsp;';

	

	toolbar +='</td></tr>';
	toolbar +='<tr><td>';
	toolbar += '<div id="FontsLayer" style="position:absolute; filter:revealTrans(transition=23,duration=0.2) blendTrans(duration=0.3); border-width:1px; border-style:solid; visibility:hidden; LEFT=55; TOP;0"><table border=0 width=200 bgcolor="#FFFFCC"><tr><td>';
	
	for (var i = 0; i <= Fonts.length;) {
		 if (Fonts[i]){
			 var FontsID = Fonts[i][0];
			 var FontsFamily = Fonts[i][1];
			 var FontsTile = Fonts[i][2];
			 toolbar +='<div style="'+ FontsFamily +'"><a href="javascript:;" id="FontName" onClick="execCmd(this.id,\''+ ID +'\',\''+ FontsID +'\');">'+ FontsTile +'('+ FontsID +')</a></div>';
		}
	  i++;
    }
	
	toolbar += '</td></tr></table></div>';
	toolbar += '<div id="FontsSizeLayer" style="position:absolute; filter:revealTrans(transition=23,duration=0.2) blendTrans(duration=0.3); border-width:1px; border-style:solid;visibility:hidden; LEFT=100; TOP;0"><table border=0 width=50 bgcolor="#FFFFCC"><tr><td>';

	for (var i = 0; i <= FontSizes.length;) {
		 if (FontSizes[i]){
			 var FontSizesID = FontSizes[i][0];
			 var FontSizesFamily = FontSizes[i][1];
			 var FontSizesTile = FontSizes[i][2];
			 toolbar +='<div style="'+ FontSizesFamily +'"><a href="javascript:;" id="FontSize" onClick="execCmd(this.id,\''+ ID +'\',\''+ FontSizesID +'\');">'+ FontSizesTile + '</a></div>';
		}
	  i++;
    }
	
	toolbar += '</td></tr></table></div>';
	toolbar += '<div id="FontsZoomLayer" style="position:absolute; filter:revealTrans(transition=23,duration=0.2) blendTrans(duration=0.3); border-width:1px; border-style:solid;visibility:hidden;"><table border=0 width=50 bgcolor="#FFFFCC"><tr><td>';
	
	for (var i = 0; i <= Zoom.length;) {
		 if (Zoom[i]){
			 var ZoomID = Zoom[i][0];
			 var ZoomFamily = Zoom[i][1];
			 var ZoomTile = Zoom[i][2];
			 toolbar +='<div style="'+ ZoomFamily +'"><a href="javascript:;" id="FontZoom" onClick="execCmd(this.id,\''+ ID +'\',\''+ ZoomID +'\');">'+ ZoomTile +'</a></div>';
		}
	  i++;
    }
	
	toolbar += '</td></tr></table></div>';
	toolbar +='</div></td></tr></table>\n';

 	var iframe = '<table cellpadding="0" cellspacing="0" border="0" style="width:'+ Hub_Width +'; height:'+ Hub_Height +'; border:solid 1 #EAEAEA;">\n <tr><td valign="top">\n' + toolbar  + '</td></tr>\n <tr><td valign="top">\n' + '<iframe id="Editor' + ID + '" marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=auto oncontextmenu="return false" ></iframe >\n' + '</td></tr>\n <tr><td valign="top">\n' + '<textarea id="Text' + ID + '" style="border:solid 1 #EAEAEA;"></textarea>\n' + '</td></tr>\n <tr><td valign="top">\n' + '<iframe id="View' + ID + '" marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=auto></iframe>\n' + '</td></tr></table>\n';

	document.getElementById(ID).style.display = 'none';
    
	document.getElementById(ID).insertAdjacentHTML("afterEnd", iframe);
	document.getElementById("Editor" + ID).style.width = Hub_Width;
	document.getElementById("Editor" + ID).style.height = Hub_Height;
	
	document.getElementById("Text" + ID).style.width = Hub_Width;
	document.getElementById("Text" + ID).style.height = Hub_Height; 
	document.getElementById("Text" + ID).style.display = 'none';
	
	document.getElementById("View" + ID).style.width = Hub_Width;
	document.getElementById("View" + ID).style.height = Hub_Height;  
	document.getElementById("View" + ID).style.display = 'none';

	var HubEditor = document.getElementById("Editor" + ID).contentWindow.document;
	var HubEditorView = document.getElementById("View" + ID).contentWindow.document;

	
	HubEditor.open("text/html");
	if(document.getElementById(ID).value == ""){
		HubEditor.write( default_html );
	}else{
		HubEditor.write( default_html );
		HubEditor.write( document.getElementById(ID).value );
	}
	HubEditor.close();
	HubEditor.body.contentEditable = true;
	HubEditor.designMode = "On";

	HubEditorView.open("text/html");
	HubEditorView.write( default_html );
	HubEditorView.close();
	HubEditorView.body.contentEditable = true;
	HubEditorView.designMode = "Off";
	
}


function ShowLayer(Cmd) {
	var LayerID = document.getElementById("Fonts"+Cmd);
	
	LayerID.filters.blendTrans.apply();

	if(Cmd == "Layer" && ( document.getElementById("FontsSizeLayer").style.visibility == "visible" || document.getElementById("FontsZoomLayer").style.visibility == "visible")){
		document.getElementById("FontsSizeLayer").style.visibility = "hidden";
		document.getElementById("FontsZoomLayer").style.visibility = "hidden";
	}
	if(Cmd == "SizeLayer" && ( document.getElementById("FontsLayer").style.visibility == "visible" || document.getElementById("FontsZoomLayer").style.visibility == "visible")){
		document.getElementById("FontsLayer").style.visibility = "hidden";
		document.getElementById("FontsZoomLayer").style.visibility = "hidden";
	}
	if(Cmd == "ZoomLayer" && ( document.getElementById("FontsSizeLayer").style.visibility == "visible" || document.getElementById("FontsLayer").style.visibility == "visible" ) ){
		document.getElementById("FontsSizeLayer").style.visibility = "hidden";
		document.getElementById("FontsLayer").style.visibility = "hidden";
	}

	var px = window.event.clientX + document.documentElement.scrollLeft;    
	LayerID.style.left = px - 10;

	if(LayerID.style.visibility == "hidden"){
		LayerID.style.visibility = "visible";
	}else{
		LayerID.style.visibility = "hidden";
	}

	LayerID.filters.blendTrans.play();
}


function execCmd(Cmd,ID,Font) {
	var HubEditor = document.getElementById("Editor" + ID).contentWindow;
	HubEditor.focus();

	if (Cmd == "New"){

		HubEditor.document.body.innerHTML = default_html;

	}else if(Cmd == "HRline"){

		HubEditor.document.selection.createRange().pasteHTML("<HR>");

	}else if(Cmd == "FontZoom" && Font){

		HubEditor.document.body.style.zoom = Font + '%';

		ShowLayer("ZoomLayer");
		
	}else if((Cmd == "FontName" && Font) || (Cmd == "FontSize" && Font)){

		HubEditor.document.execCommand(Cmd, false, Font);

		var ShowL ="";

		if(Cmd == "FontName") ShowL = "Layer"; else ShowL = "SizeLayer";

		ShowLayer(ShowL);

	}else if((Cmd == "ForeColor" && Font) || (Cmd == "BackColor" && Font)){

		HubEditor.document.execCommand(Cmd, false, Font);
		
	}else if(Cmd == "CreateLink"){
	   HubEditor.document.execCommand(Cmd, true, null);
	}else{

		HubEditor.document.execCommand(Cmd, false, null);

	}

	HubEditor.focus();
}

function ChangeType(Cmd,ID) {
	var HubEditor = document.getElementById("Editor" + ID);
	var HubEditor_Text = document.getElementById("Text" + ID);
	var HubEditor_View = document.getElementById("View" + ID);
	
	var HubEditor_Tool = document.getElementById("EditorTool");
	
	var HubEditor_Toolbar = document.getElementById("EditorToolbar");

	if(Cmd == 'HubEditor'){

		if(Now_Mode == 'Text'){

			HubEditor.contentWindow.document.body.innerHTML = HubEditor_Text.value;
			HubEditor.style.display = 'block'; 
			HubEditor_Text.style.display = 'none';
			HubEditor_View.style.display = 'none';
			
			HubEditor_Tool.style.display = 'none';	
			HubEditor_Toolbar.style.display = 'block';
			
			Now_Mode = 'Edit';

		} else if(Now_Mode == 'Edit'){

			HubEditor_Text.value = HubEditor.contentWindow.document.body.innerHTML;
			HubEditor.style.display = 'none'; 
			HubEditor_Text.style.display = 'block';
			HubEditor_View.style.display = 'none';
			HubEditor_Tool.style.display = 'block';	
			
			HubEditor_Toolbar.style.display = 'none';
			
			Now_Mode = 'Text';

		}

	} else if(Cmd == 'View'){

		HubEditor_View.contentWindow.document.body.innerHTML = HubEditor.contentWindow.document.body.innerHTML;
		HubEditor_Text.value = HubEditor.contentWindow.document.body.innerHTML;
		HubEditor.style.display = 'none';
		HubEditor_Text.style.display = 'none';
		HubEditor_View.style.display = 'block';
		
		HubEditor_Tool.style.display = 'block';	
		HubEditor_Toolbar.style.display = 'none';	
		
		Now_Mode = 'Text';

	}
}




function Popup_Open(url, name, width, height) {
	
	var res = window.showModalDialog(url, name, "unadorned:no; help:no; scroll:auto; status:no; dialogWidth:" + width + "px; dialogHeight:" + height + "px; center:yes");

	return res;

}




function Color_Picker(ID,modetype) {
	var HubEditor = document.getElementById("Editor" + ID).contentWindow;

	var res = Popup_Open( EditorDir + 'color.htm?mode='+ modetype +'&id='+ID, 'color_picker'+ID, '400', '220');
	if(modetype=="F") Cmd = "ForeColor";
	else if(modetype=="B") Cmd = "BackColor";
	try {
		if(res.result_color) {
		HubEditor.focus();
		execCmd(Cmd,ID,res.result_color);
		HubEditor.focus();
		}else {
		HubEditor.focus();
		return;
		}
	} catch(e) {
		return;
	}

}

function Table_Create(ID) {
	var HubEditor = document.getElementById("Editor" + ID).contentWindow;
	var result = Popup_Open( EditorDir + 'table.htm', 'create_table', '390', '280');

		try {

		if(result.m_nRow > 0) {
	
			ResultTable = "<table";
	
			if(result.m_nBorder) ResultTable += " border=" + result.m_nBorder;

			if(result.m_bSetWidth) ResultTable += " width=" + result.m_nWidth + result.m_bWidthMode;

			if(result.m_bSetHeight) ResultTable += " height=" + result.m_nHeight + result.m_bHeightMode;

			if(result.m_nAlign) ResultTable += " align=" + result.m_nAlign;

			if(result.m_nPadding) ResultTable += " cellpadding=" + result.m_nPadding;

			if(result.m_nSpacing)   ResultTable += " cellspacing=" + result.m_nSpacing;
			if(result.m_nBgcolor)   ResultTable += " bgcolor=" + result.m_nBgcolor;

			ResultTable += ">\n";
			for(var i=0; i < result.m_nRow; i++) {


				ResultTable += "<tr>\n";

				for(var j=0; j < result.m_nCol; j++) {

				ResultTable += "<td>&nbsp;</td>\n";

				}


				ResultTable += "</tr>\n";

			}

			
			ResultTable += "</table>\n";


			HubEditor.focus();
			HubEditor.document.selection.createRange().pasteHTML(ResultTable);
			HubEditor.focus();

		} else {

			HubEditor.focus();

			return;

		}
	
	} catch(e) {

	return;

	}

}



function Image_Insert(ID,Hub_Form) {
	var RandomDir = Hub_Form;
	var HubEditor = document.getElementById("Editor" + ID).contentWindow;

	var Result = Popup_Open( EditorDir + 'image.htm?up='+UploadDir+'&RandomDir='+RandomDir, 'insert_image', '539', '525');

	try {


		if(Result.m_bImageLink) {

		ResultImage = "<br><img src=\""+Result.m_bImageLink+"\"";

		if(Result.m_bImageWidth)  ResultImage += " width="+Result.m_bImageWidth;

		if(Result.m_bImageHeight) ResultImage += " height="+Result.m_bImageHeight;

		if(Result.m_bImageBorder) ResultImage += " border="+Result.m_bImageBorder;

		if(Result.m_bImageAlign)  ResultImage += " align="+Result.m_bImageAlign;

		ResultImage += ">";
		HubEditor.focus();

		HubEditor.document.selection.createRange().pasteHTML(ResultImage);

		HubEditor.focus();

		} else {
		HubEditor.focus();

		return;

		}

	} catch(e) {

	return;

	}

}


	
function Flash_Insert(ID) {

	var HubEditor = document.getElementById("Editor" + ID).contentWindow;

	var Result = Popup_Open( EditorDir + 'flash.htm', 'insert_flash', '400', '520');

	try {

		if(Result.m_bFlashLink) {


			ResultFlash = "<embed src='" + Result.m_bFlashLink + "' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'";


			if(Result.m_bFlashWidth)  ResultFlash += " width="+Result.m_bFlashWidth;

			if(Result.m_bFlashHeight) ResultFlash += " height="+Result.m_bFlashHeight;
			ResultFlash += "></embed>";


			HubEditor.focus();

			HubEditor.document.selection.createRange().pasteHTML(ResultFlash);

			HubEditor.focus();

		} else {
		HubEditor.focus();

		return;
	
		}
	
	} catch(e) {

		return;
	}

}



function Media_Insert(ID) {
	var HubEditor = document.getElementById("Editor" + ID).contentWindow;

	var Result = Popup_Open( EditorDir + 'media.htm', 'insert_media', '400', '520');

	try {


	if(Result.m_bMediaLink) {

		ResultMedia = "<embed src='" + Result.m_bMediaLink + "' autostart='false' ShowStatusBar='true' volume='0'";

	
		if(Result.m_bMediaWidth)  ResultMedia += " width="+Result.m_bMediaWidth;

	    if(Result.m_bMediaHeight) ResultMedia += " height="+Result.m_bMediaHeight;
		ResultMedia += "></embed>";
		HubEditor.focus();
	
		HubEditor.document.selection.createRange().pasteHTML(ResultMedia);
	
		HubEditor.focus();
		
		} else {

		HubEditor.focus();
	
		return;
	
		}
	
	} catch(e) {
		return;
	}

}