/*

HTML Text Area (HTA) v1.1
2002-12-13 14:04 <ivan@konsep.net>
based on the script from http://www.yusasp.com

FUNCTION PROTOTYPE

function saveSelection()
function restoreSelection()
function drawIcon(left, width, id, title, command)
function initEditor()
function doCmd(sCmd, sOption)
function doCmd2(sCmd,sOption)
function UpdateImage(inpImgURL, inpImgAlt, inpImgAlign, inpImgBorder, inpImgWidth, inpImgHeight, inpHSpace, inpVSpace)
function InsertImage(inpImgURL, inpImgAlt, inpImgAlign, inpImgBorder, inpImgWidth, inpImgHeight, inpHSpace, inpVSpace)
function popupShow(width,title,html)
function popupHide()
function displayParagraphBox()
function displayFontNameBox()
function displayFontSizeBox()
function displayFgColorBox()
function displayBgColorBox()
function displayDocBgColorBox()
function writeColorPicker(Name,Command,Type)
function setDisplayMode()
function applyStyle(Style)
function displayStyleBox()
function insertSymbol(Symbol)
function displaySymbolBox()
function CreateHyperlink()
function displayLinkBox()
function pasteFromWord()
function cleanFromWord()
function GetElement(oElement,sMatchTag)
function setDefaultColor(Name,Color)
function displayBgColor()
function displayBorderColor()
function displayBgColor2()
function displayBorderColor2()
function displayCellBgColor()
function displayTableBox()
function TabInsertTable()
function TabEditTable()
function TabEditCell()
function TabDisable1()
function TabDisable2()
function TableInsert()
function TableUpdate()
function CellUpdate()
function IsPosInt(sInput)
function IsPosIntNotZero(sInput)
function TableInsertRow(type)
function TableDeleteRow()
function TableInsertCol(type)
function TableDeleteCol()
function TableDeleteCell()
function TableColSpan()
function TableRowSpan()
function LoadDoc()
function ClearDoc()
function RestoreDoc()
function initIcon()
function toogleIcon(opt)

*/

var s_base_url = 'http://192.168.0.254/jmn_new/';
var s_base_rel = '/';
var s_css_path = 'scripts/';
var s_css_main = 'css_ie.css';
var s_css_lib = 'css_lib.css';
var s_css_lib_id = 'styLib';
var s_img_script = 'popup_img.php?m=1';
var s_img_path = 'images/';
var s_img_default = "images/image_content_header.jpg";
var s_pickfirst = 'You must set your pointer to the document area before editing anything.\\nPlease click anywhere on the document area.';
var s_img_dlg = "Insert Image File (You can use your local image file) : ";
var s_confirm_clear_doc = 'Clear document?';
var s_confirm_restore_doc = 'Restore original content?';

var o_sel_save;
var s_sel_type;
var displayMode = "RICH";
var oElStore;
var isLayerActive;

