function handleError() 
{
	return true;
}
window.onerror = handleError;
var oUtil=new InnovaEditorUtil();
function InnovaEditorUtil()
{
	this.oName;
	this.oSel;
	this.sType;
	this.bInside=bInside;
	this.useSelection=true;

	this.arrEditor=[];
}
function doBlur()
{
	var oEditor=eval("idContent"+this.oName);
	var oSel=oEditor.document.selection.createRange();
	var sType=oEditor.document.selection.type;

	oUtil.useSelection=true;
	if(oSel.parentElement!=null)
	{
		if(!bInside(oSel.parentElement())) oUtil.useSelection=false;
	}
	else
	{
		if(!bInside(oSel.item(0))) oUtil.useSelection=false;
	}
	if(oUtil.useSelection)
	{
		oUtil.oSel=oSel;
		oUtil.sType=sType;
	}
}
function bInside(oElement)
{
	while(oElement!=null)
	{
		if(oElement.contentEditable=="true")return true;
		oElement=oElement.parentElement;
	}
	return false;
}
function checkFocus()
{
	var oEditor=eval("idContent"+this.oName);
	var oSel=oEditor.document.selection.createRange();
	var sType=oEditor.document.selection.type;

	isInside=true;
	if(oSel.parentElement!=null)
		{
		if(!bInside(oSel.parentElement()))isInside=false;
		}
	else
		{
		if(!bInside(oSel.item(0)))isInside=false;
		}

	if(!isInside)
		{
		if(oUtil.useSelection)
			{
			oSel=oUtil.oSel;
			sType=oUtil.sType;
			try
				{
				if (oSel.parentElement)	oElement=oSel.parentElement();
				else oElement=oSel.item(0);
				}
			catch(e)
				{
				return false;
				}
			}
		else
			{
			return false;
			}
		}
	return true;
	}
function focus()
{
	var oEditor=eval("idContent"+this.oName);
	
	oEditor.focus()
}

/*********************
	EDITOR OBJECT
**********************/
function InnovaEditor(oName)
	{
	this.oName=oName;
	this.RENDER=RENDER;

	this.loadHTML=loadHTML;
	this.getHTMLBody=getHTMLBody;
	this.getHTML=getHTML;
	this.putHTML=putHTML;

	this.doBlur=doBlur;
	this.bInside=bInside;
	this.checkFocus=checkFocus;
	this.focus=focus;

	this.doCmd=doCmd;
	this.applyParagraph=applyParagraph;
	this.applyFontName=applyFontName;
	this.applyFontSize=applyFontSize;

	this.hide=hide;
	this.dropShow=dropShow;

	this.publishingPath="";//ex."http://localhost/InnovaStudio/"

	this.width="580";
	this.height="350";

	this.scriptPath="scripts/";//relative to root can be used

	this.writeIcon=writeIcon;
	this.writeIcon2=writeIcon2;
	this.iconPath="icons/";
	this.iconWidth=21;this.iconHeight=21;

	this.runtimeBorder=runtimeBorder;
	this.runtimeBorderOn=runtimeBorderOn;
	this.runtimeBorderOff=runtimeBorderOff;
	this.IsRuntimeBorderOn=true;

	this.useLastForeColor=true;
	this.stateForeColor="";
	this.btnTagSelector=true;
	this.fullScreen=fullScreen;
	this.stateFullScreen=true;
	this.btnFullScreen=true;this.btnTextFormatting=true;this.btnCssText= false;
	this.btnParagraph=true;this.btnFontName=true;this.btnFontSize=true;
	this.btnBold=true;this.btnItalic=true;this.btnUnderline=true;
	this.btnJustifyLeft=true;this.btnJustifyCenter=true;this.btnJustifyRight=true;this.btnJustifyFull=true;
	this.btnNumbering=true;this.btnBullets=true;this.btnForeColor=true;
	this.btnHyperlink=true;	this.btnImage=false;this.btnClean=true;
	this.btnAssets=false;this.btnAssetManager=false;
	this.btnHTMLSource=true;
	this.btnHTMLFullSource=false;

	//ADDITIONAL BUTTONS for COMMON CMS FUNCTIONS *********
	this.btnAssetsPublic=false;
	this.btnAssetManagerPublic=false;
	this.btnContentBlock=false;
	
	this.cmdAssetsPublic="";
	this.cmdAssetManagerPublic="";
	this.cmdContentBlock="";
	//*****************************************************

	//this.cmdAssets="modalDialogShow('assets.asp',680,520)";
	this.cmdAssetManager="";

	this.arrParagraph= [["Heading 1","H1"],
						["Heading 2","H2"],
						["Heading 3","H3"],
						["Heading 4","H4"],
						["Heading 5","H5"],
						["Heading 6","H6"],
						["Preformatted","PRE"],
						["Normal (P)","P"],
						["Normal (DIV)","DIV"]];

	this.arrFontName = ["Arial",
						"Arial Black",
						"Book Antiqua",
						"Comic Sans MS",
						"Courier New",
						"Georgia",
						"Impact",
						"Symbol",
						"Tahoma",
						"Times New Roman",
						"Trebuchet MS",
						"Verdana",
						"Webdings",
						"Wingdings",
						"serif",
						"sans-serif",
						"cursive",
						"fantasy",
						"monoscape"];

	this.arrFontSize = [["Size 1","1"],
						["Size 2","2"],
						["Size 3","3"],
						["Size 4","4"],
						["Size 5","5"],
						["Size 6","6"],
						["Size 7","7"]];

	this.initialRefresh = false;
	}

