/**********************************************************************
	Version: FreeRichTextEditor.com Version 1.00.
	License: http://creativecommons.org/licenses/by/2.5/
	Description: RunTime File.
	Author: Copyright (C) 2006  Steven Ewing
**********************************************************************
	Html2Xhtml : Javascript Mini HTML to XHTML Parser 
	Copyright (C) 2006 All rights reserved. Jacob Lee <letsgolee@lycos.co.kr>
	Free for noncommercial && commercial use.
**********************************************************************/
function getXHTML(data){
		return new Html2Xhtml(data).parse()
};

function Html2Xhtml(data){
	this.data=data||''
}

Html2Xhtml.prototype.setHTML=function(data){this.data=data||this.data};

Html2Xhtml.prototype.parse=function(){ var state=0;var xhtml='';var p=0;var unget=false;var tagname='';var attrname='';var attrval='';	var quot='';var data=this.data;var len=data.length;var phpval='';var tagtype=0;var insidepre=false;while(1){if(p>=len&&!unget){return xhtml}if(unget){unget=false}else{var c=data.substr(p++,1)}switch(state){case 0:if(c=='<'){state=1;break}var cc=c.charCodeAt();if(Html2Xhtml.charEntities[cc]){xhtml+='&'+Html2Xhtml.charEntities[cc]+';'}else{xhtml+=c}break;case 1:if(/[a-zA-Z]/.test(c)){state=2;tagtype=1;tagname=c.toLowerCase();break}if(c=='/'){state=2;tagtype=-1;break}if(c=='!'){if(data.substr(p,2)=='--'){xhtml+='<!--';p+=2;state=9;break}xhtml+='<!';state=10;break}if(c=='?'){state=11;xhtml+='<'+'?';break}xhtml+='&lt;';unget=true;state=0;break;case 2:if(Html2Xhtml.isSpaceChar[c]){xhtml+=(!insidepre&&tagtype>0&&Html2Xhtml.hasNLBefore[tagname]&&xhtml.length&&xhtml.substr(xhtml.length-1,1)!='\n'?'\n':'')+(tagtype>0?'<':'</')+tagname;state=3;break}if(c=='/'){xhtml+=(!insidepre&&tagtype>0&&Html2Xhtml.hasNLBefore[tagname]&&xhtml.length&&xhtml.substr(xhtml.length-1,1)!='\n'?'\n':'')+(tagtype>0?'<':'</')+tagname;if(data.substr(p,1)!='>'){state=3;break}state=4;break}if(c=='>'){xhtml+=(!insidepre&&tagtype>0&&Html2Xhtml.hasNLBefore[tagname]&&xhtml.length&&xhtml.substr(xhtml.length-1,1)!='\n'?'\n':'')+(tagtype>0?'<':'</')+tagname;unget=true;state=4;break}tagname+=c.toLowerCase();break;case 3:if(Html2Xhtml.isSpaceChar[c]){break}if(c=='/'){if(data.substr(p,1)!='>'){break}state=4;break}if(c=='>'){unget=true;state=4;break}attrname=c.toLowerCase();attrval='';state=5;break;case 4:xhtml+=(Html2Xhtml.isEmptyTag[tagname]?' />':'>')+(!insidepre&&tagtype<0&&Html2Xhtml.hasNLAfter[tagname]&&p<len&&data.substr(p,1)!='\n'?'\n':'');if(tagtype>0&&Html2Xhtml.dontAnalyzeContent[tagname]){state=13;attrname=attrval=quot='';tagtype=0;break}if(tagname=='pre'){insidepre=!insidepre}state=0;tagname=attrname=attrval=quot='';tagtype=0;break;case 5:if(Html2Xhtml.isSpaceChar[c]){xhtml+=' '+attrname;if(Html2Xhtml.isEmptyAttr[attrname]){xhtml+='="'+attrname+'"'}state=3;break}if(c=='/'){xhtml+=' '+attrname;if(Html2Xhtml.isEmptyAttr[attrname]){xhtml+='="'+attrname+'"'}if(data.substr(p,1)!='>'){state=3;break}state=4;break}if(c=='>'){xhtml+=' '+attrname;if(Html2Xhtml.isEmptyAttr[attrname]){xhtml+='="'+attrname+'"'}unget=true;state=4;break}if(c=='='){xhtml+=' '+attrname+'=';state=6;break}if(c=='"'||c=="'"){attrname+='?'}else{attrname+=c.toLowerCase()}break;case 6:if(Html2Xhtml.isSpaceChar[c]){xhtml+=(Html2Xhtml.isEmptyAttr[attrname]?'"'+attrname+'"':'""');state=3;break}if(c=='>'){xhtml+=(Html2Xhtml.isEmptyAttr[attrname]?'"'+attrname+'"':'""');unget=true;state=4;break}if(c=='/'&&data.substr(p,1)=='>'){xhtml+=(Html2Xhtml.isEmptyAttr[attrname]?'"'+attrname+'"':'""');state=4;break}if(c=='"'||c=="'"){quot=c;state=8;break}attrval=c;state=7;break;case 7:if(Html2Xhtml.isSpaceChar[c]){xhtml+='"'+Html2Xhtml.escapeQuot(attrval,'"')+'"';state=3;break}if(c=='/'&&data.substr(p,1)=='>'){xhtml+='"'+Html2Xhtml.escapeQuot(attrval,'"')+'"';state=4;break}if(c=='>'){unget=true;xhtml+='"'+Html2Xhtml.escapeQuot(attrval,'"')+'"';state=4;break}attrval+=c;break;case 8:if(c==quot){xhtml+='"'+Html2Xhtml.escapeQuot(attrval,'"')+'"';state=3;break}attrval+=c;break;case 9:if(c=='-'&&data.substr(p,2)=='->'){p+=2;xhtml+='-->';state=0;break}xhtml+=c;break;case 10:if(c=='>'){state=0}xhtml+=c;break;case 11:if(c=="'"||c=='"'){quot=c;state=12;break}if(c=='?'&&data.substr(p,1)=='>'){state=0;xhtml+='?'+'>';p++;break}xhtml+=c;break;case 12:if(c==quot){state=11;xhtml+=quot+Html2Xhtml.escapeQuot(phpval,quot)+quot;phpval=quot='';break}phpval+=c;break;case 13:if(c=='<'&&data.substr(p,tagname.length+1).toLowerCase()=='/'+tagname){unget=true;state=0;tagname='';break}if(tagname=='textarea'){xhtml+=Html2Xhtml.escapeHTMLChar(c)}else{xhtml+=c}break}}return xhtml};

Html2Xhtml.escapeQuot=function(str,quot){if(!quot){quot='"'}if(quot=='"'){return str.replace(/"/ig,'\\"')}return str.replace(/'/ig,"\\'")};

Html2Xhtml.escapeHTMLChar=function(c){if(c=='&'){return'&amp;'}if(c=='<'){return'&lt;'}if(c=='>'){return'&gt;'}var cc=c.charCodeAt();if(Html2Xhtml.charEntities[cc]){return'&'+Html2Xhtml.charEntities[cc]+';'}else{return c}};Html2Xhtml.isSpaceChar={' ':1,'\r':1,'\n':1,'\t':1};Html2Xhtml.isEmptyTag={'area':1,'base':1,'basefont':1,'br':1,'hr':1,'img':1,'input':1,'link':1,'meta':1,'param':1};Html2Xhtml.isEmptyAttr={'checked':1,'compact':1,'declare':1,'defer':1,'disabled':1,'ismap':1,'multiple':1,'noresize':1,'nosave':1,'noshade':1,'nowrap':1,'readonly':1,'selected':1};Html2Xhtml.hasNLBefore={'div':1,'p':1,'table':1,'tbody':1,'tr':1,'td':1,'th':1,'title':1,'head':1,'body':1,'script':1,'comment':1,'li':1,'meta':1,'h1':1,'h2':1,'h3':1,'h4':1,'h5':1,'h6':1,'hr':1,'ul':1,'ol':1,'option':1,'link':1};Html2Xhtml.hasNLAfter={'html':1,'head':1,'body':1,'p':1,'th':1,'style':1};Html2Xhtml.dontAnalyzeContent={'textarea':1,'script':1,'style':1};Html2Xhtml.charEntities={160:'nbsp',161:'iexcl',162:'cent',163:'pound',164:'curren',165:'yen',166:'brvbar',167:'sect',168:'uml',169:'copy',170:'ordf',171:'laquo',172:'not',173:'shy',174:'reg',175:'macr',176:'deg',177:'plusmn',178:'sup2',179:'sup3',180:'acute',181:'micro',182:'para',183:'middot',184:'cedil',185:'sup1',186:'ordm',187:'raquo',188:'frac14',189:'frac12',190:'frac34',191:'iquest',192:'Agrave',193:'Aacute',194:'Acirc',195:'Atilde',196:'Auml',197:'aring',198:'aelig',199:'Ccedil',200:'Egrave',201:'Eacute',202:'Ecirc',203:'Euml',204:'Igrave',205:'Iacute',206:'Icirc',207:'Iuml',208:'eth',209:'ntilde',210:'Ograve',211:'Oacute',212:'Ocirc',213:'Otilde',214:'Ouml',215:'times',216:'oslash',217:'Ugrave',218:'Uacute',219:'Ucirc',220:'Uuml',221:'Yacute',222:'thorn',223:'szlig',224:'agrave',225:'aacute',226:'acirc',227:'atilde',228:'auml',229:'aring',230:'aelig',231:'ccedil',232:'egrave',233:'eacute',234:'ecirc',235:'euml',236:'igrave',237:'iacute',238:'icirc',239:'iuml',240:'eth',241:'ntilde',242:'ograve',243:'oacute',244:'ocirc',245:'otilde',246:'ouml',247:'divide',248:'oslash',249:'ugrave',250:'uacute',251:'ucirc',252:'uuml',253:'yacute',254:'thorn',255:'yuml',338:'oelig',339:'oelig',352:'scaron',353:'scaron',376:'yuml',710:'circ',732:'tilde',8194:'ensp',8195:'emsp',8201:'thinsp',8204:'zwnj',8205:'zwj',8206:'lrm',8207:'rlm',8211:'ndash',8212:'mdash',8216:'lsquo',8217:'rsquo',8218:'sbquo',8220:'ldquo',8221:'rdquo',8222:'bdquo',8224:'dagger',8225:'dagger',8240:'permil',8249:'lsaquo',8250:'rsaquo',8364:'euro',402:'fnof',913:'alpha',914:'beta',915:'gamma',916:'delta',917:'epsilon',918:'zeta',919:'eta',920:'theta',921:'iota',922:'kappa',923:'lambda',924:'mu',925:'nu',926:'xi',927:'omicron',928:'pi',929:'rho',931:'sigma',932:'tau',933:'upsilon',934:'phi',935:'chi',936:'psi',937:'omega',945:'alpha',946:'beta',947:'gamma',948:'delta',949:'epsilon',950:'zeta',951:'eta',952:'theta',953:'iota',954:'kappa',955:'lambda',956:'mu',957:'nu',958:'xi',959:'omicron',960:'pi',961:'rho',962:'sigmaf',963:'sigma',964:'tau',965:'upsilon',966:'phi',967:'chi',968:'psi',969:'omega',977:'thetasym',978:'upsih',982:'piv',8226:'bull',8230:'hellip',8242:'prime',8243:'prime',8254:'oline',8260:'frasl',8472:'weierp',8465:'image',8476:'real',8482:'trade',8501:'alefsym',8592:'larr',8593:'uarr',8594:'rarr',8595:'darr',8596:'harr',8629:'crarr',8656:'larr',8657:'uarr',8658:'rarr',8659:'darr',8660:'harr',8704:'forall',8706:'part',8707:'exist',8709:'empty',8711:'nabla',8712:'isin',8713:'notin',8715:'ni',8719:'prod',8721:'sum',8722:'minus',8727:'lowast',8730:'radic',8733:'prop',8734:'infin',8736:'ang',8743:'and',8744:'or',8745:'cap',8746:'cup',8747:'int',8756:'there4',8764:'sim',8773:'cong',8776:'asymp',8800:'ne',8801:'equiv',8804:'le',8805:'ge',8834:'sub',8835:'sup',8836:'nsub',8838:'sube',8839:'supe',8853:'oplus',8855:'otimes',8869:'perp',8901:'sdot',8968:'lceil',8969:'rceil',8970:'lfloor',8971:'rfloor',9001:'lang',9002:'rang',9426:'copy',9674:'loz',9824:'spades',9827:'clubs',9829:'hearts',9830:'diams'}; 

function trim(str) { if (typeof str != "string") return str; str = str.replace(/^\s+|\s+$/g, ""); return str;}


function rteGetOffsetTop(elm){
	var mOffsetTop    = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop   += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}

function rteGetOffsetLeft(elm){
	var mOffsetLeft   = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetLeft  += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}

function rteHideMenus(rteName){
	var rteFormName = rteName + '_content';
	rteMouseOutFormatMenuByName(rteName);
	document.getElementById(rteName+"format3").style.display = "none";
	rteMouseOutFontFaceMenuByName(rteName);
	document.getElementById(rteName+"fontface3").style.display = "none";
	rteMouseOutFontSizeMenuByName(rteName);
	document.getElementById(rteName+"fontsize3").style.display = "none";
	rteMouseOutFontColorMenuByName(rteName);
	document.getElementById(rteName+"fontcolor3").style.display = "none";
}


function rteColorClick(hexcolor,rteName){
	rteHideMenus(rteName);
	document.getElementById(rteName).contentWindow.document.execCommand("forecolor", false, hexcolor);
	document.getElementById(rteName+"fontcolor4").style.backgroundColor = hexcolor;
}

function rteMouseOverMenuFontColorContents(){
	this.className = "rtedropdown14";
}

function rteMouseOutMenuFontColorContents(){
	this.className = "rtedropdown13";
}

function rteMouseOverMenuContents(){
	var rteName = this.id.substr(0,8);
	this.style.color           = "#FFFFFF";
	this.style.backgroundColor = "#316AC5";
	document.getElementById(rteName).contentWindow.focus();
}

function rteMouseOutMenuContents(){
	this.style.color           = "#000000";
	this.style.backgroundColor = "#FFFFFF";
}

function rteMouseDownMenuContents(){
	var rteName = this.id.substr(0,8);
	
	if (this.innerHTML == "Header 1"){
		document.getElementById(rteName).contentWindow.document.execCommand("formatblock", false, "<h1>");
		document.getElementById(rteName+"format1").innerHTML = "Header 1";
	}
	else if (this.innerHTML == "Header 2"){
		document.getElementById(rteName).contentWindow.document.execCommand("formatblock", false, "<h2>");
		document.getElementById(rteName+"format1").innerHTML = "Header 2";
	}
	else if (this.innerHTML == "Header 3"){
		document.getElementById(rteName).contentWindow.document.execCommand("formatblock", false, "<h3>");
		document.getElementById(rteName+"format1").innerHTML = "Header 3";
	}
	else if (this.innerHTML == "Header 4"){
		document.getElementById(rteName).contentWindow.document.execCommand("formatblock", false, "<h4>");
		document.getElementById(rteName+"format1").innerHTML = "Header 4";
	}
	else if (this.innerHTML == "Header 5"){
		document.getElementById(rteName).contentWindow.document.execCommand("formatblock", false, "<h5>");
		document.getElementById(rteName+"format1").innerHTML = "Header 5";
	}
	else if (this.innerHTML == "Header 6"){
		document.getElementById(rteName).contentWindow.document.execCommand("formatblock", false, "<h6>");
		document.getElementById(rteName+"format1").innerHTML = "Header 6";
	}
	else if (this.innerHTML == "Paragraph"){
		document.getElementById(rteName).contentWindow.document.execCommand("formatblock", false, "<p>");
		document.getElementById(rteName+"format1").innerHTML = "Paragraph";
	}
	else if (this.innerHTML == "Arial"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "arial");
		document.getElementById(rteName+"fontface1").innerHTML = "Arial";
	}
	else if (this.innerHTML == "Arial Black"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "arial black");
		document.getElementById(rteName+"fontface1").innerHTML = "Arial Black";
	}
	else if (this.innerHTML == "Arial Narrow"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "arial narrow");
		document.getElementById(rteName+"fontface1").innerHTML = "Arial Narrow";
	}
	else if (this.innerHTML == "Courier New"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "courier new");
		document.getElementById(rteName+"fontface1").innerHTML = "Courier New";
	}
	else if (this.innerHTML == "Century Gothic"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "century gothic");
		document.getElementById(rteName+"fontface1").innerHTML = "Century Gothic";
	}
	else if (this.innerHTML == "Comic Sans MS") {
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "comic sans ms");
		document.getElementById(rteName+"fontface1").innerHTML = "Comic Sans MS";
	}
	else if (this.innerHTML == "Impact"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "impact");
		document.getElementById(rteName+"fontface1").innerHTML = "Impact";
	}
	else if (this.innerHTML == "Tahoma"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "tahoma");
		document.getElementById(rteName+"fontface1").innerHTML = "Tahoma";
	}
	else if (this.innerHTML == "Times New Roman"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "times new roman");
		document.getElementById(rteName+"fontface1").innerHTML = "Times New Roman";
	}
	else if (this.innerHTML == "Trebuchet MS"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "trebuchet ms");
		document.getElementById(rteName+"fontface1").innerHTML = "Trebuchet MS";
	}
	else if (this.innerHTML == "Verdana"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontname", false, "verdana");
		document.getElementById(rteName+"fontface1").innerHTML = "Verdana";
	}
	else if (this.innerHTML == "1"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontsize", false, "1");
		document.getElementById(rteName+"fontsize1").innerHTML = "1";
	}
	else if (this.innerHTML == "2"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontsize", false, "2");
		document.getElementById(rteName+"fontsize1").innerHTML = "2";
	}
	else if (this.innerHTML == "3"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontsize", false, "3");
		document.getElementById(rteName+"fontsize1").innerHTML = "3";
	}
	else if (this.innerHTML == "4"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontsize", false, "4");
		document.getElementById(rteName+"fontsize1").innerHTML = "4";
	}
	else if (this.innerHTML == "5"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontsize", false, "5");
		document.getElementById(rteName+"fontsize1").innerHTML = "5";
	}
	else if (this.innerHTML == "6"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontsize", false, "6");
		document.getElementById(rteName+"fontsize1").innerHTML = "6";
	}
	else if (this.innerHTML == "7"){
		document.getElementById(rteName).contentWindow.document.execCommand("fontsize", false, "7");
		document.getElementById(rteName+"fontsize1").innerHTML = "7";
	}
	this.style.color = "#000000";
	this.style.backgroundColor = "#FFFFFF";
	rteHideMenus(rteName);
}


