if (window.FTB_AddEvent) { 
	FTB_AddEvent(window,'load',function () {
		FTB_API['ftbPageCopy'] = new FTB_FreeTextBox('ftbPageCopy',
					true,
					false,
					new Array(
						new FTB_Button('ftbPageCopy_Bold','bold',null,null,false,null),
			new FTB_Button('ftbPageCopy_Italic','italic',null,null,false,null),
			new FTB_Button('ftbPageCopy_Underline','underline',null,null,false,null),
			new FTB_Button('ftbPageCopy_JustifyLeft','justifyleft',null,null,false,null),
			new FTB_Button('ftbPageCopy_JustifyRight','justifyright',null,null,false,null),
			new FTB_Button('ftbPageCopy_JustifyCenter','justifycenter',null,null,false,null),
			new FTB_Button('ftbPageCopy_JustifyFull','justifyfull',null,null,false,null),
			new FTB_Button('ftbPageCopy_BulletedList','insertunorderedlist',null,null,false,null),
			new FTB_Button('ftbPageCopy_NumberedList','insertorderedlist',null,null,false,null),
			new FTB_Button('ftbPageCopy_Indent','indent',null,null,false,null),
			new FTB_Button('ftbPageCopy_Outdent','outdent',null,null,false,null),
			new FTB_Button('ftbPageCopy_CreateLink','createlink',function() { this.ftb.CreateLink(); },null,false,null),
			new FTB_Button('ftbPageCopy_Unlink','unlink',null,null,false,function() { this.disabled = !(this.ftb.GetParentElement().tagName.toLowerCase() == 'a') }),
			new FTB_Button('ftbPageCopy_InsertRule','inserthorizontalrule',null,null,false,null),
			new FTB_Button('ftbPageCopy_Cut','cut',function() { this.ftb.Cut(); },null,true,null),
			new FTB_Button('ftbPageCopy_Copy','copy',function() { this.ftb.Copy(); },null,true,null),
			new FTB_Button('ftbPageCopy_Paste','paste',function() { this.ftb.Paste(); },null,true,null),
			new FTB_Button('ftbPageCopy_Undo','undo',function() { this.ftb.Undo(); },null,false,function() { this.disabled=!this.ftb.CanUndo(); }),
			new FTB_Button('ftbPageCopy_Redo','redo',function() { this.ftb.Redo(); },null,false,function() { this.disabled=!this.ftb.CanRedo(); }),
			new FTB_Button('ftbPageCopy_InsertTable','',function() { this.ftb.InsertTableWindow(); },null,false,null),
			new FTB_Button('ftbPageCopy_InsertDate','',function() { var d = new Date();this.ftb.InsertHtml(d.toLocaleDateString()); },null,false,null),
			new FTB_Button('ftbPageCopy_InsertTime','',function() { var d = new Date();this.ftb.InsertHtml(d.toLocaleTimeString()); },null,false,null),
			new FTB_Button('ftbPageCopy_Preview','',function() { this.ftb.Preview(); },null,true,null)
					),
					new Array(
						new FTB_DropDownList('ftbPageCopy_StylesMenu','',function() { this.ftb.SetStyle(this.list.options[this.list.options.selectedIndex].value);  },function() { return this.ftb.GetStyle(); },null),
			new FTB_DropDownList('ftbPageCopy_Font','fontname',null,null,null),
			new FTB_DropDownList('ftbPageCopy_Color','forecolor',null,null,null)
					),				
					FTB_BREAK_P,
					FTB_PASTE_TEXT,
					FTB_TAB_INSERTSPACES,
					FTB_MODE_DESIGN,									
					null,
					'includes/style.css',
					'',
					'',
					'ftb.imagegallery.aspx?rif={0}&cif={0}',
					'~/images/',
					false,
					21,
					20
					
				);
			});
	//FTB_API['ftbPageCopy'].Initialize();
}



/*  Add events to objects
--------------------------------------- */
function FTB_AddEvents(obj, evTypes, fn) {
	for (i=0; i<evTypes.length; i++) FTB_AddEvent(obj, evTypes[i], fn);
};
function FTB_AddEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent('on'+evType, fn);
		return r;
	} else {
		return false;
	}
};
/*  API for holding all FreeTextBox's
--------------------------------------- */
FTB_API = new Object();

/* Browser Detection 'FTB_Browser'
--------------------------------------- */
function FTB_BrowserDetect() {
	doc=window.document;
	navVersion=navigator.appVersion.toLowerCase();
	this.ie4=(!doc.getElementById&&doc.all)?true:false;
	this.ie5=(navVersion.indexOf("msie 5.0")!=-1)?true:false;
	this.ie55=(navVersion.indexOf("msie 5.5")!=-1)?true:false;
	this.ie6=(navVersion.indexOf("msie 6.0")!=-1)?true:false;
	this.isIE=(this.ie5||this.ie55||this.ie6)?true:false;
	this.isGecko=!this.isIE;
};
FTB_Browser = new FTB_BrowserDetect();

/* OOP Timeout Manager 'FTB_Timeout'
--------------------------------------- */
function FTB_TimeoutManager() {
	this.pendingCalls = {};		
};
FTB_TimeoutManager.prototype.addMethod = function(name,obj,method,delay,arg1,arg2) {
	this.clearMethod(name);
	this.pendingCalls[name] = new FTB_TimeoutCall(obj,method,arg1,arg2);
	this.pendingCalls[name].timeout = 
		setTimeout('FTB_Timeout.executeMethod("' + name + '");',delay);
};
FTB_TimeoutManager.prototype.executeMethod = function(name) {
	call = this.pendingCalls[name];
	if (call != null) {
		call.obj[call.method](call.arg1,call.arg2);
		this.clearMethod(name);
	}
};
FTB_TimeoutManager.prototype.clearMethod = function(name) {
	if (this.pendingCalls[name]) 
		delete this.pendingCalls[name];
};
//* Object to hold timeout reference
function FTB_TimeoutCall(obj,method,arg1,arg2) {
	this.obj = obj;
	this.method = method;
	this.arg1 = arg1;
	this.arg2 = arg2;
	this.timeout = null;
};
FTB_Timeout = new FTB_TimeoutManager();

/* Constants 
----------------------------------------- */
FTB_MODE_HTML = 0;
FTB_MODE_DESIGN = 1;
FTB_MODE_PREVIEW = 2;
//
FTB_PASTE_DEFAULT = 0;
FTB_PASTE_DISABLED = 1;
FTB_PASTE_TEXT = 2;
//
FTB_TAB_DISABLED = 0;
FTB_TAB_NEXTCONTROL = 1;
FTB_TAB_INSERTSPACES = 2;
//
FTB_BUTTON_ON = 0;
FTB_BUTTON_OFF = 1;
//
FTB_BREAK_P = 0;
FTB_BREAK_BR = 1;
//
FTB_KEY_TAB = 9;
FTB_KEY_ENTER = 13;
FTB_KEY_QUOTE = 222;
FTB_KEY_V = 86;
FTB_KEY_P = 86;
FTB_KEY_B = 66;
FTB_KEY_I = 73;
FTB_KEY_U = 85;
FTB_KEY_Z = 90;
FTB_KEY_Y = 89;
//
FTB_CODE_OPENCURLY = '&#8220;';
FTB_CODE_CLOSECURLY = '&#8221;';
//
FTB_BUTTON_STYLEDBACKGROUNDS = 0;
FTB_BUTTON_IMAGEBACKGROUNDS = 1;


/* Misc Methods
------------------------------------------ */
function FTB_SetListValue(list, value, checkText) {
	checkText = checkText || false;
	value = String(value).toLowerCase();

	for (var i=0; i<list.options.length; i++) {
		if (list.options[i].value.toLowerCase() == value || (checkText && list.options[i].text.toLowerCase() == value)) {
			list.selectedIndex = i;
			return;
		}
	}
};
function FTB_ParseUnit(styleString) {
	var unit = new Object();
	unit.value = 0;
	unit.unitType = '';
	for(var i=0; i<styleString.length; i++) {
		if (isNaN(styleString.charAt(i)))
			unit.unitType += styleString.charAt(i);
		else 
			unit.value = parseInt(unit.value.toString() + styleString.charAt(i));
	}
	return unit;
};
function FTB_DecToHex(dec) {
	return parseInt(dec).toString(16); 
};
function FTB_RgbToHex(r,g,b) {
	return "#" + FTB_IntToHex(r) + FTB_IntToHex(g) + FTB_IntToHex(b);
};
function FTB_IntToHexColor( intColor ) {
	if (!intColor) return null;
	intColor = intColor.toString(16).toUpperCase();
	while (intColor.length < 6) intColor = "0" + intColor;
	return "#" + intColor.substring(4,6) + intColor.substring(2,4) + intColor.substring(0,2);
};
function FTB_RgbStringToHex(rgbString){ 
	var r, g, b;
	rgbString = rgbString.toString().toLowerCase();	
	if(rgbString.indexOf("rgb(") == -1 || rgbString.indexOf(")") == -1) return rgbString;
	
	rgbString = rgbString.substring(rgbString.indexOf("(")+1, rgbString.indexOf(")")-1);
	rgb = rgbString.split(',');
	r = rgb[0];
	g = rgb[1];
	if (rgb.length == 2) b = rbg[2]; else b = 0;	
	return FTB_RgbToHex(r,g,b);
};
function FTB_IntToHex(dec){ 
	var result = (parseInt(dec).toString(16)); 
	if(result.length ==1) 
	result= ("0" +result); 
	return result.toUpperCase(); 
};
function FTB_GetQueryStringValues(url) {	
	url = new String(url);
	
	var queryStringValues=new Object();
	var querystring=url.substring(url.indexOf('?')+1, url.length);
	var querystringSplit = querystring.split('&');
	
	for (i=0; i < querystringSplit.length; i++){
		var pair=querystringSplit[i].split('=');
		var name=pair[0];
		var value=pair[1];
		queryStringValues[ name ]=value;
	}
	return queryStringValues;
};
/* Static Popup HTML
---------------------------------------- */
var FTB_PopUpStyle = "\
html, body { \
	background-color: #ECE9D8; \
	color: #000000; \
	font: 11px Tahoma,Verdana,sans-serif; \
	padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\
";

var FTB_PopUpHeader = new String("<html><body> \
<head>\
<title>POPUP_TITLE</title>\
<style type='text/css'>\
html, body { \
	background-color: #ECE9D8; \
	color: #000000; \
	font: 11px Tahoma,Verdana,sans-serif; \
	padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\</style>\
<script type='text/javascript'>\
POPUP_SCRIPT\
</script>\
</head>\
<body>\
<form action=''> \
<h3>POPUP_TITLE</h3> \
POPUP_HTML \
</form> \
</body> \
</html>");



/* main FTB object
-------------------------------------- */
function FTB_FreeTextBox(id, enableToolbars, readOnly, buttons, dropdownlists, breakMode, pasteMode, tabMode, startMode, clientSideTextChanged, designModeCss, designModeBodyTagCssClass, baseUrl, textDirection, buttonImageFormat, imageGalleryUrl, imageGalleryPath, receiveFocus, buttonWidth, buttonHeight) {
	this.debug = document.getElementById('debug');
	
	this.id = id;
	this.enableToolbars = enableToolbars;
	this.readOnly = readOnly;
	this.buttons = buttons;
	this.dropdownlists = dropdownlists;
	this.breakMode = breakMode;
	this.pasteMode = pasteMode;
	this.tabMode = tabMode;
	this.startMode = startMode;
	this.clientSideTextChanged = clientSideTextChanged;

	this.designModeCss = designModeCss;
	this.designModeBodyTagCssClass = designModeBodyTagCssClass;
	this.baseUrl = baseUrl;
	this.textDirection = textDirection;
	this.buttonImageFormat = buttonImageFormat; // currently unused
	this.imageGalleryUrl = imageGalleryUrl;
	this.imageGalleryPath = imageGalleryPath;	
	this.hasFocus = false;
	this.mode = FTB_MODE_DESIGN;
	this.initialized = false;
	this.undoArray = new Array();
	this.undoArrayMax = 16;
	this.undoArrayPos = -1;
	this.lastEvent = null;
//};
//FTB_FreeTextBox.prototype.Initialize = function() {
	var ftb = this;
	

	// 2. Find everything
	//* windows
	this.htmlEditor = document.getElementById(this.id);

	if (FTB_Browser.isIE) {
		this.previewPane = eval(this.id + "_previewPane");
		this.designEditor = eval(this.id + "_designEditor");
		this.designEditor.ftb = this;
		this.designEditor.document.ftb = this;
		document.getElementById(this.id + "_designEditor").document.ftb = this;
	} else {
		this.previewPane = document.getElementById(this.id + "_previewPane").contentWindow;
		this.designEditor = document.getElementById(this.id + "_designEditor").contentWindow;
		this.designEditor.document.ftb = this;		
	}

	//* areas
	this.toolbarArea = document.getElementById(this.id + "_toolbarArea");
	this.designEditorArea = document.getElementById(this.id + "_designEditorArea");
	this.htmlEditorArea = document.getElementById(this.id + "_htmlEditorArea");
	this.previewPaneArea = document.getElementById(this.id + "_previewPaneArea");

	//* tabs
	this.designModeTab = document.getElementById(this.id + "_designModeTab");
	if (this.designModeTab) {
		this.designModeTab.ftb = this;
		this.designModeTab.onclick = function() { if (!this.ftb.readOnly) {this.ftb.GoToDesignMode(); this.ftb.Focus(); this.ftb.UpdateToolbars(); }}
	}

	this.htmlModeTab = document.getElementById(this.id + "_htmlModeTab");
	if (this.htmlModeTab) {
		this.htmlModeTab.ftb = this;
		this.htmlModeTab.onclick = function() { if (!this.ftb.readOnly) {this.ftb.GoToHtmlMode(); this.ftb.Focus();  this.ftb.UpdateToolbars(); }}
	}

	this.previewModeTab = document.getElementById(this.id + "_previewModeTab");
	if (this.previewModeTab) {
		this.previewModeTab.ftb = this;
		this.previewModeTab.onclick = function() { if (!this.ftb.readOnly) {this.ftb.GoToPreviewMode();}}
	}
	
	//* ancestor area
	this.ancestorArea = document.getElementById(this.id + "_AncestorArea");

	// 3. Tell buttons who owns them
	//* setup buttons & dropdowns
	if (this.enableToolbars) {
		for(var i=0; i<this.buttons.length; i++) {
			button = this.buttons[i];
			button.ftb = this;
			if (!this.readOnly)
				button.Initialize();
		}
		for(var i=0; i<this.dropdownlists.length; i++) {
			dropdownlist = this.dropdownlists[i];
			dropdownlist.ftb = this;
		}
	}
       
	
	// 4. Setup editor for use
	if (!this.readOnly) {
		this.designEditor.document.designMode = 'On';

		if (FTB_Browser.isGecko) this.designEditor.document.contentEditable = true;	
   	}
	
	this.designEditor.document.open();
	this.designEditor.document.write("<html" + ((this.textDirection == "rtl") ? " dir='rtl'" : "") + ">" + 
			"<head>" + 
			((this.designModeCss != '') ? "<link rel='stylesheet' href='" + this.designModeCss + "' type='text/css' />" : "") + 
			((this.baseUrl != '') ? "<base href='" + this.baseUrl + "' />" : "") + 
			"</head>" + 
			"<body" + ((this.designModeBodyTagCssClass != '') ? " class='" + this.designModeBodyTagCssClass + "'" : "") + ">" + 
				this.htmlEditor.value + 
			"</body>" + 
		"</html>");
	this.designEditor.document.close();
	
	
	if (!this.readOnly) {	
		if (FTB_Browser.isIE) this.designEditor.document.body.contentEditable = true;		
		// enable this html area
		this.htmlEditor.disabled = '';
	}	
	
	// silly IE can't get the style right until now...
	if (FTB_Browser.isIE) {
		this.designEditor.document.body.style.border = '0';		
	}
	
	// 5. Add events
    if (!this.readOnly) {
		if (FTB_Browser.isIE) {
			FTB_AddEvents(this.designEditor.document,
				new Array("keydown","keypress","mousedown"),
				function(e) { ftb.hasFocus=true; return ftb.Event(e); } 
			);
		} else {
			var evt = function(e) {	
				this.document.ftb.hasFocus=true; 
				this.document.ftb.Event(e);
				return false;
			}
			this.designEditor.addEventListener("keydown", evt, true);			
			this.designEditor.addEventListener("keypress", evt, true);			
			this.designEditor.addEventListener("mousedown", evt, true);

      		// no paste event in Mozilla
		}
		FTB_AddEvents(this.designEditor,
			new Array("blur"),
			function(e) { ftb.hasFocus=false; ftb.Event(e); ftb.StoreHtml(); } 
		);
	}
     	
	if (this.startMode == FTB_MODE_HTML)
		this.GoToHtmlMode();
		
	if (this.readOnly) 
		this.DisableAllToolbarItems();
	else
		this.UpdateToolbars();
	
	this.undoArray[0] = this.htmlEditorArea.value;
	this.initialized = true;
	if (this.receiveFocus) this.Focus();
		
	// crazy Gecko fix. apparently 'useCSS' cannot be fired before the page is loaded.
	if (FTB_Browser.isGecko && !(this.startMode == FTB_MODE_HTML)) {
		setTimeout(function()  {
			ftb.designEditor.document.designMode = 'On';
			ftb.designEditor.document.execCommand("useCSS", false, true);	
		}, 50);	
	}
};