/*********************
	RENDER
**********************/
function RENDER()
	{
	/******** ICONS ********/
	var sHTMLDropMenus="";
	var sHTMLIcons="";

	var sTmp="";

	if(this.btnFullScreen)
	sHTMLIcons+=this.writeIcon("Full Screen",this.oName+".fullScreen()","btn_fullscreen.gif");

	if(this.btnCssText)
		sTmp+= "<tr><td onclick=\"window.showModelessDialog('"+this.scriptPath+"styles_cssText.htm',window," +
				"'dialogWidth:456px;dialogHeight:443px;edge:Raised;center:Yes;help:No;resizable:No;status:No');" +
				" dropStyle.style.display='none'\""+
				" style=\"padding:2px;padding-top:1px;font-family:Tahoma;font-size:11px;background-color:#F8F8FF\" " +
				"onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" " +
				"onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>Custom CSS</td></tr>";

   
  
	if(this.btnCssText)
		{
		sHTMLIcons+=this.writeIcon("Styles & Formatting",this.oName+".dropShow(this,dropStyle)","btn_style.gif");
		if(!document.getElementById("dropStyle"))
			sHTMLDropMenus+="<table id=dropStyle cellpadding=0 cellspacing=0 " +
				"style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;" +
				"cursor:default;background-color:#F8F8FF;' unselectable=on>"+
				sTmp + "</table>";
		}
  
	if(this.btnParagraph)
		{
		sHTMLDropMenus+= "<table id=dropParagraph"+this.oName+" cellpadding=0 cellspacing=0 " +
			"style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;" +
			"cursor:default;background-color:ghostwhite;' unselectable=on>";
		for(var i=0;i<this.arrParagraph.length;i++)
			{
			sHTMLDropMenus+= "<tr><td  onclick=\""+this.oName+".applyParagraph('<"+this.arrParagraph[i][1]+">')\" " +
				"style=\"padding:0;padding-left:5px;padding-right:5px;font-family:tahoma;background-color:ghostwhite\" " +
				"onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" " +
				"onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on align=center>" +
				"<"+this.arrParagraph[i][1]+" style=\"\margin-bottom:4px\"  unselectable=on> " +
				this.arrParagraph[i][0] + "</"+this.arrParagraph[i][1]+"></td></tr>";
			}
		sHTMLDropMenus+= "</table>";
		sHTMLIcons+=this.writeIcon2("Paragraph","Paragraph",this.oName+".dropShow(this,dropParagraph"+this.oName+")","btn_paragraph.gif",89);
		}

	if(this.btnFontName)
		{
		sHTMLDropMenus+= "<table id=dropFontName"+this.oName+" cellpadding=0 cellspacing=0 " +
			"style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;" +
			"cursor:default;background-color:ghostwhite;' unselectable=on>";
		for(var i=0;i<this.arrFontName.length;i++)
			{
			sHTMLDropMenus+= "<tr><td onclick=\""+this.oName+".applyFontName('"+this.arrFontName[i]+"')\" " +
				"style=\"padding:2px;padding-top:1px;font-family:"+ this.arrFontName[i] +";font-size:11px;background-color:ghostwhite\" " +
				"onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" " +
				"onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on>" +
				this.arrFontName[i] + " <span  unselectable=on style='font-family:tahoma'>("+ this.arrFontName[i] +")</span></td></tr>";
			}
		sHTMLDropMenus+= "</table>";
		sHTMLIcons+=this.writeIcon2("Font Name","Font Name",this.oName+".dropShow(this,dropFontName"+this.oName+")","btn_fontname.gif",90);
		}

	if(this.btnFontSize)
		{
		sHTMLDropMenus+= "<table id=dropFontSize"+this.oName+" cellpadding=0 cellspacing=0 " +
			"style='z-index:1;display:none;position:absolute;border:#716F64 1px solid;" +
			"cursor:default;background-color:ghostwhite;' unselectable=on>";
		for(var i=0;i<this.arrFontSize.length;i++)
			{
			sHTMLDropMenus+= "<tr><td onclick=\""+this.oName+".applyFontSize('"+this.arrFontSize[i][1]+"')\" " +
				"style=\"padding:0;padding-left:5px;padding-right:5px;font-family:tahoma;background-color:ghostwhite\" " +
				"onmouseover=\"this.style.backgroundColor='#708090';this.style.color='#FFFFFF';\" " +
				"onmouseout=\"this.style.backgroundColor='';this.style.color='#000000';\" unselectable=on align=center>" +
				"<font unselectable=on size=\""+this.arrFontSize[i][1]+"\"> " +
				this.arrFontSize[i][0] + "</font></td></tr>";
			}
		sHTMLDropMenus+= "</table>";
		sHTMLIcons+=this.writeIcon2("Font Size","Size",this.oName+".dropShow(this,dropFontSize"+this.oName+")","btn_fontsize.gif",48);
		}

	if(this.btnBold) sHTMLIcons+=this.writeIcon("Bold",this.oName+".doCmd('Bold')","btn_bold.gif");
	if(this.btnItalic) sHTMLIcons+=this.writeIcon("Italic",this.oName+".doCmd('Italic')","btn_italic.gif");
	if(this.btnUnderline) sHTMLIcons+=this.writeIcon("Underline",this.oName+".doCmd('Underline')","btn_underline.gif");
	if(this.btnJustifyLeft) sHTMLIcons+=this.writeIcon("Justify Left",this.oName+".doCmd('JustifyLeft')","btn_left.gif");
	if(this.btnJustifyCenter) sHTMLIcons+=this.writeIcon("Justify Center",this.oName+".doCmd('JustifyCenter')","btn_center.gif");
	if(this.btnJustifyRight) sHTMLIcons+=this.writeIcon("Justify Right",this.oName+".doCmd('JustifyRight')","btn_right.gif");
	if(this.btnJustifyFull) sHTMLIcons+=this.writeIcon("Justify Full",this.oName+".doCmd('JustifyFull')","btn_full.gif");
	if(this.btnNumbering) sHTMLIcons+=this.writeIcon("Numbering",this.oName+".doCmd('InsertOrderedList')","btn_numbering.gif");
	if(this.btnBullets) sHTMLIcons+=this.writeIcon("Bullets",this.oName+".doCmd('InsertUnorderedList')","btn_bullets.gif");

	if(this.btnForeColor)
		sHTMLIcons+=this.writeIcon("Foreground Color",
			"modelessDialogShow('"+this.scriptPath+"colors_foreground.htm',380,310)","btn_forecolor.gif");

	if(this.btnImage)
		sHTMLIcons+=this.writeIcon("External Image",
			"modelessDialogShow('"+this.scriptPath+"image.htm',416,283)","btn_image.gif");

	if(this.btnAssets) sHTMLIcons+=this.writeIcon("Assets",this.cmdAssets,"btn_assets.gif");	
	if(this.btnAssetManager) sHTMLIcons+=this.writeIcon("Asset Manager",this.cmdAssetManager,"btn_assetmanager.gif");
	
	//ADDITIONAL BUTTONS for COMMON CMS FUNCTIONS *********
	if(this.btnAssetsPublic) sHTMLIcons+=this.writeIcon("Public Assets",this.cmdAssetsPublic,"btn_assets2.gif");	
	if(this.btnAssetManagerPublic) sHTMLIcons+=this.writeIcon("Public Asset Manager",this.cmdAssetManagerPublic,"btn_assetmanager2.gif");
	if(this.btnContentBlock) sHTMLIcons+=this.writeIcon("Content Block",this.cmdContentBlock,"btn_customtag.gif");	
	//*****************************************************
	
	if(this.btnInternalLink) sHTMLIcons+=this.writeIcon("Internal Link",this.cmdInternalLink,"btn_internallink.gif");
	
	if(this.btnClean) sHTMLIcons+=this.writeIcon("Clean",this.oName+".doCmd('RemoveFormat')","btn_clean.gif");
	if(this.btnHTMLFullSource)
		sHTMLIcons+=this.writeIcon("View/Edit Source","window.showModalDialog('"+this.scriptPath+"source_html_full.htm',window," +
			"'dialogWidth:600px;dialogHeight:555px;edge:Raised;center:Yes;help:No;resizable:Yes;status:No;Maximize:Yes')","btn_html.gif");
	if(this.btnHTMLSource)
	sHTMLIcons+=this.writeIcon("View/Edit Source","window.showModalDialog('"+this.scriptPath+"source_html.htm',window," +
			"'dialogWidth:600px;dialogHeight:555px;edge:Raised;center:Yes;help:No;resizable:Yes;status:No;Maximize:Yes')","btn_html.gif");
	if(this.btnTagSelector)
		sHTMLIcons+=this.writeIcon("Tag Selector","window.showModelessDialog('"+this.scriptPath+"tag_selector.htm',window," +
				"'dialogWidth:150px;dialogHeight:150px;edge:Raised;center:Yes;help:No;resizable:Yes;status:No;maximize:No;border:thin;statusbar:no')","btn_tags.gif");
	/******** /ICONS ********/

	var sHTML="";
	sHTML+="<table id=idArea"+this.oName+" name=idArea"+this.oName+" border=0 " +
			"cellpadding=0 cellspacing=0 width='"+this.width+"' height='"+this.height+"'>" +
			"<tr><td bgcolor=#e0e0e0 style='padding-top:3px;padding-left:1px;" + //info: adjustment left here, 1.5.1
			"filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#f1f1f1,endColorstr=#d4d4d4);'>" +
			"<span>" +
			sHTMLIcons +
			"</span>" +
			"</td></tr><tr><td valign=top height=100% style='background:white'>";

	
	sHTML+="<iframe  style='width:100%;height:100%;margin-top:1px;' src='"+this.scriptPath+"blank.gif'" +
			" name=idContent"+ this.oName + " id=idContent  "+ this.oName +
			" contentEditable=true onfocus=\"oUtil.oName='"+ this.oName +"';"+this.oName+".hide()\" " +
			" onblur=\""+this.oName+".doBlur();\"></iframe>" ;

	//Paste From Word Temp. Area
	sHTML+="<iframe style='width:1px;height:1px;overflow:auto;' src='"+this.scriptPath+"blank.gif'" +
					" name=idContentWord"+ this.oName +" id=idContentWord"+ this.oName +
					" contentEditable=true onfocus='"+this.oName+".hide()'></iframe>";
	
	//XHTML Conversion Temp. Area
	if(!document.getElementById("idSourceTmp"))
		{
		sHTML+="<iframe style='width:1px;height:1px;overflow:auto;' src='"+this.scriptPath+"blank.gif'" +
					" name=idSourceTmp id=idSourceTmp contentEditable=true></iframe>";			
		}
		
	//realTime
	if(!document.getElementById("btnRealTime"))
    {
		document.write("<input type=button style='position:absolute;width:1px;height:1px' id=btnRealTime name=btnRealTime>");
    }

	sHTML+="</td></tr></table>";

	sHTML+=sHTMLDropMenus; //dropdown

	document.write(sHTML);

	//paste from word temp storage
	var oWord = eval("idContentWord"+this.oName);
	oWord.document.designMode = "on";
	oWord.document.open("text/html","replace");
	oWord.document.write("<html><head></head><body></body></html>");
	oWord.document.close();
	oWord.document.body.contentEditable=true;

	oUtil.oName=this.oName;//default active editor
	
	oUtil.arrEditor.push(this.oName)
	}