function rteMouseOverFormatMenu(){
	var rteName = this.id.substr(0,8);
	document.getElementById(rteName+"format1").className = "rtedropdown4";
	document.getElementById(rteName+"format2").className = "rtedropdown5";
}

function rteMouseDownFormatMenu(){
	var rteName = this.id.substr(0,8);
	
	rteHideMenus(rteName);
	
	document.getElementById(rteName+"format1").className  = "rtedropdown4";
	document.getElementById(rteName+"format2").className  = "rtedropdown6";
	document.getElementById(rteName+"format1").style.left = rteGetOffsetLeft(document.getElementById(rteName+"format1"));
	document.getElementById(rteName+"format1").style.top  = rteGetOffsetTop(document.getElementById(rteName+"format1")) + document.getElementById(rteName+"format1").offsetHeight;
	document.getElementById(rteName+"format3").style.display = (document.getElementById(rteName+"format3").style.display == "none" ) ? "" : "none";
	
	var kids    = document.getElementById(rteName+'TableMain').getElementsByTagName('DIV');
	var totKids = kids.length;
	var auxCom  = '';
	
	for (var i=0; i < totKids; i++){
		auxCom = kids[i].id.substr(8,this.id.length-8)
		
		if(auxCom == "format1" || auxCom == "format2"){
			kids[i].onmouseout = rteMouseDownFormatMenu;
		}
		else if(auxCom == "fontface1" || auxCom == "fontface2"){
			kids[i].onmouseout = rteMouseOutFontFaceMenu;
		}
		else if(auxCom == "fontsize1" || auxCom == "fontsize2"){
			kids[i].onmouseout = rteMouseOutFontSizeMenu;
		}
		else if (auxCom == "fontcolor1" || auxCom == "fontcolor2"){
			kids[i].onmouseout = rteMouseOutFontColorMenu;
		}
	}
}

function rteMouseOutFormatMenuByName(rteName){
	document.getElementById(rteName+"format1").className = "rtedropdown1";
	document.getElementById(rteName+"format2").className = "rtedropdown2";
}

function rteMouseOutFormatMenu(){
	var rteName = this.id.substr(0,8);
	document.getElementById(rteName+"format1").className = "rtedropdown1";
	document.getElementById(rteName+"format2").className = "rtedropdown2";
}

function rteMouseOverFontFaceMenu(){
	var rteName = this.id.substr(0,8);
	document.getElementById(rteName+"fontface1").className = "rtedropdown4";
	document.getElementById(rteName+"fontface2").className = "rtedropdown5";
}

function rteMouseDownFontFaceMenu(){
	var rteName = this.id.substr(0,8);
	
	rteHideMenus(rteName);
	
	document.getElementById(rteName+"fontface1").className  = "rtedropdown4";
	document.getElementById(rteName+"fontface2").className  = "rtedropdown6";
	document.getElementById(rteName+"fontface1").style.left = rteGetOffsetLeft(document.getElementById(rteName+"fontface1"));
	document.getElementById(rteName+"fontface1").style.top  = rteGetOffsetTop(document.getElementById(rteName+"fontface1")) + document.getElementById(rteName+"fontface1").offsetHeight;
	document.getElementById(rteName+"fontface3").style.display = (document.getElementById(rteName+"fontface3").style.display == "none" ) ? "" : "none";
	
	var kids    = document.getElementById(rteName+'TableMain').getElementsByTagName('DIV');
	var totKids = kids.length;
	
	for (var i=0; i < totKids; i++){
		auxCom = kids[i].id.substr(8,this.id.length-8)
		
		if (auxCom == "format1" || auxCom == "format2"){
			kids[i].onmouseout = rteMouseOutFormatMenu;
		}
		else if (auxCom == "fontface1" || auxCom == "fontface2"){
			kids[i].onmouseout = rteMouseDownFontFaceMenu;
		}
		else if (auxCom == "fontsize1" || auxCom == "fontsize2"){
			kids[i].onmouseout = rteMouseOutFontSizeMenu;
		}
		else if (auxCom == "fontcolor1" || auxCom == "fontcolor2"){
			kids[i].onmouseout = rteMouseOutFontColorMenu;
		}
	}
}


function rteMouseOutFontFaceMenuByName(rteName){
	document.getElementById(rteName+"fontface1").className = "rtedropdown1";
	document.getElementById(rteName+"fontface2").className = "rtedropdown2";	
}
function rteMouseOutFontFaceMenu(){
	var rteName = this.id.substr(0,8);
	document.getElementById(rteName+"fontface1").className = "rtedropdown1";
	document.getElementById(rteName+"fontface2").className = "rtedropdown2";
}


function rteMouseOverFontSizeMenu(){
	var rteName = this.id.substr(0,8);
	document.getElementById(rteName+"fontsize1").className = "rtedropdown4";
	document.getElementById(rteName+"fontsize2").className = "rtedropdown5";
}

function rteMouseDownFontSizeMenu(){
	var rteName = this.id.substr(0,8);
	
	rteHideMenus(rteName);
	
	document.getElementById(rteName+"fontsize1").className  = "rtedropdown4";
	document.getElementById(rteName+"fontsize2").className  = "rtedropdown6";
	document.getElementById(rteName+"fontsize1").style.left = rteGetOffsetLeft(document.getElementById(rteName+"fontsize1"));
	document.getElementById(rteName+"fontsize1").style.top  = rteGetOffsetTop(document.getElementById(rteName+"fontsize1")) + document.getElementById(rteName+"fontsize1").offsetHeight;
	document.getElementById(rteName+"fontsize3").style.display = (document.getElementById(rteName+"fontsize3").style.display == "none" ) ? "" : "none";
	
	var kids    = document.getElementById(rteName+'TableMain').getElementsByTagName('DIV');
	var totKids = kids.length;
	
	for (var i=0; i < totKids; i++){
		auxCom = kids[i].id.substr(8,this.id.length-8)
		
		if (auxCom == "format1" || auxCom == "format2"){
			kids[i].onmouseout = rteMouseOutFormatMenu;
		}
		else if (auxCom == "fontface1" || auxCom == "fontface2"){
			kids[i].onmouseout = rteMouseOutFontFaceMenu;
		}
		else if (auxCom == "fontsize1" || auxCom == "fontsize2"){
			kids[i].onmouseout = rteMouseDownFontSizeMenu;
		}
		else if (auxCom == "fontcolor1" || auxCom == "fontcolor2"){
			kids[i].onmouseout = rteMouseOutFontColorMenu;
		}
	}
}

function rteMouseOutFontSizeMenuByName(rteName){
	document.getElementById(rteName+"fontsize1").className = "rtedropdown1";
	document.getElementById(rteName+"fontsize2").className = "rtedropdown2";
}

function rteMouseOutFontSizeMenu(){
	var rteName = this.id.substr(0,8);
	document.getElementById(rteName+"fontsize1").className = "rtedropdown1";
	document.getElementById(rteName+"fontsize2").className = "rtedropdown2";
}


function rteMouseOverFontColorMenu(){
	var rteName = this.id.substr(0,8);
	document.getElementById(rteName+"fontcolor1").className = "rtedropdown8";
	document.getElementById(rteName+"fontcolor2").className = "rtedropdown5b";
}


function rteMouseDownFontColorMenu(){
	var rteName = this.id.substr(0,8);
	
	var auxCom = '';
	rteHideMenus(rteName);
	
	document.getElementById(rteName+"fontcolor1").className  = "rtedropdown12";
	document.getElementById(rteName+"fontcolor2").className  = "rtedropdown9b";
	document.getElementById(rteName+"fontcolor1").style.left = rteGetOffsetLeft(document.getElementById(rteName+"fontcolor1"));
	document.getElementById(rteName+"fontcolor1").style.top  = rteGetOffsetTop(document.getElementById(rteName+"fontcolor1")) + document.getElementById(rteName+"fontcolor1").offsetHeight;
	document.getElementById(rteName+"fontcolor3").style.display = (document.getElementById(rteName+"fontcolor3").style.display == "none" ) ? "" : "none";
	
	var kids    = document.getElementById(rteName+'TableMain').getElementsByTagName('DIV');
	var totKids = kids.length;
	
	for (var i=0; i < totKids; i++){
		auxCom = kids[i].id.substr(8,kids[i].id.length-8);
		if (auxCom == "format1" || auxCom == "format2"){
			kids[i].onmouseout = rteMouseOutFormatMenu;
		}
		else if (auxCom == "fontface1" || auxCom == "fontface2"){
			kids[i].onmouseout = rteMouseOutFontFaceMenu;
		}
		else if (auxCom == "fontsize1" || auxCom == "fontsize2"){
			kids[i].onmouseout = rteMouseOutFontSizeMenu;
		}
		else if (auxCom == "fontcolor1" || auxCom == "fontcolor2"){
			kids[i].onmouseout = rteMouseDownFontColorMenu;
		}
	}
}

function rteMouseOutFontColorMenuByName(rteName){
	document.getElementById(rteName+"fontcolor1").className = "rtedropdown10";
	document.getElementById(rteName+"fontcolor2").className = "rtedropdown11b";
}

function rteMouseOutFontColorMenu(){
	var rteName = this.id.substr(0,8);
	document.getElementById(rteName+"fontcolor1").className = "rtedropdown10";
	document.getElementById(rteName+"fontcolor2").className = "rtedropdown11b"
}


function rteBtnMouseUpBottom(){
	this.className = "rtebtn9";
}

function rteBtnMouseOutBottom(){
	this.className = "rtebtn6";
}

function rteBtnMouseOutDownBottom(){
	this.className = "rtebtn9";
}

function rteBtnMouseOverBottom(){
	this.className = "rtebtn7";
}