FTB_FreeTextBox.prototype.AddStyle = function(css) {
	var styleEl=document.createElement('style');
	styleEl.type='text/css';
	styleEl.appendChild(css);
	this.designEditor.document.appendChild(styleEl);
};

FTB_FreeTextBox.prototype.Event = function(ev) {
 	if (ev != null) { 	

 		if (FTB_Browser.isIE) {
 			sel = this.GetSelection();
 			r = this.CreateRange(sel);	 		
	 		
 			// check for undo && redo
 			if (ev.ctrlKey && ev.keyCode == FTB_KEY_Z) {
 				this.Undo();
				this.CancelEvent(ev);			
 			} else if (ev.ctrlKey && ev.keyCode == FTB_KEY_Y) { 			
 				this.Redo(); 
				this.CancelEvent(ev);
 			} else {
		 		
 				if (ev.keyCode == FTB_KEY_ENTER) {
 					if (this.breakMode == FTB_BREAK_BR || ev.ctrlKey) {
						if (sel.type == 'Control') {
							return;
						}
						if ((!this.CheckTag(r.parentElement(),'LI'))&&(!this.CheckTag(r.parentElement(),'H'))) {
							r.pasteHTML('<br>');
							this.CancelEvent(ev);
							r.select();
							r.collapse(false);
							return false;
						} 			
 					} 
				} else if ((ev.ctrlKey && !ev.shiftKey && !ev.altKey)) {					
					if (ev.keyCode == FTB_KEY_V || ev.keyCode == 118) {										
						this.CapturePaste();
						this.CancelEvent(ev);
					}
 				} else if (ev.keyCode == FTB_KEY_TAB) {	
	 				if (this.CheckTag(r.parentElement(),'LI')) {
	 					if (ev.shiftKey)
	 						this.ExecuteCommand("outdent");
	 					else
	 						this.ExecuteCommand("indent");
	 					this.CancelEvent(ev);
	 				} else {	 				
	 					switch (this.tabMode) {
	 						default:
	 						case FTB_TAB_NEXTCONTROL:
	 							break;
	 						case FTB_TAB_INSERTSPACES:
	 							this.InsertHtml("&nbsp;&nbsp;&nbsp;");
	 							this.CancelEvent(ev);
	 							break;
	 						case FTB_TAB_DISABLED:
	 							this.CancelEvent(ev);
	 							break;	 						
	 					}
	 				}
 				}
 			}
	 	
 		} else { 	 	
	 		if (ev.type == "keypress" || ev.type == "keydown") {
	 			
	 			
				// check for undo && redo
				if (ev.ctrlKey && ev.which && ev.which == FTB_KEY_Z) {	 			
					this.Undo();
					this.CancelEvent(ev);		
				} else if (ev.ctrlKey && ev.which && ev.which == FTB_KEY_Y) {	 			
					this.Redo(); 
					this.CancelEvent(ev);		
				} else {

					if (ev.keyCode == FTB_KEY_ENTER) {
						if (this.breakMode == FTB_BREAK_P) {
							
						}

					// check for control+commands (not in Mozilla by default)
					} else if ((ev.ctrlKey && !ev.shiftKey && !ev.altKey)) {
						
						if (ev.which == FTB_KEY_V || ev.which == 118) {										
							if (ev.which == 118 && this.pasteMode != FTB_PASTE_DEFAULT) {
								this.CapturePaste();
								this.CancelEvent(ev);
							}
						} else if (ev.which == FTB_KEY_B || ev.which == 98) {
							if (ev.which == FTB_KEY_B) this.ExecuteCommand('bold');
							this.CancelEvent(ev);
						} else if (ev.which == FTB_KEY_I || ev.which == 105) {
							if (ev.which == FTB_KEY_I) this.ExecuteCommand('italic');
							this.CancelEvent(ev);
						} else if (ev.which == FTB_KEY_U || ev.which == 117) {
							if (ev.which == FTB_KEY_U) this.ExecuteCommand('underline');				 						
							this.CancelEvent(ev);
						}
					} else if (ev.which == FTB_KEY_TAB) {
						if (this.CheckTag(r.parentElement,'LI')) {
							// do it's own thing!
						} else {	 				
							switch (this.tabMode) {
								default:
								case FTB_TAB_NEXTCONTROL:
									// unsupported in Mozilla
									break;
								case FTB_TAB_INSERTSPACES:
									// do it's own thing
									break;
								case FTB_TAB_DISABLED:
									this.CancelEvent(ev);
									break;	 						
							}
						}			

					}
				}
  			} 	
 		}
 	}
 
	if (this.mode == FTB_MODE_DESIGN) {
		FTB_Timeout.addMethod(this.id+'_UpdateToolbars',this,'UpdateToolbars',200);
	}
	
	if (this.clientSideTextChanged)
		this.clientSideTextChanged(this);
};
FTB_FreeTextBox.prototype.CancelEvent = function(ev) {
	if (FTB_Browser.isIE) {
		ev.cancelBubble = true;
		ev.returnValue = false;
	} else {
		ev.preventDefault();
		ev.stopPropagation();
	}
};
FTB_FreeTextBox.prototype.InsertElement = function(el) {
	var sel = this.GetSelection();
	var range = this.CreateRange(sel);
	
	if (FTB_Browser.isIE) {
		range.pasteHTML(el.outerHTML);
	} else {
		this.InsertNodeAtSelection(el);
	}
};
FTB_FreeTextBox.prototype.RecordUndoStep = function() {	
	if (!this.initialized) return;
	++this.undoArrayPos;
	if (this.undoArrayPos >= this.undoArrayMax) {
		// remove the first element
		this.undoArray.shift();
		--this.undoArrayPos;
	}
	
	var take = true;
	var html = this.designEditor.document.body.innerHTML;
	if (this.undoArrayPos > 0)
		take = (this.undoArray[this.undoArrayPos - 1] != html);
	if (take) {
		this.undoArray[this.undoArrayPos] = html;
	} else {
		this.undoArrayPos--;
	}
};
FTB_FreeTextBox.prototype.Undo = function() {
	if (this.undoArrayPos > 0) {
		var html = this.undoArray[--this.undoArrayPos];
		if (html)
			this.designEditor.document.body.innerHTML = html;
		else 
			++this.undoArrayPos;
	}
};
FTB_FreeTextBox.prototype.CanUndo = function() {
	return true;
	return (this.undoArrayPos > 0);
};
FTB_FreeTextBox.prototype.Redo = function() {
	if (this.undoArrayPos < this.undoArray.length - 1) {
		var html = this.undoArray[++this.undoArrayPos];
		if (html) 
			this.designEditor.document.body.innerHTML = html;
		else 
			--this.undoArrayPos;
	}
	
};
FTB_FreeTextBox.prototype.CanRedo = function() {
	return true;
	return (this.undoArrayPos < this.undoArray.length - 1);
};
FTB_FreeTextBox.prototype.CapturePaste = function() {
 
 	switch (this.pasteMode) {
 		case FTB_PASTE_DISABLED:
 			return false;
 		case FTB_PASTE_TEXT:
 			if (window.clipboardData) {
				var text = window.clipboardData.getData('Text');
				text = text.replace(/<[^>]*>/gi,'');
				this.InsertHtml(text);
			} else {
				alert("Your browser does not support pasting rich content");
			}
			return false; 				
 		default:
 		case FTB_PASTE_DEFAULT:
			try {
				this.ExecuteCommand('paste'); 
			} catch (e) {
				alert('Your security settings to not allow you to use this command.  Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
			}	
 			return true;
 	}		
};
FTB_FreeTextBox.prototype.Debug = function(text) {
	if (this.debug)
		this.debug.value += text + '\r';
};
FTB_FreeTextBox.prototype.UpdateToolbars = function() {
	
	if (this.hasFocus) {

		if (this.mode == FTB_MODE_DESIGN) {
			if (this.enableToolbars) {
				for (var i=0; i<this.buttons.length; i++) {
					button = this.buttons[i];

					if (button.customStateQuery)
						button.state = button.customStateQuery();			
					else if (button.commandIdentifier != null && button.commandIdentifier != '')
						button.state = this.QueryCommandState(button.commandIdentifier);

					button.SetButtonBackground("Out");
				}
				for (var i=0; i<this.dropdownlists.length; i++) {
					dropdownlist = this.dropdownlists[i];

					if (dropdownlist.customStateQuery)
						dropdownlist.SetSelected(dropdownlist.customStateQuery());
					else if (dropdownlist.commandIdentifier != null && dropdownlist.commandIdentifier != '') 
						dropdownlist.SetSelected(this.QueryCommandValue(dropdownlist.commandIdentifier));

				}
			}
		}	
		
	} else {
	
		if (this.enableToolbars) {
			for (var i=0; i<this.buttons.length; i++) {
				button = this.buttons[i];
				button.state = FTB_BUTTON_OFF;
				button.SetButtonBackground("Out");
			}
			for (var i=0; i<this.dropdownlists.length; i++) {
				dropdownlist = this.dropdownlists[i];
				dropdownlist.list.selectedIndex = 0;
			}
		}	
	}

	if (!this.undoTimer) {
		this.RecordUndoStep();
		var editor = this;
		this.undoTimer = setTimeout(function() {
			editor.undoTimer = null;
		}, 500);
	}
	
	this.SetToolbarItemsEnabledState();	
	
	if (this.timerToolbar) 
		this.timerToolbar = null;	
};

FTB_FreeTextBox.prototype.SetToolbarItemsEnabledState = function() {	
	if (!this.enableToolbars) return;
	if (this.hasFocus || !this.initialized) {
	
		if (this.mode == FTB_MODE_DESIGN ) {		
			for (i=0; i<this.buttons.length; i++) {
				button = this.buttons[i];

				if (button.customEnabled)
					button.customEnabled();
				else 
					button.disabled = false;

				if (button.disabled)
					this.DisableButton(button);			
				else
					this.EnableButton(button);
			}

			for (i=0; i<this.dropdownlists.length; i++) {
				this.dropdownlists[i].list.disabled=false;
			}		
		} else {
			for (i=0; i<this.buttons.length; i++) {
				button = this.buttons[i];

				if (button.htmlModeEnabled) 
					button.disabled=false
				else
					button.disabled = true;

				if (button.disabled)
					this.DisableButton(button);			
				else
					this.EnableButton(button);
			}

			for (i=0; i<this.dropdownlists.length; i++) {
				this.dropdownlists[i].list.selectedIndex=0;
				this.dropdownlists[i].list.disabled=true;
			}	
		}
	} 
};
FTB_FreeTextBox.prototype.DisableAllToolbarItems = function() {	
	if (this.enableToolbars) {
		for (i=0; i<this.buttons.length; i++) {
			this.DisableButton(this.buttons[i]);			
		}

		for (i=0; i<this.dropdownlists.length; i++) {
			this.dropdownlists[i].list.disabled=true;
		}
	}
};
FTB_FreeTextBox.prototype.EnableButton = function(button) {
	if (FTB_Browser.isIE)
		button.buttonImage.style.filter = "alpha(opacity = 100);";
	else 
		button.buttonImage.style.MozOpacity = 1;
};
FTB_FreeTextBox.prototype.DisableButton = function(button) {
	button.state = FTB_BUTTON_OFF;
	button.SetButtonStyle("Out");

	if (FTB_Browser.isIE)
		button.buttonImage.style.filter = "alpha(opacity = 25);";		
	else 
		button.buttonImage.style.MozOpacity = 0.25;
};
FTB_FreeTextBox.prototype.CopyHtmlToIframe = function(iframe) {
   	if (this.initialized) {
		html = this.htmlEditor.value;
		iframe.document.body.innerHTML = html;
   	} else {
		iframe.document.open();
		iframe.document.write("<html>" + 
			"<head>" + 
			((this.designModeCss != '' && FTB_Browser.isGecko) ? "<style type='text/css'>@import url(" + this.designModeCss + ");</style>" : "") + 
			((this.baseUrl != '') ? "<base href='" + this.baseUrl + "' />" : "") + 
			"</head>" + 
			"<body>" + this.htmlEditor.value + "</body>" + 
		"</html>");
		iframe.document.close();
	}
};
FTB_FreeTextBox.prototype.CopyDesignToHtml = function() {
	this.htmlEditor.value = this.designEditor.document.body.innerHTML;
	
	// clear out default moz & ie properties
	if (this.htmlEditor.value == '<br>' || this.htmlEditor.value == '<br>\r\n' || // Moz
		this.htmlEditor.value == '<P>&nbsp;</P>') { // IE
		this.htmlEditor.value = '';
	}	
};
FTB_FreeTextBox.prototype.GoToHtmlMode = function() {
    if (this.mode == FTB_MODE_DESIGN) this.CopyDesignToHtml();
	
	if (FTB_Browser.isGecko)
		this.designEditor.document.designMode = 'Off';
		
    this.designEditorArea.style.display = 'none';
    this.htmlEditorArea.style.display = '';
    this.previewPaneArea.style.display = 'none';
   
	if (this.ancestorArea) this.ancestorArea.innerHTML = "";    
    this.SetActiveTab(this.htmlModeTab);    
         
	this.mode = FTB_MODE_HTML;  
    return true;
};
FTB_FreeTextBox.prototype.GoToDesignMode = function() {
	if (this.mode == FTB_MODE_DESIGN) return false;

	this.CopyHtmlToIframe(this.designEditor);
	this.designEditorArea.style.display = '';
	this.htmlEditorArea.style.display = 'none';
	this.previewPaneArea.style.display = 'none';	

	// reset for Gecko	
	if (FTB_Browser.isGecko) {
		this.designEditor.document.designMode = 'On';
		this.designEditor.document.execCommand("useCSS", false, true);
	}
    
    if (this.ancestorArea) this.ancestorArea.innerHTML = "";
    
    this.SetActiveTab(this.designModeTab);
    this.mode = FTB_MODE_DESIGN;

    return true;
};
FTB_FreeTextBox.prototype.GoToPreviewMode = function() {
    if (this.mode == FTB_MODE_DESIGN) this.CopyDesignToHtml();
    this.CopyHtmlToIframe(this.previewPane);

    this.designEditorArea.style.display = 'none';
    this.htmlEditorArea.style.display = 'none';
    this.previewPaneArea.style.display = '';
      
    this.SetActiveTab(this.previewModeTab);
    if (this.ancestorArea) this.ancestorArea.innerHTML = "";
    
    this.mode = FTB_MODE_PREVIEW;
    return true;
};
FTB_FreeTextBox.prototype.HtmlEncode = function( text ) {
	if ( typeof( text ) != "string" )
		text = text.toString() ;

	text = text.replace(/&/g, "&amp;") ;
	text = text.replace(/"/g, "&quot;") ;
	text = text.replace(/</g, "&lt;") ;
	text = text.replace(/>/g, "&gt;") ;
	text = text.replace(/'/g, "&#146;") ;

	return text ;
};
FTB_FreeTextBox.prototype.ExecuteCommand = function(commandName, middle, commandValue) {
	if (this.mode != FTB_MODE_DESIGN) return;
	this.designEditor.focus();
	if (commandName == 'backcolor' && !FTB_Browser.isIE) commandName = 'hilitecolor';
	this.designEditor.document.execCommand(commandName,middle,commandValue);
	if (this.clientSideTextChanged)
		this.clientSideTextChanged(this);
};
FTB_FreeTextBox.prototype.QueryCommandState = function(commandName) {
	if (this.mode != FTB_MODE_DESIGN) return false;
	try {
		if (this.designEditor.document.queryCommandState(commandName)) {
			return FTB_BUTTON_ON;
		} else {
			// special case for paragraph on IE
			if (commandName == 'justifyleft') {
				if (this.designEditor.document.queryCommandState('justifyright') == false &&
					this.designEditor.document.queryCommandState('justifycenter') == false &&
					this.designEditor.document.queryCommandState('justifyfull') == false ) {
					return FTB_BUTTON_ON;
				} else {
					return FTB_BUTTON_OFF;
				}
			} else { 
				return FTB_BUTTON_OFF;
			}
		}
	} catch(exp) {
		return FTB_BUTTON_OFF;
	}
};
FTB_FreeTextBox.prototype.QueryCommandValue = function(commandName) {
	if (this.mode != FTB_MODE_DESIGN) return false;
	value = this.designEditor.document.queryCommandValue(commandName);
	switch (commandName) {
		case "backcolor":
			if (FTB_Browser.isIE) {
				value = FTB_IntToHexColor(value);
			} else {
				if (value == "") value = "#FFFFFF";
			}
			break;
		case "forecolor":
			if (FTB_Browser.isIE) {
				value = FTB_IntToHexColor(value);
			} else {
				if (value == "") value = "#000000";
			}
			break;
		case "formatBlock":
			if (!FTB_Browser.isIE) {
				if (value == "" || value == "<x>")
					value = "<p>";
				else
					value = "<" + value + ">";
			}
			break;
	}
	if (value == '' || value == null) {
		if (commandName == 'fontsize') return '3';
		if (commandName == 'fontname') return 'Times New Roman';	
		if (commandName == 'forecolor') return '#000000';	
		if (commandName == 'backcolor') return '#ffffff';
	}
		
	return value;

};
FTB_FreeTextBox.prototype.SurroundHtml = function(start,end) {
	if (this.mode == FTB_MODE_HTML) return;
	this.designEditor.focus();
	
	if (FTB_Browser.isIE) {
		var sel = this.designEditor.document.selection.createRange();
		html = start + sel.htmlText + end;
		sel.pasteHTML(html);		
	} else {
        selection = this.designEditor.window.getSelection();
        if (selection) {
            range = selection.getRangeAt(0);
        } else {
            range = this.designEditor.document.createRange();
        } 
        
        this.InsertHtml(start + selection + end);
	}	
};
FTB_FreeTextBox.prototype.InsertHtml = function(html) {
	if (this.mode != FTB_MODE_DESIGN) return;
	this.designEditor.focus();
	if (FTB_Browser.isIE) {
		sel = this.designEditor.document.selection.createRange();
		sel.pasteHTML(html);
	} else {

        selection = this.designEditor.window.getSelection();
		if (selection) {
			range = selection.getRangeAt(0);
		} else {
			range = editor.document.createRange();
		}

        var fragment = this.designEditor.document.createDocumentFragment();
        var div = this.designEditor.document.createElement("div");
        div.innerHTML = html;

        while (div.firstChild) {
            fragment.appendChild(div.firstChild);
        }

        selection.removeAllRanges();
        range.deleteContents();

        var node = range.startContainer;
        var pos = range.startOffset;

        switch (node.nodeType) {
            case 3:
                if (fragment.nodeType == 3) {
                    node.insertData(pos, fragment.data);
                    range.setEnd(node, pos + fragment.length);
                    range.setStart(node, pos + fragment.length);
                } else {
                    node = node.splitText(pos);
                    node.parentNode.insertBefore(fragment, node);
                    range.setEnd(node, pos + fragment.length);
                    range.setStart(node, pos + fragment.length);
                }
                break;

            case 1:
                node = node.childNodes[pos];
                node.parentNode.insertBefore(fragment, node);
                range.setEnd(node, pos + fragment.length);
                range.setStart(node, pos + fragment.length);
                break;
        }
        selection.addRange(range);
	}
};
/* ------------------------------------------------
START: Node and Selection Methods */

FTB_FreeTextBox.prototype.CheckTag = function(item,tagName) {
	if (!item) return null;
	if (item.tagName.search(tagName)!=-1) {
		return item;
	}
	if (item.tagName=='BODY') {
		return false;
	}
	item=item.parentElement;
	return this.CheckTag(item,tagName);
};
FTB_FreeTextBox.prototype.GetParentElement = function() {

	var sel = this.GetSelection();
	var range = this.CreateRange(sel);
	if (FTB_Browser.isIE) {
		switch (sel.type) {
		    case "Text":
		    case "None":
				return range.parentElement();
		    case "Control":
				return range.item(0);
		    default:
				return this.designEditor.document.body;
		}
	} else try {
		var p = range.commonAncestorContainer;
		if (!range.collapsed && range.startContainer == range.endContainer &&
		    range.startOffset - range.endOffset <= 1 && range.startContainer.hasChildNodes())
			p = range.startContainer.childNodes[range.startOffset];

		while (p.nodeType == 3) {
			p = p.parentNode;
		}
		return p;
	} catch (e) {
		return null;
	}
};
FTB_FreeTextBox.prototype.InsertNodeAtSelection = function(toBeInserted) {
	if (!FTB_Browser.isIE) {
		var sel = this.GetSelection();
		var range = this.CreateRange(sel);
		// remove the current selection
		sel.removeAllRanges();
		range.deleteContents();
		var node = range.startContainer;
		var pos = range.startOffset;
		switch (node.nodeType) {
		    case 3: // Node.TEXT_NODE
			// we have to split it at the caret position.
			if (toBeInserted.nodeType == 3) {
				// do optimized insertion
				node.insertData(pos, toBeInserted.data);
				range = this._createRange();
				range.setEnd(node, pos + toBeInserted.length);
				range.setStart(node, pos + toBeInserted.length);
				sel.addRange(range);
			} else {
				node = node.splitText(pos);
				var selnode = toBeInserted;
				if (toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */) {
					selnode = selnode.firstChild;
				}
				node.parentNode.insertBefore(toBeInserted, node);
				this.SelectNodeContents(selnode);
			}
			break;
		    case 1: // Node.ELEMENT_NODE
			var selnode = toBeInserted;
			if (toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */) {
				selnode = selnode.firstChild;
			}
			node.insertBefore(toBeInserted, node.childNodes[pos]);
			this.SelectNodeContents(selnode);
			break;
		}
	}
};
FTB_FreeTextBox.prototype.SelectNodeContents = function(node, pos) {
	var range;
	var collapsed = (typeof pos != "undefined");
	if (isIE) {
		range = this.designEditor.document.body.createTextRange();
		range.moveToElementText(node);
		(collapsed) && range.collapse(pos);
		range.select();
	} else {
		var sel = this.GetSelection();
		range = this.designEditor.document.createRange();
		range.selectNodeContents(node);
		(collapsed) && range.collapse(pos);
		sel.removeAllRanges();
		sel.addRange(range);
	}
};
FTB_FreeTextBox.prototype.SelectNextNode = function(el) {
	var node = el.nextSibling;
	while (node && node.nodeType != 1) {
		node = node.nextSibling;
	}
	if (!node) {
		node = el.previousSibling;
		while (node && node.nodeType != 1) {
			node = node.previousSibling;
		}
	}
	if (!node) {
		node = el.parentNode;
	}
	this.SelectNodeContents(node);
};
FTB_FreeTextBox.prototype.GetSelection = function() {
	if (FTB_Browser.isIE) {
		return this.designEditor.document.selection;
	} else {
		return this.designEditor.getSelection();
	}
};
FTB_FreeTextBox.prototype.CreateRange = function(sel) {
	if (FTB_Browser.isIE) {
		return sel.createRange();
	} else {
		if (typeof sel != "undefined") {
			try {
				return sel.getRangeAt(0);
			} catch(e) {
				return this.designEditor.document.createRange();
			}
		} else {
			return this.designEditor.document.createRange();
		}
	}
};
FTB_FreeTextBox.prototype.SelectNodeContents = function(node, pos) {
	var range;
	var collapsed = (typeof pos != "undefined");
	if (FTB_Browser.isIE) {
		range = this.designEditor.document.body.createTextRange();
		range.moveToElementText(node);
		(collapsed) && range.collapse(pos);
		range.select();
	} else {
		var sel = this.GetSelection();
		range = this.designEditor.document.createRange();
		range.selectNodeContents(node);
		(collapsed) && range.collapse(pos);
		sel.removeAllRanges();
		sel.addRange(range);
	}
};
FTB_FreeTextBox.prototype.GetNearest = function(tagName) {
	var ancestors = this.GetAllAncestors();
	var ret = null;
	tagName = ("" + tagName).toLowerCase();
	for (var i=0;i<ancestors.length;i++) {
		var el = ancestors[i];
		if (el) {
			if (el.tagName.toLowerCase() == tagName) {
				ret = el;
				break;
			}
		}
	}
	return ret;
};
FTB_FreeTextBox.prototype.GetAllAncestors = function() {
	var p = this.GetParentElement();
	var a = [];
	while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
		a.push(p);
		p = p.parentNode;
	}
	a.push(this.designEditor.document.body);
	return a;
};
FTB_FreeTextBox.prototype.GetStyle = function() {
	var parent = this.GetParentElement();
	return parent.className;	
};
FTB_FreeTextBox.prototype.SetActiveTab = function(theTD) {
	if (theTD) {
		parentTR = theTD.parentElement;
		parentTR = document.getElementById(this.id + "_TabRow");

		selectedTab = 1;
		totalButtons = parentTR.cells.length-1;
		for (var i=1;i< totalButtons;i++) {
			parentTR.cells[i].className = this.id + "_TabOffRight";
			if (theTD == parentTR.cells[i]) { selectedTab = i; }
		}

		if (selectedTab==1) {
			parentTR.cells[0].className = this.id + "_StartTabOn";
		} else {
			parentTR.cells[0].className = this.id + "_StartTabOff";
			parentTR.cells[selectedTab-1].className = this.id + "_TabOffLeft";
		}

		theTD.className = this.id + "_TabOn";
	}
};
FTB_FreeTextBox.prototype.Focus = function() {
	if (this.mode == FTB_MODE_DESIGN) {
		this.designEditor.focus();
		this.UpdateToolbars();
	} else if (this.mode == FTB_MODE_HTML) {
		this.htmlEditor.focus();
	}
	this.hasFocus = true;
};
FTB_FreeTextBox.prototype.SetStyle = function(className) {
	
	// retrieve parent element of the selection
	var parent = this.GetParentElement();
	
	var surround = true;
	var isSpan = (parent && parent.tagName.toLowerCase() == "span");
	
	// if we're already in a SPAN
	if (isSpan) {
		if (parent.childNodes.length == 1) {
			parent.className = className;
			surround = false;
			this.UpdateToolbars();
			return;
		}
	} else {
		
	}

	if (surround) {
		this.SurroundHtml("<span class='" + className + "'>", "</span>");
	}
};
FTB_FreeTextBox.prototype.GetHtml = function() {
	if (this.mode == FTB_MODE_DESIGN)
		this.CopyDesignToHtml();
		
	return this.htmlEditor.value;
};
FTB_FreeTextBox.prototype.SetHtml = function(html) {
	this.htmlEditor.value = html;
	this.mode = FTB_MODE_HTML;	
	this.GoToDesignMode();
};
FTB_FreeTextBox.prototype.StoreHtml = function() {
	if (!this.initialized) return;
	
	if (this.mode == FTB_MODE_DESIGN)
		this.CopyDesignToHtml();
		
	return true;
};
/* START: Button Methods 
-------------------------------- */
FTB_FreeTextBox.prototype.DeleteContents = function() {
	if (confirm('Do you want to delete all the HTML and text presently in the editor?')) {	
		this.designEditor.document.body.innerHTML = '';
		this.htmlEditor.value='';
		this.GoToDesignMode();
	}
};
FTB_FreeTextBox.prototype.Cut = function() {
	if (this.mode == FTB_MODE_DESIGN) {

		try {
			this.ExecuteCommand('cut'); 
		} catch (e) {
			alert('Your security settings to not allow you to use this command.  Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
		}	
	} 
};
FTB_FreeTextBox.prototype.Copy = function() {
	if (this.mode == FTB_MODE_DESIGN) {
		try {
			this.ExecuteCommand('copy');
		} catch (e) {
			alert('Your security settings to not allow you to use this command.  Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
		}	
	} 
};
FTB_FreeTextBox.prototype.Paste = function() {
	if (this.mode == FTB_MODE_DESIGN) this.CapturePaste();
}
FTB_FreeTextBox.prototype.SelectAll = function() {
	if (this.mode == FTB_MODE_DESIGN) {		
		this.SelectNodeContents(this.designEditor.document.body);
	}
};
FTB_FreeTextBox.prototype.Print = function() {
	if (this.mode == FTB_MODE_DESIGN) {
		if (FTB_Browser.isIE) {
			this.ExecuteCommand('print'); 
		} else {
			this.designEditor.print();
		}	
	} else {
		printWindow = window.open('','','');
		printWindow.document.open();
		printWindow.document.write("<html><body><pre>" + this.HtmlEncode(this.htmlEditor.value) + "</code></body></html>");
		printWindow.document.close();
		printWindow.document.body.print();
		printWindow.close();
	}
};
FTB_FreeTextBox.prototype.CreateLink = function() {
	if (FTB_Browser.isIE) {
		this.ExecuteCommand('createlink','1',null);
	} else {
		//need to pull
		var link = this.GetNearest('a');
		var url = prompt('Enter a URL:', (link) ? link.href : 'http://');
		if ((url != null) && (url != '')) 
			this.ExecuteCommand('createlink',null,url);
	}
};
FTB_FreeTextBox.prototype.IeSpellCheck = function() {
	if (!FTB_Browser.isIE) {
		alert('IE Spell is not supported in Mozilla');
		return;
	}
	try {
		var tspell = new ActiveXObject('ieSpell.ieSpellExtension');
		tspell.CheckAllLinkedDocuments(window.document);
	} catch (err){
		if (window.confirm('You need ieSpell to use spell check. Would you like to install it?')){
			window.open('http://www.iespell.com/download.php');
		};
	}
};
FTB_FreeTextBox.prototype.NetSpell = function() {
	if (typeof(checkSpellingById) == 'function') {
		checkSpellingById(this.id + '_designEditor');
	} else {
		alert('Netspell libraries not properly linked.');
	}
};
FTB_FreeTextBox.prototype.InsertImage = function() {
	if (FTB_Browser.isIE) {
		this.ExecuteCommand('insertimage','1',null);
	} else {
		var img = this.GetNearest('img');
		var imgSrc = prompt('Enter an image URL:', (img) ? img.src : 'http://');
		if ((imgSrc != null) && (imgSrc != '')) 
			this.ExecuteCommand('insertimage',null,imgSrc);			
	}
};
FTB_FreeTextBox.prototype.SaveButton = function() {
	this.StoreHtml();	
	dotNetName = this.id.split('_').join(':');
	__doPostBack(dotNetName,'Save');
};
FTB_FreeTextBox.prototype.InsertImageFromGallery = function() {
	
	url = this.imageGalleryUrl.replace(/\{0\}/g,this.imageGalleryPath);	
	url += "&ftb=" + this.id;

	var gallery = window.open(url,'gallery','width=700,height=600,toolbars=0,resizable=1');
	gallery.focus();	
}
FTB_FreeTextBox.prototype.Preview = function() {
	this.CopyDesignToHtml();

	printWindow = window.open('','','toolbars=no');
	printWindow.document.open();
	printWindow.document.write("<html><head><link rel='stylesheet' href='" + this.designModeCss + "' type='text/css' />" + ((this.baseUrl != '') ? "<base href='" + this.baseUrl + "' />" : "") + "</head><body>" + this.htmlEditor.value + "</body></html>");
	printWindow.document.close();	
};
/* START: InsertTable */
FTB_FreeTextBox.prototype.InsertTable = function(cols,rows,width,widthUnit,align,cellpadding,cellspacing,border) {
	this.designEditor.focus();
	var sel = this.GetSelection();
	var range = this.CreateRange(sel);	
	
	var doc = this.designEditor.document;
	// create the table element
	var table = doc.createElement("table");	

	// assign the given arguments
	table.style.width 	= width + widthUnit;
	table.align	 		= align;
	table.border	 	= border;
	table.cellSpacing 	= cellspacing;
	table.cellPadding 	= cellpadding;
	
	var tbody = doc.createElement("tbody");
	table.appendChild(tbody);
	
	for (var i = 0; i < rows; ++i) {
		var tr = doc.createElement("tr");
		tbody.appendChild(tr);
		for (var j = 0; j < cols; ++j) {
			var td = doc.createElement("td");
			tr.appendChild(td);			
			if (!FTB_Browser.isIE) td.appendChild(doc.createElement("br"));
		}
	}
	
	if (FTB_Browser.isIE) {
		range.pasteHTML(table.outerHTML);
	} else {
		this.InsertNodeAtSelection(table);
	}
	
	return true;
};
FTB_FreeTextBox.prototype.InsertTableWindow = function() {
	this.LaunchTableWindow(false);
};
FTB_FreeTextBox.prototype.EditTable = function() {
	this.LaunchTableWindow(true);
};
FTB_FreeTextBox.prototype.LaunchTableWindow = function(editing) {
		
	var tableWin = window.open("","tableWin","width=400,height=200");
	if (tableWin) {
		tableWin.focus();
	} else {
		alert("Please turn off your PopUp blocking software");
		return;
	}
		
	tableWin.document.body.innerHTML = '';
	tableWin.document.open();
	tableWin.document.write(FTB_TablePopUpHtml);
	tableWin.document.close();
	
	launchParameters = new Object();
	launchParameters['ftb'] = this;
	launchParameters['table'] = (editing) ? this.GetNearest("table") : null;	
	tableWin.launchParameters = launchParameters;
	tableWin.load();
};
var FTB_TablePopUpHtml = new String("\
<html><body> \
<head>\
<title>Table Editor</title>\
<style type='text/css'>\
html, body { \
	background-color: #ECE9D8; \
	color: #000000; \
	font: 11px Tahoma,Verdana,sans-serif; \
	padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\</style>\
<script type='text/javascript'>\
function doTable() { \
	ftb = window.launchParameters['ftb'];\
	table = window.launchParameters['table'];\
	if (table) { \
		table.style.width = document.getElementById('f_width').value + document.getElementById('f_unit').options[document.getElementById('f_unit').selectedIndex].value; \
		table.align = document.getElementById('f_align').options[document.getElementById('f_align').selectedIndex].value;  \
		table.cellPadding = (document.getElementById('f_padding').value.length > 0 && !isNaN(document.getElementById('f_padding').value)) ? parseInt(document.getElementById('f_padding').value) : ''; \
		table.cellSpacing = (document.getElementById('f_spacing').value.length > 0 && !isNaN(document.getElementById('f_spacing').value)) ? parseInt(document.getElementById('f_spacing').value) : ''; \
		table.border = parseInt(document.getElementById('f_border').value); \
	} else {\
		cols = parseInt(document.getElementById('f_cols').value); \
		rows = parseInt(document.getElementById('f_rows').value); \
		width = document.getElementById('f_width').value; \
		widthUnit = document.getElementById('f_unit').options[document.getElementById('f_unit').selectedIndex].value; \
		align = document.getElementById('f_align').value; \
		cellpadding = document.getElementById('f_padding').value; \
		cellspacing = document.getElementById('f_spacing').value; \
		border = document.getElementById('f_border').value; \
		ftb.InsertTable(cols,rows,width,widthUnit,align,cellpadding,cellspacing,border); \
	} \
	window.close(); \
}\
</script>\
</head>\
<body>\
<form action=''> \
<h3>Table Editor</h3> \
<table border='0' style='padding: 0px; margin: 0px'> \
  <tbody> \
  <tr> \
    <td style='width: 4em; text-align: right'>Rows:</td> \
    <td><input type='text' name='rows' id='f_rows' size='5' title='Number of rows' value='2' /></td> \
    <td></td> \
    <td></td> \
    <td></td> \
  </tr> \
  <tr> \
    <td style='width: 4em; text-align: right'>Cols:</td> \
    <td><input type='text' name='cols' id='f_cols' size='5' title='Number of columns' value='4' /></td> \
    <td style='width: 4em; text-align: right'>Width:</td> \
    <td><input type='text' name='width' id='f_width' size='5' title='Width of the table' value='100' /></td> \
    <td><select size='1' name='unit' id='f_unit' title='Width unit'> \
      <option value='%' selected='1'  >Percent</option> \
      <option value='px'              >Pixels</option> \
      <option value='em'              >Em</option> \
    </select></td> \
  </tr> \
  </tbody> \
</table> \
<table width='100%'>\
<tr><td valign='top'>\
	<fieldset>\
	<legend>Layout</legend> \
		<table>\
		<tr><td class='f_title'>Alignment:</td><td>\
			<select size='1' name='align' id='f_align' \
			title='Positioning of the table'> \
			<option value='' selected='1'                >Not set</option> \
			<option value='left'                         >Left</option> \
			<option value='center'                       >Center</option> \
			<option value='right'                        >Right</option> \
			</select> \
		</td></tr>\
		<tr><td class='f_title'>Border thickness:</td><td>\
			<input type='text' name='border' id='f_border' size='5' value='1' title='Leave empty for no border' /> \
		</td></tr></table>\
	</fieldset>\
</td><td valign='top'>\
	<fieldset>\
	<legend>Spacing</legend> \
		<table>\
		<tr><td class='f_title'>Cell spacing:</td><td>\
			<input type='text' name='spacing' id='f_spacing' size='5' value='1' title='Space between adjacent cells' /> \
		</td></tr>\
		<tr><td class='f_title'>Cell padding:</td><td>\
			<input type='text' name='padding' id='f_padding' size='5' value='1' title='Space between content and border in cell' /> \
		</td></tr></table>\
	</fieldset> \
</td></tr></table>\
<div class='footer'> \
<button type='button' name='ok' id='f_goButton' onclick='doTable();window.close();'>OK</button> \
<button type='button' name='cancel' onclick='window.close();'>Cancel</button> \
</div> \
<script language='JavaScript'> \
function load() { \
	ftb = window.launchParameters['ftb'];\
	table = window.launchParameters['table'];\
	if (table) { \
		width = window.opener.FTB_ParseUnit(table.style.width); \
		document.getElementById('f_width').value = width.value; \
		window.opener.FTB_SetListValue(document.getElementById('f_align'),table.align,true); \
		window.opener.FTB_SetListValue(document.getElementById('f_unit'),width.unitType,true); \
		document.getElementById('f_border').value = table.border; \
		document.getElementById('f_padding').value = table.cellPadding; \
		document.getElementById('f_spacing').value = table.cellSpacing; \
		document.getElementById('f_cols').disabled = true; \
		document.getElementById('f_rows').disabled = true; \
	} \
} \
</script></form> \
</body> \
</html>");

/* END: InsertTable */
/* --------------------------------
END: Button Methods */


/* FTB_Button
---------------------------------------------- */
function FTB_Button(id, commandIdentifier, customAction, customStateQuery, htmlModeEnabled, customEnabled) {
	this.state = FTB_BUTTON_OFF;
	this.id = id;
	this.ftb = null;
	this.commandIdentifier = commandIdentifier;
	this.customAction = customAction;
	this.customStateQuery = customStateQuery;	
	
	this.disabled = false;
	this.htmlModeEnabled = htmlModeEnabled	;
	this.customEnabled = customEnabled;
	
	this.td = document.getElementById(id);
	this.td.button = this;
	
	if (FTB_Browser.isIE) {		
		this.buttonImage = this.td.childNodes[0];
	} else {
		this.buttonImage = this.td.childNodes[1];
	}
};
FTB_Button.prototype.Initialize = function() {
	var id=this.td.button.id;
	FTB_AddEvent(this.td,"click",function() { if(FTB_Browser.isIE) document.getElementById(id).button.Click(); else this.button.Click(); } );
	FTB_AddEvent(this.td,"mouseover",function() { if(FTB_Browser.isIE) document.getElementById(id).button.MouseOver(); else this.button.MouseOver(); } );
	FTB_AddEvent(this.td,"mouseout",function() { if(FTB_Browser.isIE) document.getElementById(id).button.MouseOut(); else this.button.MouseOut(); } );
};
FTB_Button.prototype.Click = function() {
	if (!this.disabled) {
		
		if (this.customAction) 			
			this.customAction();	
		else if (this.commandIdentifier != null && this.commandIdentifier != '') 
			this.ftb.ExecuteCommand(this.commandIdentifier);

		this.ftb.Event();
		
	}
};
FTB_Button.prototype.MouseOver = function() {
	if (!this.disabled) this.SetButtonBackground("Over");
};
FTB_Button.prototype.MouseOut = function() {
	if (!this.disabled) this.SetButtonBackground("Out");
};
FTB_Button.prototype.SetButtonBackground = function(mouseState) {
		this.SetButtonStyle(mouseState);
}
FTB_Button.prototype.SetButtonStyle = function(mouseState) {
	this.td.className = this.ftb.id + "_Button_" + ((this.state == FTB_BUTTON_ON) ? "On" : "Off") + "_" + mouseState;
}

/* FTB_DropDownList
---------------------------------------------- */

function FTB_DropDownList(id, commandIdentifier, customAction, customStateQuery, customEnabled) {
	this.id = id;
	this.ftb = null;
	this.commandIdentifier = commandIdentifier;
	this.customAction = customAction;
	this.customStateQuery = customStateQuery;
	this.customEnabled = customEnabled;
	
	this.list = document.getElementById(id);
	if (this.list) {
		this.list.dropDownList = this;

		FTB_AddEvent(this.list,"change",function() { if(FTB_Browser.isIE) document.getElementById(id).dropDownList.Select(); else this.dropDownList.Select(); } );
	} else {
		alert(id + ' is not setup properly');
	}
};
FTB_DropDownList.prototype.Select = function() {	
	if (this.customAction) 
		this.customAction();
	else if (this.commandIdentifier != null && this.commandIdentifier != '') 
		this.ftb.ExecuteCommand(this.commandIdentifier, '', this.list.options[this.list.selectedIndex].value);	
	
	this.list.selectedIndex = 0;
	
	this.ftb.Event();
};
FTB_DropDownList.prototype.SetSelected = function(commandValue) {
	value = String(commandValue).toLowerCase();

	for (var i=0; i<this.list.options.length; i++) {
		if (this.list.options[i].value.toLowerCase() == value || this.list.options[i].text.toLowerCase() == value) {
			this.list.selectedIndex = i;
			return;
		}
	}
};


FTB_FreeTextBox.prototype.InsertDiv = function() {
	var div = window.document.createElement("div");
	div.style.width = "200px";
	div.style.height = "200px";
	div.style.border = "dotted 1px gray";
	this.InsertElement(div);

};
FTB_FreeTextBox.prototype.EditStyle = function() {
	// custom implimentation of GetParentElement() and GetSelection() and GetRange()
	el = this.GetParentElement();

	this.EditElementStyle(el);
};
FTB_FreeTextBox.prototype.EditElementStyle = function(el) {

	var styleWin = window.open("","propWin","width=530,height=420,status=0,toolbars=0");
	if (styleWin) {
		styleWin.focus();
	} else {
		alert("Please turn off your PopUp blocking software");
		return;
	}
	//return;
	html = FTB_StyleEditorHtml;
		
	styleWin.document.body.innerHTML = '';
	styleWin.document.open();	
	styleWin.document.write( html );
	styleWin.document.close();	
	
	launchParameters = new Object();
	launchParameters['ftb'] = this;
	launchParameters['element'] = el;	
	styleWin.launchParameters = launchParameters;
	styleWin.load();
};
/* START: Table Functions 
These functions are derived from HTMLAREA who
gave permission for them to be used in FreeTextBox
- Thanks HTMLAREA!!
----------------------------------------------- */

FTB_FreeTextBox.prototype.InsertTableColumnBefore = function() {
	this.InsertTableColumn(false);
};
FTB_FreeTextBox.prototype.InsertTableColumnAfter = function() {
	this.InsertTableColumn(true);
};
FTB_FreeTextBox.prototype.InsertTableColumn = function(after) {
   var td = this.GetNearest("td");
   if (!td) {
      return;
   }
   var rows = td.parentNode.parentNode.rows;
   var index = td.cellIndex;
   for (var i = rows.length; --i >= 0;) {
      var tr = rows[i];
      var otd = this.designEditor.document.createElement("td");
      otd.innerHTML = (FTB_Browser.isIE) ? "" : "<br />";

      //if last column and insert column after is select append child
      if (index==tr.cells.length-1 && after) {
         tr.appendChild(otd);
      } else {
         var ref = tr.cells[index + ((after) ? 1 : 0)]; // 0 
         tr.insertBefore(otd, ref);
      } 
   }
};
FTB_FreeTextBox.prototype.InsertTableRowBefore = function() {
	this.InsertTableRow(false);
};
FTB_FreeTextBox.prototype.InsertTableRowAfter = function() {
	this.InsertTableRow(true);
};
FTB_FreeTextBox.prototype.InsertTableRow = function(after) {
	var tr = this.GetNearest("tr");
	if (!tr) return;
	var otr = tr.cloneNode(true);
	this.ClearRow(otr);
	tr.parentNode.insertBefore(otr, ((after) ? tr.nextSibling : tr));
};
FTB_FreeTextBox.prototype.DeleteTableColumn = function() {
	var td = this.GetNearest("td");
	if (!td) {
		return;
	}
	var index = td.cellIndex;
	if (td.parentNode.cells.length == 1) {
		return;
	}
	// set the caret first to a position that doesn't disappear
	this.SelectNextNode(td);
	var rows = td.parentNode.parentNode.rows;
	for (var i = rows.length; --i >= 0;) {
		var tr = rows[i];
		tr.removeChild(tr.cells[index]);
	}
};
FTB_FreeTextBox.prototype.DeleteTableRow = function() {
	var tr = this.GetNearest("tr");
	if (!tr) {
		return;
	}
	var par = tr.parentNode;
	if (par.rows.length == 1) {
		return;
	}
	// set the caret first to a position that doesn't disappear.
	this.SelectNextNode(tr);
	par.removeChild(tr);
};
// helper table
FTB_FreeTextBox.prototype.ClearRow = function(tr) {
	var tds = tr.getElementsByTagName("td");
	for (var i = tds.length; --i >= 0;) {
		var td = tds[i];
		td.rowSpan = 1;
		td.innerHTML = (FTB_Browser.isIE) ? "" : "<br />";
	}
};
FTB_FreeTextBox.prototype.SplitRow = function(td) {
	var n = parseInt("" + td.rowSpan);
	var nc = parseInt("" + td.colSpan);
	td.rowSpan = 1;
	tr = td.parentNode;
	var itr = tr.rowIndex;
	var trs = tr.parentNode.rows;
	var index = td.cellIndex;
	while (--n > 0) {
		tr = trs[++itr];
		var otd = editor._doc.createElement("td");
		otd.colSpan = td.colSpan;
		otd.innerHTML = mozbr;
		tr.insertBefore(otd, tr.cells[index]);
	}
};
FTB_FreeTextBox.prototype.SplitCol = function(td) {
	var nc = parseInt("" + td.colSpan);
	td.colSpan = 1;
	tr = td.parentNode;
	var ref = td.nextSibling;
	while (--nc > 0) {
		var otd = editor._doc.createElement("td");
		otd.rowSpan = td.rowSpan;
		otd.innerHTML = mozbr;
		tr.insertBefore(otd, ref);
	}
}

FTB_FreeTextBox.prototype.SplitCell = function(td) {
	var nc = parseInt("" + td.colSpan);
	splitCol(td);
	var items = td.parentNode.cells;
	var index = td.cellIndex;
	while (nc-- > 0) {
		this.SplitRow(items[index++]);
	}
};
/* FORM Functions
-------------------------------------- */
FTB_FreeTextBox.prototype.IsInForm = function() {
	return (this.GetNearest("form")) ? true : false ;
};
FTB_FreeTextBox.prototype.InsertForm = function() {
	var form = window.document.createElement("form");
	this.InsertElement(form);
};
FTB_FreeTextBox.prototype.InsertCheckBox = function() {
	this.InsertInputElement("","checkbox");
};
FTB_FreeTextBox.prototype.InsertTextBox = function() {
	this.InsertInputElement("","text");
};
FTB_FreeTextBox.prototype.InsertRadioButton = function() {
	this.InsertInputElement("","radio");
};
FTB_FreeTextBox.prototype.InsertButton = function() {
	this.InsertInputElement("","button");
};
FTB_FreeTextBox.prototype.InsertDropDownList = function() {
	var select = window.document.createElement("select");
	this.InsertElement(select);
};
FTB_FreeTextBox.prototype.InsertTextArea = function() {
	var textarea = window.document.createElement("textarea");
	this.InsertElement(textarea);
};
FTB_FreeTextBox.prototype.InsertInputElement = function(id,type) {
	var input = window.document.createElement("input");
	input.id = id;

	input.type = type;
	this.InsertElement(input);
}
/* Color picker Functions
-------------------------------------- */
FTB_FreeTextBox.prototype.FontForeColorPicker = function() {
	this.LaunchColorPickerWindow('forecolor');
};
FTB_FreeTextBox.prototype.FontBackColorPicker = function() {
	this.LaunchColorPickerWindow('backcolor');
};
FTB_FreeTextBox.prototype.LaunchColorPickerWindow = function(commandName, startValue) {

	var pickerWin = window.open("","colorPickerWin","width=290,height=180");
	if (pickerWin) {
		pickerWin.focus();
	} else {
		alert("Please turn off your PopUp blocking software");
		return;
	}
	
	pickerWin.document.body.innerHTML = '';
	pickerWin.document.open();
	pickerWin.document.write(FTB_ColorPickerHtml);
	pickerWin.document.close();

	launchParameters = new Object();
	launchParameters['ftb'] = this;
	launchParameters['commandName'] = commandName;
	pickerWin.launchParameters = launchParameters;
	pickerWin.load();
};
FTB_FreeTextBox.prototype.InsertImage = function() {
	var imageWin = window.open("","imageWin","width=500,height=310");
	if (imageWin) {
		imageWin.focus();
	} else {
		alert("Please turn off your PopUp blocking software");
		return;
	}


	//imageWin.document.body.innerHTML = '';
	imageWin.document.open();
	imageWin.document.write(FTB_ImagePopUpHtml);
	imageWin.document.close();
	
	launchParameters = new Object();
	launchParameters['ftb'] = this;
	imageWin.launchParameters = launchParameters;
	imageWin.load();
};
/* Misc Pro features
--------------------------------------- */
FTB_FreeTextBox.prototype.WordClean = function() {

	var text = this.designEditor.document.body.innerHTML;
	
	text=text.replace(/<FONT[^>]*>/gi,"");
	text=text.replace(/<\/FONT>/gi,"");
	text=text.replace(/<U>/gi,"");
	text=text.replace(/<\/U>/gi,"");
	text=text.replace(/<H[^>]*>/gi,"");
	text=text.replace(/<\/H[^>]*>/gi,"");
	
	// Change these tags.
	text=text.replace(/<B[^>]*>/gi,"&bold");
	text=text.replace(/<\/B[^>]*>/gi,"&cbold");
	text=text.replace(/<STRONG[^>]*>/gi,"&bold");
	text=text.replace(/<\/STRONG[^>]*>/gi,"&cbold");

	text=text.replace(/<I[^>]*>/gi,"&ital");
	text=text.replace(/<\/I[^>]*>/gi,"&cital");
	text=text.replace(/<EM[^>]*>/gi,"&ital");
	text=text.replace(/<\/EM[^>]*>/gi,"&cital");
	
	text=text.replace(/<UL[^>]*>/gi,"&ultag");
	text=text.replace(/<LI[^>]*>/gi,"&litag");
	text=text.replace(/<OL[^>]*>/gi,"&oltag");
	text=text.replace(/<\/OL>/gi,"&olctag");
	text=text.replace(/<\/LI>/gi,"&lictag");
	text=text.replace(/<\/UL>/gi,"&ulctag");

	text=text.replace(/<P[^>]*>/gi,"&parag");
	text=text.replace(/<\/P>/gi,"");
	
	/*
	text=text.replace(/”/gi,'\"');
	text=text.replace(/“/gi,'\"');
	text=text.replace(/„/gi,'\"');
	text=text.replace(/mailto:/gi,'\"');
	text=text.replace(/Ä/g,"&Auml;");
	text=text.replace(/Ö/g,"&Ouml;");
	text=text.replace(/Ü/g,"&Uuml;");
	text=text.replace(/ä/g,"&auml;");
	text=text.replace(/ö/g,"&ouml;");
	text=text.replace(/ü/g,"&uuml;");
	text=text.replace(/ß/gi,"&szlig;");	
	*/
	
	text=text.replace(/&lt;[^>]&gt*;/gi,"");
	text=text.replace(/&lt;\/[^>]&gt*;/gi," ");
	text=text.replace(/<o:[^>]*>/gi,"");
	text=text.replace(/<\/o:[^>]*>/gi,"");
	text=text.replace(/<\?xml:[^>]*>/gi,"");
	text=text.replace(/<\/?st[^>]*>/gi,"");
	text=text.replace(/<[^>]*</gi,"<");
	text=text.replace(/<SPAN[^>]*>/gi,"");
	text=text.replace(/<SPAN[^class]*>/gi,"");
	text=text.replace(/<\/SPAN>/gi,"");
	//text=text.replace(/<\/A>/gi,"");
	
	// Clear the inner parts of other tags.
	text=text.replace(/style=[^>]*"/g,' ');
	text=text.replace(/style=[^>]*'/g," ");
	text=text.replace(/style=[^>]*>/g,">");
	text=text.replace(/lang=[^>]*>/g,">");
	text=text.replace(/name=[^>]* /g,"");
	text=text.replace(/name=[^>]*>/g,">");
	text=text.replace(/<A[^>]*>/g,"");
	
	//text=text.replace(/<p[^>]*>/gi,"<p>");

	
	// Put the tags back
	text=text.replace(/&bold/g,"<B>");
	text=text.replace(/&cbold/g,"</B>");

	text=text.replace(/&ital/g,"<EM>");
	text=text.replace(/&cital/g,"</EM>");

	text=text.replace(/&ultag/g,"<UL>");
	text=text.replace(/&litag/g,"<LI>");
	text=text.replace(/&oltag/g,"<OL>");
	text=text.replace(/&olctag/g,"<\/OL>");	
	text=text.replace(/&lictag/g,"<\/LI>");
	text=text.replace(/&ulctag/g,"<\/UL>");

	text=text.replace(/&parag/g,"<BR>");
	
	this.designEditor.document.body.innerHTML = text;
};
FTB_FreeTextBox.prototype.CreateLink = function() {
	// impliment pro feature of PopUp window
	
	var linkWin = window.open("","linkWin","width=350,height=155");
	if (linkWin) {
		linkWin.focus();
	} else {
		alert("Please turn off your PopUp blocking software");
		return;
	}
	
	linkWin.document.body.innerHTML = '';
	linkWin.document.open();	
	linkWin.document.write(FTB_LinkPopUpHtml);
	linkWin.document.close();	
	
	launchParameters = new Object();
	launchParameters['ftb'] = this;
	linkWin.launchParameters = launchParameters;
	linkWin.load();
};

/* PopUpScripts 
---------------------------------------- */


var FTB_ImagePopUpHtml = new String("\
<html><body> \
<head>\
<title>Image Editor</title>\
<style type='text/css'>\
html, body { \
	background-color: #ECE9D8; \
	color: #000000; \
	font: 11px Tahoma,Verdana,sans-serif; \
	padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\</style>\
<script type='text/javascript'>\
function updateImage() {\
	ftb = window.launchParameters['ftb'];\
	img = ftb.GetNearest('img');\
	src = document.getElementById('image_src');\
	if (src.value == '') {\
		alert('You must enter an image url');\
		return false;\
	}\
	if (!img) {\
		ftb.ExecuteCommand('insertimage',null,src.value);\
		img = ftb.GetNearest('a');\
	}\
	updateImageProperties(img);\
}\
function updateImageProperties(img) {\
	if (img) {\
		src = document.getElementById('image_src');\
		alt = document.getElementById('image_alt');\
		align = document.getElementById('image_align');\
		border = document.getElementById('image_border');\
		hspace = document.getElementById('image_hspace');\
		vspace = document.getElementById('image_vspace');\
		width = document.getElementById('image_width');\
		height = document.getElementById('image_height');\
		img.src = src.value;\
		img.alt = alt.value;\
		img.align = align.value;\
		img.border = border.value;\
		img.hspace = hspace.value;\
		img.vspace = vspace.value;\
		img.width = width.value;\
		img.height = height.value;\
	}\
}\
function updatePreview() {\
	src = document.getElementById('image_src');\
	alt = document.getElementById('image_alt');\
	align = document.getElementById('image_align');\
	border = document.getElementById('image_border');\
	hspace = document.getElementById('image_hspace');\
	vspace = document.getElementById('image_vspace');\
	preview = document.getElementById('preview');\
	width = document.getElementById('image_width');\
	height = document.getElementById('image_height');\
	\
	if (width.value == ''|| height.value == '') preview.src = new Image();\
	preview.src = src.value;\
	preview.alt = alt.value;\
	preview.align = align.value;\
	preview.border = border.value;\
	preview.hspace = hspace.value;\
	preview.vspace = vspace.value;\
	if (width.value != '') preview.width = width.value;\
	if (height.value != '') preview.height = height.value;\
}\
</script>\
</head>\
<body>\
<form action=''> \
<h3>Image Editor</h3> \
<table><tr><td>\
	<table>\
	<tr><td class='f_title'>Image Source:</td>\
	<td><input type='text' id='image_src' style='width:200px;' onblur='updatePreview();' /></td></tr>\
	<tr><td class='f_title'>Alternate Text:</td>\
	<td><input type='text' id='image_alt' style='width:200px;' onblur='updatePreview();' /></td></tr>\
	</table>\
</td><td rowspan='3' valign='top'>\
	<fieldset><legend>Preview</legend>\
	<div style='width:180px;height:180px;overflow:scroll;background-color:#fff;'>\
		<p><img id='preview' />Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum accumsan, ipsum ut dapibus dapibus, nunc arcu congue velit, sit amet pretium est felis ut libero. Suspendisse hendrerit vestibulum pede.</p>\
	</div>\
	</fieldset>\
</td></tr><tr><td>\
	<fieldset><legend>Layout</legend><table>\
	<tr><td class='f_title'>Alignment:</td>\
	<td><select id='image_align' style='width:70px;' onchange='updatePreview();'>\
	<option value='' selected='1'>Not set</option> \
	<option value='left'         >Left</option> \
	<option value='center'       >Center</option> \
	<option value='right'        >Right</option> \
	<option value='texttop'      >TextTop</option> \
	<option value='AbsMiddle'    >AbsMiddle</option> \
	<option value='Baseline'     >Baseline</option> \
	<option value='AbsBottom'    >AbsBottom</option> \
	<option value='Middle'       >Middle</option> \
	<option value='Top'          >Top</option> \
	</select> \
	</td></tr>\
	<tr><td class='f_title'>Border Thickness:</td>\
	<td><input type='text' id='image_border' style='width:70px;' onblur='updatePreview();' /></td></tr>\
	</table>\
	</fieldset>\
</td></tr><tr><td>\
	<table cellspacing='0' cellpadding='0'><tr><td style='padding-right:5px;'>\
		<fieldset><legend>Spacing</legend><table>\
		<tr><td class='f_title'>Horizontal:</td>\
		<td><input type='text' id='image_hspace' style='width:30px;' onblur='updatePreview();' /></td></tr>\
		<tr><td class='f_title'>Vertical:</td>\
		<td><input type='text' id='image_vspace' style='width:30px;' onblur='updatePreview();' /></td></tr>\
		</table>\
		</fieldset>\
	</td><td>\
		<fieldset><legend>Dimensions</legend><table>\
		<tr><td class='f_title'>Width:</td>\
		<td><input type='text' id='image_width' style='width:40px;' onblur='updatePreview();' /></td></tr>\
		<tr><td class='f_title'>Height:</td>\
		<td><input type='text' id='image_height' style='width:40px;' onblur='updatePreview();' /></td></tr>\
		</table>\
		</fieldset>\
	</td></tr></table>\
</td></tr></table>\
<div class='footer'>\
<button type='button' name='updateImageButton' id='updateImageButton' onclick='updateImage();window.close();'>OK</button>\
<button type='button' name='cancel' id='cancelButton' onclick='window.close();'>Cancel</button>\
</div>\
<script type='text/javascript'>\
function load() {\
	ftb = window.launchParameters['ftb'];\
	img = ftb.GetNearest('img');\
	src = document.getElementById('image_src');\
	alt = document.getElementById('image_alt');\
	align = document.getElementById('image_align');\
	border = document.getElementById('image_border');\
	hspace = document.getElementById('image_hspace');\
	vspace = document.getElementById('image_vspace');\
	width = document.getElementById('image_width');\
	height = document.getElementById('image_height');\
	if (img) {\
		src.value = img.src;\
		alt.value = img.alt;\
		window.opener.FTB_SetListValue(align,img.align,true);\
		border.value = img.border;\
		hspace.value = img.hspace;\
		vspace.value = img.vspace;\
		width.value = img.width;\
		height.value = img.height;\
		updatePreview();\
	}\
}\
</script>\
</form> \
</body> \
</html>");

var FTB_LinkPopUpHtml = new String("\
<html><body> \
<head>\
<title>Link Editor</title>\
<style type='text/css'>\
html, body { \
	background-color: #ECE9D8; \
	color: #000000; \
	font: 11px Tahoma,Verdana,sans-serif; \
	padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\
</style>\
<script type='text/javascript'>\
function insertLink() {\
	ftb = window.launchParameters['ftb'];\
	link = ftb.GetNearest('a');\
	href = document.getElementById('link_href');\
	if (href.value == '') {\
		alert('You must enter a link');\
		return false;\
	}\
	if (!link) {\
		ftb.ExecuteCommand('createlink',null,href.value);\
		link = ftb.GetNearest('a');\
	}\
	updateLink(link);\
}\
function updateLink(link) {\
	if (link) {\
		href = document.getElementById('link_href');\
		title = document.getElementById('link_title');\
		target = document.getElementById('link_target');\
		cssClass = document.getElementById('link_cssClass');\
		targetVal = target.options[target.selectedIndex].value;\
		customtarget = document.getElementById('link_customtarget');\
		link.href = href.value;\
		link.title = title.value;\
		link.className = cssClass.value;\
		if (targetVal == '_custom') link.target = customtarget.value; else link.target = targetVal;\
	}\
}\
function link_target_changed() {\
	list = document.getElementById('link_target');\
	customtarget = document.getElementById('link_customtarget');\
	if (list.options[list.options.selectedIndex].value == '_custom')\
		customtarget.style.display = '';\
	else\
		customtarget.style.display = 'none';\
}\
</script>\
</head>\
<body>\
<form action=''> \
<h3>Link Editor</h3> \
<fieldset><legend>Link Properties</legend><table>\
<tr><td class='f_title'>URL</td>\
<td><input type='text' id='link_href' style='width:250px;' /></td></tr>\
<tr><td class='f_title'>Title</td>\
<td><input type='text' id='link_title' style='width:250px;' /></td></tr>\
<tr><td class='f_title'>Target</td>\
<td><select id='link_target' style='width:150px;' onchange='link_target_changed();'>\
<option value=''>None</option>\
<option value='_blank'>New Window (_blank)</option>\
<option value='_top'>Top Frame (_top)</option>\
<option value='_parent'>Parent Frame (_parent)</option>\
<option value='_self'>Same Frame (_self)</option>\
<option value='_custom'>Custom Target</option>\
</select>&nbsp;\
<input type='text' id='link_customtarget' style='width:95px;display:none;' /> \
</td></tr>\
<tr style='display:none;'><td class='f_title'>Class</td>\
<td><input type='text' id='link_cssClass' style='width:250px;' /></td></tr>\
</table>\
</fieldset>\
<div class='footer'>\
<button type='button' name='insertLinkButton' id='insertLinkButton' onclick='insertLink();window.close();'>OK</button>\
<button type='button' name='cancel' id='cancelButton' onclick='window.close();'>Cancel</button>\
</div>\
<script type='text/javascript'>\
function load() {\
	ftb = window.launchParameters['ftb'];\
	link = ftb.GetNearest('a');\
	href = document.getElementById('link_href');\
	title = document.getElementById('link_title');\
	target = document.getElementById('link_target');\
	customtarget = document.getElementById('link_customtarget');\
	cssClass = document.getElementById('link_cssClass');\
	if (link) {\
		href.value = link.href;\
		title.value = link.title;\
		cssClass.value = link.className;\
		if (link.target == '' || link.target == '_blank' || link.target == '_top' || link.target == '_self' || link.target == '_parent')\
			window.opener.FTB_SetListValue(target,link.target,true);\
		else\
			window.opener.FTB_SetListValue(target,'_custom',false);\
		\
		if (target.options[target.options.selectedIndex].value == '_custom') {\
			customtarget.style.display='';\
			customtarget.value = link.target;\
		}\
	}\
}\
</script>\
</form> \
</body> \
</html>");


/* ColorPicker
---------------------------------------- */
var FTB_ColorPickerHtml = new String("\
<html><body> \
<head>\
<title>Image Editor</title>\
<style type='text/css'>\
html, body { \
	background-color: #ECE9D8; \
	color: #000000; \
	font: 11px Tahoma,Verdana,sans-serif; \
	padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
  font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
  margin-top: 5px; \
  margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\
</style>\
<script type='text/javascript'>\
function cO(theTD) { \
	color = theTD.style.backgroundColor; \
	if (color.toString().toLowerCase().indexOf('rgb') > -1) color = window.opener.FTB_RgbStringToHex(color); \
	previewColor(color); \
	setTextField(color); \
} \
function cC(theTD) { \
	color = theTD.style.backgroundColor; \
	if (color.toString().toLowerCase().indexOf('rgb') > -1) color = window.opener.FTB_RgbStringToHex(color); \
	setTextField(color); \
	returnColor(color); \
} \
function setTextField(ColorString) { \
	document.getElementById('ColorText').value = ColorString.toUpperCase(); \
} \
function returnColor(ColorString) { \
	ftb = window.launchParameters['ftb'];\
	if (ftb) {\
		command = new String(window.launchParameters['commandName']);\
		ftb.ExecuteCommand(command,'',ColorString);\
	} else {\
	}\
	\
	window.close();	 \
} \
function userInput(theinput) {	 \
	previewColor(theinput.value); \
} \
function previewColor(theColor) { \
	try { \
		document.getElementById('PreviewDiv').style.backgroundColor = theColor; \
	} catch (e) {} \
}\
function okButton() { \
	theColor = document.getElementById('ColorText').value; \
	returnColor(theColor);\
}\
</script>\
</head>\
<body>\
<form action=''> \
<h3>Image Editor</h3> \
	<style> \
	.cc { width:10;height:8; } \
	</style> \
	<table><tr><td>\
		<table cellpadding=0 cellspacing=1 style='background-color:ffffff;' border=0 ><tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFFFFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFFFCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFFF99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFFF66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFFF33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFFF00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFCCFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFCCCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFCC99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFCC66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFCC33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FFCC00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF99FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF99CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF9999;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF9966;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF9933;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF9900;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCFFFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCFFCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCFF99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCFF66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCFF33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCFF00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCCCFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCCCCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCCC99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCCC66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCCC33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CCCC00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC99FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC99CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC9999;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC9966;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC9933;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC9900;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99FFFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99FFCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99FF99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99FF66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99FF33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99FF00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99CCFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99CCCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99CC99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99CC66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99CC33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:99CC00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:9999FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:9999CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:999999;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:999966;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:999933;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:999900;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66FFFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66FFCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66FF99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66FF66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66FF33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66FF00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66CCFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66CCCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66CC99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66CC66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66CC33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:66CC00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:6699FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:6699CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:669999;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:669966;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:669933;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:669900;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33FFFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33FFCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33FF99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33FF66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33FF33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33FF00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33CCFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33CCCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33CC99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33CC66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33CC33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:33CC00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:3399FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:3399CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:339999;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:339966;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:339933;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:339900;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00FFFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00FFCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00FF99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00FF66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00FF33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00FF00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00CCFF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00CCCC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00CC99;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00CC66;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00CC33;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:00CC00;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:0099FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:0099CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:009999;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:009966;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:009933;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:009900;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF66FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF66CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF6699;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF6666;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF6633;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF6600;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF33FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF33CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF3399;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF3366;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF3333;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF3300;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF00FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF00CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF0099;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF0066;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF0033;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:FF0000;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC66FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC66CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC6699;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC6666;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC6633;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC6600;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC33FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC33CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC3399;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC3366;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC3333;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC3300;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC00FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC00CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC0099;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC0066;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC0033;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:CC0000;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:9966FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:9966CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:996699;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:996666;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:996633;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:996600;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:9933FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:9933CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:993399;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:993366;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:993333;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:993300;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:9900FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:9900CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:990099;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:990066;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:990033;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:990000;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:6666FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:6666CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:666699;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:666666;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:666633;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:666600;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:6633FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:6633CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:663399;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:663366;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:663333;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:663300;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:6600FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:6600CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:660099;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:660066;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:660033;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:660000;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:3366FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:3366CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:336699;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:336666;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:336633;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:336600;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:3333FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:3333CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:333399;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:333366;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:333333;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:333300;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:3300FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:3300CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:330099;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:330066;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:330033;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:330000;' class=cc></td> \
	</tr> \
	<tr> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:0066FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:0066CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:006699;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:006666;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:006633;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:006600;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:0033FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:0033CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:003399;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:003366;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:003333;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:003300;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:0000FF;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:0000CC;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:000099;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:000066;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:000033;' class=cc></td> \
		<td onmouseover='cO(this);' onclick='cC(this);' style='background-color:000000;' class=cc></td> \
	</tr> \
	</table> \
	</td><td valign='top'>\
		<div id='PreviewDiv' style='width:60px;height:40px;border: 1px solid black; background-color: START_VALUE;'>&nbsp;</div><br /> \
		<input type='text' name='ColorText' id='ColorText' style='width:60px;' onkeyup='userInput(this);' value=''> \
	</td></tr></table>\
	<div class='footer'>\
	<input type='button' id='ColorButton' value='OK' onclick='okButton();window.close();' />\
	<input type='button' id='CancelButton' value='Cancel' onclick='window.close();' >\
</div>\
</form>\
<script type='text/javascript'>\
function load() {\
	ftb = window.launchParameters['ftb'];\
	color = ftb.QueryCommandValue(window.launchParameters['commandName']);\
	if (color.toString().toLowerCase().indexOf('rgb') > -1) color = window.opener.FTB_RgbStringToHex(color); \
	previewColor(color); \
	setTextField(color); \
}\
</script>\
</body>\
</html>");


var FTB_StyleEditorHtml = "<html>\
<head>\
<style type='text/css'>\
h1 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;}\
h2 { margin: 0; margin-top: 4px;  margin-bottom: 5px; font-size: 12px; border-bottom: 1px solid #90A8F0; color: #90A8F0;}\
#s_container { height: 240px;  clear: both;}\
#s_sampleContainer { background-color: #fff;}\
.tabMenu { list-style:none; margin:0px; padding:0px; }\
.tabMenu li {  margin:0px; padding:0px; }\
a:link, a:visited, a:active, a:hover { text-decoration:none; }\
a.selectedTab { color: #000; display: block; width:80px; border: 1px solid #aaa; border-top: 1px solid #fff; border-left: 1px solid #fff; padding: 4px; margin:0px; background-color: #Edf0D9;}\
a.unselectedTab { color: #000; display: block; width:80px; border: 0; padding: 5px; margin:0px; background-color: #ECE9D8;}\
html, body {  background-color: #ECE9D8;  color: #000000; font: 11px Tahoma,Verdana,sans-serif; padding: 0px; }\
body { margin: 5px; }\
form { margin: 0px; padding: 0px;}\
table { font: 11px Tahoma,Verdana,sans-serif; }\
fieldset { padding: 0px 10px 5px 5px; }\
button { width: 75px; }\
select, input, button { font: 11px Tahoma,Verdana,sans-serif; }\
.f_title { text-align:right; width: 70px;}\
</style>\
<script type='text/javascript'>\
function FTB_StyleEditor(id) {\
	this.id = id;\
};\
FTB_StyleEditor.prototype.UpdateStylePreview = function() {\
	this.ChangeElementStyle(this.previewDiv);\
};\
FTB_StyleEditor.prototype.ReturnStyle = function() {\
	el = window.launchParameters['element'];\
	this.ChangeElementStyle(el);\
	ftb = window.launchParameters['ftb'];\
};\
FTB_StyleEditor.prototype.Initialize = function() {\
	styleEditor = this;\
	\
	this.ftb = window.launchParameters['ftb'];\
	\
	this.previewDiv = document.getElementById('s_sample');\
	\
	this.fontLayer = document.getElementById('s_layer_font');\
	this.textLayer = document.getElementById('s_layer_text');\
	this.backgroundLayer = document.getElementById('s_layer_background');\
	this.spacingLayer = document.getElementById('s_layer_spacing');\
	this.bordersLayer = document.getElementById('s_layer_borders');\
	\
	this.fontTab = document.getElementById('s_tab_font');\
	this.fontTab.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.fontTab,'click',function() {this.styleEditor.ShowLayer(this.styleEditor.fontTab,this.styleEditor.fontLayer); });\
	this.textTab = document.getElementById('s_tab_text');\
	this.textTab.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.textTab,'click',function() {this.styleEditor.ShowLayer(this.styleEditor.textTab,this.styleEditor.textLayer); });\
	this.backgroundTab = document.getElementById('s_tab_background');\
	this.backgroundTab.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.backgroundTab,'click',function() {this.styleEditor.ShowLayer(this.styleEditor.backgroundTab,this.styleEditor.backgroundLayer); });\
	this.spacingTab = document.getElementById('s_tab_spacing');\
	this.spacingTab.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.spacingTab,'click',function() {this.styleEditor.ShowLayer(this.styleEditor.spacingTab,this.styleEditor.spacingLayer); });\
	this.bordersTab = document.getElementById('s_tab_borders');\
	this.bordersTab.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.bordersTab,'click',function() {this.styleEditor.ShowLayer(this.styleEditor.bordersTab,this.styleEditor.bordersLayer); });\
\
	\
	this.fontFamily = document.getElementById('s_fontFamily');\
	this.fontFamily.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.fontFamily,'keyup',function() {this.styleEditor.UpdateStylePreview(); } );\
	this.color = document.getElementById('s_color');\
	this.color.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.color,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.size = document.getElementById('s_fontSize');\
	this.size.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.size,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.sizeUnit = document.getElementById('s_fontSizeUnit');\
	this.sizeUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.sizeUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
\
	\
	this.bold = document.getElementById('s_bold');\
	this.bold.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.bold,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	this.italic = document.getElementById('s_italic');\
	this.italic.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.italic,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	this.smallcaps = document.getElementById('s_smallcaps');\
	this.smallcaps.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.smallcaps,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	this.strikethrough = document.getElementById('s_strikethrough');\
	this.strikethrough.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.strikethrough,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	this.underline = document.getElementById('s_underline');\
	this.underline.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.underline,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	this.overline = document.getElementById('s_overline');\
	this.overline.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.overline,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	this.capitalization = document.getElementById('s_capitalization');\
	this.capitalization.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.capitalization,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	\
	this.halign = document.getElementById('s_halign');\
	this.halign.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.halign,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.valign = document.getElementById('s_valign');\
	this.valign.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.valign,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.textIndent = document.getElementById('s_textIndent');\
	this.textIndent.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.textIndent,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.textIndentUnit = document.getElementById('s_textIndentUnit');\
	this.textIndentUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.textIndentUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.direction = document.getElementById('s_direction');\
	this.direction.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.direction,'change',function() {this.styleEditor.UpdateStylePreview(); });\
\
	\
	this.backcolor = document.getElementById('s_backcolor');\
	this.backcolor.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.backcolor,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	\
	this.letterSpacing = document.getElementById('s_letterSpacing');\
	this.letterSpacing.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.letterSpacing,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.letterSpacingUnit = document.getElementById('s_letterSpacingUnit');\
	this.letterSpacingUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.letterSpacingUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.lineHeight = document.getElementById('s_lineHeight');\
	this.lineHeight.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.lineHeight,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.lineHeightUnit = document.getElementById('s_lineHeightUnit');\
	this.lineHeightUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.lineHeightUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	\
	this.marginLeft = document.getElementById('s_marginLeft');\
	this.marginLeft.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.marginLeft,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.marginLeftUnit = document.getElementById('s_marginLeft_unit');\
	this.marginLeftUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.marginLeftUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.marginRight = document.getElementById('s_marginRight');\
	this.marginRight.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.marginRight,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.marginRightUnit = document.getElementById('s_marginRight_unit');\
	this.marginRightUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.marginRightUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.marginTop = document.getElementById('s_marginTop');\
	this.boldmarginTopstyleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.marginTop,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.marginTopUnit = document.getElementById('s_marginTop_unit');\
	this.marginTopUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.marginTopUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.marginBottom = document.getElementById('s_marginBottom');\
	this.marginBottom.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.marginBottom,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.marginBottomUnit = document.getElementById('s_marginBottom_unit');\
	this.marginBottomUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.marginBottomUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	\
	this.paddingLeft = document.getElementById('s_paddingLeft');\
	this.paddingLeft.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.paddingLeft,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.paddingLeftUnit = document.getElementById('s_paddingLeft_unit');\
	this.paddingLeftUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.paddingLeftUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.paddingRight = document.getElementById('s_paddingRight');\
	this.paddingRight.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.paddingRight,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.paddingRightUnit = document.getElementById('s_paddingRight_unit');\
	this.paddingRightUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.paddingRightUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.paddingTop = document.getElementById('s_paddingTop');\
	this.paddingTop.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.paddingTop,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.paddingTopUnit = document.getElementById('s_paddingTop_unit');\
	this.paddingTopUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.paddingTopUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.paddingBottom = document.getElementById('s_paddingBottom');\
	this.paddingBottom.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.paddingBottom,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.paddingBottomUnit = document.getElementById('s_paddingBottom_unit');\
	this.paddingBottomUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.paddingBottomUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	\
	this.borderFullWidth = document.getElementById('s_borderFull_width');\
	this.borderFullWidth.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderFullWidth,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderFullWidthUnit = document.getElementById('s_borderFull_unit');\
	this.borderFullWidthUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderFullWidthUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderFullStyle = document.getElementById('s_borderFull_style');\
	this.borderFullStyle.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderFullStyle,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderFullColor = document.getElementById('s_borderFull_color');\
	this.borderFullColor.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderFullColor,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderLeftWidth = document.getElementById('s_borderLeft_width');\
	this.borderLeftWidth.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderLeftWidth,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderLeftWidthUnit = document.getElementById('s_borderLeft_unit');\
	this.borderLeftWidthUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderLeftWidthUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderLeftStyle = document.getElementById('s_borderLeft_style');\
	this.borderLeftStyle.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderLeftStyle,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderLeftColor = document.getElementById('s_borderLeft_color');\
	this.borderLeftColor.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderLeftColor,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderRightWidth = document.getElementById('s_borderRight_width');\
	this.borderRightWidth.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderRightWidth,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderRightWidthUnit = document.getElementById('s_borderRight_unit');\
	this.borderRightWidthUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderRightWidthUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderRightStyle = document.getElementById('s_borderRight_style');\
	this.borderRightStyle.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderRightStyle,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderRightColor = document.getElementById('s_borderRight_color');\
	this.borderRightColor.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderRightColor,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderTopWidth = document.getElementById('s_borderTop_width');\
	this.borderTopWidth.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderTopWidth,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderTopWidthUnit = document.getElementById('s_borderTop_unit');\
	this.borderTopWidthUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderTopWidthUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderTopStyle = document.getElementById('s_borderTop_style');\
	this.borderTopStyle.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderTopStyle,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderTopColor = document.getElementById('s_borderTop_color');\
	this.borderTopColor.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderTopColor,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderBottomWidth = document.getElementById('s_borderBottom_width');\
	this.borderBottomWidth.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderBottomWidth,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderBottomWidthUnit = document.getElementById('s_borderBottom_unit');\
	this.borderBottomWidthUnit.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderBottomWidthUnit,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderBottomStyle = document.getElementById('s_borderBottom_style');\
	this.borderBottomStyle.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderBottomStyle,'change',function() {this.styleEditor.UpdateStylePreview(); });\
	this.borderBottomColor = document.getElementById('s_borderBottom_color');\
	this.borderBottomColor.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.borderBottomColor,'keyup',function() {this.styleEditor.UpdateStylePreview(); });\
	this.allBorders = document.getElementById('s_borders_type_all');\
	this.allBorders = document.getElementById('s_borderBottom_style');\
	window.opener.FTB_AddEvent(this.allBorders,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	this.individualBorders = document.getElementById('s_borders_type_individual');\
	this.individualBorders = document.getElementById('s_borderBottom_style');\
	window.opener.FTB_AddEvent(this.individualBorders,'click',function() {this.styleEditor.UpdateStylePreview(); });\
	this.updateButton = document.getElementById('s_updateButton');\
	this.updateButton.styleEditor = styleEditor;\
	window.opener.FTB_AddEvent(this.updateButton,'click',function() {this.styleEditor.ReturnStyle();window.close(); });\
};\
FTB_StyleEditor.prototype.ChangeElementStyle = function(el) {\
\
	\
	try { el.style.fontFamily = this.fontFamily.value; } catch (e) {}\
	try { el.style.color = this.color.value; } catch (e) {}\
	if (this.size.value != '') try { el.style.fontSize = this.size.value + this.sizeUnit.options[this.sizeUnit.selectedIndex].value; } catch(e) {} else el.style.fontSize = '';\
	\
	el.style.fontWeight = (this.bold.checked) ? 'bold' : '' ;\
	el.style.fontStyle = (this.italic.checked) ? 'italic' : '' ;\
	el.style.fontVariant = (this.smallcaps.checked) ? 'small-caps' : '' ;\
	textDecoration = '';\
	textDecoration += (this.strikethrough.checked) ? 'line-through ' : '' ;\
	textDecoration += (this.underline.checked) ? 'underline ' : '' ;\
	textDecoration += (this.overline.checked) ? 'overline' : '' ;\
	el.style.textDecoration = textDecoration;\
	el.style.textTransform = this.capitalization.options[this.capitalization.selectedIndex].value;\
	\
	el.style.textAlign = this.halign.options[this.halign.selectedIndex].value;\
	el.style.verticalAlign = this.valign.options[this.valign.selectedIndex].value;\
	if (this.textIndent.value != '') try { el.style.textIndent = this.textIndent.value + this.textIndentUnit.options[this.textIndentUnit.selectedIndex].value; } catch(e) {} else el.style.textIdent = '';\
	el.style.direction = this.direction.options[this.direction.selectedIndex].value;\
	\
	try { el.style.backgroundColor = this.backcolor.value; } catch (e) {}\
	\
	if (this.letterSpacing.value != '') try { el.style.letterSpacing = this.letterSpacing.value + this.letterSpacingUnit.options[this.letterSpacingUnit.selectedIndex].value; } catch(e) {} else el.style.letterSpacing = '';\
	if (this.lineHeight.value != '') try { el.style.lineHeight = this.lineHeight.value + this.lineHeightUnit.options[this.lineHeightUnit.selectedIndex].value; } catch(e) {} else el.style.lineHeight = '';\
	\
	if (this.marginLeft.value != '') try { el.style.marginLeft = this.marginLeft.value + this.marginLeftUnit.options[this.marginLeftUnit.selectedIndex].value; } catch(e) {} else el.style.marginLeft = '';\
	if (this.marginRight.value != '') try { el.style.marginRight = this.marginRight.value + this.marginRightUnit.options[this.marginRightUnit.selectedIndex].value; } catch(e) {} else el.style.marginRight = '';\
	if (this.marginTop.value != '') try { el.style.marginTop = this.marginTop.value + this.marginTopUnit.options[this.marginTopUnit.selectedIndex].value; } catch(e) {} else el.style.marginTop = '';\
	if (this.marginBottom.value != '') try { el.style.marginBottom = this.marginBottom.value + this.marginBottomUnit.options[this.marginBottomUnit.selectedIndex].value; } catch(e) {} else el.style.marginBottom = '';\
	\
	if (this.paddingLeft.value != '') try { el.style.paddingLeft = this.paddingLeft.value + this.paddingLeftUnit.options[this.paddingLeftUnit.selectedIndex].value; } catch(e) {} else el.style.paddingLeft = '';\
	if (this.paddingRight.value != '') try { el.style.paddingRight = this.paddingRight.value + this.paddingRightUnit.options[this.paddingRightUnit.selectedIndex].value; } catch(e) {} else el.style.paddingRight = '';\
	if (this.paddingTop.value != '') try { el.style.paddingTop = this.paddingTop.value + this.paddingTopUnit.options[this.paddingTopUnit.selectedIndex].value; } catch(e) {} else el.style.paddingTop = '';\
	if (this.paddingBottom.value != '') try { el.style.paddingBottom = this.paddingBottom.value + this.paddingBottomUnit.options[this.paddingBottomUnit.selectedIndex].value; } catch(e) {} else el.style.paddingBottom = '';\
	\
	if (this.allBorders.checked) {\
		if (this.borderFullWidth.value != '' && this.borderFullColor.value != '') {\
			try {el.style.border = this.borderFullWidth.value + this.borderFullWidthUnit.options[this.borderFullWidthUnit.selectedIndex].value + ' ' + this.borderFullStyle.options[this.borderFullStyle.selectedIndex].value + ' ' + this.borderFullColor.value; } catch(e) {}\
		} else {\
			if (el.style.border != '') el.style.border = '';\
		}\
	} else {\
		if (this.borderLeftWidth.value != '' && this.borderLeftColor.value != '') {\
			try {el.style.borderLeft = this.borderLeftWidth.value + this.borderLeftWidthUnit.options[this.borderLeftWidthUnit.selectedIndex].value + ' ' + this.borderLeftStyle.options[this.borderLeftStyle.selectedIndex].value + ' ' + this.borderLeftColor.value; } catch(e) {}\
		} else {\
			if (el.style.borderLeft != '') el.style.borderLeft = '';\
		}\
		if (this.borderRightWidth.value != '' && this.borderRightColor.value != '') {\
			try {el.style.borderRight = this.borderRightWidth.value + this.borderRightWidthUnit.options[this.borderRightWidthUnit.selectedIndex].value + ' ' + this.borderRightStyle.options[this.borderRightStyle.selectedIndex].value + ' ' + this.borderRightColor.value; } catch(e) {}\
		} else {\
			if (el.style.borderRight != '') el.style.borderRight = '';\
		}\
		if (this.borderTopWidth.value != '' && this.borderTopColor.value != '') {\
			try {el.style.borderTop = this.borderTopWidth.value + this.borderTopWidthUnit.options[this.borderTopWidthUnit.selectedIndex].value + ' ' + this.borderTopStyle.options[this.borderTopStyle.selectedIndex].value + ' ' + this.borderTopColor.value; } catch(e) {}\
		} else {\
			if (el.style.borderTop != '') el.style.borderTop = '';\
		}\
		if (this.borderBottomWidth.value != '' && this.borderBottomColor.value != '') {\
			try {el.style.borderBottom = this.borderBottomWidth.value + this.borderBottomWidthUnit.options[this.borderBottomWidthUnit.selectedIndex].value + ' ' + this.borderBottomStyle.options[this.borderBottomStyle.selectedIndex].value + ' ' + this.borderBottomColor.value; } catch(e) {}\
		} else {\
			if (el.style.borderBottom != '') el.style.borderBottom = '';\
		}\
	}\
};\
FTB_StyleEditor.prototype.ReadElementStyle = function(el) {\
	\
	this.fontFamily.value = el.style.fontFamily;\
	this.color.value = el.style.color;\
	this.SetUnitStyle(el.style.fontSize, this.size, this.sizeUnit);\
	\
	this.bold.checked = (el.style.fontWeight.indexOf('bold') > -1) ? true : false;\
	this.italic.checked = (el.style.fontStyle.indexOf('italic') > -1) ? true : false;\
	this.smallcaps.checked = (el.style.fontVariant.indexOf('small-caps') > -1) ? true : false;\
	this.strikethrough.checked = (el.style.textDecoration.indexOf('line-through') > -1) ? true : false;\
	this.underline.checked = (el.style.textDecoration.indexOf('underline') > -1) ? true : false;\
	this.overline.checked = (el.style.textDecoration.indexOf('overline') > -1) ? true : false;\
	window.opener.FTB_SetListValue(this.capitalization,el.style.textTransform);\
	\
	window.opener.FTB_SetListValue(this.halign,el.style.textAlign);\
	window.opener.FTB_SetListValue(this.valign,el.style.verticalAlign);\
	this.SetUnitStyle(el.style.textIndent, this.textIndent, this.textIndentUnit);\
	window.opener.FTB_SetListValue(this.direction,el.style.direction);\
	\
	this.backcolor.value = el.style.backgroundColor;\
	\
	this.SetUnitStyle(el.style.letterSpacing, this.letterSpacing, this.letterSpacingUnit);\
	this.SetUnitStyle(el.style.lineHeight, this.lineHeight, this.lineHeightUnit);\
	\
	this.SetUnitStyle(el.style.paddingLeft, this.paddingLeft, this.paddingLeftUnit);\
	this.SetUnitStyle(el.style.paddingRight, this.paddingRight, this.paddingRightUnit);\
	this.SetUnitStyle(el.style.paddingTop, this.paddingTop, this.paddingTopUnit);\
	this.SetUnitStyle(el.style.paddingBottom, this.paddingBottom, this.paddingBottomUnit);\
	\
	this.SetUnitStyle(el.style.marginLeft, this.marginLeft, this.marginLeftUnit);\
	this.SetUnitStyle(el.style.marginRight, this.marginRight, this.marginRightUnit);\
	this.SetUnitStyle(el.style.marginTop, this.marginTop, this.marginTopUnit);\
	this.SetUnitStyle(el.style.marginBottom, this.marginBottom, this.marginBottomUnit);\
	\
	if (el.style.border != '') {\
		this.allBorders.checked = true;\
		this.individualBorders.checked = false;\
		this.SetBorderStyle(el.style.border, this.borderFullWidth, this.borderFullWidthUnit, this.borderFullStyle, this.borderFullColor);\
	} else {\
		this.allBorders.checked = false;\
		this.individualBorders.checked = true;\
		this.SetBorderStyle(el.style.borderLeft, this.borderLeftWidth, this.borderLeftWidthUnit, this.borderLeftStyle, this.borderLeftColor);\
		this.SetBorderStyle(el.style.borderRight, this.borderRightWidth, this.borderRightWidthUnit, this.borderRightStyle, this.borderRightColor);\
		this.SetBorderStyle(el.style.borderTop, this.borderTopWidth, this.borderTopWidthUnit, this.borderTopStyle, this.borderTopColor);\
		this.SetBorderStyle(el.style.borderBottom, this.borderBottomWidth, this.borderBottomWidthUnit, this.borderBottomStyle, this.borderBottomColor);\
	}\
\
};\
FTB_StyleEditor.prototype.SetUnitStyle = function(elStyleProperty,valueControl,unitControl) {\
	if (elStyleProperty != '') {\
		property = window.opener.FTB_ParseUnit(elStyleProperty);\
		valueControl.value = property.value;\
		window.opener.FTB_SetListValue(unitControl,property.unitType);\
	}\
};\
FTB_StyleEditor.prototype.SetBorderStyle = function(elBorderProperty,widthControl,widthUnitControl,styleControl,colorControl) {\
	if (elBorderProperty != '') {\
		var props = elBorderProperty.split(' ');\
		if (props.length == 3) {\
			this.SetUnitStyle(props[1], widthControl, widthUnitControl);\
			window.opener.FTB_SetListValue(styleControl,props[2]);\
			colorControl.value = props[0];\
		}\
	}\
};\
FTB_StyleEditor.prototype.SetBorder = function(elStyleProperty,valueControl,unitControl) {\
	if (elStyleProperty != '') {\
		property = window.opener.FTB_ParseUnit(elStyleProperty);\
		valueControl.value = property.value;\
		window.opener.FTB_SetListValue(unitControl,property.unitType);\
	}\
};\
FTB_StyleEditor.prototype.ReadCurrentElement = function() {\
	el = window.launchParameters['element'];\
	this.previewDiv.innerHTML = 'Sample text within the current &lt;' + el.tagName + '&gt; element';\
	this.ReadElementStyle(el);\
};\
FTB_StyleEditor.prototype.ShowLayer = function(tab,layer) {\
	\
	this.fontLayer.style.display = 'none';\
	this.textLayer.style.display = 'none';\
	this.backgroundLayer.style.display = 'none';\
	this.spacingLayer.style.display = 'none';\
	this.bordersLayer.style.display = 'none';\
	\
	this.fontTab.className = 'unselectedTab';\
	this.textTab.className = 'unselectedTab';\
	this.backgroundTab.className = 'unselectedTab';\
	this.spacingTab.className = 'unselectedTab';\
	this.bordersTab.className = 'unselectedTab';\
	tab.className = 'selectedTab';\
	layer.style.display = 'block';\
};\
</script>\
</head>\
<body >\
<h1>Style Editor</h1>\
<table width='500' cellpadding='0' cellspacing='0'><tr><td valign='top' width='80' style='border: solid 1px #aaa; border-right: solid 1px #fff; border-bottom: solid 1px #fff;'>\
<ul class='tabMenu'>\
	<li><a href='javascript:void(0);' id='s_tab_font' class='selectedTab'>Font</a></li>\
	<li><a href='javascript:void(0);' id='s_tab_text' class='unselectedTab'>Text</a></li>\
	<li><a href='javascript:void(0);' id='s_tab_background' class='unselectedTab'>Background</a></li>\
	<li><a href='javascript:void(0);' id='s_tab_spacing' class='unselectedTab'>Spacing</a></li>\
	<li><a href='javascript:void(0);' id='s_tab_borders' class='unselectedTab'>Borders</a></li>\
</ul>\
</td><td style='padding: 2px;'>\
<div id='s_container'>\
<div id='s_layer_font'>\
<h2>Font</h2>\
	<fieldset>\
	<legend>Properties</legend>\
		<table cellpadding='1' cellspacing='0' border='0'>\
			<tr><td class='f_title'>Family</td>\
				<td><input type='text' id='s_fontFamily' style='width: 100px;' /></td>\
			</tr>\
			<tr><td class='f_title'>Color</td>\
				<td><input type='text' id='s_color' style='width: 100px;' /></td>\
			</tr>\
			<tr><td class='f_title'>Size</td>\
				<td>\
					<input type='text' id='s_fontSize' style='width: 100px;' />\
					<select id='s_fontSizeUnit' >\
						<option value='px'>px</option>\
						<option value='pt'>pt</option>\
						<option value='%'>%</option>\
						<option value='em'>em</option>\
						<option value='in'>in</option>\
						<option value='mm'>mm</option>\
						<option value='cm'>cm</option>\
					</select>\
				</td>\
			</tr>\
			<tr><td class='f_title'>Capitalization</td>\
				<td>\
					<select id='s_capitalization' >\
						<option value=''>Not Set</option>\
						<option value='uppercase'>UPPERCASE</option>\
						<option value='lowercase'>lowercase</option>\
						<option value='capitalize'>First Letter</option>\
					</select>\
				</td>\
			</tr>\
		</table>\
	</fieldset>\
	<fieldset>\
		<legend>Effects</legend>\
			<table><tr><td>\
		<input type='checkbox' id='s_bold'  /><label for='s_bold'>Bold</label><br />\
		<input type='checkbox' id='s_italic' /><label for='s_italic'>Italic</label><br />\
		<input type='checkbox' id='s_smallcaps' /><label for='s_smallcaps'>Small Caps</label><br />\
		</td><td>\
		<input type='checkbox' id='s_strikethrough' /><label for='s_strikethrough'>Strikethrough</label><br />\
		<input type='checkbox' id='s_underline' /><label for='s_underline'>Underline</label><br />\
		<input type='checkbox' id='s_overline' /><label for='s_overline'>Overline</label><br />\
		</td></tr>\
		</table>\
	</fieldset>\
</div>\
<div id='s_layer_text' style='display:none;'>\
<h2>Text</h2>\
<fieldset>\
	<legend>Paragraph</legend>\
	<table cellpadding='1' cellspacing='0' border='0'	>\
		<tr><td class='f_title'>Horz. Align</td>\
			<td>\
				<select id='s_halign' style='width: 100px;' >\
					<option value=''>Not Set</option>\
					<option value='left'>Left</option>\
					<option value='right'>Right</option>\
					<option value='center'>Center</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Vert. Align</td>\
			<td>\
				<select id='s_valign'  style='width: 100px;'>\
					<option value=''>Not Set</option>\
					<option value='baseline'>baseline</option>\
					<option value='super'>super</option>\
					<option value='sub'>sub</option>\
					<option value='top'>top</option>\
					<option value='text-top'>text-top</option>\
					<option value='middle'>middle</option>\
					<option value='bottom'>bottom</option>\
					<option value='text-bottom'>text-bottom</option>\
				</select>\
			</td>\
		</tr>\
	</table>\
</fieldset>\
<fieldset>\
	<legend>Spacing Between</legend>\
	<table cellpadding='1' cellspacing='0' border='0'>\
		<tr><td class='f_title'>Letters</td>\
			<td>\
				<input type='text' id='s_letterSpacing' style='width: 50px;' />\
				<select id='s_letterSpacingUnit'>\
					<option value='pt'>pt</option>\
					<option value='pc'>pc</option>\
					<option value='px'>px</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Lines</td>\
			<td>\
				<input type='text' id='s_lineHeight' style='width: 50px;' />\
				<select id='s_lineHeightUnit'>\
					<option value='pt'>pt</option>\
					<option value='pc'>pc</option>\
					<option value='px'>px</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
	</table>\
</fieldset>\
\
<fieldset>\
	<legend>Text Flow</legend>\
	<table cellpadding='1' cellspacing='0' border='0'	>\
		<tr><td class='f_title'>Text Indent</td>\
			<td>\
				<input type='text' id='s_textIndent' style='width:80px;' />\
				<select id='s_textIndentUnit'>\
					<option value='pt'>pt</option>\
					<option value='pc'>pc</option>\
					<option value='px'>px</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Text Direction</td>\
			<td>\
				<select id='s_direction' style='width: 120px;'>\
					<option value=''>Not Set</option>\
					<option value='ltr'>Left to Right</option>\
					<option value='rtl'>Right to Left</option>\
				</select>\
			</td>\
		</tr>\
	</table>\
</fieldset>\
\
</div>\
<div id='s_layer_background' style='display:none;'>\
<h2>Background</h2>\
<fieldset>\
	<legend>Color</legend>\
	<table cellpadding='1' cellspacing='0' border='0'>\
		<tr><td class='f_title'>Color</td>\
			<td><input type='text' id='s_backcolor' style='width: 100px;' />\
				<input type='checkbox' id='s_backcolor_transparent' /><label for='s_backcolor_transparent'>Transparent</label>\
			</td>\
		</tr>\
	</table>\
</fieldset>\
</div>\
<div id='s_layer_spacing' style='display:none;'>\
<h2>Spacing</h2>\
<table cellpadding='1' cellspacing='0' border='0' width='100%'><tr><td>\
<fieldset>\
	<legend>Margins</legend>\
	<table cellpadding='1' cellspacing='0' border='0'>\
		<tr><td class='f_title'>Left</td>\
			<td>\
				<input type='text' id='s_marginLeft' style='width: 50px;' />\
				<select id='s_marginLeft_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='%'>%</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Right</td>\
			<td>\
				<input type='text' id='s_marginRight' style='width: 50px;' />\
				<select id='s_marginRight_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='%'>%</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Top</td>\
			<td>\
				<input type='text' id='s_marginTop' style='width: 50px;' />\
				<select id='s_marginTop_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='%'>%</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Bottom</td>\
			<td>\
				<input type='text' id='s_marginBottom' style='width: 50px;' />\
				<select id='s_marginBottom_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='%'>%</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
	</table>\
</fieldset>\
</td><td>\
<fieldset>\
	<legend>Padding</legend>\
	<table cellpadding='1' cellspacing='0' border='0'>\
		<tr><td class='f_title'>Left</td>\
			<td>\
				<input type='text' id='s_paddingLeft' style='width: 50px;' />\
				<select id='s_paddingLeft_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='%'>%</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Right</td>\
			<td>\
				<input type='text' id='s_paddingRight' style='width: 50px;' />\
				<select id='s_paddingRight_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='%'>%</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Top</td>\
			<td>\
				<input type='text' id='s_paddingTop' style='width: 50px;' />\
				<select id='s_paddingTop_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='%'>%</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
		<tr><td class='f_title'>Bottom</td>\
			<td>\
				<input type='text' id='s_paddingBottom' style='width: 50px;' />\
				<select id='s_paddingBottom_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='%'>%</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
		</tr>\
	</table>\
</fieldset>\
</td></tr></table>\
</div>\
<div id='s_layer_borders' style='display:none;'>\
<h2>Borders</h2>\
\
<fieldset>\
	<legend><input type='radio' id='s_borders_type_all' name='s_borders_types' checked='checked'><label for='s_borders_type_all'>Full Border</label></legend>\
	<table cellpadding='1' cellspacing='0' border='0'>\
		<tr><td class='f_title'>Border</td>\
			<td>\
				<input type='text' id='s_borderFull_width' style='width: 20px;' />\
			</td>\
			<td>\
				<select id='s_borderFull_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
			<td>\
				<select id='s_borderFull_style'>\
					<option value='solid'>Solid Line</option>\
					<option value='double'>Double Line</option>\
					<option value='dashed'>Dashed</option>\
					<option value='dotted'>Dotted</option>\
					<option value='groove'>Groove</option>\
					<option value='ridge'>Ridge</option>\
					<option value='inset'>Inset</option>\
					<option value='outset'>Outset</option>\
				</select>\
			</td>\
			<td>\
				<input type='text' id='s_borderFull_color' style='width: 70px;' />\
			</td>\
		</tr>\
	</table>\
</fieldset>\
\
<fieldset>\
	<legend><input type='radio' id='s_borders_type_individual' name='s_borders_types'><label for='s_borders_type_individual'>Individual Borders</label></legend>\
	<table cellpadding='1' cellspacing='0' border='0'>\
		<tr><td class='f_title'>Left</td>\
			<td>\
				<input type='text' id='s_borderLeft_width' style='width: 20px;' />\
			</td>\
			<td>\
				<select id='s_borderLeft_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
			<td>\
				<select id='s_borderLeft_style'>\
					<option value='solid'>Solid Line</option>\
					<option value='double'>Double Line</option>\
					<option value='dashed'>Dashed</option>\
					<option value='dotted'>Dotted</option>\
					<option value='groove'>Groove</option>\
					<option value='ridge'>Ridge</option>\
					<option value='inset'>Inset</option>\
					<option value='outset'>Outset</option>\
				</select>\
			</td>\
			<td>\
				<input type='text' id='s_borderLeft_color' style='width: 70px;' />\
			</td>\
		</tr>\
		<tr><td class='f_title'>Right</td>\
			<td>\
				<input type='text' id='s_borderRight_width' style='width: 20px;' />\
			</td>\
			<td>\
				<select id='s_borderRight_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
			<td>\
				<select id='s_borderRight_style'>\
					<option value='solid'>Solid Line</option>\
					<option value='double'>Double Line</option>\
					<option value='dashed'>Dashed</option>\
					<option value='dotted'>Dotted</option>\
					<option value='groove'>Groove</option>\
					<option value='ridge'>Ridge</option>\
					<option value='inset'>Inset</option>\
					<option value='outset'>Outset</option>\
				</select>\
			</td>\
			<td>\
				<input type='text' id='s_borderRight_color' style='width: 70px;' />\
			</td>\
		</tr>\
		<tr><td class='f_title'>Top</td>\
			<td>\
				<input type='text' id='s_borderTop_width' style='width: 20px;' />\
			</td>\
			<td>\
				<select id='s_borderTop_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
			<td>\
				<select id='s_borderTop_style'>\
					<option value='solid'>Solid Line</option>\
					<option value='double'>Double Line</option>\
					<option value='dashed'>Dashed</option>\
					<option value='dotted'>Dotted</option>\
					<option value='groove'>Groove</option>\
					<option value='ridge'>Ridge</option>\
					<option value='inset'>Inset</option>\
					<option value='outset'>Outset</option>\
				</select>\
			</td>\
			<td>\
				<input type='text' id='s_borderTop_color' style='width: 70px;' />\
			</td>\
		</tr>\
		<tr><td class='f_title'>Bottom</td>\
			<td>\
				<input type='text' id='s_borderBottom_width' style='width: 20px;' />\
			</td>\
			<td>\
				<select id='s_borderBottom_unit'>\
					<option value='px'>px</option>\
					<option value='pt'>pt</option>\
					<option value='em'>em</option>\
					<option value='in'>in</option>\
					<option value='mm'>mm</option>\
					<option value='cm'>cm</option>\
				</select>\
			</td>\
			<td>\
				<select id='s_borderBottom_style'>\
					<option value='solid'>Solid Line</option>\
					<option value='double'>Double Line</option>\
					<option value='dashed'>Dashed</option>\
					<option value='dotted'>Dotted</option>\
					<option value='groove'>Groove</option>\
					<option value='ridge'>Ridge</option>\
					<option value='inset'>Inset</option>\
					<option value='outset'>Outset</option>\
				</select>\
			</td>\
			<td>\
				<input type='text' id='s_borderBottom_color' style='width: 70px;' />\
			</td>\
		</tr>\
	</table>\
</fieldset>\
</div>\
</div>\
<div id='sampleHolder'>\
	<fieldset>\
		<legend>Sample</legend>\
		<table style='width:100%;height:100px;border: solid 1px #ddd; border-right: solid 1px #fff; border-bottom: solid 1px #fff;' id='s_sampleContainer'><tr><td align='center'>\
			<div id='s_sample' >\
\
			</div>\
		</td></tr></table>\
	</fieldset>\
</div>\
<div style='text-align:center;'>\
	<input type='button' id='s_updateButton' value='Update Style'  />\
	<input type='button' value='Cancel' onclick='window.close();' />\
</div>\
</td></tr>\
</table>\
<script type='text/javascript'>\
function load() {\
	StyleEditor = new FTB_StyleEditor('style');\
	StyleEditor.Initialize();\
	StyleEditor.ReadCurrentElement();\
	StyleEditor.UpdateStylePreview();\
}\
</script>\
</body>\
</html>";