/*********************
	CONTENT
**********************/
function loadHTML(sHTML)//hanya utk first load.
	{
	var oEditor=eval("idContent"+this.oName);

	var oDoc = oEditor.document.open("text/html", "replace");
	if(this.publishingPath!="")
		{
		if(sHTML.indexOf("<BASE")==-1)
			{
			//sHTML="<BASE HREF=\""+this.publishingPath+"\"/>" + sHTML;
			sHTML="<HTML><HEAD><BASE HREF=\""+this.publishingPath+"\"/></HEAD><BODY contentEditable=true>" + sHTML + "</BODY></HTML>";
			//kalau cuma tambah <HTML><HEAD></HEAD><BODY.. tdk apa2.
			}
		}
	else
		{
		sHTML="<HTML><HEAD></HEAD><BODY contentEditable=true>" + sHTML + "</BODY></HTML>";
		}
	oDoc.write(sHTML);
	oDoc.close();

	oEditor.document.body.contentEditable=true;
	oEditor.document.execCommand("2D-Position", true, true);//make focus
	oEditor.document.execCommand("MultipleSelection", true, true);//make focus
	oEditor.document.execCommand("LiveResize", true, true);//make focus

	oEditor.document.body.onkeydown = new Function("editorDoc_onkeydown('" + this.oName + "')");
	oEditor.document.body.onkeyup = new Function("editorDoc_onkeyup('" + this.oName + "')");
	oEditor.document.body.onmouseup = new Function("editorDoc_onmouseup('" + this.oName + "')");

	//*** RUNTIME STYLES ***
	eval(this.oName).runtimeBorder(false);
	//***********************

	//fix undisplayed content
	if(this.initialRefresh)
		{
		oEditor.document.execCommand("SelectAll");
		window.setTimeout("eval('idContentWord"+this.oName+"').document.execCommand('SelectAll');",0);
		}

	oEditor.document.body.style.width=50;
	oEditor.document.body.style.height=50;
	oEditor.document.body.style.width="";
	oEditor.document.body.style.height="";
	//oEditor.document.body.style.cssText="overflow-x:scroll;overflow-y:scroll";
	}