function rteModeType(id,rteName){
	var rteFormName = rteName + '_content';
	
	if (id == "rte_design_mode"){
		rteFormHandler2(rteName);
		document.getElementById(rteName).contentWindow.document.body.innerHTML = getXHTML(trim(document.getElementById(rteFormName).value));
		document.getElementById(rteName+"tb1").style.display = "";
		document.getElementById(rteName+"tb2").style.display = "";
		document.getElementById(rteName+"tb3").style.display = "";
		document.getElementById(rteFormName).style.display = "none";
		document.getElementById(rteName).style.display = "";
		document.getElementById("preview_" + rteName).style.display = "none";
		document.getElementById(rteName).contentWindow.focus();
		return false;
	}
	else if (id == "rte_code_mode"){
		rteFormHandler(rteName);
		document.getElementById(rteFormName).value = getXHTML(trim(document.getElementById(rteName).contentWindow.document.body.innerHTML));
		document.getElementById(rteName+"tb1").style.display = "none";
		document.getElementById(rteName+"tb2").style.display = "none";
		document.getElementById(rteName+"tb3").style.display = "none";
		document.getElementById(rteFormName).style.display   = "";
		document.getElementById(rteName).style.display       = "none";
		document.getElementById("preview_" + rteName).style.display = "none";
	}
	else if (id == "rte_preview_mode"){
		rteFormHandler(rteName);
		html = "<div style=\"padding:5px;\">" + getXHTML(trim(document.getElementById(rteFormName).value)) + "</div>";
		document.getElementById('preview_' + rteName).contentWindow.document.open();
		document.getElementById('preview_' + rteName).contentWindow.document.write("<html><head><style type=\"text/css\">@import url("+document.getElementById(rteName+"preview_css").value+");</style></head><body>" + html + "</body></html>");
		document.getElementById('preview_' + rteName).contentWindow.document.close();
		document.getElementById(rteName+"tb1").style.display = "none";
		document.getElementById(rteName+"tb2").style.display = "none";
		document.getElementById(rteName+"tb3").style.display = "none";
		document.getElementById(rteFormName).style.display   = "none";
		document.getElementById(rteName).style.display       = "none";
		document.getElementById("preview_" + rteName).style.display = "";
	}
}


function rteBtnMouseDownBottom(){
	var rteName = this.id.substr(0,8);
	
	var kids    = document.getElementById(rteName+'TableMain').getElementsByTagName('DIV');
	var totKids = kids.length;
	
	for (var i=0; i < totKids; i++){
		if(kids[i].className == "rtebtn6" || kids[i].className == "rtebtn7" || kids[i].className == "rtebtn8" || kids[i].className == "rtebtn9"){
			kids[i].className   = "rtebtn6";
			kids[i].onmouseover = rteBtnMouseOverBottom;
			kids[i].onmouseout  = rteBtnMouseOutBottom;
			kids[i].onmousedown = rteBtnMouseDownBottom;
			kids[i].onmouseup   = rteBtnMouseUpBottom;
		}
	}
	this.className   = "rtebtn9";
	this.onmouseover = rteBtnMouseOverBottom;
	this.onmouseout  = rteBtnMouseOutDownBottom;
	this.onmouseup   = rteBtnMouseUpBottom;
}


function rteBtnMouseDown(){
	var rteName = this.id.substr(0,8);
	var kids    = document.getElementById(rteName+'TableMain').getElementsByTagName('DIV');
	var totKids = kids.length;
	
	for (var i=0; i < totKids; i++){
		if (kids[i].className == "rtebtn2" || kids[i].className == "rtebtn3" || kids[i].className == "rtebtn4"){
			kids[i].className = "rtebtn1";
		}
	}
	rteSelection(rteName);
	this.className = "rtebtn4";
}

function rteBtnMouseUp(){
	this.className = "rtebtn4";
}

function rteBtnMouseOut(){
	this.className = "rtebtn1";
}

function rteBtnMouseOver(){
	this.className = "rtebtn2";
}






var rteNameAuxWindowEdit = '';

function rteBtnCreateLink(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertLink , "blank","toolbar=no,width=250,height=300");
}
function rteBtnEditLink(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathEditLink , "blank","toolbar=no,width=250,height=300");
}



function rteBtnInsertImage(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertImage , "blank","toolbar=no,width=300,height=220");
}



function rteBtnEditTable(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathEditTable , "blank","toolbar=no,width=320,height=210");
}

function rteBtnInsertForm(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertForm , "blank","toolbar=no,width=320,height=180");
}

function rteBtnInsertCheckbox(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertCheckbox , "blank","toolbar=no,width=320,height=150");
}

function rteBtnInsertRadio(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertRadiobutton , "blank","toolbar=no,width=320,height=150");
}

function rteBtnInsertFlash(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertFlash , "blank","toolbar=no,width=350,height=130");
}


function rteBtnInsertTextArea(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertTextArea , "blank","toolbar=no,width=320,height=230");
}

function rteBtnInsertSubmit(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertSubmit , "blank","toolbar=no,width=320,height=130");
}

function rteBtnInsertImageSubmit(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertImageSubmit , "blank","toolbar=no,width=320,height=130");
}

function rteBtnInsertReset(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertReset , "blank","toolbar=no,width=320,height=130");
}

function rteBtnInsertHidden(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertHidden , "blank","toolbar=no,width=320,height=130");
}

function rteBtnInsertPassword(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertPassword , "blank","toolbar=no,width=320,height=150");
}

function rteBtnInsertText(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertText , "blank","toolbar=no,width=320,height=170");
}

function rteBtnInsertTable(rteName){
	rteNameAuxWindowEdit = rteName;
	window.open(rteHTMLPathInsertTable , "blank","toolbar=no,width=320,height=240");
}





function rteBtnPrint(rteName){
	if (document.all){
		var oFrame = window.frames[rteName];
		oFrame.focus();
		oFrame.print();
	}
	else{
		var oFrame = document.getElementById(rteName).contentWindow;
		oFrame.focus();
		oFrame.window.print();
	}
}






function rteInsertHTML(html,rteName){
	if (document.all){
		var oRng = document.getElementById(rteName).contentWindow.document.selection.createRange();
		oRng.pasteHTML(html);
		oRng.collapse(false);
		oRng.select();
	}
	else{
		document.getElementById(rteName).contentWindow.document.execCommand('insertHTML', false, html);
	}
}






















function rteAbout(){
	msg=window.open("","msg","height=100,width=320");
	msg.document.write("<style>");
	msg.document.write("body, td {");
	msg.document.write("background-color:#ECE9D8;");
	msg.document.write("font-family:arial;");
	msg.document.write("font-size:11px;");
	msg.document.write("}");
	msg.document.write("input {");
	msg.document.write("font-family:arial;");
	msg.document.write("font-size:11px;");
	msg.document.write("}");
	msg.document.write("select {");
	msg.document.write("font-family:arial;");
	msg.document.write("font-size:11px;");
	msg.document.write("}");
	msg.document.write("</style>");
	msg.document.write("<fieldset>");
	msg.document.write("<legend><b>About FreeRichTextEditor</b></legend>");
	msg.document.write("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"0\" border=\"0\">");
	msg.document.write("<tr>");
	msg.document.write("<td colspan=\"2\" align=\"center\">Copyright &copy; 2006 Steven Ewing<br><a href=\"http://www.freerichtexteditor.com\" target=\"_blank\">www.FreeRichTextEditor.com</a></td>");
	msg.document.write("</tr>");
	msg.document.write("<tr>");
	msg.document.write("<td colspan=\"2\" align=\"center\"><input type=\"button\" value=\"License\" onclick=\"window.open('http://www.freerichtexteditor.com/page/5.htm' , 'blank','');\"><input type=\"button\" value=\"Donate\" onclick=\"window.open('http://www.freerichtexteditor.com/page/7.htm' , 'blank','');\"><input type=\"button\" value=\"Download\" onclick=\"window.open('http://www.freerichtexteditor.com/page/4.htm' , 'blank','');\"></td>");
	msg.document.write("</tr>");
	msg.document.write("</table>");
	msg.document.write("</fieldset>");
	msg.document.close();
}


function rteBtnInsertTableRowBefore(rteName){
	if (window.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.window.getSelection().focusNode;
	}
	else if (document.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.getSelection().focusNode;
	}
	else if (document.selection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.selection.createRange().parentElement();
	}
	current_tag = selected_obj;
	while(current_tag.tagName != "TABLE"){
		if (current_tag.tagName == "TR"){
			cellTotal = current_tag.cells.length;
			RowIndex  = current_tag.rowIndex;
		}
		if (current_tag.parentNode.tagName == "TBODY"){
			var x=current_tag.parentNode.insertRow(RowIndex);
			for (i=0; i < cellTotal; i++){
				var j=x.insertCell(i); j.innerHTML="&nbsp;";
			}
		}
		current_tag = current_tag.parentNode;
	}
}

function rteBtnInsertTableRowAfter(rteName){
	if (window.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.window.getSelection().focusNode;
	}
	else if (document.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.getSelection().focusNode;
	}
	else if (document.selection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.selection.createRange().parentElement();
	}
	current_tag = selected_obj;
	while(current_tag.tagName != "TABLE"){
		if (current_tag.tagName == "TR"){
			cellTotal = current_tag.cells.length;
			RowIndex = current_tag.rowIndex;
		}
		if (current_tag.parentNode.tagName == "TBODY"){
			var x=current_tag.parentNode.insertRow(RowIndex+1);
			for (i=0; i < cellTotal; i++){
				var j=x.insertCell(i); j.innerHTML="&nbsp;";
			}
		}
		current_tag = current_tag.parentNode;
	}
}

function rteBtnInsertTableColumnBefore(rteName){
	if (window.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.window.getSelection().focusNode;
	}
	else if (document.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.getSelection().focusNode;
	}
	else if (document.selection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.selection.createRange().parentElement();
	}
	current_tag = selected_obj;
	while(current_tag.tagName != "TABLE"){
		if(current_tag.tagName == "TD"){
			cellIndex = current_tag.cellIndex;
		}
		if (current_tag.tagName == "TBODY"){
			RowTotal = current_tag.parentNode.rows.length;
			var x=current_tag.parentNode;
			for (i=0; i < RowTotal; i++){
				var j=x.rows[i].insertCell(cellIndex); j.innerHTML="&nbsp;";
			}
		}
		current_tag = current_tag.parentNode;
	}
}

function rteBtnInsertTableColumnAfter(rteName){
	if (window.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.window.getSelection().focusNode;
	}
	else if (document.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.getSelection().focusNode;
	}
	else if (document.selection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.selection.createRange().parentElement();
	}
	current_tag = selected_obj;
	while(current_tag.tagName != "TABLE"){
		if (current_tag.tagName == "TD"){
			cellIndex = current_tag.cellIndex;
		}
		if (current_tag.tagName == "TBODY"){
			RowTotal = current_tag.parentNode.rows.length;
			var x=current_tag.parentNode;
			for (i=0; i < RowTotal; i++){
				var j=x.rows[i].insertCell(cellIndex+1); j.innerHTML="&nbsp;";
			}
		}
		current_tag = current_tag.parentNode;
	}
}

function rteBtnDeleteTableColumn(rteName){
	if (window.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.window.getSelection().focusNode;
	}
	else if (document.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.getSelection().focusNode;
	}
	else if (document.selection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.selection.createRange().parentElement();
	}
	current_tag = selected_obj;
	while(current_tag.tagName != "TABLE"){
		if (current_tag.tagName == "TD"){
			cellIndex = current_tag.cellIndex;
		}
		if (current_tag.tagName == "TBODY"){
			RowTotal = current_tag.parentNode.rows.length;
			var x=current_tag.parentNode;
			for(i=0; i < RowTotal; i++ ){
				j=x.rows[i].deleteCell(cellIndex);
			}
		}
		current_tag = current_tag.parentNode;
	}
}

function rteBtnDeleteTableRow(rteName){
	if (window.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.window.getSelection().focusNode;
	}
	else if (document.getSelection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.getSelection().focusNode;
	}
	else if (document.selection){
		var selected_obj = document.getElementById(rteName).contentWindow.document.selection.createRange().parentElement();
	}
	current_tag = selected_obj;
	while(current_tag.tagName != "TABLE"){
		if (current_tag.tagName == "TR"){
			RowIndex = current_tag.rowIndex;
		}
		if (current_tag.tagName == "TBODY"){
			RowTotal = current_tag.parentNode.rows.length;
			var x=current_tag.parentNode;
			x.deleteRow(RowIndex);
		}
		current_tag = current_tag.parentNode;
	}
}

function rteAction(){
	var rteName = this.id.substr(0,8);
	var idAux   = this.id.substr(8,this.id.length-8);
	
	rteHideMenus(rteName);
	
	if (idAux != "editlink" && idAux != "insertflash"&& idAux != "edittable" && idAux != "createlink" && idAux != "insertimage" && idAux != "inserttable" && idAux != "insertrowbelow" && idAux && idAux != "insertcolumnleft" && idAux != "insertcolumnright" && idAux != "deletecolumn" && idAux != "deleterow" && idAux != "insertform" && idAux != "form_checkbox" && idAux != "form_radio" && idAux != "form_dropdown" && idAux != "form_textarea" && idAux != "form_submit" && idAux != "form_image_submit" && idAux != "form_reset" && idAux != "form_hidden" && idAux != "form_password" && idAux != "form_textfield" && idAux != "spellcheck" && idAux != "printrte" && idAux != "aboutrte"){
		document.getElementById(rteName).contentWindow.document.execCommand(idAux, false, null);
		this.className  = "rtebtn4";
		this.onmouseout = rteBtnMouseDown;
		document.getElementById(rteName).contentWindow.focus();
	}
}


function rteFormHandler(rteName){
	var rteFormName = rteName + '_content';
	
	if (document.getElementById(rteFormName).style.display == ""){
		var newHTML = getXHTML(trim(document.getElementById(rteFormName).value));
	}
	else{
		var newHTML = getXHTML(trim(document.getElementById(rteName).contentWindow.document.body.innerHTML));
	}
	pattern = /<div[^>]*border: 1px dotted red[^>]*>.*<\/form><\/div>/gi;
	matchesArray = newHTML.match(pattern);
	if (matchesArray != null){
		for (i=0; i<matchesArray.length; i++){
			pattern2 = /<div[^>]*border: 1px dotted red[^>]*>/gi;
			pattern3 = /<\/div>/gi;
			replacement = matchesArray[i];
			replacement = replacement.replace(pattern2, "");
			replacement = replacement.replace(pattern3, "");
			if (document.getElementById(rteFormName).style.display == ""){
				newHTML = document.getElementById(rteFormName).value.replace(matchesArray[i], replacement);
			}
			else{
				newHTML = document.getElementById(rteName).contentWindow.document.body.innerHTML.replace(matchesArray[i], replacement);
			}
		}
	}
	pattern = /<table[^>]*class=\"rte_tbl\"[^>]*>/gi;
	matchesArray = newHTML.match(pattern);
	if (matchesArray != null){
		for (i=0; i<matchesArray.length; i++){
			pattern2 = /class=\"rte_tbl\"/gi;
			replacement = matchesArray[i];
			replacement = replacement.replace(pattern2, "");
			newHTML = newHTML.replace(matchesArray[i], replacement);
		}
	}
	document.getElementById(rteFormName).value = newHTML;
	document.getElementById(rteName).contentWindow.document.body.innerHTML = newHTML;
}