/**********
**********/
function saveSelection() {
	o_sel_save = idContent.document.selection.createRange();
	s_sel_type = idContent.document.selection.type;
}
/**********
**********/
function restoreSelection() {
	o_sel_save.select();
}
/**********
**********/
function drawIcon(left, width, id, title, command) {
//	alert("<span style=\"width: "+width+";height:22; clip: rect(0 "+width+" 22 0);overflow: hidden;\">	<span unselectable=\"on\" style=\"position:absolute;\">	<img unselectable=\"on\" id=\""+id+"\" 	title=\""+title+"\" onclick=\"if (document.activeElement.id!='idContent') { alert('" + s_pickfirst + "'); return };"+command+"\" src=\"" + s_img_path + "toolbar.gif\" 	style=\"position:absolute;top:0;left:-"+left+";\" 	onmouseover=\"this.style.pixelTop=-22\" 	onmousedown=\"this.style.pixelTop=-44\" 	onmouseup=\"this.style.pixelTop=-22\" 	onmouseout=\"this.style.pixelTop=0\" 	oncontextmenu=\"return false\" ondragstart=\"return false\" 	width=\"1151\" 	height=\"110\" />	<table width="+width+"><tr><td unselectable=\"on\" onselectstart='return false' style=\"position:absolute;top:4;left:7;\" id=\""+id+"Text\"></td></tr></table>	</span>	</span>");

//	document.write("<span style=\"width: "+width+";height:22; clip: rect(0 "+width+" 22 0);overflow: hidden;\">")
	document.write("<span style='width: "+width+";height:22; clip: rect(0 "+width+" 22 0);overflow: hidden;'>")
	document.write("<span unselectable=\"on\" style=\"position:absolute;\">")
	document.write("<img unselectable=\"on\" id=\""+id+"\" ")
	document.write("title=\""+title+"\" onclick=\"if (document.activeElement.id!='idContent') { alert('" + s_pickfirst + "'); return };"+command+"\" src=\"" + s_img_path + "toolbar.gif\" ")
	document.write("style=\"position:absolute;top:0;left:-"+left+";\" ")
	document.write("onmouseover=\"this.style.pixelTop=-22\" ")
	document.write("onmousedown=\"this.style.pixelTop=-44\" ")
	document.write("onmouseup=\"this.style.pixelTop=-22\" ")
	document.write("onmouseout=\"this.style.pixelTop=0\" ")
	document.write("oncontextmenu=\"return false\" ondragstart=\"return false\" ")
	document.write("width=\"1151\" ")
	document.write("height=\"110\" />")
	document.write("<table width="+width+"><tr><td unselectable=\"on\" onselectstart='return false' style=\"position:absolute;top:4;left:7;\" id=\""+id+"Text\"></td></tr></table>")
	document.write("</span>")
	document.write("</span>")
}
/**********
**********/
function initEditor() {
	var sHTML = '';
	sHTML = "<link rel=\"stylesheet\" href=\"" + s_css_path + s_css_main + "\" type=\"text/css\" />" +
			"<link rel=\"stylesheet\" href=\"" + s_css_path + s_css_lib + "\" type=\"text/css\" />" +
			"<body oncontextmenu=\"return false\" class=\"normal\">" +
			"<div></div>" +
			"</body>";
	idContent.document.designMode = "on";
	idContent.document.open("text/html","replace")
	idContent.document.write(sHTML)
	idContent.document.close()

	idContent.document.execCommand("2D-Position", true, true);
	idContent.document.execCommand("MultipleSelection", true, true);
	idContent.document.execCommand("LiveResize", true, true);

	LoadDoc()
	idWord.document.designMode = "on";
}
/**********
**********/
function doCmd(sCmd, sOption) {
	popupHide()
	idContent.focus()

	var oSel = idContent.document.selection.createRange();
	var sType = idContent.document.selection.type;
	var oTarget = (sType == "None" ? idContent.document : oSel);
	oSel.select();

	if (sCmd=="DialogImage") {
		var popleft=((document.body.clientWidth - 440) / 2)+window.screenLeft;
		var poptop=(((document.body.clientHeight - 460) / 2))+window.screenTop-40;
		window.open(s_img_script, "popup_img", "scrollbars=0, width=480, height=480, left="+popleft+", top="+poptop);
		return true;
	}
	oTarget.execCommand(sCmd, false, sOption);
}
/**********
**********/
function doCmd2(sCmd,sOption) {
	popupHide()

	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oTarget = (sType == "None" ? idContent.document : oSel)
	oSel.select()

	oTarget.execCommand(sCmd, false, sOption)
}
/**********
**********/
function UpdateImage(inpImgURL, inpImgAlt, inpImgAlign, inpImgBorder, inpImgWidth, inpImgHeight, inpHSpace, inpVSpace) {
	var oSel = idContent.document.selection.createRange()
	var sType = idContent.document.selection.type
	if ((oSel.item) && (oSel.item(0).tagName=="IMG"))
		{
		oSel.item(0).style.width="";
		oSel.item(0).style.height="";

		oSel.item(0).src = inpImgURL
		if(inpImgAlt!="")
			oSel.item(0).alt = '"' + inpImgAlt + '"'
		else
			oSel.item(0).alt = '""'
		oSel.item(0).align = inpImgAlign
		oSel.item(0).border = inpImgBorder
		if(inpImgWidth!="")
			oSel.item(0).width = inpImgWidth
		else
			oSel.item(0).removeAttribute("width",0)
		if(inpImgHeight!="")
			oSel.item(0).height = inpImgHeight
		else
			oSel.item(0).removeAttribute("height",0)
		if(inpHSpace!="")
			oSel.item(0).hspace = inpHSpace
		else
			oSel.item(0).removeAttribute("hspace",0)
		if(inpVSpace!="")
			oSel.item(0).vspace = inpVSpace
		else
			oSel.item(0).removeAttribute("vspace",0)
		}
}
/**********
**********/
function InsertImage(inpImgURL, inpImgAlt, inpImgAlign, inpImgBorder, inpImgWidth, inpImgHeight, inpHSpace, inpVSpace) {
	doCmd("InsertImage",inpImgURL);
	oSel = idContent.document.selection.createRange()
	sType = idContent.document.selection.type
	if ((oSel.item) && (oSel.item(0).tagName=="IMG"))
		{
		if(inpImgAlt!="")
			oSel.item(0).alt = inpImgAlt
		else
			oSel.item(0).alt = ''
		oSel.item(0).align = inpImgAlign
		oSel.item(0).border = inpImgBorder
		if(inpImgWidth!="")
			oSel.item(0).width = inpImgWidth
		if(inpImgHeight!="")
			oSel.item(0).height = inpImgHeight
		if(inpHSpace!="")
			oSel.item(0).hspace = inpHSpace
		if(inpVSpace!="")
			oSel.item(0).vspace = inpVSpace
		}
}
/**********
**********/
function popupShow(width,title,html) {
	popupHide();
	//construct & display popup
	var sHTML = '';
	sHTML = "<link rel=\"stylesheet\" href=\"" + s_css_path + s_css_main + "\" type=\"text/css\" />" +
			"<link rel=\"stylesheet\" href=\"" + s_css_path + s_css_lib + "\" type=\"text/css\" />" +
			"<style>" +
			"body {border: 0px lightgrey solid;}" +
			"</style>" +
			"<body style=\"overflow:hidden\" oncontextmenu=\"return false\" topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0 ONSELECTSTART=\"return event.srcElement.tagName=='INPUT'\">" +
			"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"table-layout: fixed\" bgcolor=Gainsboro ID=\"tblPopup\">" +
			"<col width="+width+"><col width=13>" +
			"<tr>" +
			"<td>" +
			"<div class=\"acebar\" style=\"padding-left: 5px;\">" +
			"<span class=\"acepopup\"><b>"+title+"</b></span>" +
			"</div>" +
			"</td>" +
			"<td style=\"cursor:hand\" onclick=\"parent.popupHide()\">" +
			"<div class=\"acebar\">" +
			"<span class=\"acepopup\"><b>X</b></span>" +
			"</div>" +
			"</td>" +
			"</tr>" +
			"<tr>" +
			"<td colspan=2 style=\"border-left: #336699 1px solid;border-right: #336699 1px solid;border-bottom: #336699 1px solid;\" valign=top>" +
			"<br>" +
			"<div id=\"divPopup\" align=center></div>" +
			"<br>" +
			"</td>" +
			"</tr>" +
			"</table>" +
			"</body>"

	idContentTmp.document.open("text/html","replace")
	idContentTmp.document.write(sHTML)
	idContentTmp.document.close()
	document.all.idContentTmp.style.zIndex = 2
	document.all.idContentTmp.style.visibility = ""

	idContentTmp.document.all.tblPopup.focus()//for idContent lost focus

	//fill popup content
	idContentTmp.divPopup.innerHTML = html

	//set dimension
	document.all.idContentTmp.style.width = idContentTmp.document.all.tblPopup.offsetWidth
	document.all.idContentTmp.style.height = idContentTmp.document.all.tblPopup.offsetHeight

	//set position
	if(document.body.clientHeight - document.all.idContentTmp.offsetHeight > 0)
		document.all.idContentTmp.style.pixelTop=((document.body.clientHeight - document.all.idContentTmp.offsetHeight) / 2);
	else
		document.all.idContentTmp.style.pixelTop=0
	if(document.body.clientWidth - document.all.idContentTmp.offsetWidth > 0)
		document.all.idContentTmp.style.pixelLeft=(document.body.clientWidth - document.all.idContentTmp.offsetWidth) / 2 ;
	else
		document.all.idContentTmp.style.pixelLeft=0
}
/**********
**********/
function popupHide() {
	document.all.idContentTmp.style.visibility = "hidden";
	document.all.idContent.focus();
}
/**********
**********/
function displayParagraphBox() {
	saveSelection()
	var a_opt = new Array('H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'PRE', 'P');
	var a_opt_cap = new Array('Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', 'Heading 6', 'Preformatted', 'Normal');
	var n_len = a_opt.length;
	var sHTML = '';
	sHTML += "<table align=center border=0 width=100% height=100% cellpadding=0 cellspacing=0>"
	for (i = 0; i < n_len; i++) {
		sHTML += "<tr onclick=\"parent.doCmd2('FormatBlock','<" + a_opt[i] + ">');\" onmouseover=\"this.style.color='tomato'\" onmouseout=\"this.style.color='black'\" style=\"cursor:hand\"><td align=\"center\" height=\"10\"><" + a_opt[i] + ">" + a_opt_cap[i] + "</" + a_opt[i] + "></td></tr>";
	}
	sHTML += "</table>";
	popupShow(253,"Paragraph Style",sHTML)
}
/**********
**********/
function displayFontNameBox() {
	saveSelection()
	var a_opt = new Array('Arial', 'Arial Black', 'Arial Narrow', 'Comic Sans MS', 'Courier New', 'System', 'Tahoma', 'Times New Roman', 'Verdana', 'Wingdings');
	var n_len = a_opt.length;
	var sHTML = '';

	sHTML += "<table align=center border=0 width=100% height=100% cellpadding=0 cellspacing=0>";
	for (i = 0; i < n_len; i++) {
		sHTML += "<tr onclick=\"parent.doCmd2('fontname','" + a_opt[i] + "');\" onmouseover=\"this.style.color='tomato'\" onmouseout=\"this.style.color='black'\" style=\"cursor:hand\"><td align=\"center\"><span style=\"font-family:" + a_opt[i] + ";\">" + a_opt[i] + "</span></td></tr>";
	}
	sHTML += "</table>";
	popupShow(213,"Font Name",sHTML)
}
/**********
**********/
function displayFontSizeBox() {
	saveSelection();
	var a_opt = new Array('1', '2', '3', '4', '5', '6', '7');
	var n_len = a_opt.length;
	var sHTML = '';

	sHTML += "<table align=center border=0 width=100% height=100% cellpadding=0 cellspacing=0>";
	for (i = 0; i < n_len; i++) {
		sHTML += "<tr onclick=\"parent.doCmd2('fontsize'," + a_opt[i] + ");\" onmouseover=\"this.style.color='tomato'\" onmouseout=\"this.style.color='black'\" style=\"cursor:hand\"><td align=center><font size=\"" + a_opt[i] + "\">" + a_opt[i] + "</span></td></tr>";
	}
	sHTML += "</table>";
	popupShow(253,"Font Size",sHTML)
}
/**********
**********/
function displayFgColorBox() {
	saveSelection()

	var sHTML = writeColorPicker("idForeColor","parent.doCmd2('ForeColor',idForeColor.value);",0);
	popupShow(433,"Foreground Color",sHTML)
}
/**********
**********/
function displayBgColorBox() {
	saveSelection()

	var sHTML = writeColorPicker("idBackColor","parent.doCmd2('BackColor',idBackColor.value);",0);
	popupShow(433,"Background Color",sHTML)
}
/**********
**********/
function displayDocBgColorBox() {
	saveSelection()

	var sHTML = writeColorPicker("idDocBackColor", "parent.idContent.document.body.style.background=idDocBackColor.value;parent.popupHide()", 0);
	popupShow(433,"Document Background Color",sHTML)
}
/**********
**********/
function writeColorPicker(Name,Command,Type) {
	var OutputID = Name
	var TextID = Name + "_1"
	var ColorID = Name + "_2"
	var c1 = new Array("FFFFCC", "FFCC66", "FF9900", "FFCC99", "FF6633", "FFCCCC", "CC9999", "FF6699", "FF99CC", "FF66CC", "FFCCFF", "CC99CC", "CC66FF", "CC99FF", "9966CC", "CCCCFF", "9999CC", "3333FF", "6699FF", "0066FF", "99CCFF", "66CCFF", "99CCCC", "CCFFFF", "99FFCC", "66CC99", "66FF99", "99FF99", "CCFFCC", "33FF33", "66FF00", "CCFF99", "99FF00", "CCFF66", "CCCC66", "FFFFFF")
	var c2 = new Array("FFFF99", "FFCC00", "FF9933", "FF9966", "CC3300", "FF9999", "CC6666", "FF3366", "FF3399", "FF00CC", "FF99FF", "CC66CC", "CC33FF", "9933CC", "9966FF", "9999FF", "6666FF", "3300FF", "3366FF", "0066CC", "3399FF", "33CCFF", "66CCCC", "99FFFF", "66FFCC", "33CC99", "33FF99", "66FF66", "99CC99", "00FF33", "66FF33", "99FF66", "99FF33", "CCFF00", "CCCC33", "CCCCCC")
	var c3 = new Array("FFFF66", "FFCC33", "CC9966", "FF6600", "FF3300", "FF6666", "CC3333", "FF0066", "FF0099", "FF33CC", "FF66FF", "CC00CC", "CC00FF", "9933FF", "6600CC", "6633FF", "6666CC", "3300CC", "0000FF", "3366CC", "0099FF", "00CCFF", "339999", "66FFFF", "33FFCC", "00CC99", "00FF99", "33FF66", "66CC66", "00FF00", "33FF00", "66CC00", "99CC66", "CCFF33", "999966", "999999")
	var c4 = new Array("FFFF33", "CC9900", "CC6600", "CC6633", "FF0000", "FF3333", "993333", "CC3366", "CC0066", "CC6699", "FF33FF", "CC33CC", "9900CC", "9900FF", "6633CC", "6600FF", "666699", "3333CC", "0000CC", "0033FF", "6699CC", "3399CC", "669999", "33FFFF", "00FFCC", "339966", "33CC66", "00FF66", "669966", "00CC00", "33CC00", "66CC33", "99CC00", "CCCC99", "999933", "666666")
	var c5 = new Array("FFFF00", "CC9933", "996633", "993300", "CC0000", "FF0033", "990033", "996666", "993366", "CC0099", "FF00FF", "990099", "996699", "660099", "663399", "330099", "333399", "000099", "0033CC", "003399", "336699", "0099CC", "006666", "00FFFF", "33CCCC", "009966", "00CC66", "339933", "336633", "33CC33", "339900", "669933", "99CC33", "666633", "999900", "333333")
	var c6 = new Array("CCCC00", "996600", "663300", "660000", "990000", "CC0033", "330000", "663333", "660033", "990066", "CC3399", "993399", "660066", "663366", "330033", "330066", "333366", "000066", "000033", "003366", "006699", "003333", "336666", "00CCCC", "009999", "006633", "009933", "006600", "003300", "00CC33", "009900", "336600", "669900", "333300", "666600", "000000")

	var sHTML = "";
	sHTML += ("<table border=0 width=370 align=center cellpadding=0 cellspacing=0><tr><td width=45>  <table border=1 cellpadding=0 cellspacing=0><tr><td id='"+ColorID+"' width=25 height=25></td></tr></table>   <div id='"+TextID+"'><span class=\"acetextnote\">&nbsp;</span></div> </td><td>&nbsp;</td><td>")
	sHTML += ("<table cellpadding=0 cellspacing=1 bgcolor=black>")
	if (Type==0) {
		for (var i=1;i<=6;i++) {
			sHTML += ("<tr>")
			for(var r=0;r<eval("c"+i).length;r++) {
				var colour = eval("c"+i+"[r]");
				sHTML += ("<td onclick=\""+OutputID+".value='"+colour+"';"+Command+"\" style=\"cursor:hand;background-color:"+colour+";\" width=9 height=6 onmouseover=\""+ColorID+".style.background='#"+colour+"';"+TextID+".innerHTML='<span class=acetextnote>"+colour+"</span>'\"></td>");
			}
			sHTML += ("</tr>");
		}
	}
	if (Type==1) {
		for (var i=1;i<=6;i++) {
			sHTML += ("<tr>");
			for(var r=0;r<eval("c"+i).length;r++) {
				var colour = eval("c"+i+"[r]");
				sHTML += ("<td onclick=\""+ColorID+".style.background='#"+colour+"';"+TextID+".innerHTML='<span class=acetextnote>"+colour+"</span>';"+OutputID+".value='"+colour+"';"+Command+"\" style=\"cursor:hand;background-color:"+colour+";\" width=9 height=6 onmouseover=\""+ColorID+".style.background='#"+colour+"';"+TextID+".innerHTML='<span class=acetextnote>"+colour+"</span>'\"></td>");
			}
			sHTML += ("</tr>");
		}
	}
	sHTML += ("</table>");
	sHTML += ("<input type=hidden id='"+OutputID+"'>");
	sHTML += ("</td></tr></table>");
	return sHTML;
}
/**********
**********/
function setDisplayMode() {
	popupHide()
	if(displayMode=='RICH'){
		idContent.document.body.clearAttributes;
		idContent.document.body.style.fontFamily = 'Courier New';
		idContent.document.body.style.fontSize = '12px';
		s_content = idContent.document.body.innerHTML;
		s_content = s_content.replace(s_base_url,s_base_rel);
		idContent.document.body.innerText = s_content;
		displayMode = 'HTML';
		toogleIcon(0);
	} else {
		idContent.document.body.clearAttributes;
		idContent.document.body.style.fontFamily = '';
		idContent.document.body.style.fontSize = '';
		idContent.document.body.innerHTML = idContent.document.body.innerText;

		var sATag = idContent.document.body.all.tags("A");
		for (var i = sATag.length - 1; i >= 0; i--) {
			oA = sATag[i];
			oA.href = (oA.href).replace(s_base_url,s_base_rel);
		}

		var sImgTag = idContent.document.body.all.tags("IMG");
		for (var i = sImgTag.length - 1; i >= 0; i--) {
			oA = sImgTag[i];
			oA.src = (oA.src).replace(s_base_url,s_base_rel);
		}
		displayMode = 'RICH';
		toogleIcon(1);
	}
}
/**********
**********/
function applyStyle(Style) {
	popupHide()

	var oSel = o_sel_save;
	var sType = s_sel_type;

	if(oSel.parentElement != null) {
		oSel.select();
		var sApplied = "<font class='"+Style+"'>"+oSel.text+"</font>";
		oSel.pasteHTML(sApplied);
	}

}
/**********
**********/
function displayStyleBox() {
	saveSelection();

	var val;
	var sHTML = "<table align=center border=0 width=100% height=100% cellpadding=0 cellspacing=0>";
	for(var i=0;i<document.styleSheets(s_css_lib_id).rules.length;i++) {
		h = document.styleSheets(s_css_lib_id).rules.item(i).selectorText;
		var selArr = h.split(".");
		var itemCount = selArr.length;
		if(itemCount>1) {
			val = selArr[1];
		} else {
			val = h;
		}
		sHTML += "<tr onclick=\"parent.applyStyle('"+val+"');\" onmouseover=\"this.style.color='tomato'\" onmouseout=\"this.style.color='black'\" style=\"cursor:'hand'\"><td align=\"center\"><span class=\""+val+"\">" + val + "</span></td></tr>";
	}
	sHTML += "</table>";
	popupShow(230,"Select Style (from CSS)",sHTML);
}
/**********
**********/
function insertSymbol(Symbol) {
	popupHide();
	var oSel = o_sel_save;
	var sType = s_sel_type;
	oSel.select();
	if(oSel.parentElement) {
		oSel.pasteHTML(Symbol);
	}
}
/**********
**********/
function displaySymbolBox() {
	saveSelection()

	var s1 = new Array("&nbsp;", "!", "&quot;", "#", "$", "%", "&amp;", "'", "(", ")", "*", "+", ", ", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "&lt;", "=", "&gt;", "?")
	var s2 = new Array("@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_")
	var s3 = new Array("`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "&#9633;")
	var s4 = new Array("€", "&#9633;", "‚", "ƒ", "„", "…", "†", "‡", "ˆ", "‰", "Š", "‹", "Œ", "&#9633;", "Ž", "&#9633;", "&#9633;", "&#8242;", "&#8242;", "&#8243;", "&#8243;", "•", "–", "—", "˜", "™", "š", "›", "œ", "&#9633;", "ž", "Ÿ")
	var s5 = new Array("&nbsp;", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "&copy;", "ª", "«", "¬", "­", "&reg;", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿")
	//var s6 = new Array("À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß")
	//var s7 = new Array("à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ")
	var sHTML="";
	sHTML += "<table border=1 cellspacing=0 cellpadding=0 style=\"border-collapse:collapse;border:none;border-left:'solid windowtext 1.0pt'\">"
	for(var i=1;i<=5;i++)
		{
		sHTML += "<tr>"
		for(var j=0;j<32;j++) {
			sHTML += "<td class=acesymbol align=center onclick=\"parent.insertSymbol(this.innerText);\" onmouseover=\"this.style.color='tomato'\" onmouseout=\"this.style.color='black'\" style=\"cursor:hand\">" + eval("s"+i)[j] + "</td>"
		}
		sHTML += "</tr>"
		}
	sHTML += "</table>"
	popupShow(560,"Select Symbol",sHTML)
}
/**********
**********/
function CreateHyperlink() {
	//Get URL typed by user
	var inpURL = idContentTmp.idLinkURL.value
	var inpURLType = idContentTmp.idLinkType.value
	var sURL = inpURLType + inpURL

	sURL = sURL.replace(s_base_url,s_base_rel);

	//Use the previous active selection
	var oSel = o_sel_save;
	var sType = s_sel_type;

	if ((oSel.item) && (oSel.item(0).tagName=="IMG")) {
		oSel.item(0).width = oSel.item(0).offsetWidth;
		oSel.item(0).height = oSel.item(0).offsetHeight;
		oSel.item(0).border = idContentTmp.idLinkImageBorder.value;
	}

	if(inpURL!="") {
		if (oSel.parentElement) {
			if(idContentTmp.btnLinkAction.value == "Insert") {
				if(oSel.text!="") {
					//noop
				} else {
					var oSelTmp = oSel.duplicate()
					oSel.text = sURL	//displayed text = sURL
					oSel.setEndPoint("StartToStart",oSelTmp)
					oSel.select()
					sType="Text"
				}
			}
			if(idContentTmp.btnLinkAction.value == "Update") {
				if(oSel.text!="") {
					//noop
					//oEl = GetElement(oSel.parentElement(),"A")
					//oEl.innerText = sURL
				} else {
					//noop
					//oEl = GetElement(oSel.parentElement(),"A")
					//oEl.innerText = sURL
				}
			}
		}

		// idLinkType & idLinkURL (sURL)
		oSel.execCommand("CreateLink",false,sURL);

		if (oSel.parentElement) {
			oEl = GetElement(oSel.parentElement(),"A");
		} else {
			oEl = GetElement(oSel.item(0),"A");
		}
		if(oEl) {
			if(idContentTmp.idLinkTarget.value=="") {
				oEl.removeAttribute("target",0);
			} else {
				oEl.target = idContentTmp.idLinkTarget.value;
			}
		}
		idContent.focus();
		oSel.select();
		}

//Activate layer again
//if(isLayerActive)oElStore.setActive();
}
/**********
**********/
function displayLinkBox() {
	saveSelection();

	var sHTML = "<table cellpadding=\"0\" cellspacing=\"3\" align=center>" +
				"<tr>" +
				"<td colspan=2>" +
				"&nbsp;" +
				"<select id=\"idLinkType\" NAME=\"idLinkType\">" +
				"<option value=\"\" selected></option>" +
				"<option value=\"http://\" selected>http://</option>" +
				"<option value=\"https://\">https://</option>" +
				"<option value=\"mailto:\">mailto:</option>" +
				"<option value=\"ftp://\">ftp://</option>" +
				"<option value=\"news:\">news:</option>" +
				"</select>" +
				"<input type=text size=30 id=idLinkURL value=\"\" style=\"height: 19px;font:8pt verdana,arial,sans-serif\" NAME=\"idLinkURL\">" +
				"</td>" +
				"</tr>" +
				"<tr>" +
				"<td>" +
				"&nbsp;&nbsp;Target : " +
				"<select id=\"idLinkTarget\" NAME=\"idLinkTarget\">" +
				"<option value=\"_self\" selected>Current</option>" +
				"<option value=\"_blank\">New Window</option>" +
				"</select>" +
				"<div id=\"idLinkImage\" style=\"display:none\">" +
				"</td>" +
				"<td>" +
				"&nbsp;&nbsp;Image Border : " +
				"<select id=\"idLinkImageBorder\" NAME=\"idLinkImageBorder\">" +
				"<option value=\"0\" selected>0</option>" +
				"<option value=\"1\">1</option>" +
				"<option value=\"2\">2</option>" +
				"<option value=\"3\">3</option>" +
				"<option value=\"4\">4</option>" +
				"<option value=\"5\">5</option>" +
				"</select>" +
				"</div>" +
				"</td>" +
				"</tr>" +
				"<tr>" +
				"<td align=center colspan=2><br>" +
				"<input type=\"button\" value=\"Cancel\" onclick=\"parent.popupHide();\" style=\"height: 22px;font:8pt verdana,arial,sans-serif\">" +
				"<input type=\"button\" id=\"btnLinkAction\" name=\"btnLinkAction\" value=\"Insert\" onclick=\"parent.CreateHyperlink();parent.popupHide();\" style=\"height: 22px;font:8pt verdana,arial,sans-serif\">" +
				"</td>" +
				"</tr>" +
				"</table>";
	popupShow(310,"Insert/Edit Link",sHTML)

	var sURL;
	var oSel = o_sel_save;
	var sType = s_sel_type;

	if (oSel.parentElement) {
		oEl = GetElement(oSel.parentElement(),"DIV");
		oElStore = oEl;//Store the active layer, so we can activate it after editing links
		isLayerActive=true;
	} else {
		isLayerActive=false;
	}

	// idLinkImage & idLinkImageBorder
	// Is the selection image or not ?

	if (oSel.parentElement) {
		oEl = GetElement(oSel.parentElement(),"A");
		idContentTmp.idLinkImage.style.display = "none";//do not display Image features on the Link Dialog
	} else {
		oEl = GetElement(oSel.item(0),"A"); //Get A element if any
		if ((oSel.item) && (oSel.item(0).tagName=="IMG")) {
			idContentTmp.idLinkImage.style.display = "block"; //display Image features on the Link Dialog
			idContentTmp.idLinkImageBorder.value = oSel.item(0).border; //get image border
		}
	}

	/*****************************************************************************/
	/*					idLinkTarget & idLinkType & idLinkURL
	/*****************************************************************************/
	//Is there an A element ?
	if (oEl)//If Yes
		{
		idContentTmp.btnLinkAction.value = "Update"
		sURL = oEl.href //get image url
		idContentTmp.idLinkTarget.value = oEl.target;//get image target
		if(sURL.indexOf(":")!=-1) {
			switch(sURL.split(":")[0]) {
				case "http":
					idContentTmp.idLinkType.value = "http://";
					idContentTmp.idLinkURL.value = sURL.substr(7);
					break;
				case "https":
					idContentTmp.idLinkType.value = "https://";
					idContentTmp.idLinkURL.value = sURL.substr(8);
					break;
				case "mailto":
					idContentTmp.idLinkType.value = "mailto:";
					idContentTmp.idLinkURL.value = sURL.split(":")[1];
					break;
				case "ftp":
					idContentTmp.idLinkType.value = "ftp://";
					idContentTmp.idLinkURL.value = sURL.substr(6);
					break;
				case "news":
					idContentTmp.idLinkType.value = "news:";
					idContentTmp.idLinkURL.value = sURL.split(":")[1];
					break;
			}
		} else {
			idContentTmp.idLinkType.value = "";
			idContentTmp.idLinkURL.value = sURL;
		}
	} else {
		idContentTmp.btnLinkAction.value = "Insert"

		idContentTmp.idLinkTarget.value = ""
		idContentTmp.idLinkType.value = ""
		idContentTmp.idLinkURL.value = ""
		idContentTmp.idLinkImageBorder.value = 0
	}
	//idContentTmp.idLinkURL.focus();
}
/**********
**********/
function pasteFromWord() {
	idContent.focus() // => popupHide()
	var oSel	= idContent.document.selection.createRange()
	if(oSel.parentElement) {
		idWord.focus()
		idWord.document.execCommand("SelectAll")
		idWord.document.execCommand("Paste")

		oSel.pasteHTML(cleanFromWord())
		oSel.execCommand("SelectAll")
	}
}
/**********
**********/
function cleanFromWord() {
   	for (var i = 0; i < idContent.document.body.all.length; i++) {
		idContent.document.body.all[i].removeAttribute("className","",0);
		idContent.document.body.all[i].removeAttribute("style","",0);
	}
	var sHTML = idContent.document.body.innerHTML;
	sHTML = sHTML.replace(/<st1:.*?>/g, '');
//	sHTML = sHTML.replace(/o:/g, '');
//	sHTML = sHTML.replace(/<p><\/p>/g, '');
//	sHTML = sHTML.replace(/<o:p>&nbsp;<\/o:p>/g, '');
//	sHTML = sHTML.replace(/<\?xml:.*?\/>/g, '');

	idContent.document.body.innerHTML = sHTML;
//   	return  sHTML;
}
/**********
**********/
function GetElement(oElement,sMatchTag) {
	while (oElement!=null && oElement.tagName!=sMatchTag) {
		if(oElement.id=="idContent") return null;
		oElement = oElement.parentElement
	}
	return oElement
}
/**********
**********/
function setDefaultColor(Name,Color) {
	var OutputID = Name
	var TextID = Name + "_1"
	var ColorID = Name + "_2"
	eval("idContentTmp."+OutputID).value = Color;
	eval("idContentTmp."+TextID).innerHTML = "<span class=\"acetextnote\">"+Color+"</span>"
	eval("idContentTmp."+ColorID).style.background = Color;
}
/**********
**********/
function displayBgColor() {
	if(idContentTmp.divBgColorPick.style.display=="none")
		{
		//check if it was already written
		if(idContentTmp.divBgColorPick.innerHTML=="")
			{
			//if not written yet, then write
			idContentTmp.divBgColorPick.innerHTML = writeColorPicker("inpBgColorPick","inpBgColor.value=inpBgColorPick.value",1);
			//parent.displayBgColor => writeColorPicker dilakukan di IFRAME (dimana ada inpBgColor & inpBgColorPick)
			//makanya inpBgColor.value=inpBgColorPick.value tdk perlu pake parent

			//set default color
			setDefaultColor("inpBgColorPick",idContentTmp.inpBgColor.value)
			}
		else
			{
			//already written
			//set default color
			setDefaultColor("inpBgColorPick",idContentTmp.inpBgColor.value)
			}
		//display
		idContentTmp.divBgColorPick.style.display="block"
		}
	else
		{
		//hide
		idContentTmp.divBgColorPick.style.display='none'
		}

}
/**********
**********/
function displayBorderColor() {
	if(idContentTmp.divBorderColorPick.style.display=="none")
		{
		//check if it was already written
		if(idContentTmp.divBorderColorPick.innerHTML=="")
			{
			//if not written yet, then write
			idContentTmp.divBorderColorPick.innerHTML = writeColorPicker("inpBorderColorPick","inpBorderColor.value=inpBorderColorPick.value",1);
			//set default color
			setDefaultColor("inpBorderColorPick",idContentTmp.inpBorderColor.value)
			}
		else
			{
			//already written
			//set default color
			setDefaultColor("inpBorderColorPick",idContentTmp.inpBorderColor.value)
			}
		//display
		idContentTmp.divBorderColorPick.style.display="block"
		}
	else
		{
		//hide
		idContentTmp.divBorderColorPick.style.display='none'
		}
}
/**********
**********/
function displayBgColor2() {
	if(idContentTmp.divBgColor2Pick.style.display=="none")
		{
		//check if it was already written
		if(idContentTmp.divBgColor2Pick.innerHTML=="")
			{
			//if not written yet, then write
			idContentTmp.divBgColor2Pick.innerHTML = writeColorPicker("inpBgColor2Pick","inpBgColor2.value=inpBgColor2Pick.value",1);
			//set default color
			setDefaultColor("inpBgColor2Pick",idContentTmp.inpBgColor2.value)
			}
		else
			{
			//already written
			//set default color
			setDefaultColor("inpBgColor2Pick",idContentTmp.inpBgColor2.value)
			}
		//display
		idContentTmp.divBgColor2Pick.style.display="block"
		}
	else
		{
		//hide
		idContentTmp.divBgColor2Pick.style.display='none'
		}
}
/**********
**********/
function displayBorderColor2() {
	if(idContentTmp.divBorderColor2Pick.style.display=="none")
		{
		//check if it was already written
		if(idContentTmp.divBorderColor2Pick.innerHTML=="")
			{
			//if not written yet, then write
			idContentTmp.divBorderColor2Pick.innerHTML = writeColorPicker("inpBorderColor2Pick","inpBorderColor2.value=inpBorderColor2Pick.value",1);
			//set default color
			setDefaultColor("inpBorderColor2Pick",idContentTmp.inpBorderColor2.value)
			}
		else
			{
			//already written
			//set default color
			setDefaultColor("inpBorderColor2Pick",idContentTmp.inpBorderColor2.value)
			}
		//display
		idContentTmp.divBorderColor2Pick.style.display="block"
		}
	else
		{
		//hide
		idContentTmp.divBorderColor2Pick.style.display='none'
		}
}
/**********
**********/
function displayCellBgColor() {
	if(idContentTmp.divCellBgColorPick.style.display=="none")
		{
		//check if it was already written
		if(idContentTmp.divCellBgColorPick.innerHTML=="")
			{
			//if not written yet, then write
			idContentTmp.divCellBgColorPick.innerHTML = writeColorPicker("inpCellBgColorPick","inpCellBgColor.value=inpCellBgColorPick.value",1);
			//set default color
			setDefaultColor("inpCellBgColorPick",idContentTmp.inpCellBgColor.value)
			}
		else
			{
			//already written
			//set default color
			setDefaultColor("inpCellBgColorPick",idContentTmp.inpCellBgColor.value)
			}
		//display
		idContentTmp.divCellBgColorPick.style.display="block"
		}
	else
		{
		//hide
		idContentTmp.divCellBgColorPick.style.display='none'
		}
}
/**********
**********/
function displayTableBox() {
	saveSelection()

	var sHTML = "" +
	"<table border=\"0\" cellpadding=\"4\" cellspacing=\"2\" style=\"TABLE-LAYOUT: fixed\" align=center height=405>" +
	"<col width=438>" +
	"<tr>" +
	"<td align=center valign=top>" +

	"<table border=0 style=\"table-layout:fixed\" bgcolor=Gainsboro width=402 height=20 cellpadding=0 cellspacing=0>" +
	"<col width=130><col width=130><col width=130><col width=42>" +
	"<tr>" +
	"<td align=center id=\"tab1\" style=\"border-top: darkgray 1px solid; border-left: darkgray 1px solid;\">" +
	"&nbsp;" +
	"</td>" +
	"<td align=center id=\"tab2\" style=\"border-top: darkgray 1px solid; border-left: darkgray 1px solid;\">" +
	"&nbsp;" +
	"</td>" +
	"<td align=center id=\"tab3\" style=\"border-top: darkgray 1px solid; border-left: darkgray 1px solid;  border-right: darkgray 1px solid;\">" +
	"&nbsp;" +
	"</td>" +
	"<td style=\"border-bottom: darkgray 1px solid;\">&nbsp;</td>" +
	"</tr>" +
	"</table>" +

	"<!-- Insert Table Panel -->" +
	"<div id=\"idInsertTable\">" +
	"<table border=0 style=\"table-layout:fixed\" width=420 cellpadding=2 cellspacing=2 bgcolor=\"#ececec\" style=\"border-left: darkgray 1px solid; border-bottom: darkgray 1px solid; border-right: darkgray 1px solid;\">" +
	"<col width=80><col width=130><col width=80><col width=130>" +

	"<tr><td>Rows:</td>" +
	"<td><INPUT type=\"text\" id=inpRows name=inpRows size=2 value=2></td>" +
	"<td>Columns:</td>" +
	"<td><INPUT type=\"text\" id=inpCols name=inpCols size=2 value=2></td></tr>" +

	"<tr><td>Width:</td>" +
	"<td><INPUT type=\"text\" id=\"inpWidth\" name=inpWidth size=2 value=100>" +
	"<SELECT ID=\"inpWidthMe\" NAME=\"inpWidthMe\">" +
	"<OPTION value=\"\">pixels</OPTION>" +
	"<OPTION value=\"%\" selected>percent</OPTION>" +
	"</SELECT>" +
	"</td>" +
	"<td>Height:</td>" +
	"<td><INPUT type=\"text\" id=\"inpHeight\" name=inpHeight size=2>" +
	"<SELECT ID=\"Select2\" NAME=\"inpHeightMe\">" +
	"<OPTION value=\"\">pixels</OPTION>" +
	"<OPTION value=\"%\">percent</OPTION>" +
	"</SELECT>" +
	"</td></tr>" +

	"<tr><td colspan=4>Background Color:" +
	"<INPUT type=\"text\" id=\"inpBgColor\" name=inpBgColor size=6>" +
	"<INPUT type=\"button\" onclick=\"parent.displayBgColor()\" value=\"Pick\" ID=\"Button3\" NAME=\"Button3\">" +
	"</td></tr>" +
	"<tr><td colspan=4>" +
	"<div id=\"divBgColorPick\" style=\"display:none\"></div>" +
	"</td></tr>" +

	"<tr><td colspan=4>Background Image URL:" +
	"<INPUT type=\"text\" id=inpBgImage name=inpBgImage size=30></td></tr>" +

	"<tr><td>Border Size:</td>" +
	"<td><INPUT type=\"text\" id=inpBorder name=inpBorder size=2 value=1></td>" +
	"<td>Alignment:</td>" +
	"<td>" +
	"<SELECT ID=\"inpTblAlign\" NAME=\"inpTblAlign\">" +
	"<OPTION value=\"\"></OPTION>" +
	"<OPTION value=\"left\">Left</OPTION>" +
	"<OPTION value=\"center\">Center</OPTION>" +
	"<OPTION value=\"right\">Right</OPTION>" +
	"</SELECT>" +
	"</td></tr>" +

	"<tr><td colspan=4>Border Color:" +
	"<INPUT type=\"text\" id=inpBorderColor name=inpBorderColor size=6 value=\"#000000\">" +
	"<INPUT type=\"button\" onclick=\"parent.displayBorderColor()\" value=\"Pick\" ID=\"Button4\" NAME=\"Button4\">" +
	"</td></tr>" +
	"<tr><td colspan=4>" +
	"<div id=\"divBorderColorPick\" style=\"display:none\"></div>" +
	"</td></tr>" +

	"<tr><td>Cell Padding:</td>" +
	"<td><INPUT type=\"text\" id=inpPadding name=inpPadding size=2 value=0></td>" +
	"<td>Cell Spacing:</td>" +
	"<td><INPUT type=\"text\" id=inpSpacing name=inpSpacing size=2 value=0></td></tr>" +

	"<tr><td colspan=4><hr></td></tr>" +

	"<tr><td>&nbsp;</td>" +
	"<td align=right><INPUT type=\"button\" value=\"Cancel\" onclick=\"parent.popupHide();\"></td>" +
	"<td><INPUT type=\"button\" value=\"&nbsp;&nbsp;OK&nbsp;&nbsp;\" onclick=\"if(parent.TableInsert())parent.popupHide();\"></td>" +
	"<td>&nbsp;</td></tr>" +
	"</table>" +
	"</div>" +
	"<!-- /Insert Table Panel -->" +

	"<!-- Edit Table Panel -->" +
	"<div id=\"idEditTable\" align=left style=\"display:none\">" +
	"<table border=0 style=\"table-layout:fixed\" width=420 cellpadding=2 cellspacing=2 bgcolor=\"#ececec\" style=\"border-left: darkgray 1px solid; border-bottom: darkgray 1px solid; border-right: darkgray 1px solid;\" ID=\"Table2\">" +
	"<col width=80><col width=130><col width=80><col width=130>" +

	"<tr><td colspan=4>Background Color:" +
	"<INPUT type=\"text\" id=\"inpBgColor2\" name=inpBgColor2 size=6>" +
	"<INPUT type=\"button\" onclick=\"parent.displayBgColor2()\" value=\"Pick\" ID=\"Button1\" NAME=\"Button1\">" +
	"</td></tr>" +
	"<tr><td colspan=4>" +
	"<div id=\"divBgColor2Pick\" style=\"display:none\"></div>" +
	"</td></tr>" +

	"<tr><td colspan=4>Background Image URL:" +
	"<INPUT type=\"text\" id=inpBgImage2 name=inpBgImage2 size=30></td></tr>" +

	"<tr><td>Width:</td>" +
	"<td><INPUT type=\"text\" id=\"inpWidth2\" name=inpWidth2 size=2>" +
	"<SELECT ID=\"inpWidth2Me\" NAME=\"inpWidth2Me\">" +
	"<OPTION value=\"\">pixels</OPTION>" +
	"<OPTION value=\"%\">percent</OPTION>" +
	"</SELECT>" +
	"</td>" +
	"<td>Height:</td>" +
	"<td><INPUT type=\"text\" id=\"inpHeight2\" name=inpHeight2 size=2>" +
	"<SELECT ID=\"Select1\" NAME=\"inpHeight2Me\">" +
	"<OPTION value=\"\">pixels</OPTION>" +
	"<OPTION value=\"%\">percent</OPTION>" +
	"</SELECT>" +
	"</td></tr>" +

	"<tr><td>Cell Padding:</td>" +
	"<td><INPUT type=\"text\" id=inpPadding2 name=inpPadding2 size=2 value=0></td>" +
	"<td>Cell Spacing:</td>" +
	"<td><INPUT type=\"text\" id=inpSpacing2 name=inpSpacing2 size=2 value=0></td></tr>" +

	"<tr><td>Border Size:</td>" +
	"<td><INPUT type=\"text\" id=inpBorder2 name=inpBorder2 size=2 value=1></td>" +
	"<td>Alignment :</td>" +
	"<td>" +
	"<SELECT ID=\"inpTblAlign2\" NAME=\"inpTblAlign2\">" +
	"<OPTION value=\"left\">Left</OPTION>" +
	"<OPTION value=\"center\">Center</OPTION>" +
	"<OPTION value=\"right\">Right</OPTION>" +
	"</SELECT>" +
	"</td></tr>" +

	"<tr><td colspan=4>Border Color:" +
	"<INPUT type=\"text\" id=\"inpBorderColor2\" name=inpBorderColor2 size=6>" +
	"<INPUT type=\"button\" onclick=\"parent.displayBorderColor2()\" value=\"Pick\" ID=\"Button7\" NAME=\"Button7\">" +
	"</td></tr>" +
	"<tr><td colspan=4>" +
	"<div id=\"divBorderColor2Pick\" style=\"display:none\"></div>" +
	"</td></tr>" +

	"<tr><td colspan=4><hr></td></tr>" +

	"<tr><td>&nbsp;</td>" +
	"<td align=right><INPUT type=\"button\" value=\"Cancel\" onclick=\"parent.popupHide();\" id=\"Button5\" name=button1></td>" +
	"<td><INPUT type=\"button\" value=\"&nbsp;&nbsp;OK&nbsp;&nbsp;\" onclick=\"if(parent.TableUpdate())parent.popupHide();\" id=\"Button6\" name=button1></td>" +
	"<td>&nbsp;</td></tr>" +
	"</table>" +
	"</div>" +
	"<!-- /Edit Table Panel -->" +

	"<!-- Edit Cell Panel -->" +
	"<div id=\"idEditCell\" align=left style=\"display:none\">" +
	"<table border=0 style=\"table-layout:fixed\" width=420 cellpadding=2 cellspacing=2 bgcolor=\"#ececec\" style=\"border-left: darkgray 1px solid; border-bottom: darkgray 1px solid; border-right: darkgray 1px solid;\" ID=\"Table3\">" +
	"<col width=80><col width=130><col width=80><col width=130>" +

	"<tr><td colspan=4>Cell Background Color :" +
	"<INPUT type=\"text\" id=\"inpCellBgColor\" name=inpCellBgColor size=6>" +
	"<INPUT type=\"button\" onclick=\"parent.displayCellBgColor()\" value=\"Pick\" ID=\"Button2\" NAME=\"Button1\">" +
	"</td></tr>" +
	"<tr><td colspan=4>" +
	"<div id=\"divCellBgColorPick\" style=\"display:none\"></div>" +
	"</td></tr>" +

	"<tr><td colspan=4>Cell Background Image URL :" +
	"<INPUT type=\"text\" id=\"inpCellBgImage\" name=inpCellBgImage size=30></td></tr>" +

	"<tr><td>Cell Width :</td>" +
	"<td><INPUT type=\"text\" id=\"inpCellWidth\" name=inpCellWidth size=2>" +
	"<SELECT ID=\"inpCellWidthMe\" NAME=\"inpCellWidthMe\">" +
	"<OPTION value=\"\">pixels</OPTION>" +
	"<OPTION value=\"%\">percent</OPTION>" +
	"</SELECT>" +
	"</td>" +
	"<td>Cell Height :</td>" +
	"<td><INPUT type=\"text\" id=\"inpCellHeight\" name=inpCellHeight size=2>" +
	"<SELECT ID=\"inpCellHeightMe\" NAME=\"inpCellHeightMe\">" +
	"<OPTION value=\"\">pixels</OPTION>" +
	"<OPTION value=\"%\">percent</OPTION>" +
	"</SELECT>" +
	"</td></tr>" +

	"<tr><td>Alignment :</td>" +
	"<td>" +
	"<SELECT ID=\"inpCellAlign\" NAME=\"inpCellAlign\">" +
	"<OPTION value=\"left\">Left</OPTION>" +
	"<OPTION value=\"center\">Center</OPTION>" +
	"<OPTION value=\"right\">Right</OPTION>" +
	"</SELECT>" +
	"</td>" +
	"<td colspan=2>Vertical Alignment :" +
	"<SELECT ID=\"inpCellVAlign\" NAME=\"inpCellVAlign\">" +
	"<OPTION value=\"top\">Top</OPTION>" +
	"<OPTION value=\"middle\">Middle</OPTION>" +
	"<OPTION value=\"bottom\">Bottom</OPTION>" +
	"</SELECT>" +
	"</td></tr>" +

	"<tr><td>Wrap Text :</td>" +
	"<td><INPUT type=\"checkbox\" ID=\"inpCellWrap\" NAME=\"inpCellWrap\"></td>" +
	"<td colspan=2></td></tr>" +

	"<tr><td>Insert Row:</td>" +
	"<td colspan=3>" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableInsertRow('above');parent.popupHide();\" value=\"Above\" id=\"btnInsertRow\" NAME=\"btnInsertRow\">" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableInsertRow('below');parent.popupHide();\" value=\"Below\" id=\"btnInsertRow\" NAME=\"btnInsertRow\">" +
	"</td></tr>" +
	"<tr><td>Insert Column:</td>" +
	"<td colspan=3>" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableInsertCol('left');parent.popupHide();\" value=\"to the Left\" id=\"btnInsertColumn\" NAME=\"btnInsertColumn\">" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableInsertCol('right');parent.popupHide();\" value=\"to the Right\" id=\"btnInsertColumn\" NAME=\"btnInsertColumn\">" +
	"</td></tr>" +

	"<tr><td>Delete:</td>" +
	"<td colspan=3>" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableDeleteRow();parent.popupHide();\" value=\"Delete Row\" id=\"btnDeleteRow\" NAME=\"btnDeleteRow\">" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableDeleteCol();parent.popupHide();\" value=\"Delete Column\" id=\"btnDeleteColumn\" NAME=\"btnDeleteColumn\">" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableDeleteCell();parent.popupHide();\" value=\"Delete Cell\" id=\"btnDeleteCell\" NAME=\"btnDeleteCell\">" +
	"</td></tr>" +

	"<tr><td>Span:</td>" +
	"<td colspan=3>" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableColSpan();parent.popupHide();\" value=\"Columns Span\" id=\"btnColumnsSpan\" NAME=\"btnColumnsSpan\">" +
	"<INPUT style=\"width=95\" type=\"button\" onclick=\"parent.TableRowSpan();parent.popupHide();\" value=\"Rows Span\" id=\"btnRowsSpan\" NAME=\"btnRowsSpan\">" +
	"</td></tr>" +

	"<tr><td colspan=4><hr></td></tr>" +

	"<tr><td>&nbsp;</td>" +
	"<td align=right><INPUT type=\"button\" value=\"Cancel\" onclick=\"parent.popupHide();\"></td>" +
	"<td><INPUT type=\"button\" value=\"&nbsp;&nbsp;OK&nbsp;&nbsp;\" onclick=\"if(parent.CellUpdate())parent.popupHide();\"></td>" +
	"<td>&nbsp;</td></tr>" +

	"</table>" +
	"</div>" +
	"<!-- /Edit Cell Panel -->" +

	"</td>" +
	"</tr>" +
	"</table>"

	popupShow(440,"Create/Edit Table",sHTML)

	//set default value
	idContentTmp.inpRows.value = 2;
	idContentTmp.inpCols.value = 2;
	idContentTmp.inpTblAlign.value = "";
	idContentTmp.inpWidth.value = 99;
	idContentTmp.inpHeight.value = "";
	idContentTmp.inpPadding.value = 0;
	idContentTmp.inpSpacing.value = 0;
	idContentTmp.inpBorder.value = 1;
	idContentTmp.inpBorderColor.value = "";
	idContentTmp.inpBgImage.value = "";
	idContentTmp.inpBgColor.value = "";

	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oBlock = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TABLE") : GetElement(oSel.item(0),"TABLE"))
	if (oBlock!=null) //If inside existing table
		{
		//Get existing table properties
		idContentTmp.inpTblAlign2.value = oBlock.align

		var st = oBlock.width
		if(st.indexOf("%")!=-1)
			{
			idContentTmp.inpWidth2.value = st.substring(0,st.indexOf("%")) //remove last %
			idContentTmp.inpWidth2Me.value = "%"
			}
		else
			{
			idContentTmp.inpWidth2.value = oBlock.width
			idContentTmp.inpWidth2Me.value = ""
			}

		var st2 = oBlock.height
		if(st2.indexOf("%")!=-1)
			{
			idContentTmp.inpHeight2.value = st2.substring(0,st2.indexOf("%")) //remove last %
			idContentTmp.inpHeight2Me.value = "%"
			}
		else
			{
			idContentTmp.inpHeight2.value = oBlock.height
			idContentTmp.inpHeight2Me.value = ""
			}
		idContentTmp.inpPadding2.value = oBlock.cellPadding
		idContentTmp.inpSpacing2.value = oBlock.cellSpacing
		idContentTmp.inpBorder2.value = oBlock.border

		idContentTmp.inpBorderColor2.value = (oBlock.borderColor).substring(1)
		idContentTmp.inpBgImage2.value = oBlock.background
		idContentTmp.inpBgColor2.value = (oBlock.bgColor).substring(1)

		if(oSel.parentElement != null)//yg dipilih text, bukan control(=table)
			{//Get existing cell properties

			var oTD = GetElement(oSel.parentElement(),"TD");

			if(oTD==null)return; //jika yg di select adl text tapi meliputi lebih dari satu cell

			var st3 = oTD.width //HTML : width
			if(st3.indexOf("%")!=-1)
				{
				idContentTmp.inpCellWidth.value = st3.substring(0,st3.indexOf("%")) //remove last %
				idContentTmp.inpCellWidthMe.value = "%"
				}
			else
				{
				idContentTmp.inpCellWidth.value = oTD.width
				idContentTmp.inpCellWidthMe.value = ""
				}
			var st4 = oTD.height //HTML : height
			if(st4.indexOf("%")!=-1)
				{
				idContentTmp.inpCellHeight.value = st4.substring(0,st4.indexOf("%")) //remove last %
				idContentTmp.inpCellHeightMe.value = "%"
				}
			else
				{
				idContentTmp.inpCellHeight.value = oTD.height
				idContentTmp.inpCellHeightMe.value = ""
				}

			idContentTmp.inpCellAlign.value = oTD.align //HTML : align
			idContentTmp.inpCellVAlign.value = oTD.vAlign //HTML : vAlign
			idContentTmp.inpCellBgImage.value = oTD.background //HTML : background
			idContentTmp.inpCellBgColor.value = (oTD.bgColor).substring(1)	//HTML : bgColor
			idContentTmp.inpCellWrap.checked = !oTD.noWrap;

			//set the tab
			TabEditCell()
			}
		else
			{
			//set the tab
			TabEditTable()

			//disable create table & edit table
			TabDisable1()
			}
		}
	else
		{
		//set the tab
		TabInsertTable()

		//disable edit table & edit cell
		TabDisable2()
		}
}
/**********
**********/
function TabInsertTable() {
	idContentTmp.divBorderColorPick.style.display = "none";
	idContentTmp.divBgColorPick.style.display = "none";

	idContentTmp.idInsertTable.style.display="block";
	idContentTmp.idEditTable.style.display="none";
	idContentTmp.idEditCell.style.display="none";

	idContentTmp.tab1.style.cursor = "";
	idContentTmp.tab1.style.background = "#ececec";
	idContentTmp.tab1.style.color = "darkslateblue";
	idContentTmp.tab1.style.borderBottom = "";
	idContentTmp.tab1.innerHTML = "<b>Create Table</b>"

	idContentTmp.tab2.style.background = "#bebebe";
	idContentTmp.tab2.style.color = "darkslateblue";
	idContentTmp.tab2.style.borderBottom = "darkgray 1px solid";
	idContentTmp.tab2.innerHTML = "<div style='cursor:hand;width=100%;' onclick='parent.TabEditTable()'><b><u>Edit Table</u></b></div>"

	idContentTmp.tab3.style.background = "#bebebe";
	idContentTmp.tab3.style.color = "darkslateblue";
	idContentTmp.tab3.style.borderBottom = "darkgray 1px solid";
	idContentTmp.tab3.innerHTML = "<div style='cursor:hand;width=100%;' onclick='parent.TabEditCell()'><b><u>Edit Cell</u></b></div>"

	//when the control (table) is selected, the focus shouldn't be displayed.
	//Then set the focus to another control.
	//inpRows.focus();
}
/**********
**********/
function TabEditTable() {
	idContentTmp.divBorderColor2Pick.style.display = "none";
	idContentTmp.divBgColor2Pick.style.display = "none";

	idContentTmp.idInsertTable.style.display="none";
	idContentTmp.idEditTable.style.display="block";
	idContentTmp.idEditCell.style.display="none";

	idContentTmp.tab1.style.background = "#bebebe";
	idContentTmp.tab1.style.color = "darkslateblue";
	idContentTmp.tab1.style.borderBottom = "darkgray 1px solid";
	idContentTmp.tab1.innerHTML = "<div style='cursor:hand;width=100%;' onclick='parent.TabInsertTable()'><b><u>Create Table</u></b></div>"

	idContentTmp.tab2.style.cursor = "";
	idContentTmp.tab2.style.background = "#ececec";
	idContentTmp.tab2.style.color = "darkslateblue";
	idContentTmp.tab2.style.borderBottom = "";
	idContentTmp.tab2.innerHTML = "<b>Edit Table</b>"

	idContentTmp.tab3.style.background = "#bebebe";
	idContentTmp.tab3.style.color = "darkslateblue";
	idContentTmp.tab3.style.borderBottom = "darkgray 1px solid";
	idContentTmp.tab3.innerHTML = "<div style='cursor:hand;width=100%;' onclick='parent.TabEditCell()'><b><u>Edit Cell</u></b></div>"

	//when the control (table) is selected, the focus shouldn't be displayed.
	//Then set the focus to another control.
	//inpBgColor2.focus()
}
/**********
**********/
function TabEditCell() {
	idContentTmp.idEditCell.style.display="block";
	idContentTmp.divCellBgColorPick.style.display = "none";

	idContentTmp.idInsertTable.style.display="none";
	idContentTmp.idEditTable.style.display="none";
	idContentTmp.idEditCell.style.display="block";

	idContentTmp.tab1.style.background = "#bebebe";
	idContentTmp.tab1.style.color = "darkslateblue";
	idContentTmp.tab1.style.borderBottom = "darkgray 1px solid";
	idContentTmp.tab1.innerHTML = "<div style='cursor:hand;width=100%;' onclick='parent.TabInsertTable()'><b><u>Create Table</u></b></div>"

	idContentTmp.tab2.style.background = "#bebebe";
	idContentTmp.tab2.style.color = "darkslateblue";
	idContentTmp.tab2.style.borderBottom = "darkgray 1px solid";
	idContentTmp.tab2.innerHTML = "<div style='cursor:hand;width=100%;' onclick='parent.TabEditTable()'><b><u>Edit Table</u></b></div>"

	idContentTmp.tab3.style.cursor = "";
	idContentTmp.tab3.style.background = "#ececec";
	idContentTmp.tab3.style.color = "darkslateblue";
	idContentTmp.tab3.style.borderBottom = "";
	idContentTmp.tab3.innerHTML = "<b>Edit Cell</b>"

	//when the control (table) is selected, the focus shouldn't be displayed.
	//Then set the focus to another control.
	//inpCellBgColor.focus()
}
/**********
**********/
function TabDisable1() {
	idContentTmp.tab1.style.cursor = "";
	idContentTmp.tab1.style.background = "#bebebe";
	idContentTmp.tab1.style.color = "darkgray";
	idContentTmp.tab1.style.borderBottom = "";
	idContentTmp.tab1.innerHTML = "<b><u>Create Table</u></b>";

	idContentTmp.tab3.style.cursor = "";
	idContentTmp.tab3.style.background = "#bebebe";
	idContentTmp.tab3.style.color = "darkgray";
	idContentTmp.tab3.style.borderBottom = "";
	idContentTmp.tab3.innerHTML = "<b><u>Edit Cell</u></b>";
}
/**********
**********/
function TabDisable2() {
	idContentTmp.tab2.style.cursor = "";
	idContentTmp.tab2.style.background = "#bebebe";
	idContentTmp.tab2.style.color = "darkgray";
	idContentTmp.tab2.style.borderBottom = "";
	idContentTmp.tab2.innerHTML = "<b><u>Edit Table</u></b>";

	idContentTmp.tab3.style.cursor = "";
	idContentTmp.tab3.style.background = "#bebebe";
	idContentTmp.tab3.style.color = "darkgray";
	idContentTmp.tab3.style.borderBottom = "";
	idContentTmp.tab3.innerHTML = "<b><u>Edit Cell</u></b>";
}
/**********
**********/
function TableInsert() {
	if(!(IsPosIntNotZero(idContentTmp.inpRows.value) &&
		IsPosIntNotZero(idContentTmp.inpCols.value) &&
		IsPosIntNotZero(idContentTmp.inpWidth.value) &&
		IsPosIntNotZero(idContentTmp.inpHeight.value) &&
		IsPosInt(idContentTmp.inpBorder.value) &&
		IsPosInt(idContentTmp.inpPadding.value) &&
		IsPosInt(idContentTmp.inpSpacing.value)))
		{
		alert("Invalid input.");
		return false;
		}

	var sHTML = ""
		+ "<TABLE "
		+ (((idContentTmp.inpBorder.value=="") || (idContentTmp.inpBorder.value=="0")) ? "class=\"NOBORDER\"" : "")
		+	(idContentTmp.inpTblAlign.value != "" ? "align=\"" + idContentTmp.inpTblAlign.value + "\" " : "")
		+	(idContentTmp.inpWidth.value != "" ? "width=\"" + idContentTmp.inpWidth.value + idContentTmp.inpWidthMe.value + "\" " : "")
		+	(idContentTmp.inpHeight.value != "" ? "height=\"" + idContentTmp.inpHeight.value + idContentTmp.inpHeightMe.value + "\" " : "")
		+	(idContentTmp.inpPadding.value != "" ? "cellPadding=\"" + idContentTmp.inpPadding.value + "\" " : "")
		+	(idContentTmp.inpSpacing.value != "" ? "cellSpacing=\"" + idContentTmp.inpSpacing.value + "\" " : "")
		+	(idContentTmp.inpBorder.value != "" ? "border=\"" + idContentTmp.inpBorder.value + "\" " : "")
		+	(idContentTmp.inpBorderColor.value != "" ? "bordercolor=\"" + idContentTmp.inpBorderColor.value + "\" " : "")
		+	(idContentTmp.inpBgImage.value != "" ? "background=\"" + idContentTmp.inpBgImage.value + "\" " : "")
		+	(idContentTmp.inpBgColor.value != "" ? "bgColor=\"" + idContentTmp.inpBgColor.value + "\" " : "")
		+ ">"
	for (var i=0; i < idContentTmp.inpRows.value; i++)
		{
		sHTML += "<TR>"
		for (var j=0; j < idContentTmp.inpCols.value; j++)
		sHTML += "<TD></TD>"
		sHTML += "</TR>"
		}
	sHTML += "</TABLE>"

	//idContent.focus()
	var oSel = o_sel_save;
	var sType = s_sel_type;

	if (sType=="Control")oSel.item(0).outerHTML = sHTML
	else oSel.pasteHTML(sHTML)

	return true;
}
/**********
**********/
function TableUpdate() {
	if(!(IsPosIntNotZero(idContentTmp.inpWidth2.value) &&
		IsPosIntNotZero(idContentTmp.inpHeight2.value) &&
		IsPosInt(idContentTmp.inpPadding2.value) &&
		IsPosInt(idContentTmp.inpSpacing2.value) &&
		IsPosInt(idContentTmp.inpBorder2.value)))
		{
		alert("Invalid input.");
		return false;
		}

	//idContent.focus()
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oBlock = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TABLE") : GetElement(oSel.item(0),"TABLE"))
	if (oBlock!=null)
		{
		oBlock.align = idContentTmp.inpTblAlign2.value
		if(idContentTmp.inpWidth2.value!="")
			{
			oBlock.style.width=""; //remove style width
			oBlock.width = idContentTmp.inpWidth2.value + idContentTmp.inpWidth2Me.value;
			}
		else
			{
			oBlock.width = ""
			}
		if(idContentTmp.inpHeight2.value!="")
			{
			oBlock.style.height=""; //remove style height
			oBlock.height = idContentTmp.inpHeight2.value + idContentTmp.inpHeight2Me.value;
			}
		else
			{
			oBlock.height = ""
			}
		oBlock.cellPadding = idContentTmp.inpPadding2.value
		oBlock.cellSpacing = idContentTmp.inpSpacing2.value
		oBlock.border = idContentTmp.inpBorder2.value
		oBlock.borderColor = idContentTmp.inpBorderColor2.value
		oBlock.background = idContentTmp.inpBgImage2.value
		oBlock.bgColor = idContentTmp.inpBgColor2.value
		}

	oSel.select()
	return true;
}
/**********
**********/
function CellUpdate() {
	if(!(IsPosIntNotZero(idContentTmp.inpCellWidth.value) &&
		IsPosIntNotZero(idContentTmp.inpCellHeight.value)))
		{
		alert("Invalid input.");
		return false;
		}

	//idContent.focus()
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oTD = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TD") : GetElement(oSel.item(0),"TD"))
	if (oTD!=null)
		{
		if(idContentTmp.inpCellWidth.value!="")
			{
			//oTD.style.width=""; //remove style width => tdk perlu
			oTD.width = idContentTmp.inpCellWidth.value + idContentTmp.inpCellWidthMe.value;
			}
		else
			{
			oTD.width = ""
			}
		if(idContentTmp.inpCellHeight.value!="")
			{
			//oTD.style.height=""; //remove style height => tdk perlu
			oTD.height = idContentTmp.inpCellHeight.value + idContentTmp.inpCellHeightMe.value;
			}
		else
			{
			oTD.height = ""
			}

		oTD.align = idContentTmp.inpCellAlign.value ;
		oTD.vAlign = idContentTmp.inpCellVAlign.value;
		oTD.background = idContentTmp.inpCellBgImage.value;
		oTD.bgColor = idContentTmp.inpCellBgColor.value ;
		oTD.noWrap = !idContentTmp.inpCellWrap.checked;
		}

	oSel.select()

	return true;
}
/**********
**********/
function IsPosInt(sInput) {
	if(sInput=="") return true;//must be empty or number greater than or equal 0
	var sTmp = sInput.toString();
	for(var i=0;i<sTmp.length;i++)
		{
		var sChar = sTmp.charAt(i);
		if(sChar<"0"||sChar>"9") return false;
		}
	return true;
}
/**********
**********/
//must be empty or number greater than or equal 1
function IsPosIntNotZero(sInput) {
	if(sInput=="") return true;
	var sTmp = sInput.toString();
	for(var i=0;i<sTmp.length;i++)
		{
		var sChar = sTmp.charAt(i);
		if(sChar<"0"||sChar>"9") return false;
		}
	if(sInput*1==0) {return false}
	else {return true};
}
/**********
**********/
function TableInsertRow(type) {
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oBlock = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TABLE") : GetElement(oSel.item(0),"TABLE"))

	var numofrows = oBlock.rows.length; //num of rows

	//Dia ada di row mana ?
	var i,iRow;
	var oTR = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TR") : GetElement(oSel.item(0),"TR"))
	for (i=0;i<numofrows;i++)
		{
		if(oTR==oBlock.rows[i]) iRow=i;
		}

	var numofcols = oBlock.rows[0].cells.length //num of cols

	var elRow;
	if(type=="above") elRow = oBlock.insertRow(iRow); //insert above
	if(type=="below") elRow = oBlock.insertRow(iRow+1); //insert below

	for (i=0;i<numofcols;i++)
		{
		try
			{
			var elCell = elRow.insertCell()
			elCell.innerHTML = "&nbsp;"
			}
		catch(e)
			{}
		}
}
/**********
**********/
function TableDeleteRow() {
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oBlock = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TABLE") : GetElement(oSel.item(0),"TABLE"))
	var oTR = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TR") : GetElement(oSel.item(0),"TR"))

	try
		{
		var iRow;
		for (var i=0;i<oBlock.rows.length;i++) //num of rows
			{
			if(oTR==oBlock.rows[i])oBlock.deleteRow(i);
			}
		}
	catch(e)
		{
		return;
		}
}
/**********
**********/
function TableInsertCol(type) {
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oBlock = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TABLE") : GetElement(oSel.item(0),"TABLE"))

	//Di row yg aktif, dia ada di col mana ?
	var oTD = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TD") : GetElement(oSel.item(0),"TD"))
	var iCol;
	iCol = oTD.cellIndex; //insert left
	if(type=="right") iCol=iCol+1; //insert right

	var numofrows = oBlock.rows.length; //num of rows
	for (var i=0;i<numofrows;i++) //num of rows
		{
		try
			{
			var elCell = oBlock.rows[i].insertCell(iCol)
			elCell.innerHTML = "&nbsp;"
			}
		catch(e)
			{}
		}
}
/**********
**********/
function TableDeleteCol() {
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oBlock = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TABLE") : GetElement(oSel.item(0),"TABLE"))
	var oTD = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TD") : GetElement(oSel.item(0),"TD"))
	try
		{
		//Dia ada di row mana ?
		var iRow;
		var oTR = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TR") : GetElement(oSel.item(0),"TR"))
		for (var i=0;i<oBlock.rows.length;i++) //num of rows
			{
			if(oTR==oBlock.rows[i]) iRow=i;
			}
		//Di row yg aktif, dia ada di col mana ?
		var iCol = oTD.cellIndex;
		for (var i=0;i<oBlock.rows.length;i++) //num of rows
			{
			oBlock.rows[i].deleteCell(iCol);
			}
		}
	catch(e)
		{
		return;
		}
}
/**********
**********/
function TableDeleteCell() {
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oBlock = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TABLE") : GetElement(oSel.item(0),"TABLE"))
	var oTD = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TD") : GetElement(oSel.item(0),"TD"))
	try
		{
		//Dia ada di row mana ?
		var iRow;
		var oTR = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TR") : GetElement(oSel.item(0),"TR"))
		for (var i=0;i<oBlock.rows.length;i++) //num of rows
			{
			if(oTR==oBlock.rows[i]) iRow=i;
			}
		//Di row yg aktif, dia ada di col mana ?
		var iCol = oTD.cellIndex;
		oBlock.rows[iRow].deleteCell(iCol);
		}
	catch(e)
		{
		return;
		}
}
/**********
**********/
function TableColSpan() {
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oTD = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TD") : GetElement(oSel.item(0),"TD"))
	oTD.colSpan = 2;
}
/**********
**********/
function TableRowSpan() {
	var oSel = o_sel_save;
	var sType = s_sel_type;

	var oTD = (oSel.parentElement != null ? GetElement(oSel.parentElement(),"TD") : GetElement(oSel.item(0),"TD"));
	oTD.rowSpan = 2;
}
/**********
**********/
function LoadDoc() {
	if (displayMode == 'HTML') {
		idContent.document.body.innerText = idOriginal.innerHTML;
	} else {
		idContent.document.body.innerHTML = idOriginal.innerHTML;
	}
	var sDocBgColor= "";
	if(sDocBgColor!="") idContent.document.body.style.background = "";
}
/**********
**********/
function ClearDoc() {
	if (!confirm(s_confirm_clear_doc)) return;
	idContent.document.body.innerHTML = '';
	var sDocBgColor= "";
	if(sDocBgColor!="") idContent.document.body.style.background = "";
}
/**********
**********/
function RestoreDoc() {
	if (!confirm(s_confirm_restore_doc)) return;
	LoadDoc();
}
/**********
**********/
function initIcon() {
//	drawIcon(484,23,"btnRedo","Redo","doCmd('Redo')");

//	drawIcon(0,57,"btnStyle","Apply Style","displayStyleBox()");

//	alert("<span style=\"width: "+width+";height:22; clip: rect(0 "+width+" 22 0);overflow: hidden;\">	<span unselectable=\"on\" style=\"position:absolute;\">	<img unselectable=\"on\" id=\""+id+"\" 	title=\""+title+"\" onclick=\"if (document.activeElement.id!='idContent') { alert('" + s_pickfirst + "'); return };"+command+"\" src=\"" + s_img_path + "toolbar.gif\" 	style=\"position:absolute;top:0;left:-"+left+";\" 	onmouseover=\"this.style.pixelTop=-22\" 	onmousedown=\"this.style.pixelTop=-44\" 	onmouseup=\"this.style.pixelTop=-22\" 	onmouseout=\"this.style.pixelTop=0\" 	oncontextmenu=\"return false\" ondragstart=\"return false\" 	width=\"1151\" 	height=\"110\" />	<table width="+width+"><tr><td unselectable=\"on\" onselectstart='return false' style=\"position:absolute;top:4;left:7;\" id=\""+id+"Text\"></td></tr></table>	</span>	</span>");

//	drawIcon(163,110,"btnFontName","Font Name","displayFontNameBox()");
	document.write("<span id=\"test_span\" style=\"test;\"></span>");
	left = 163;
	width = 110; 
	id = "btnFontName";
	title = "Font Name"; 
	command = "displayFontNameBox()";

	document.write("<span style=\"width: "+width+";height:22; clip: rect(0 "+width+" 22 0);overflow: hidden;\">	<span unselectable=\"on\" style=\"position:absolute;\">	<img unselectable=\"on\" id=\""+id+"\" 	title=\""+title+"\" onclick=\"if (document.activeElement.id!='idContent') { alert('" + s_pickfirst + "'); return };"+command+"\" src=\"" + s_img_path + "toolbar.gif\" 	style=\"position:absolute;top:0;left:-"+left+";\" 	onmouseover=\"this.style.pixelTop=-22\" 	onmousedown=\"this.style.pixelTop=-44\" 	onmouseup=\"this.style.pixelTop=-22\" 	onmouseout=\"this.style.pixelTop=0\" 	oncontextmenu=\"return false\" ondragstart=\"return false\" 	width=\"1151\" 	height=\"110\" />	<table width="+width+"><tr><td unselectable=\"on\" onselectstart='return false' style=\"position:absolute;top:4;left:7;\" id=\""+id+"Text\"></td></tr></table>	</span>	</span>");	

	drawIcon(273,96,"btnFontSize","Font Size","displayFontSizeBox()");
	drawIcon(1013,23,"btnForeground","Foreground","displayFgColorBox()");
	drawIcon(1036,23,"btnBackground","Background","displayBgColorBox();");
	drawIcon(507,23,"btnBold","Bold (Ctrl+B)","doCmd('Bold');");
	drawIcon(530,23,"btnItalic","Italic (Ctrl+I)","doCmd('italic');");
	drawIcon(553,23,"btnUnderline","Underline (Ctrl+U)","doCmd('underline');");
	drawIcon(576,23,"btnStrikethrough","Strikethrough","doCmd('strikethrough');");
	drawIcon(599,23,"btnSuperscript","Superscript","doCmd('superscript');");
	drawIcon(622,23,"btnSubscript","Subscript","doCmd('subscript');");
	drawIcon(1082,23,"btnRemoveFormat","Remove Formatting","doCmd('removeformat')");

	drawIcon(645,23,"btnInsertSymbol","Insert Symbol","displaySymbolBox()");

	document.write("<br>");

	drawIcon(392,23,"btnCut","Cut (Ctrl+X)","doCmd('Cut');");
	drawIcon(415,23,"btnCopy","Copy (Ctrl+C)","doCmd('Copy');");
	drawIcon(438,23,"btnPaste","Paste (Ctrl+V)","doCmd('Paste');");
	drawIcon(461,23,"btnUndo","Undo (Ctrl+Z)","doCmd('Undo')");

	drawIcon(57,106,"btnParagraph","Paragraph","displayParagraphBox()");
	drawIcon(668,23,"btnJustifyLeft","Justify Left","doCmd('justifyleft');");
	drawIcon(691,23,"btnJustifyCenter","Justify Center","doCmd('justifycenter');");
	drawIcon(714,23,"btnJustifyRight","Justify Right","doCmd('justifyright');");
	drawIcon(737,23,"btnJustifyFull","Justify Full","doCmd('justifyfull');");
	drawIcon(760,23,"btnInsertOrderedList","Ordered List","doCmd('insertorderedlist');");
	drawIcon(783,23,"btnInsertUnorderedList","Unordered List","doCmd('insertunorderedlist');");
	drawIcon(806,23,"btnIndent","Indent","doCmd('indent');");
	drawIcon(829,23,"btnOutdent","Outdent","doCmd('outdent');");

	drawIcon(852,23,"btnHorizontalLine","Horizontal Line","doCmd('InsertHorizontalRule')");
	drawIcon(875,23,"btnTable","Create/Edit Table","displayTableBox()");
	drawIcon(898,23,"btnExternalLink","External Link","displayLinkBox()");
	drawIcon(944,23,"btnUnlink","Unlink","doCmd('unlink')");
	drawIcon(990,23,"btnInternalImage","Insert/Update Image","doCmd('DialogImage')");
}
/**********
**********/
function toogleIcon(opt) {
	var a_icon = new Array('btnStyle', 'btnFontName', 'btnFontSize', 'btnParagraph', 'btnCut', 'btnCopy', 'btnPaste', 'btnUndo', 'btnBold', 'btnItalic', 'btnUnderline', 'btnStrikethrough', 'btnSuperscript', 'btnSubscript', 'btnJustifyLeft', 'btnJustifyCenter', 'btnJustifyRight', 'btnJustifyFull', 'btnInsertOrderedList', 'btnInsertUnorderedList', 'btnIndent', 'btnOutdent', 'btnHorizontalLine', 'btnTable', 'btnExternalLink', 'btnUnlink', 'btnInternalImage', 'btnForeground', 'btnBackground', 'btnRemoveFormat', 'btnInsertSymbol');
	var n_len = a_icon.length;
	var s_visible = (opt == 1) ? '' : 'hidden';
	for (i = 0;  i < n_len; i++) {
		eval('document.all.' + a_icon[i] + '.style.visibility = "' + s_visible + '"');
	}
}