function putHTML(sHTML)
{
	var oEditor=eval("idContent"+this.oName);

	var oDoc = oEditor.document.open("text/html", "replace");
	oDoc.write(sHTML);
	oDoc.close();
	
	oEditor.document.body.contentEditable=true;
	oEditor.document.execCommand("2D-Position", true, true);
	oEditor.document.execCommand("MultipleSelection", true, true);
	oEditor.document.execCommand("LiveResize", true, true);

	oEditor.document.body.onkeydown = new Function("editorDoc_onkeydown('" + this.oName + "')");
	oEditor.document.body.onkeyup = new Function("editorDoc_onkeyup('" + this.oName + "')");
	oEditor.document.body.onmouseup = new Function("editorDoc_onmouseup('" + this.oName + "')");

	//*** RUNTIME STYLES *** 
	eval(this.oName).runtimeBorder(false);
	//***********************
}
function getHTML()//RICH Mode
{
	var oEditor=eval("idContent"+this.oName);
	sHTML = oEditor.document.documentElement.outerHTML;
	sHTML = jsReplace(sHTML," contentEditable=true","");
	return sHTML;
}
function getHTMLBody()//RICH Mode
{
	var oEditor=eval("idContent"+this.oName);
	sHTML = oEditor.document.body.innerHTML;
	sHTML = jsReplace(sHTML," contentEditable=true","");
	return sHTML;
}
function fullScreen()
{
	this.hide();
	if(this.stateFullScreen)
		{
		this.stateFullScreen=false;

		eval("idArea" + this.oName).style.position = "";
		eval("idArea" + this.oName).style.top = "0";
		eval("idArea" + this.oName).style.left = "0";
		eval("idArea" + this.oName).style.width = this.width;
		eval("idArea" + this.oName).style.height = this.height;

		for(var i=0;i<oUtil.arrEditor.length;i++)
			{
			if(oUtil.arrEditor[i]!=this.oName) eval("idArea" + oUtil.arrEditor[i]).style.display="block";
			}
		}
	else
		{
		this.stateFullScreen=true;

		eval("idArea" + this.oName).style.position = "absolute";
		eval("idArea" + this.oName).style.top = "0";
		eval("idArea" + this.oName).style.left = "0";
		if(document.body.style.overflow=="hidden")
		{
			w=(document.body.offsetWidth)
		}
		else
		{
		    w=(document.body.offsetWidth-22)
		}
		h=(document.body.offsetHeight)
		eval("idArea" + this.oName).style.width = w;
		eval("idArea" + this.oName).style.height = h;

		for(var i=0;i<oUtil.arrEditor.length;i++)
		{
			if(oUtil.arrEditor[i]!=this.oName) eval("idArea" + oUtil.arrEditor[i]).style.display="none";
		}			
		
		var oEditor=eval("idContent"+this.oName);
		oEditor.focus();//1.7.2
				
    }
}
/*********************
REALTIME
**********************/
function editorDoc_onkeydown(oName)
{
	realTime(oName);
}
function editorDoc_onkeyup(oName)
{
	realTime(oName);
}
function editorDoc_onmouseup(oName)
{
	realTime(oName);
}
var arrTmp = []
function GetElement(oElement,sMatchTag)//Used in realTime() only. 1.5.1
{
	while (oElement!=null && oElement.tagName!=sMatchTag)
    {
		if(oElement.tagName=="BODY") return null;
		oElement = oElement.parentElement;
	}
	return oElement;
}
function realTime(oName)
{
	document.all.btnRealTime.click();
}
function selectElement(oName,i)
	{
	var oEditor=eval("idContent"+oName);
	var oSelRange = oEditor.document.body.createControlRange()
	try
		{
		oSelRange.add(arrTmp[i]);
		oSelRange.select();
		}
	catch(e)
		{
		var oSelRange = oEditor.document.body.createTextRange();
		oSelRange.moveToElementText(arrTmp[i]);
		oSelRange.select();
		}

	realTime(oName);
	}