function rteFormHandler2(rteName){
	var rteFormName = rteName + '_content';
	
	if (document.getElementById(rteFormName).style.display == ""){
		var newHTML = document.getElementById(rteFormName).value;
	}
	else{
		var newHTML = document.getElementById(rteName).contentWindow.document.body.innerHTML;
	}
	pattern = /<form[^>]*>[^<]*<\/form>/gi;
	matchesArray = newHTML.match(pattern);
	if (matchesArray != null){
		for (i=0; i<matchesArray.length; i++){
			replacement = matchesArray[i];
			replacement = replacement.replace(matchesArray[i], "<div style=\"border: 1px dotted red;\">" + matchesArray[i] + "</div>");
			if (document.getElementById(rteFormName).style.display == ""){
				newHTML = document.getElementById(rteFormName).value.replace(matchesArray[i], replacement);
			}
			else{
				newHTML = document.getElementById(rteName).contentWindow.document.body.innerHTML.replace(matchesArray[i], replacement);
			}
		}
	}
	pattern = /<table[^>]*border=\"0\"[^>]*>/gi;
	matchesArray = newHTML.match(pattern);
	if (matchesArray != null){
		for (i=0; i<matchesArray.length; i++){
			pattern2 = /border=\"0\"/gi;
			replacement = matchesArray[i];
			replacement = replacement.replace(pattern2, "border=\"0\" class=\"rte_tbl\"");
			newHTML = newHTML.replace(matchesArray[i], replacement);
		}
	}
	if (document.getElementById(rteFormName).style.display == ""){
		document.getElementById(rteFormName).value = newHTML;
	}
	else{
		document.getElementById(rteName).contentWindow.document.body.innerHTML = newHTML;
	}
}

function rteSelectionObj(){
	var rteName = this.document.objRTEName.substr(0,8);
	rteSelection(rteName);
}

function rteSelection(rteName){
	var rteFormName = rteName + '_content';
	rteHideMenus(rteName);
	if (document.getElementById(rteName+"rte_code_mode").className == "rtebtn9"){
		document.getElementById(rteName+"tb1").style.display = "none";
		document.getElementById(rteName+"tb2").style.display = "none";
		document.getElementById(rteName+"tb3").style.display = "none";
	}
	else{
		/*document.getElementById(rteName+"format1").innerHTML   = "Paragraph";
		document.getElementById(rteName+"fontface1").innerHTML = "Verdana";
		document.getElementById(rteName+"fontsize1").innerHTML = "2";
		*/
		
		var kids    = document.getElementById(rteName+'TableMain').getElementsByTagName('DIV');
		var totKids = kids.length;
		
		for (var i=0; i < totKids; i++){
			switch(kids[i].className){
				case "rtebtn1":
					if (kids[i].onmouseover != rteBtnMouseOver){
						kids[i].onmouseover = rteBtnMouseOver;
					}
					if (kids[i].onclick != rteAction){
						kids[i].onclick = rteAction;
					}
					if (kids[i].className == "rtebtn4"){
						if (kids[i].onmouseout != rteBtnMouseDown){
							kids[i].onmouseout = rteBtnMouseDown;
						}
					}
					else {
						if (kids[i].onmouseout != rteBtnMouseOut){
							kids[i].onmouseout = rteBtnMouseOut;
						}
					}
					if (kids[i].onmousedown != rteBtnMouseDown){
						kids[i].onmousedown = rteBtnMouseDown;
					}
					if (kids[i].onmouseup != rteBtnMouseUp){
						kids[i].onmouseup = rteBtnMouseUp;
					}
				break;
				case "rtebtn2":
					kids[i].className = "rtebtn1";
					if (kids[i].onmouseover != rteBtnMouseOver){
						kids[i].onmouseover = rteBtnMouseOver;
					}
					if (kids[i].onclick != rteAction){
						kids[i].onclick = rteAction;
					}
					if (kids[i].className == "rtebtn4"){
						if (kids[i].onmouseout = rteBtnMouseDown){
							kids[i].onmouseout = rteBtnMouseDown;
						}
					}
					else{
						if (kids[i].onmouseout != rteBtnMouseOut){
							kids[i].onmouseout = rteBtnMouseOut;
						}
					}
					if (kids[i].onmousedown != rteBtnMouseDown){
						kids[i].onmousedown = rteBtnMouseDown;
					}
					if (kids[i].onmouseup != rteBtnMouseUp){
						kids[i].onmouseup = rteBtnMouseUp;
					}
				break;
				case "rtebtn3":
					kids[i].className = "rtebtn1";
					if (kids[i].onmouseover != rteBtnMouseOver){
						kids[i].onmouseover = rteBtnMouseOver;
					}
					if (kids[i].onclick != rteAction){
						kids[i].onclick = rteAction;
					}
					if (kids[i].className == "rtebtn4"){
						if (kids[i].onmouseout != rteBtnMouseDown){
							kids[i].onmouseout = rteBtnMouseDown;
						}
					}
					else {
						if (kids[i].onmouseout != rteBtnMouseOut){
							kids[i].onmouseout = rteBtnMouseOut;
						}
					}
					if (kids[i].onmousedown != rteBtnMouseDown){
						kids[i].onmousedown = rteBtnMouseDown;
					}
					if (kids[i].onmouseup != rteBtnMouseUp){
						kids[i].onmouseup = rteBtnMouseUp;
					}
				break;
				case "rtebtn4":
					kids[i].className = "rtebtn1"; 
					if (kids[i].onmouseover != rteBtnMouseOver){
						kids[i].onmouseover = rteBtnMouseOver;
					}
					if (kids[i].onclick != rteAction){
						kids[i].onclick = rteAction;
					}
					if (kids[i].onmouseout != rteBtnMouseOut){
						kids[i].onmouseout = rteBtnMouseOut;
					}
					if (kids[i].onmousedown != rteBtnMouseDown){
						kids[i].onmousedown = rteBtnMouseDown;
					}
					if (kids[i].onmouseup != rteBtnMouseUp){
						kids[i].onmouseup = rteBtnMouseUp;
					}
				break;
			}
			
			var idAux = kids[i].id.substr(8,kids[i].id.length-8);
			
			switch(idAux){
				case "format1":
					if (kids[i].onmouseover != rteMouseOverFormatMenu){
						kids[i].onmouseover = rteMouseOverFormatMenu;
					}
					if (kids[i].onmousedown != rteMouseDownFormatMenu){
						kids[i].onmousedown = rteMouseDownFormatMenu;
					}
					if (kids[i].onmouseout != rteMouseOutFormatMenu){
						kids[i].onmouseout = rteMouseOutFormatMenu;
					}
					if (kids[i].className == "rtedropdown6"){
						if (kids[i].onmouseout != rteMouseDownFormatMenu){
							kids[i].onmouseout = rteMouseDownFormatMenu;
						}
					}
					else { 
						if (kids[i].onmouseout != rteMouseOutFormatMenu){
							kids[i].onmouseout = rteMouseOutFormatMenu;
						}
					}
				break;
				case "format2":
					if (kids[i].onmouseover != rteMouseOverFormatMenu){
						kids[i].onmouseover = rteMouseOverFormatMenu;
					}
					if (kids[i].onmousedown != rteMouseDownFormatMenu){
						kids[i].onmousedown = rteMouseDownFormatMenu;
					}
					if (kids[i].onmouseout != rteMouseOutFormatMenu){
						kids[i].onmouseout = rteMouseOutFormatMenu;
					}
					if (kids[i].className == "rtedropdown6"){
						kids[i].onmouseout = rteMouseDownFormatMenu;
					}
					else {
						kids[i].onmouseout = rteMouseOutFormatMenu;
					}
				break;
				case "fontface1":
					if (kids[i].onmouseover != rteMouseOverFontFaceMenu)
					{ kids[i].onmouseover = rteMouseOverFontFaceMenu;}
					if (kids[i].onmousedown != rteMouseDownFontFaceMenu)
					{ kids[i].onmousedown = rteMouseDownFontFaceMenu;}
					if (kids[i].onmouseout != rteMouseOutFontFaceMenu)
					{ kids[i].onmouseout = rteMouseOutFontFaceMenu;}
					if (kids[i].className == "rtedropdown6") { if (kids[i].onmouseout != rteMouseDownFontFaceMenu)
					{ kids[i].onmouseout = rteMouseDownFontFaceMenu;}
					} else { if (kids[i].onmouseout != rteMouseOutFontFaceMenu)
					{ kids[i].onmouseout = rteMouseOutFontFaceMenu;}
					}
				break;
				case "fontface2":
					if (kids[i].onmouseover != rteMouseOverFontFaceMenu)
					{ kids[i].onmouseover = rteMouseOverFontFaceMenu;}
					if (kids[i].onmousedown != rteMouseDownFontFaceMenu)
					{ kids[i].onmousedown = rteMouseDownFontFaceMenu;}
					if (kids[i].onmouseout != rteMouseOutFontFaceMenu)
					{ kids[i].onmouseout = rteMouseOutFontFaceMenu;}
					if (kids[i].className == "rtedropdown6") { if (kids[i].onmouseout != rteMouseDownFontFaceMenu)
					{ kids[i].onmouseout = rteMouseDownFontFaceMenu;}
					} else { if (kids[i].onmouseout != rteMouseOutFontFaceMenu)
					{ kids[i].onmouseout = rteMouseOutFontFaceMenu;}
					}
				break;
				case "fontsize1":
					if (kids[i].onmouseover != rteMouseOverFontSizeMenu)
					{ kids[i].onmouseover = rteMouseOverFontSizeMenu;}
					if (kids[i].onmousedown != rteMouseDownFontSizeMenu)
					{ kids[i].onmousedown = rteMouseDownFontSizeMenu;}
					if (kids[i].onmouseout != rteMouseOutFontSizeMenu)
					{ kids[i].onmouseout = rteMouseOutFontSizeMenu;}
					if (kids[i].className == "rtedropdown6") { if (kids[i].onmouseout != rteMouseDownFontSizeMenu)
					{ kids[i].onmouseout = rteMouseDownFontSizeMenu;}
					} else { if (kids[i].onmouseout != rteMouseOutFontSizeMenu)
					{ kids[i].onmouseout = rteMouseOutFontSizeMenu;}
					}
				break;
				case "fontsize2":
					if (kids[i].onmouseover != rteMouseOverFontSizeMenu)
					{ kids[i].onmouseover = rteMouseOverFontSizeMenu;}
					if (kids[i].onmousedown != rteMouseDownFontSizeMenu)
					{ kids[i].onmousedown = rteMouseDownFontSizeMenu;}
					if (kids[i].onmouseout != rteMouseOutFontSizeMenu)
					{ kids[i].onmouseout = rteMouseOutFontSizeMenu;}
					if (kids[i].className == "rtedropdown6") { if (kids[i].onmouseout != rteMouseDownFontSizeMenu)
					{ kids[i].onmouseout = rteMouseDownFontSizeMenu;}
					} else { if (kids[i].onmouseout != rteMouseOutFontSizeMenu)
					{ kids[i].onmouseout = rteMouseOutFontSizeMenu;}
					}
				break;
				case "fontcolor1":
					if (kids[i].onmouseover != rteMouseOverFontColorMenu)
					{ kids[i].onmouseover = rteMouseOverFontColorMenu;}
					if (kids[i].onmousedown != rteMouseDownFontColorMenu)
					{ kids[i].onmousedown = rteMouseDownFontColorMenu;}
					if (kids[i].onmouseout != rteMouseOutFontColorMenu)
					{ kids[i].onmouseout = rteMouseOutFontColorMenu;}
					if (kids[i].className == "rtedropdown9") { if (kids[i].onmouseout != rteMouseDownFontColorMenu)
					{ kids[i].onmouseout = rteMouseDownFontColorMenu;}
					} else { if (kids[i].onmouseout != rteMouseOutFontColorMenu)
					{ kids[i].onmouseout = rteMouseOutFontColorMenu;}
					}
				break;
				case "fontcolor2":
					if (kids[i].onmouseover != rteMouseOverFontColorMenu)
					{ kids[i].onmouseover = rteMouseOverFontColorMenu;}
					if (kids[i].onmousedown != rteMouseDownFontColorMenu)
					{ kids[i].onmousedown = rteMouseDownFontColorMenu;}
					if (kids[i].onmouseout != rteMouseOutFontColorMenu)
					{ kids[i].onmouseout = rteMouseOutFontColorMenu;}
					if (kids[i].className == "rtedropdown9") { if (kids[i].onmouseout != rteMouseDownFontColorMenu)
					{ kids[i].onmouseout = rteMouseDownFontColorMenu;}
					} else { if (kids[i].onmouseout != rteMouseOutFontColorMenu)
					{ kids[i].onmouseout = rteMouseOutFontColorMenu;}
					}
				break;
				case "formatblock":
					if (kids[i].onmouseover != rteMouseOverMenuContents)
					{ kids[i].onmouseover = rteMouseOverMenuContents;}
					if (kids[i].onmouseout != rteMouseOutMenuContents)
					{ kids[i].onmouseout = rteMouseOutMenuContents;}
					if (kids[i].onmousedown != rteMouseDownMenuContents)
					{ kids[i].onmousedown = rteMouseDownMenuContents;}
				break;
				case "fontface":
					if (kids[i].onmouseover != rteMouseOverMenuContents)
					{ kids[i].onmouseover = rteMouseOverMenuContents;}
					if (kids[i].onmouseout != rteMouseOutMenuContents)
					{ kids[i].onmouseout = rteMouseOutMenuContents;}
					if (kids[i].onmousedown != rteMouseDownMenuContents)
					{ kids[i].onmousedown = rteMouseDownMenuContents;}
				break;
				case "fontsize":
					if (kids[i].onmouseover != rteMouseOverMenuContents)
					{ kids[i].onmouseover = rteMouseOverMenuContents;}
					if (kids[i].onmouseout != rteMouseOutMenuContents)
					{ kids[i].onmouseout = rteMouseOutMenuContents;}
					if (kids[i].onmousedown != rteMouseDownMenuContents)
					{ kids[i].onmousedown = rteMouseDownMenuContents;}
				break;
				case "fontcolor":
					if (kids[i].onmouseover != rteMouseOverMenuFontColorContents)
					{ kids[i].onmouseover = rteMouseOverMenuFontColorContents;}
					if (kids[i].onmouseout != rteMouseOutMenuFontColorContents)
					{ kids[i].onmouseout = rteMouseOutMenuFontColorContents;}
				break;
			}
		}
		
		
		var tbl     = false;
		var in_list = false;
		if (window.getSelection){
			var selected_obj = document.getElementById(rteName).contentWindow.window.getSelection().focusNode;
		}
		else if (document.getSelection){
			var selected_obj = document.getElementById(rteName).contentWindow.document.getSelection().focusNode;
		}
		else if (document.selection){
			var selected_obj = document.getElementById(rteName).contentWindow.document.selection.createRange().parentElement();
		}
		var is_link  = false;
		var is_table = false;
		var current_tag = selected_obj;
		
		if (current_tag != null){
			var previous_tagName = selected_obj.tagName;
		}
		else{
			var previous_tagName = "HTML";
		}
		var textcolor = "";
		
		document.getElementById(rteName+"fontcolor4").style.backgroundColor = "#000000";
		
		while(previous_tagName != "HTML"){
			if(previous_tagName == "B" || previous_tagName == "STRONG"){
				document.getElementById(rteName+"bold").className = "rtebtn4";
				document.getElementById(rteName+"bold").onmouseout = rteBtnMouseDown;
			}
			else if (previous_tagName == "LI") {
				in_list = true;
			}
			else if (previous_tagName == "TD" && !is_table){
				is_table = true;
			}
			else if(previous_tagName == "I" || previous_tagName == "EM"){
				document.getElementById(rteName+"italic").className  = "rtebtn4";
				document.getElementById(rteName+"italic").onmouseout = rteBtnMouseDown;
			}
			else if(previous_tagName == "U"){
				document.getElementById(rteName+"underline").className  = "rtebtn4";
				document.getElementById(rteName+"underline").onmouseout = rteBtnMouseDown;
			}
			else if(previous_tagName == "STRIKE"){
				document.getElementById(rteName+"strikethrough").className  = "rtebtn4";
				document.getElementById(rteName+"strikethrough").onmouseout = rteBtnMouseDown;
			}
			else if(previous_tagName == "A"){
				is_link = true;
				document.getElementById(rteName+"editlink").className  = "rtebtn4";
				document.getElementById(rteName+"editlink").onmouseout = rteBtnMouseDown;
			}
			else if(previous_tagName == "UL"){
				document.getElementById(rteName+"insertunorderedlist").className  = "rtebtn4";
				document.getElementById(rteName+"insertunorderedlist").onmouseout = rteBtnMouseDown;
			}
			else if(previous_tagName == "OL"){
				document.getElementById(rteName+"insertorderedlist").className  = "rtebtn4";
				document.getElementById(rteName+"insertorderedlist").onmouseout = rteBtnMouseDown;
			}
			else if(previous_tagName == "SUB"){
				document.getElementById(rteName+"subscript").className  = "rtebtn4";
				document.getElementById(rteName+"subscript").onmouseout = rteBtnMouseDown;
			}
			else if(previous_tagName == "SUP"){
				document.getElementById(rteName+"superscript").className = "rtebtn4";
				document.getElementById(rteName+"superscript").onmouseout = rteBtnMouseDown;
			}
			else if(previous_tagName == "H1"){
				document.getElementById(rteName+"format1").innerHTML = "Header 1";
			}
			else if(previous_tagName == "H2"){
				document.getElementById(rteName+"format1").innerHTML = "Header 2";
			}
			else if(previous_tagName == "H3"){
				document.getElementById(rteName+"format1").innerHTML = "Header 3";
			}
			else if(previous_tagName == "H4"){
				document.getElementById(rteName+"format1").innerHTML = "Header 4";
			}
			else if(previous_tagName == "H5"){
				document.getElementById(rteName+"format1").innerHTML = "Header 5";
			}
			else if(previous_tagName == "H6"){
				document.getElementById(rteName+"format1").innerHTML = "Header 6";
			}
			else if(previous_tagName == "BLOCKQUOTE"){
				document.getElementById(rteName+"indent").className  = "rtebtn4";
				document.getElementById(rteName+"indent").onmouseout = rteBtnMouseDown;
			}
			
			if (is_table){
				document.getElementById(rteName+"table_options_on").style.display  = "";
				document.getElementById(rteName+"table_options_off").style.display = "none";
			}
			else{
				document.getElementById(rteName+"table_options_on").style.display  = "none";
				document.getElementById(rteName+"table_options_off").style.display = "";
			}
			
			if (current_tag.align == "left"){
				document.getElementById(rteName+"justifyleft").className  = "rtebtn4";
				document.getElementById(rteName+"justifyleft").onmouseout = rteBtnMouseDown;
			}
			else if (current_tag.align == "center"){
				document.getElementById(rteName+"justifycenter").className  = "rtebtn4";
				document.getElementById(rteName+"justifycenter").onmouseout = rteBtnMouseDown;
			}
			else if (current_tag.align == "right"){
				document.getElementById(rteName+"justifyright").className  = "rtebtn4";
				document.getElementById(rteName+"justifyright").onmouseout = rteBtnMouseDown;
			}
			else if (current_tag.align == "justify"){
				document.getElementById(rteName+"justifyfull").className  = "rtebtn4";
				document.getElementById(rteName+"justifyfull").onmouseout = rteBtnMouseDown;
			}
			else if (current_tag.align == ""){
				document.getElementById(rteName+"justifyleft").className = "rtebtn1";
			}
			else { }
		
			if (current_tag.face == "arial"){
				document.getElementById(rteName+"fontface1").innerHTML = "Arial";
			}
			else if (current_tag.face == "arial black"){
				document.getElementById(rteName+"fontface1").innerHTML = "Arial Black";
			}
			else if (current_tag.face == "arial narrow"){
				document.getElementById(rteName+"fontface1").innerHTML = "Arial Narrow";
			}
			else if (current_tag.face == "courier new"){
				document.getElementById(rteName+"fontface1").innerHTML = "Courier New";
			}
			else if (current_tag.face == "century gothic"){
				document.getElementById(rteName+"fontface1").innerHTML = "Century Gothic";
			}
			else if (current_tag.face == "comic sans ms"){
				document.getElementById(rteName+"fontface1").innerHTML = "Comic Sans MS";
			}
			else if (current_tag.face == "impact"){
				document.getElementById(rteName+"fontface1").innerHTML = "Impact";
			}
			else if (current_tag.face == "tahoma"){
				document.getElementById(rteName+"fontface1").innerHTML = "Tahoma";
			}
			else if (current_tag.face == "times new roman"){
				document.getElementById(rteName+"fontface1").innerHTML = "Times New Roman";
			}
			else if (current_tag.face == "trebuchet ms"){
				document.getElementById(rteName+"fontface1").innerHTML = "Trebuchet MS";
			}
			else if (current_tag.face == "verdana"){
				document.getElementById(rteName+"fontface1").innerHTML = "Verdana";
			}
			if (current_tag.size == "1"){
				document.getElementById(rteName+"fontsize1").innerHTML = "1";
			}
			else if (current_tag.size == "2"){
				document.getElementById(rteName+"fontsize1").innerHTML = "2";
			}
			else if (current_tag.size == "3"){
				document.getElementById(rteName+"fontsize1").innerHTML = "3";
			}
			else if (current_tag.size == "4"){
				document.getElementById(rteName+"fontsize1").innerHTML = "4";
			}
			else if (current_tag.size == "5"){
				document.getElementById(rteName+"fontsize1").innerHTML = "5";
			}
			else if (current_tag.size == "6"){
				document.getElementById(rteName+"fontsize1").innerHTML = "6";
			}
			else if (current_tag.size == "7"){
				document.getElementById(rteName+"fontsize1").innerHTML = "7";
			}
			else { }
			
			if (current_tag.color != null){
				textcolor = current_tag.color;
			}
			
			current_tag      = current_tag.parentNode;
			previous_tagName = current_tag.tagName;
		}
		
		if (in_list){ }
		
	}
	
	if (textcolor == ""){
		textcolor = "#000000";
	}
	if (is_table){
		document.getElementById(rteName+"edittable").className       = "rtebtn4";
		document.getElementById(rteName+"edittable").onmouseout      = rteBtnMouseDown;
		document.getElementById(rteName+"inserttable").style.display = "none";
		document.getElementById(rteName+"edittable").style.display   = "";
	}
	else{
		document.getElementById(rteName+"edittable").className       = "rtebtn1";
		document.getElementById(rteName+"edittable").onmouseout      = rteBtnMouseOut;
		document.getElementById(rteName+"inserttable").style.display = "";
		document.getElementById(rteName+"edittable").style.display   = "none";
	}
	
	document.getElementById(rteName+"fontcolor4").style.backgroundColor = textcolor;
		
	if (is_link){
		document.getElementById(rteName+"createlink").style.display = "none";
		document.getElementById(rteName+"editlink").style.display   = "";
	}
	else{
		document.getElementById(rteName+"createlink").style.display = "";
		document.getElementById(rteName+"editlink").style.display   = "none";
	}
}


function rteSpellCheck(){
	alert('Not yet supported.');
}; 


function menuBuilder(rteName){
	if (rteFormat) { document.getElementById(rteName+"rteformat").style.display = "";} else { document.getElementById(rteName+"rteformat").style.display = "none";}
	if (rteFontFace) { document.getElementById(rteName+"rtefontface").style.display = "";} else { document.getElementById(rteName+"rtefontface").style.display = "none";}
	if (rteFontSize) { document.getElementById(rteName+"rtefontsize").style.display = "";} else { document.getElementById(rteName+"rtefontsize").style.display = "none";}
	if (rteFontColor) { document.getElementById(rteName+"rtefontcolor").style.display = "";} else { document.getElementById(rteName+"rtefontcolor").style.display = "none";}
	if (rteBold) { document.getElementById(rteName+"bold").style.display = "";} else { document.getElementById(rteName+"bold").style.display = "none";}
	if (rteItalic) { document.getElementById(rteName+"italic").style.display = "";} else { document.getElementById(rteName+"italic").style.display = "none";}
	if (rteUnderline) { document.getElementById(rteName+"underline").style.display = "";} else { document.getElementById(rteName+"underline").style.display = "none";}
	if (rteStrikeThrough) { document.getElementById(rteName+"strikethrough").style.display = "";} else { document.getElementById(rteName+"strikethrough").style.display = "none";}
	if (rteLeftAlign) { document.getElementById(rteName+"justifyleft").style.display = "";} else { document.getElementById(rteName+"justifyleft").style.display = "none";}
	if (rteCenterAlign) { document.getElementById(rteName+"justifycenter").style.display = "";} else { document.getElementById(rteName+"justifycenter").style.display = "none";}
	if (rteRightAlign) { document.getElementById(rteName+"justifyright").style.display = "";} else { document.getElementById(rteName+"justifyright").style.display = "none";}
	if (rteFullAlign) { document.getElementById(rteName+"justifyfull").style.display = "";} else { document.getElementById(rteName+"justifyfull").style.display = "none";}
	if (rteHorizontalRule) { document.getElementById(rteName+"inserthorizontalrule").style.display = "";} else { document.getElementById(rteName+"inserthorizontalrule").style.display = "none";}
	if (rteSubscript) { document.getElementById(rteName+"subscript").style.display = "";} else { document.getElementById(rteName+"subscript").style.display = "none";}
	if (rteSuperscript) { document.getElementById(rteName+"superscript").style.display = "";} else { document.getElementById(rteName+"superscript").style.display = "none";}
	if (rteLink) { document.getElementById(rteName+"createlink").style.display = "";} else { document.getElementById(rteName+"createlink").style.display = "none";}
	if (rteUnlink) { document.getElementById(rteName+"unlink").style.display = "";} else { document.getElementById(rteName+"unlink").style.display = "none";}
	if (rteImages) { document.getElementById(rteName+"insertimage").style.display = "";} else { document.getElementById(rteName+"insertimage").style.display = "none";}
	if (rteRemoveFormat) { document.getElementById(rteName+"removeformat").style.display = "";} else { document.getElementById(rteName+"removeformat").style.display = "none";}
	if (rteTables) { document.getElementById(rteName+"tables").style.display = "";} else { document.getElementById(rteName+"tables").style.display = "none";}
	if (rteOrderedList) { document.getElementById(rteName+"insertorderedlist").style.display = "";} else { document.getElementById(rteName+"insertorderedlist").style.display = "none";}
	if (rteUnorderedList) { document.getElementById(rteName+"insertunorderedlist").style.display = "";} else { document.getElementById(rteName+"insertunorderedlist").style.display = "none";}
	if (rteIndent) { document.getElementById(rteName+"indent").style.display = "";} else { document.getElementById(rteName+"indent").style.display = "none";}
	if (rteOutdent) { document.getElementById(rteName+"outdent").style.display = "";} else { document.getElementById(rteName+"outdent").style.display = "none";}
	if (rteUndo) { document.getElementById(rteName+"undo").style.display = "";} else { document.getElementById(rteName+"undo").style.display = "none";}
	if (rteRedo) { document.getElementById(rteName+"redo").style.display = "";} else { document.getElementById(rteName+"redo").style.display = "none";}
	if (rteCutCopyPaste) { document.getElementById(rteName+"cutcopypaste").style.display = "";} else { document.getElementById(rteName+"cutcopypaste").style.display = "none";}
	if (rteInsertForm) { document.getElementById(rteName+"insertform").style.display = "";} else { document.getElementById(rteName+"insertform").style.display = "none";}
	if (rteInsertCheckbox) { document.getElementById(rteName+"form_checkbox").style.display = "";} else { document.getElementById(rteName+"form_checkbox").style.display = "none";}
	if (rteInsertRadio) { document.getElementById(rteName+"form_radio").style.display = "";} else { document.getElementById(rteName+"form_radio").style.display = "none";}
	if (rteInsertTextArea) { document.getElementById(rteName+"form_textarea").style.display = "";} else { document.getElementById(rteName+"form_textarea").style.display = "none";}
	if (rteInsertSubmit) { document.getElementById(rteName+"form_submit").style.display = "";} else { document.getElementById(rteName+"form_submit").style.display = "none";}
	if (rteInsertImageSubmit) { document.getElementById(rteName+"form_image_submit").style.display = "";} else { document.getElementById(rteName+"form_image_submit").style.display = "none";}
	if (rteInsertReset) { document.getElementById(rteName+"form_reset").style.display = "";} else { document.getElementById(rteName+"form_reset").style.display = "none";}
	if (rteInsertHidden) { document.getElementById(rteName+"form_hidden").style.display = "";} else { document.getElementById(rteName+"form_hidden").style.display = "none";}
	if (rteInsertPassword) { document.getElementById(rteName+"form_password").style.display = "";} else { document.getElementById(rteName+"form_password").style.display = "none";}
	if (rteInsertTextField) { document.getElementById(rteName+"form_textfield").style.display = "";} else { document.getElementById(rteName+"form_textfield").style.display = "none";}
	if (rtePrint) { document.getElementById(rteName+"printrte").style.display = "";} else { document.getElementById(rteName+"printrte").style.display = "none";}
	if (rteSelectAll) { document.getElementById(rteName+"selectall").style.display = "";} else { document.getElementById(rteName+"selectall").style.display = "none";}
	if (rteSpellCheck) { document.getElementById(rteName+"spellchecker").style.display = "";} else { document.getElementById(rteName+"spellchecker").style.display = "none";}
	if (!rteFormat && !rteFontFace && !rteFontSize && !rteFontColor) { document.getElementById(rteName+"rtesep1").style.display = "none"; document.getElementById(rteName+"rtesep2").style.display = "none";}
	if (!rteBold && !rteItalic && !rteUnderline && !rteStrikeThrough) { document.getElementById(rteName+"rtesep3").style.display = "none";}
	if (!rteLeftAlign && !rteCenterAlign && !rteRightAlign && !rteFullAlign && !rteHorizontalRule) { document.getElementById(rteName+"rtesep4").style.display = "none";}
	if (!rteFormat && !rteFontFace && !rteFontSize && !rteBold && !rteItalic && !rteUnderline && !rteStrikeThrough && !rteLeftAlign && !rteCenterAlign && !rteRightAlign && !rteFullAlign && !rteHorizontalRule && !rteSuperscript && !rteSubscript) { document.getElementById(rteName+"tb1").style.display = "none";}
	if (!rteLink && !rteUnlink && !rteImages && !rteRemoveFormat && !rteTables && !rteOrderedList && !rteUnorderedList && !rteIndent && !rteOutdent && !rteUndo && !rteRedo && !rteCutCopyPaste) { document.getElementById(rteName+"tb2").style.display = "none";}
	if (!rteLink && !rteUnlink) { document.getElementById(rteName+"rtesep5").style.display = "none";}
	if (!rteImages && !rteRemoveFormat) { document.getElementById(rteName+"rtesep6").style.display = "none";}
	if (!rteTables) { document.getElementById(rteName+"rtesep7").style.display = "none";}
	if (!rteOrderedList && !rteUnorderedList && !rteIndent && !rteOutdent) { document.getElementById(rteName+"rtesep8").style.display = "none";}
	if (!rteUndo && !rteRedo) { document.getElementById(rteName+"rtesep9").style.display = "none";}
	if (!rteInsertForm && !rteInsertCheckbox && !rteInsertRadio && !rteInsertTextArea && !rteInsertSubmit && !rteInsertImageSubmit && !rteInsertReset && !rteInsertHidden && !rteInsertPassword && !rteInsertTextField) { document.getElementById(rteName+"rtesep10").style.display = "none";}
	if (!rtePrint && !rteSelectAll && !rteSpellCheck) { document.getElementById(rteName+"rtesep11").style.display = "none";}
}; 