/*********************
	RUNTIME BORDERS
**********************/
function runtimeBorderOn()
	{
	eval(this.oName).runtimeBorderOff();//reset

	var oEditor=eval("idContent"+this.oName);
	var oTables = oEditor.document.getElementsByTagName("TABLE");
	for (i=0;i<oTables.length;i++)
		{
		if(oTables[i].border==0)
			{
			for(j=0;j<oTables[i].getElementsByTagName("TD").length;j++)
				{
				if(oTables[i].getElementsByTagName("TD")[j].style.borderLeftWidth=="0px"||
					oTables[i].getElementsByTagName("TD")[j].style.borderLeftWidth=="" ||
					oTables[i].getElementsByTagName("TD")[j].style.borderLeftWidth=="medium")
						{
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderLeftWidth=1;
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderLeftColor = "#BCBCBC";
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderLeftStyle = "dotted";
						}
				if(oTables[i].getElementsByTagName("TD")[j].style.borderRightWidth=="0px"||
					oTables[i].getElementsByTagName("TD")[j].style.borderRightWidth=="" ||
					oTables[i].getElementsByTagName("TD")[j].style.borderRightWidth=="medium")
						{
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderRightWidth=1;
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderRightColor = "#BCBCBC";
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderRightStyle = "dotted";
						}
				if(oTables[i].getElementsByTagName("TD")[j].style.borderTopWidth=="0px"||
					oTables[i].getElementsByTagName("TD")[j].style.borderTopWidth=="" ||
					oTables[i].getElementsByTagName("TD")[j].style.borderTopWidth=="medium")
						{
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderTopWidth=1;
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderTopColor = "#BCBCBC";
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderTopStyle = "dotted";
						}
				if(oTables[i].getElementsByTagName("TD")[j].style.borderBottomWidth=="0px"||
					oTables[i].getElementsByTagName("TD")[j].style.borderBottomWidth=="" ||
					oTables[i].getElementsByTagName("TD")[j].style.borderBottomWidth=="medium")
						{
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderBottomWidth=1;
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderBottomColor = "#BCBCBC";
						oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderBottomStyle = "dotted";
						}
				}
			}
		}
	}