function startRTE(rteName, rtePreloadContent){
	var rteFormName = rteName + '_content';
	rteCSS = document.getElementById(rteName+"preview_css").value;
	/*	var kids = document.getElementsByTagName("FORM");
		for (var i=0; i < kids.length; i++){
		kids[i].onsubmit = rteFormHandler;
	}*/
	document.getElementById(rteName).contentWindow.document.designMode = "on";
	document.getElementById(rteFormName).value = rtePreloadContent;
	document.getElementById(rteName).contentWindow.document.open();
	document.getElementById(rteName).contentWindow.document.write("<html><head><style type=\"text/css\">@import url("+rteCSS+");</style></head><body>" + rtePreloadContent + "</body></html>");
	document.getElementById(rteName).contentWindow.document.close();
	if (document.all && !window.opera){
		document.getElementById(rteName).document.objRTEName = rteName;
		document.getElementById(rteName).contentWindow.document.attachEvent("onkeypress", rteSelectionObj);
		document.getElementById(rteName).contentWindow.document.attachEvent("onclick", rteSelectionObj);
		document.getElementById(rteName).contentWindow.document.attachEvent("onmouseup", rteSelectionObj);
	}
	else{
		document.getElementById(rteName).document.objRTEName = rteName;
		document.getElementById(rteName).contentWindow.document.execCommand("useCSS", false, null);
		document.getElementById(rteName).contentWindow.document.addEventListener("keypress", rteSelectionObj, true);
		document.getElementById(rteName).contentWindow.document.addEventListener("click", rteSelectionObj, true);
		document.getElementById(rteName).contentWindow.document.addEventListener("mouseup", rteSelectionObj, true);
	}
	rteSelection(rteName);
	
	var kids    =  document.getElementById(rteName+'TableMain').getElementsByTagName("DIV");
	var totKids = kids.length;
	
	for (var i=0; i < totKids; i++){
		if(kids[i].className == "rtebtn6"){
			kids[i].onmouseover = rteBtnMouseOverBottom;
			kids[i].onmouseout  = rteBtnMouseOutBottom;
			kids[i].onmousedown = rteBtnMouseDownBottom;
			kids[i].onmouseup   = rteBtnMouseUpBottom;
		}
	}
}

function onDesignMode(rteName){
	if(document.getElementById(rteName).contentWindow.document.designMode!="on"){
		var rteFormName = rteName + '_content';
		rteCSS = document.getElementById(rteName+"preview_css").value;
		
		document.getElementById(rteName).contentWindow.document.designMode = "on";
		rtePreloadContent = document.getElementById(rteFormName).value;
		document.getElementById(rteName).contentWindow.document.open();
		document.getElementById(rteName).contentWindow.document.write("<html><head><style type=\"text/css\">@import url("+rteCSS+");</style></head><body>" + rtePreloadContent + "</body></html>");
		document.getElementById(rteName).contentWindow.document.close();
	}
}

function initRTE(rtePreloadContent, rteName, rteWidth, rteHeight, rteImagePath, rteCSS){
	var rteFormName = rteName + '_content';
	if (!document.designMode){
			document.write('<textarea id="' + rteFormName + '" name="' + rteFormName + '" style="width:' + rteWidth + ';height:' + rteHeight + ';"></textarea>');
	}
	else{
		document.write('<style>');
		document.write('.rtebg {');
		document.write('	background-image:url(' + rteImagePath + 'bg.gif);');
		document.write('	font-family:Arial, Helvetica, sans-serif;');
		document.write('	float:left;');
		document.write('	height:25px;');
		document.write('	font-size:10px;');
		document.write('}');
		document.write('.rtedropdown1 {');
		document.write('	height:16px;');
		document.write('	font-family:Arial, Helvetica, sans-serif;');
		document.write('	padding-left:3px;');
		document.write('	padding-right:3px;');
		document.write('	font-size:11px;');
		document.write('	border:1px solid #FFFFFF;');
		document.write('	cursor:default;');
		document.write('}');
		document.write('.rtedropdown2 {');
		document.write('	width:11px;');
		document.write('	background-image:url(' + rteImagePath + 'bg.gif);');
		document.write('	border-top:1px solid #FFFFFF;');
		document.write('	border-right:1px solid #FFFFFF;');
		document.write('	border-bottom:1px solid #FFFFFF;');
		document.write('	cursor:default;');
		if (document.all && !window.opera){
			document.write('	height:20px;');
		}
		else{
			document.write('	height:16px;');
		}
		document.write('}');
		document.write('.rtedropdown4 {');
		document.write('	font-family:Arial, Helvetica, sans-serif;');
		document.write('	padding-left:3px;');
		document.write('	padding-right:3px;');
		document.write('	font-size:11px;');
		document.write('	border:1px solid #002D96;');
		document.write('	cursor:default;');
		if (document.all && !window.opera){
			document.write('	line-height:18px;');
		}
		else{
			document.write('	height:16px;');
		}
		document.write('}');
		document.write('.rtedropdown5 {');
		document.write('	background-image:url(' + rteImagePath + 'bgover.gif);');
		document.write('	border-top:1px solid #000080;');
		document.write('	border-right:1px solid #000080;');
		document.write('	border-bottom:1px solid #000080;');
		document.write('	cursor:default;');
		if (document.all && !window.opera){
			document.write('	height:20px;');
		}
		else{
			document.write('	height:16px;');
		}
		document.write('}');
		document.write('.rtedropdown5b {');
		document.write('	background-image:url(' + rteImagePath + 'bgover.gif);');
		document.write('	border-top:1px solid #000080;');
		document.write('	border-right:1px solid #000080;');
		document.write('	border-bottom:1px solid #000080;');
		document.write('	cursor:default;');
		if (document.all && !window.opera){
			document.write('	height:21px;');
		}
		else{
			document.write('	height:19px;');
		}
		document.write('}');
		document.write('.rtedropdown6 {');
		document.write('	width:11px;');
		document.write('	background-image:url(' + rteImagePath + 'bgdown.gif);');
		document.write('	border-top:1px solid #000080;');
		document.write('	border-right:1px solid #000080;');
		document.write('	border-bottom:1px solid #000080;');
		document.write('	cursor:default;');
		if (document.all && !window.opera){
			document.write('	height:20px;');
		}
		else{
			document.write('	height:16px;');
		}
		document.write('}');
		document.write('.rtedropdown7 {');
		document.write('	border:1px solid #002D96;');
		document.write('	background-color:#FFFFFF;');
		document.write('	font-family:Arial, Helvetica, sans-serif;');
		document.write('	cursor:default;');
		document.write('}');
		document.write('.rtedropdown8 {');
		document.write('	background-image:url(' + rteImagePath + 'bgover.gif);');
		document.write('	border:1px solid #002D96;');
		document.write('	cursor:default;'); document.write('}');
		document.write('.rtedropdown9 {');
		document.write('	background-image:url(' + rteImagePath + 'bgdown.gif);');
		document.write('	border-top:1px solid #000080;');
		document.write('	border-right:1px solid #000080;');
		document.write('	border-bottom:1px solid #000080;');
		document.write('	cursor:default;'); document.write('}');
		document.write('.rtedropdown9b {');
		document.write('	background-image:url(' + rteImagePath + 'bgdown.gif);');
		document.write('	border-top:1px solid #000080;');
		document.write('	border-right:1px solid #000080;');
		document.write('	border-bottom:1px solid #000080;');
		document.write('	cursor:default;');
		if (document.all && !window.opera){
			document.write('	height:21px;');
		}
		else{
			document.write('	height:19px;');
		}
		document.write('}');
		document.write('.rtedropdown10 {');
		document.write('	border:0px solid transparent;');
		document.write('	cursor:default;');
		document.write('}');
		document.write('.rtedropdown11 {');
		document.write('	border-top:0px solid transparent;');
		document.write('	border-right:0px solid transparent;');
		document.write('	border-bottom:0px solid transparent;');
		document.write('	cursor:default;');
		document.write('}');
		document.write('.rtedropdown11b {');
		document.write('	border-top:0px solid transparent;');
		document.write('	border-right:0px solid transparent;');
		document.write('	border-bottom:0px solid transparent;');
		document.write('	cursor:default;');
		document.write('	height:19px;');
		document.write('}');
		document.write('.rtedropdown12 {');
		document.write('	background-image:url(' + rteImagePath + 'bgdown.gif);');
		document.write('	border:1px solid #000080;');
		document.write('	cursor:default;');
		document.write('}');
		document.write('.rtedropdown13 {');
		document.write('	padding:1px;');
		document.write('	border:1px solid #FFFFFF;');
		document.write('	background-color:#FFFFFF;');
		document.write('}');
		document.write('.rtedropdown14 {');
		document.write('	padding:1px;');
		document.write('	border:1px solid #000080;');
		document.write('	background-color:#FFEEC2;');
		document.write('}');
		document.write('.rtebtn1 {');
		document.write('	display:block;');
		document.write('	width:21px;');
		document.write('	height:20px;');
		document.write('	padding: 1px;');
		document.write('	background-image:url(' + rteImagePath + 'bg.gif);');
		document.write('}');
		document.write('.rtebtn2 {');
		document.write('	display:block;');
		document.write('	width:21px;');
		document.write('	height:20px;');
		document.write('	border:1px solid #000080;');
		document.write('	background-image:url(' + rteImagePath + 'bgover.gif);');
		document.write('}');
		document.write('.rtebtn3 {');
		document.write('	display:block;');
		document.write('	width:21px;');
		document.write('	height:20px;');
		document.write('	border:1px solid #000080;');
		document.write('	background-image:url(' + rteImagePath + 'bgselect.gif);');
		document.write('}');
		document.write('.rtebtn4 {');
		document.write('	display:block;');
		document.write('	width:21px;');
		document.write('	height:20px;');
		document.write('	border:1px solid #000080;');
		document.write('	background-image:url(' + rteImagePath + 'bgdown.gif);');
		document.write('}');
		document.write('.rtebtn5 {');
		document.write('	display:block;');
		document.write('	width:21px;');
		document.write('	height:20px;');
		document.write('	padding: 1px;');
		document.write('	background-image:url(' + rteImagePath + 'bg.gif);');
		document.write('}');
		document.write('.rtebtn6 {');
		document.write('	display:block;');
		document.write('	padding: 3px;');
		document.write('	cursor:default;');
		document.write('}');
		document.write('.rtebtn7 {');
		document.write('	display:block;');
		document.write('	border:1px solid #000080;');
		document.write('	background-image:url(' + rteImagePath + 'bgover.gif);');
		document.write('	cursor:default;');
		document.write('	padding: 2px;');
		document.write('}');
		document.write('.rtebtn8 {');
		document.write('	display:block;');
		document.write('	border:1px solid #000080;');
		document.write('	background-image:url(' + rteImagePath + 'bgselect.gif);');
		document.write('	cursor:default;');
		document.write('	padding: 2px;');
		document.write('}');
		document.write('.rtebtn9 {');
		document.write('	display:block;');
		document.write('	border:1px solid #000080;');
		document.write('	background-image:url(' + rteImagePath + 'bgdown.gif);');
		document.write('	cursor:default;');
		document.write('	padding: 2px;');
		document.write('}');
		document.write('</style>');
		document.write('<input type="hidden" id="'+rteName+'preview_css" value="' + rteCSS + '">');
		document.write('<input type="hidden" id="'+rteName+'iframe_name" value="' + rteName + '">');
		document.write('<table id="'+rteName+'TableMain" style="width:' + rteWidth + ';border-left:1px solid #3B619C;border-right:1px solid #3B619C;border-top:1px solid #3B619C;" cellpadding="0" cellspacing="0">');
		document.write('  <tr>');
		document.write('    <td bgcolor="#C3DAF9">');
		document.write('	<div id="'+rteName+'tb1" onmousedown="return false;">');
		document.write('        <div style="width:7px;float:left;height:25px;"><img src="' + rteImagePath + 'start.gif" width="7" height="25"></div>');
		document.write('        <div class="rtebg" id="'+rteName+'rtesep1" style="float:left;height:25px;"><img src="' + rteImagePath + 'blank.gif"></div>');
		document.write('        <div background="' + rteImagePath + 'bg.gif" id="'+rteName+'rteformat" style="float:left;height:25px;">');
		document.write('			<table style="width:50px;height:25px;" cellpadding="0" cellspacing="0" id="'+rteName+'format4" bgcolor="#FFFFFF" title="Style">');
		document.write('          		<tr>');
		document.write('        		    <td nowrap><div unselectable="on" id="'+rteName+'format1" class="rtedropdown1" style="width:58px;font-family:arial;font-size:11px;color:#000000;">Paragraph</div></td>');
		document.write('       		    	<td><div unselectable="on" id="'+rteName+'format2" class="rtedropdown2"><img src="' + rteImagePath + 'arrow.gif" width="11" height="16"></div></td>');
		document.write('        		</tr>');
		document.write('        	</table>');
		document.write('			<div id="'+rteName+'format3" class="rtedropdown7" style="position:absolute;display:none;">');
		document.write('				<div unselectable="on" id="'+rteName+'formatblock" style="font-size:24px; font-family:arial;color:#000000;font-weight:bold;padding:5px;" nowrap>Header 1</div>');
		document.write('				<div unselectable="on" id="'+rteName+'formatblock" style="font-size:18px; font-family:arial;color:#000000;font-weight:bold;padding:5px;" nowrap>Header 2</div>');
		document.write('				<div unselectable="on" id="'+rteName+'formatblock" style="font-size:16px; font-family:arial;color:#000000;font-weight:bold;padding:5px;" nowrap>Header 3</div>');
		document.write('				<div unselectable="on" id="'+rteName+'formatblock" style="font-size:14px; font-family:arial;color:#000000;font-weight:bold;padding:5px;" nowrap>Header 4</div>');
		document.write('				<div unselectable="on" id="'+rteName+'formatblock" style="font-size:12px; font-family:arial;color:#000000;font-weight:bold;padding:5px;" nowrap>Header 5</div>');
		document.write('				<div unselectable="on" id="'+rteName+'formatblock" style="font-size:10px; font-family:arial;color:#000000;font-weight:bold;padding:5px;" nowrap>Header 6</div>');
		document.write('				<div unselectable="on" id="'+rteName+'formatblock" style="font-size:12px; font-family:arial;color:#000000;font-weight:bold;padding:5px;" nowrap>Paragraph</div>');
		document.write('			</div>');
		document.write('        </div>');
		document.write('        <div class="'+rteName+'rtebg" style="float:left;"><img src="' + rteImagePath + 'blank.gif"></div>');
		document.write('        <div background="' + rteImagePath + 'bg.gif" id="'+rteName+'rtefontface" style="float:left;height:25px;">');
		document.write('			<table style="width:50px;height:25px;" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" title="Font">');
		document.write('        	  <tr>');
		document.write('        	    <td nowrap><div unselectable="on" id="'+rteName+'fontface1" class="rtedropdown1" style="width:98px;font-family:arial;font-size:11px;color:#000000;">Verdana</div></td>');
		document.write('        	    <td><div unselectable="on" id="'+rteName+'fontface2" class="rtedropdown2"><img src="' + rteImagePath + 'arrow.gif" width="11" height="16"></div></td>');
		document.write('        	  </tr>');
		document.write('        	</table>');
		document.write('			<div id="'+rteName+'fontface3" class="rtedropdown7" style="position:absolute;display:none;">');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:arial;padding:5px;" nowrap>Arial</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:arial black;padding:5px;" nowrap>Arial Black</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:arial narrow;padding:5px;" nowrap>Arial Narrow</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:courier new;padding:5px;" nowrap>Courier New</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:century gothic;padding:5px;" nowrap>Century Gothic</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:comic sans ms;padding:5px;" nowrap>Comic Sans MS</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:impact;padding:5px;" nowrap>Impact</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:tahoma;padding:5px;" nowrap>Tahoma</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:times new roman;padding:5px;" nowrap>Times New Roman</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:trebuchet ms;padding:5px;" nowrap>Trebuchet MS</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="color:#000000;font-family:verdana;padding:5px;" nowrap>Verdana</div>');
		document.write('			</div>');
		document.write('        </div>');
		document.write('        <div class="rtebg"><img src="' + rteImagePath + 'blank.gif"></div>');
		document.write('        <div background="' + rteImagePath + 'bg.gif" id="'+rteName+'rtefontsize" style="float:left;height:25px;">');
		document.write('			<table style="width:28px;height:25px;" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" title="Font Size">');
		document.write(' 		         <tr>');
		document.write(' 		           <td><div unselectable="on" id="'+rteName+'fontsize1" class="rtedropdown1" style="font-family:arial;font-size:11px;color:#000000;">2</div></td>');
		document.write('    	           <td><div unselectable="on" id="'+rteName+'fontsize2" class="rtedropdown2"><img src="' + rteImagePath + 'arrow.gif" width="11" height="16"></div></td>');
		document.write('    	        </tr>');
		document.write('    	    </table>');
		document.write('			<div id="'+rteName+'fontsize3" class="rtedropdown7" style="position:absolute;display:none;">');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="font-family:arial;color:#000000;font-size:7px;padding:5px;">1</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="font-family:arial;color:#000000;font-size:10px;padding:5px;">2</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="font-family:arial;color:#000000;font-size:12px;padding:5px;">3</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="font-family:arial;color:#000000;font-size:13px;padding:5px;">4</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="font-family:arial;color:#000000;font-size:17px;padding:5px;">5</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="font-family:arial;color:#000000;font-size:23px;padding:5px;">6</div>');
		document.write('				<div unselectable="on" id="'+rteName+'fontface" style="font-family:arial;color:#000000;font-size:35px;padding:5px;">7</div>');
		document.write('			</div>');
		document.write('        </div>');
		document.write('        <div style="float:left" class="rtebg"><img src="' + rteImagePath + 'blank.gif"></div>');
		document.write('        <div style="float:left"  class="rtebg" id="'+rteName+'rtefontcolor" title="Font Color">');
		document.write('        	<table style="width:35px;" border="0" cellspacing="0" cellpadding="0">');
		document.write('        		<tr>');
		if (!document.all || window.opera){
			document.write('        			<td><div id="'+rteName+'fontcolor1" align="center" class="rtedropdown5" style="padding-bottom:1px;"><img src="' + rteImagePath + 'fontcolor.gif"><br><img id="'+rteName+'fontcolor4" src="' + rteImagePath + 'fontcolor2.gif" style="background-color:#FF0000;"></div></td>');
			document.write('        			<td><div id="'+rteName+'fontcolor2" align="center" class="rtedropdown8"><img src="' + rteImagePath + 'arrow.gif"></div></td>');
		}
		else{
			document.write('        			<td><div id="'+rteName+'fontcolor1" align="center" class="rtedropdown5" style="padding-bottom:1px;"><img src="' + rteImagePath + 'fontcolor.gif"><br><img id="'+rteName+'fontcolor4" src="' + rteImagePath + 'fontcolor2.gif" style="background-color:#FF0000;"></div></td>');
			document.write('        			<td><div id="'+rteName+'fontcolor2" align="center" class="rtedropdown8"><img src="' + rteImagePath + 'arrow.gif"></div></td>');
		}
		document.write('        		</tr>');
		document.write('        	</table>');
		document.write('			<div id="'+rteName+'fontcolor3" class="rtedropdown7" style="position:absolute;display:none;padding:4px;border:1px solid #002D96;">');
		document.write('				<table border="0" cellspacing="1" cellpadding="0">');
		document.write('					<tr>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#000000;" onClick="rteColorClick(\'#000000\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#993300;" onClick="rteColorClick(\'#993300\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#333300;" onClick="rteColorClick(\'#333300\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#003300;" onClick="rteColorClick(\'#003300\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#003366;" onClick="rteColorClick(\'#003366\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#000080;" onClick="rteColorClick(\'#000080\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#333399;" onClick="rteColorClick(\'#333399\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#333333;" onClick="rteColorClick(\'#333333\',\''+rteName+'\');"></div></td>');
		document.write('					</tr>');
		document.write('					<tr>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#800000;" onClick="rteColorClick(\'#800000\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FF6600;" onClick="rteColorClick(\'#FF6600\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#808000;" onClick="rteColorClick(\'#808000\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#008000;" onClick="rteColorClick(\'#008000\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#008080;" onClick="rteColorClick(\'#008080\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#0000FF;" onClick="rteColorClick(\'#0000FF\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#666699;" onClick="rteColorClick(\'#666699\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#808080;" onClick="rteColorClick(\'#808080\',\''+rteName+'\');"></div></td>');
		document.write('					</tr>');
		document.write('					<tr>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FF0000;" onClick="rteColorClick(\'#FF0000\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FF9900;" onClick="rteColorClick(\'#FF9900\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#99CC00;" onClick="rteColorClick(\'#99CC00\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#339966;" onClick="rteColorClick(\'#339966\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#33CCCC;" onClick="rteColorClick(\'#33CCCC\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#3366FF;" onClick="rteColorClick(\'#3366FF\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#800080;" onClick="rteColorClick(\'#800080\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#999999;" onClick="rteColorClick(\'#999999\',\''+rteName+'\');"></div></td>');
		document.write('					</tr>');
		document.write('					<tr>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FF00FF;" onClick="rteColorClick(\'#FF00FF\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FFCC00;" onClick="rteColorClick(\'#FFCC00\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FFFF00;" onClick="rteColorClick(\'#FFFF00\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#00FF00;" onClick="rteColorClick(\'#00FF00\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#00FFFF;" onClick="rteColorClick(\'#00FFFF\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#00CCFF;" onClick="rteColorClick(\'#00CCFF\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#993366;" onClick="rteColorClick(\'#993366\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#C0C0C0;" onClick="rteColorClick(\'#C0C0C0\',\''+rteName+'\');"></div></td>');
		document.write('					</tr>');
		document.write('					<tr>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FF99CC;" onClick="rteColorClick(\'#FF99CC\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FFCC99;" onClick="rteColorClick(\'#FFCC99\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FFFF99;" onClick="rteColorClick(\'#FFFF99\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#CCFFCC;" onClick="rteColorClick(\'#CCFFCC\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#CCFFFF;" onClick="rteColorClick(\'#CCFFFF\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#99CCFF;" onClick="rteColorClick(\'#99CCFF\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#CC99FF;" onClick="rteColorClick(\'#CC99FF\',\''+rteName+'\');"></div></td>');
		document.write('						<td><div id="'+rteName+'fontcolor" class="rtedropdown13"><img src="' + rteImagePath + 'fontcolor3.gif" style="background-color:#FFFFFF;" onClick="rteColorClick(\'#FFFFFF\',\''+rteName+'\');"></div></td>');
		document.write('					</tr>');
		document.write('				</table>');
		document.write('			</div>');
		document.write('        </div>');
		document.write('        <div style="float:left" class="rtebg" id="'+rteName+'rtesep2"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div style="float:left" class="rtebg" title="Bold"><div id="'+rteName+'bold" class="rtebtn1"><img src="' + rteImagePath + 'bold.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" title="Italic"><div id="'+rteName+'italic" class="rtebtn1"><img src="' + rteImagePath + 'italic.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" title="Underline"><div id="'+rteName+'underline" class="rtebtn1"><img src="' + rteImagePath + 'underline.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" title="Strikethrough"><div id="'+rteName+'strikethrough" class="rtebtn1"><img src="' + rteImagePath + 'strikethrough.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" id="'+rteName+'rtesep3"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div style="float:left" class="rtebg" title="Align Left"><div id="'+rteName+'justifyleft" class="rtebtn1"><img src="' + rteImagePath + 'leftalign.gif" width="21" height="20"></div></div>');
		document.write('        <div style="float:left" class="rtebg" title="Center"><div id="'+rteName+'justifycenter" class="rtebtn1"><img src="' + rteImagePath + 'centeralign.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" title="Align Right"><div id="'+rteName+'justifyright" class="rtebtn1"><img src="' + rteImagePath + 'rightalign.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" title="Justify"><div id="'+rteName+'justifyfull" class="rtebtn1"><img src="' + rteImagePath + 'fullalign.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" title="Horizontal Rule"><div id="'+rteName+'inserthorizontalrule" class="rtebtn1"><img src="' + rteImagePath + 'hr.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" id="'+rteName+'rtesep4"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div style="float:left" class="rtebg" title="Superscript"><div id="'+rteName+'superscript" class="rtebtn1"><img src="' + rteImagePath + 'superscript.gif"></div></div>');
		document.write('        <div style="float:left" class="rtebg" title="Subscript"><div id="'+rteName+'subscript" class="rtebtn1"><img src="' + rteImagePath + 'subscript.gif"></div></div>');
		document.write('        <div style="float:left" width="14"><img src="' + rteImagePath + 'finish.gif" width="14" height="25"></div>');
		document.write('    </div></td>');
		document.write('  </tr>');
		document.write('  <tr>');
		document.write('    <td bgcolor="#C3DAF9">');
		document.write('	<div id="'+rteName+'tb2" onmousedown="return false;">');
		document.write('        <div style="float:left" width="7"><img src="' + rteImagePath + 'start.gif" width="7" height="25" /></div>');
		document.write('        <div class="rtebg"><img src="' + rteImagePath + 'blank.gif"></div>');
		document.write('        <div class="rtebg"><div id="'+rteName+'createlink" class="rtebtn1" title="Insert Hyperlink"><a href="javascript:rteBtnCreateLink(\''+rteName+'\');" style="cursor:default;"><img src="' + rteImagePath + 'insertlink.gif" border="0"></a></div><div style="display:none;" id="'+rteName+'editlink" class="rtebtn1" title="Edit Hyperlink"><a href="javascript:rteBtnEditLink(\''+rteName+'\');" style="cursor:default;"><img src="' + rteImagePath + 'insertlink.gif"border="0"></a></div></div>');
		document.write('        <div class="rtebg" title="Remove Hyperlink"><div id="'+rteName+'unlink" class="rtebtn1"><img src="' + rteImagePath + 'unlink.gif"></div></div>');
		document.write('        <div class="rtebg" id="'+rteName+'rtesep5"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div class="rtebg" title="Insert Image"><div id="'+rteName+'insertimage" class="rtebtn1"><a href="javascript:rteBtnInsertImage(\''+rteName+'\');" style="cursor:default;"><img src="' + rteImagePath + 'insertimage.gif" border="0"></a></div></div>');
		document.write('        <div class="rtebg" title="Remove Formatting"><div id="'+rteName+'removeformat" class="rtebtn1"><img src="' + rteImagePath + 'format.gif"></div></div>');
		document.write('        <div class="rtebg" id="'+rteName+'rtesep6"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div class="rtebg" id="'+rteName+'tables">');
		document.write('			<table border="0" width="0" cellspacing="0" cellpadding="0" id="'+rteName+'table_options_on" style="display:none;">');
		document.write('				<tr>');
		document.write('     				 <td><div id="'+rteName+'inserttable" class="rtebtn1" title="Insert Table"><a href="javascript:rteBtnInsertTable(\''+rteName+'\');" style="cursor:default;"><img src="' + rteImagePath + 'inserttable.gif" border="0"></a></div><div id="'+rteName+'edittable" class="rtebtn1" title="Edit Table Properties"><a href="javascript:rteBtnEditTable(\''+rteName+'\');" style="cursor:default;"><img src="' + rteImagePath + 'inserttable.gif" border="0"></a></div></td>');
		document.write('     		  		 <td><div id="'+rteName+'insertcolumnleft" class="rtebtn1" title="Insert Column to the left"><img src="' + rteImagePath + 'insertcolumnleft.gif" onClick="rteBtnInsertTableColumnBefore(\''+rteName+'\');"></div></td>');
		document.write('       				 <td><div id="'+rteName+'insertcolumnright" class="rtebtn1" title="Insert Column to the right"><img src="' + rteImagePath + 'insertcolumnright.gif" onClick="rteBtnInsertTableColumnAfter(\''+rteName+'\');"></div></td>');
		document.write('       				 <td><div id="'+rteName+'insertrowabove" class="rtebtn1" title="Insert Row above"><img src="' + rteImagePath + 'insertrowabove.gif" onClick="rteBtnInsertTableRowBefore(\''+rteName+'\');"></div></td>');
		document.write('       				 <td><div id="'+rteName+'insertrowbelow" class="rtebtn1" title="Insert Row below"><img src="' + rteImagePath + 'insertrowbelow.gif" onClick="rteBtnInsertTableRowAfter(\''+rteName+'\');"></div></td>');
		document.write('       				 <td><div id="'+rteName+'deletecolumn" class="rtebtn1" title="Delete Current column"><img src="' + rteImagePath + 'deletecolumn.gif" onClick="rteBtnDeleteTableColumn(\''+rteName+'\');"></div></td>');
		document.write('       				 <td><div id="'+rteName+'deleterow" class="rtebtn1" title="Delete Current row"><img src="' + rteImagePath + 'deleterow.gif" onClick="rteBtnDeleteTableRow(\''+rteName+'\');"></div></td>');
		document.write('       		   </tr>');
		document.write('			</table>');
		document.write('			<table border="0" width="0" cellspacing="0" cellpadding="0" id="'+rteName+'table_options_off">');
		document.write('				<tr>');
		document.write('   			      <td><div id="'+rteName+'inserttable" class="rtebtn1" title="Insert Table"><a href="javascript:rteBtnInsertTable(\''+rteName+'\');" style="cursor:default;"><img src="' + rteImagePath + 'inserttable.gif" border="0"></div></a></td>');
		document.write('    		      <td><div class="rtebtn5" title="Insert Column to the left"><img src="' + rteImagePath + 'insertcolumnleftgrey.gif"></div></td>');
		document.write('     		      <td><div class="rtebtn5" title="Insert Column to the right"><img src="' + rteImagePath + 'insertcolumnrightgrey.gif"></div></td>');
		document.write('    			  <td><div class="rtebtn5" title="Insert Row above"><img src="' + rteImagePath + 'insertrowabovegrey.gif"></div></td>');
		document.write(' 			      <td><div class="rtebtn5" title="Insert Row below"><img src="' + rteImagePath + 'insertrowbelowgrey.gif"></div></td>');
		document.write('        		  <td><div class="rtebtn5" title="Delete Current column"><img src="' + rteImagePath + 'deletecolumngrey.gif"></div></td>');
		document.write('    			  <td><div class="rtebtn5" title="Delete Current row"><img src="' + rteImagePath + 'deleterowgrey.gif"></div></td>');
		document.write('   			    </tr>');
		document.write('			</table>');
		document.write('		</div>');
		document.write('        <div class="rtebg" id="'+rteName+'rtesep7"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div class="rtebg" title="Numbering"><div id="'+rteName+'insertorderedlist" class="rtebtn1"><img src="' + rteImagePath + 'orderedlist.gif"></div></div>');
		document.write('        <div class="rtebg" title="Bullets"><div id="'+rteName+'insertunorderedlist" class="rtebtn1"><img src="' + rteImagePath + 'unorderedlist.gif"></div></div>');
		document.write('        <div class="rtebg" title="Decrease Indent"><div id="'+rteName+'outdent" class="rtebtn1"><img src="' + rteImagePath + 'decreaseindent.gif"></div></div>');
		document.write('        <div class="rtebg" title="Increase Indent"><div id="'+rteName+'indent" class="rtebtn1"><img src="' + rteImagePath + 'increaseindent.gif"></div></div>');
		document.write('        <div class="rtebg" id="'+rteName+'rtesep8"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div class="rtebg" title="Undo"><div id="'+rteName+'undo" class="rtebtn1"><img src="' + rteImagePath + 'undo.gif"></div></div>');
		document.write('        <div class="rtebg" title="Redo"><div id="'+rteName+'redo" class="rtebtn1"><img src="' + rteImagePath + 'redo.gif"></div></div>');
		document.write('        <div class="rtebg" id="'+rteName+'rtesep9"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('		<div class="rtebg" width="30" id="'+rteName+'cutcopypaste">');
		document.write('		  <table border="0" width="0" cellspacing="0" cellpadding="0">');
		document.write('			<tr>');
		if (!document.all || window.opera){
			document.write('        	<td title="Cut"><div class="rtebtn5"><img src="' + rteImagePath + 'cutgrey.gif"></div></td>');
			document.write('      		<td title="Copy"><div class="rtebtn5"><img src="' + rteImagePath + 'copygrey.gif"></div></td>');
			document.write('        	<td title="Paste"><div class="rtebtn5"><img src="' + rteImagePath + 'pastegrey.gif"></div></td>');
		}
		else{
			document.write('        	<td title="Cut"><div id="'+rteName+'cut" class="rtebtn1"><img src="' + rteImagePath + 'cut.gif"></div></td>');
			document.write('        	<td title="Copy"><div id="'+rteName+'copy" class="rtebtn1"><img src="' + rteImagePath + 'copy.gif"></div></td>');
			document.write('        	<td title="Paste"><div id="'+rteName+'paste" class="rtebtn1"><img src="' + rteImagePath + 'paste.gif"></div></td>');
		}
		document.write('			</tr>');
		document.write('		  </table>');
		document.write('		</div>');
		document.write('        <div style="float:left" ><img src="' + rteImagePath + 'finish.gif" width="14" height="25" /></div>');
		document.write('    </div></td>');
		document.write('  </tr>');
		document.write('  <tr>');
		document.write('    <td bgcolor="#C3DAF9">');
		document.write('	<div id="'+rteName+'tb3" onmousedown="return false;">');
		document.write('        <div width="7" style="float:left;"><img src="' + rteImagePath + 'start.gif" width="7" height="25" /></div>');
		document.write('        <div class="rtebg" title="Form"><a href="javascript:rteBtnInsertForm(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'insertform" class="rtebtn1"><img src="' + rteImagePath + 'form.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Check Box"><a href="javascript:rteBtnInsertCheckbox(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_checkbox" class="rtebtn1"><img src="' + rteImagePath + 'checkbox.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Radio Button"><a href="javascript:rteBtnInsertRadio(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_radio" class="rtebtn1"><img src="' + rteImagePath + 'radio.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Text Area"><a href="javascript:rteBtnInsertTextArea(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_textarea" class="rtebtn1"><img src="' + rteImagePath + 'textarea.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Submit Button"><a href="javascript:rteBtnInsertSubmit(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_submit" class="rtebtn1"><img src="' + rteImagePath + 'submit.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Image Button"><a href="javascript:rteBtnInsertImageSubmit(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_image_submit" class="rtebtn1"><img src="' + rteImagePath + 'imagesubmit.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Reset Button"><a href="javascript:rteBtnInsertReset(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_reset" class="rtebtn1"><img src="' + rteImagePath + 'reset.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Hidden Field"><a href="javascript:rteBtnInsertHidden(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_hidden" class="rtebtn1"><img src="' + rteImagePath + 'hidden.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Password Field"><a href="javascript:rteBtnInsertPassword(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_password" class="rtebtn1"><img src="' + rteImagePath + 'password.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" title="Text Field"><a href="javascript:rteBtnInsertText(\''+rteName+'\');" style="cursor:default;"><div id="'+rteName+'form_textfield" class="rtebtn1"><img src="' + rteImagePath + 'textfield.gif" border="0"></div></a></div>');
		document.write('        <div class="rtebg" id="'+rteName+'rtesep10"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div class="rtebg" title="Print"><div id="'+rteName+'printrte" class="rtebtn1"><img src="' + rteImagePath + 'print.gif" onClick="rteBtnPrint(\'+'+rteName+'+\');"></div></div>');
		document.write('        <div class="rtebg" title="Select All"><div id="'+rteName+'selectall" class="rtebtn1"><img src="' + rteImagePath + 'selectall.gif"></div></div>');
		if (!document.all || window.opera){
			document.write('        <div id="'+rteName+'spellchecker" class="rtebg" title="Spell Check"><div id="'+rteName+'spellcheck" class="rtebtn5"><img src="' + rteImagePath + 'spellcheckgrey.gif"></div></div>');
		}
		else{
			document.write('        <div id="'+rteName+'spellchecker" class="rtebg" title="Spell Check"><div id="'+rteName+'spellcheck" class="rtebtn5"><img src="' + rteImagePath + 'spellcheckgrey.gif"></div></div>');
		}
		document.write('        <div class="rtebg" id="'+rteName+'rtesep11"><img src="' + rteImagePath + 'seperator.gif"></div>');
		document.write('        <div class="rtebg" title="About Free Rich Text Editor"><div id="'+rteName+'aboutrte" class="rtebtn1"><a href="javascript:rteAbout();" style="cursor:default;"><img src="' + rteImagePath + 'about.gif" border="0"></a></div></div>');
		document.write('        <div style="float:left" width="14"><img src="' + rteImagePath + 'finish.gif" width="14" height="25" /></div>');
		document.write('    </div>');
		document.write('    </td>');
		document.write('  <tr>');
		document.write('    <td style="border:1px solid #C3DAF9; ">');
		document.write('		<iframe name="' + rteName + '" id="' + rteName + '" style="width:100%; height:' + rteHeight + '; background-color:#FFFFFF;" frameborder="0"></iframe>');
		document.write('		<textarea name="' + rteFormName + '" id="' + rteFormName + '" style="display:none;width:' + rteWidth + '; height:' + rteHeight + '; background-color:#FFFFFF; font-family:courier new; font-size:12px; color:#000000; border:0px;"></textarea>');
		document.write('		<iframe id="preview_' + rteName + '" style="width:' + rteWidth + '; height:' + rteHeight + '; background-color:#FFFFFF; display:none;" frameborder="0"></iframe>');
		document.write('	</td>');
		document.write('  </tr>');
		document.write('  <tr>');
		document.write('    <td bgcolor="#C3DAF9" height="25" class="rtebg">');
		document.write('		<table width="100%" cellspacing="0" cellpadding="0" border="0" onmousedown="return false;">');
		document.write('			<tr>');
		document.write('				<td>');
		document.write('					<table width="0" cellspacing="3" cellpadding="0" border="0" class="rtebg">');
		document.write('						<tr>');
		if(rteDesignMode){
			document.write('							<td style="color:#000000; font-family:arial; font-size:11px;"><div class="rtebtn9" id="'+rteName+'rte_design_mode" onclick="rteModeType(\'rte_design_mode\',\''+rteName+'\');"><img src="' + rteImagePath + 'design.gif">&nbsp;Design</div></td>');
		}
		else{
			document.write('							<td style="display:none;color:#000000; font-family:arial; font-size:11px;"><div class="rtebtn9" id="'+rteName+'rte_design_mode"><img src="' + rteImagePath + 'design.gif">&nbsp;Design</div></td>');
		}
		if (rteCodeMode){
			document.write('							<td style="color:#000000; font-family:arial; font-size:11px;"><div class="rtebtn6" id="'+rteName+'rte_code_mode" onclick="rteModeType(\'rte_code_mode\',\''+rteName+'\');"><img src="' + rteImagePath + 'code.gif">&nbsp;Code</div></td>');
		}
		else{
			document.write('							<td style="display:none;color:#000000; font-family:arial; font-size:11px;"><div class="rtebtn6" id="'+rteName+'rte_code_mode"><img src="' + rteImagePath + 'code.gif">&nbsp;Code</div></td>');
		}
		if (rtePreviewMode){
			document.write('							<td style="color:#000000; font-family:arial; font-size:11px;"><div class="rtebtn6" id="'+rteName+'rte_preview_mode" onclick="rteModeType(\'rte_preview_mode\',\''+rteName+'\');"><img src="' + rteImagePath + 'preview.gif">&nbsp;Preview</div></td>');
		}
		else{
			document.write('							<td style="display:none;color:#000000; font-family:arial; font-size:11px;"><div class="rtebtn6" id="'+rteName+'rte_preview_mode"><img src="' + rteImagePath + 'preview.gif">&nbsp;Preview</div></td>');
		}
		document.write('						</tr>');
		document.write('					</table>');
		document.write('				</td>');
		document.write('			</tr>');
		document.write('		</table>');
		document.write('	</td>');
		document.write('  </tr>');
		document.write('</table>');
		startRTE(rteName, rtePreloadContent);
		menuBuilder(rteName);
	}
};