function runtimeBorderOff()
{
	var oEditor=eval("idContent"+this.oName);
	var oTables = oEditor.document.getElementsByTagName("TABLE");
	for (i=0;i<oTables.length;i++)
	{
		if(oTables[i].border==0)
		{
			for(j=0;j<oTables[i].getElementsByTagName("TD").length;j++)
			{
				oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderWidth = "";
				oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderColor = "";
				oTables[i].getElementsByTagName("TD")[j].runtimeStyle.borderStyle = "";
			}
		}
 	}
}
function runtimeBorder(bToggle)
{
	if(bToggle)
		{
		if(this.IsRuntimeBorderOn)
		{
			this.runtimeBorderOff();
			this.IsRuntimeBorderOn=false;
		}
    	else
		{
			this.runtimeBorderOn();
			this.IsRuntimeBorderOn=true;
			}
		}
	    else
		{
		    if(this.IsRuntimeBorderOn)
			{
			   this.runtimeBorderOn();
			}
		    else
			{
			   this.runtimeBorderOff();
			}
	    }		
}
/*********************
TOOLBAR ICONS
**********************/
function writeIcon(title,command,img)
{
	w = this.iconWidth;
	h = this.iconHeight;
	imgPath = this.scriptPath+this.iconPath+img;
	sHTML="" +
		"<span unselectable='on' style='margin-left:0;margin-right:1;margin-bottom:1;width:"+w+";height:"+h+";'>" +
		"<span unselectable='on' style='position:absolute;clip: rect(0 "+w+"px "+h+"px 0)'>" +
		"<img unselectable='on' btntoggle=true title='"+title+"' src='"+imgPath+"' style='position:absolute;top:-0;width:"+w+"'" +
		"onmouseover='this.style.top=-"+h+"' onmouseout='this.style.top=0'" +
		"onmousedown='this.style.top=-"+2*h+"' onmouseup=\"this.style.top=0;"+command+";\">" +
		"</span></span>";

	return sHTML;
}
function writeIcon2(title,caption,command,img,width)
{
	h = this.iconHeight;
	imgPath = this.scriptPath+this.iconPath+img;
	sHTML="" +
		"<span unselectable='on' style='margin-left:0;margin-right:1;margin-bottom:1;width:"+width+";height:"+h+";'>" +
		"<span unselectable='on' style='position:absolute;clip: rect(0 "+width+"px "+h+"px 0)'>" +
		"<img unselectable='on' btntoggle=true title='"+title+"' src='"+imgPath+"' style='position:absolute;top:-0;width:"+width+"'" +
		"onmouseover='this.style.top=-"+h+"' onmouseout='this.style.top=0'" +
		"onmousedown='this.style.top=-"+2*h+"' onmouseup=\"this.style.top=0;"+command+";\">" +
		"</span></span>";

	return sHTML;
}

/*********************
	OTHERS
**********************/
function doCmd(sCmd,sOption)
{
	//Focus stuff
	if(!eval(this.oName).checkFocus())return;

	var oEditor=eval("idContent"+this.oName);
	var oSel=oEditor.document.selection.createRange();
	var sType=oEditor.document.selection.type;
	var oTarget=(sType=="None" ? oEditor.document : oSel);
	oTarget.execCommand(sCmd, false, sOption);
}
function applyParagraph(val)
{
	var oEditor=eval("idContent"+this.oName);

	var oSel=oEditor.document.selection.createRange();
	eval(this.oName).hide();
	oSel.select()

	eval(this.oName).doCmd("FormatBlock",val);
	
}
function applyFontName(val)
{
	var oEditor=eval("idContent"+this.oName);

	var oSel=oEditor.document.selection.createRange();
	eval(this.oName).hide();
	oSel.select()

	eval(this.oName).doCmd("fontname",val);
}
function applyFontSize(val)
{
	var oEditor=eval("idContent"+this.oName);

	var oSel=oEditor.document.selection.createRange();
	eval(this.oName).hide();
	oSel.select();

	eval(this.oName).doCmd("fontsize",val);
}
function dropShow(oEl,box)
{
	eval(this.oName).hide();

	box.style.display="block";
	var nTop=0;
	var nLeft=0;

	oElTmp = oEl;
	while(oElTmp.tagName!="BODY" && oElTmp.tagName!="HTML")
	{
		if(oElTmp.style.top!="")
		{
			nTop += oElTmp.style.top.substring(1,oElTmp.style.top.length-2) * 1;
		}
		else nTop +=oElTmp.offsetTop;
		oElTmp = oElTmp.offsetParent;
	}
	
	oElTmp = oEl;
	while(oElTmp.tagName!="BODY" && oElTmp.tagName!="HTML")
	{
		if(oElTmp.style.left!="")
		{
			nLeft += oElTmp.style.left.substring(1,oElTmp.style.left.length-2) * 1;
		}
		else nLeft +=oElTmp.offsetLeft;
		oElTmp = oElTmp.offsetParent;
	}
	
	box.style.left=nLeft;
	box.style.top=nTop + 22;
	box.focus();
	
}
function modelessDialogShow(url,width,height)
{
	window.showModelessDialog(url,window,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;resizable:No;status:No");
}
function modalDialogShow(url,width,height)
{
	window.showModalDialog(url,window,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;resizable:No;status:No");
}
function hide()
{
	if(this.btnCssText) eval("dropStyle").style.display="none";
	if(this.btnParagraph) eval("dropParagraph"+this.oName).style.display="none";
	if(this.btnFontName) eval("dropFontName"+this.oName).style.display="none";
	if(this.btnFontSize) eval("dropFontSize"+this.oName).style.display="none";
}
function jsReplace(sText, sFind, sReplace)
{
	var arrTmp = sText.split(sFind);
	if (arrTmp.length > 1) sText = arrTmp.join(sReplace);
	return sText;
}

