
	//=============================================================
	//		TextArea Rich 
	//		Version 3.0 Build 04804
	//=============================================================
	//
	//		Warning: Changing the code below may cause the editor
	//		to not respond properly. Please only change the code if
	//		you are experienced with JavaScript.
	//
	//		If you would like any code changing or adding, please
	//		contact us for a quote for custom work. 
	//
	//		If you experience any problems - please email
	//		support@textarearich.com
	//
	//=============================================================
	
	if (location.href.indexOf("textarearich.com") != -1){
	}
	else {
	//alert("You cannot use this script outside of TextArea Rich");
	//location.replace("http://www.textarearich.com");
	}
	
	//=============================================================
	//		DRAW EDITOR
	//=============================================================
	
	button_pressed = "true";			//set a button pressed

	function draw_editor() {

		editor = ""; 	//var to store the editor output
		
		editor += "<div id='tr_iView_menu' style='background:" + menu_bg_col + "'></div>"; 		//context menu
		editor += "<div id='tr_dropMenu' unselectable='on' style='background:" + menu_bg_col + "'></div>"; //toolbar menu
		editor += "<div id='tr_dropMenu_sub' unselectable='on' style='background:" + menu_bg_col + "'></div>"; //toolbar menu
		editor += "<div id='tr_drop_color_menu' style='text-align:center;width:150' unselectable='on' style='background:" + menu_bg_col + "'></div>";	//color menu
		
		//set up the editor sizes
		
		editor += "<table width='" + editorWidth + "' cellpadding='0' cellspacing='0' border='0' class='editor_surround'>\n";
		editor += "<tr><td align='left' class='toolbar' valign='top'>";

		//draw the toolbars
		/*	PLEASE NOTE
		By removing or altering the info_button() function below in any way, you are breaking the conditions of the free user licence.
		Please see http://www.textarearich.com/licences/ for more information
		*/
		editor += info_button() + save_button() + preview_button() + basic_buttons() + single_button(tbl_code,"toggle()");
		editor += seperator();
		editor += style_buttons() + insert_drop_down();
		editor += seperator();
		editor += table_button() + form_button();
		
		editor += "</td><tr>";								//close first toolbar
		editor += "<tr><td align='left' class='toolbar' valign='top'>";	//open second toolbar
		
		editor += style_fonts() + style_fontsize() + style_fontformat() + style_styles();
		
		editor += seperator();
		editor += font_colors();
		editor += seperator();
		editor += other_buttons();

		editor += "</td><tr>";								//close second toolbar
		editor += "<tr><td valign='top' id=\"wysiwyg_td\">";		//open editor section
		
		editor += wysiwyg_frame();
		
		editor += "</td></tr>";								//close editor section
		editor += "<tr><td class='toolbar' valign='middle'>";				//open bottom toolbar
		
		editor += "<table cellpadding='0' width='100%' border='0'><tr>";
		editor += "<td align='left' class='html_path'>&nbsp;<a name='html_path'></a>&nbsp</td>";
		editor += "<td width='1'>&nbsp;</td>";
		editor += "<td width='150' align='right'><a name='editor_status'></a>&nbsp</td>";
		editor += "</tr></table>";

		editor += "</td></tr>";								//close bottom toolbar
		editor += "</table>";
		
		document.write(editor);
	}
	
	function editor_header() {
		//output the headers for the editor if any are required
		tmp = "";
		return tmp;
	}	
	
	function checkState() {
		//only some buttons want to be checked for their state - so go through an array of
		//buttons to be checked (set in config)
		
		clearButton('desc_undo');
		clearButton('desc_redo');
		
		for (x=0;x<=tlb_style_buttons.length-1;x++) {
			if (iView.document.queryCommandState(tlb_style_buttons[x][1])) {
				doStyle('on',tlb_style_buttons[x][3])
			} else {
				doStyle('off',tlb_style_buttons[x][3])
			}
			err_rcf_report = 0;
		}
		
		//now get the font details to change the font list
		if (allowFonts) {
			font_name = iView.document.queryCommandValue("fontname"); 
			if (font_name) { 
			   var currentFont = font_name.toLowerCase(); 
			   try {
				   for (x=0; x<tbl_style_fonts.length; x++) { 
						  if (tbl_style_fonts[x][1].toLowerCase() == currentFont) {
								document.getElementById(formName).fontname.selectedIndex = x+1; //form name is specified in config file
						  } 
				   }
			   } catch (error) {
					alert("Error: 2002\n\nDesc: There was a problem loading the fonts list" + errDesc);
			   }
			} else {
				document.getElementById(formName).fontname.selectedIndex = 0;
			}
		}
		
		//font size
		if (allowFontSize) {
			font_size = iView.document.queryCommandValue("fontsize");
			if ((font_size == null) || (font_size == "")) { document.getElementById(formName).fontSize.selectedIndex = 0;}
			for (x=0; x<tbl_style_fontsize.length; x++)
			{
					//alert(font_size + " - " +tbl_style_fontsize[x][0]);
					if (font_size == tbl_style_fontsize[x][0]) { 
						document.getElementById(formName).fontSize.selectedIndex = x+1; 
					}
			}
		}
		
		//font class/style
		if (allowStyles) {
			var theSelection = iView.document.selection.createRange();
			if (iView.document.selection.type == "Control") {
				el = theSelection(0).parentNode;
			} else {
				el = theSelection.parentElement()
			}
			font_class = el.className;
			
			if ((font_class == null) || (font_class == "")) { document.getElementById(formName).fontClass.selectedIndex = 0;}
			for (x=0; x<tbl_style_styles.length; x++)
			{
					//alert(font_size + " - " +tbl_style_fontsize[x][0]);
					if (font_class == tbl_style_styles[x][0]) { 
						document.getElementById(formName).fontClass.selectedIndex = x+1; 
					}
			}
		}
		
		
		//font format
		if (allowFormat) {
			font_format = iView.document.queryCommandValue("formatblock");
			if ((font_format == null) || (font_format == "")) { document.getElementById(formName).fontFormat.selectedIndex = 0;}
			for (x=0; x<tbl_style_fontformat.length; x++)
			{
					//alert(font_format + " - " +tbl_style_fontformat[x][0]);
					if (font_format == tbl_style_fontformat[x][0]) { 
						document.getElementById(formName).fontFormat.selectedIndex = x+1; 
					}
			}
		}
		
	}
	
	function convert(color) {
		//convert the number returned from IE to hex
		function makehex(d) {
			return (d < 16) ? ("0" + d.toString(16)) : d.toString(16);
		};
		var r = color & 0xFF;
		var g = (color >> 8) & 0xFF;
		var b = (color >> 16) & 0xFF;
		theColor = "#" + makehex(r) + makehex(g) + makehex(b);
		return theColor;
	}
	
	function checkColor() {
		//check the color of the selction
		color = iView.document.queryCommandValue("forecolor");
		convert(color);
		if (document.all['color_0']) { document.all.color_0.style.backgroundColor = theColor; }
		return true;
	}
	
	function checkBackColor() {
		//check the background font color
		color = iView.document.queryCommandValue("backcolor");
		convert(color);
		if (document.all['color_1']) { document.all.color_1.style.backgroundColor = theColor; }
		return true;
	}
	
	
	
	
	function doStyle(state,ctrl) {
		if (state == "on") {
			//change the highlighting to make the button look pressed (change this in button_styles.js)
			btnPressed(ctrl);
		} else {
			//change the button back to its original state. 
			clearButton(ctrl);
		}
	}
	
	function my_onMouseUp() {
		if ((document.getElementById("desc_forecol")) && (viewMode != 2)) { checkColor();     }  //only call if colour buttons exist
		if ((document.getElementById("desc_backcol")) && (viewMode != 2)) { checkBackColor(); }	//only call if colour buttons exist
		checkState();		//change the state of the buttons
		parentElement();	//show the HTML path in the status bar
		return true;
	}
	
	function my_onKeyUp() {
		if ((document.getElementById("desc_forecol")) && (viewMode != 2)) { checkColor();     }  //only call if colour buttons exist
		if ((document.getElementById("desc_backcol")) && (viewMode != 2)) { checkBackColor(); }	//only call if colour buttons exist
		checkState();		//change the state of the buttons
		parentElement();	//show the HTML path in the status bar
		return true;
	}
	
	//===========================
	//	Draw the toolbar bits
	//===========================
	function style_buttons() {
		tmp = "";
		for (x=0;x<=tlb_style_buttons.length-1;x++) {
			tmp += "<img src='editor/images/buttons/" + tlb_style_buttons[x][2] + "' ";
			tmp += "class = 'button' alt='"+ tlb_style_buttons[x][0] +"' ";
			tmp += "onMouseOver =\"btnOver(this)\" ";
			tmp += "onMouseOut  =\"btnOut(this)\" ";
			tmp += "onMouseDown =\"btnDown(this)\" ";
			tmp += "onClick=\"cmdExec('" + tlb_style_buttons[x][1] + "')\" ";
			tmp += "name='" + tlb_style_buttons[x][3] + "' ";
			tmp += " align='absbottom' unselectable='on'>";
		}
		return tmp;
	}
	
	function style_fonts() {
		tmp = "";
		if (allowFonts) {
			tmp += "<select name='fontname' class='dropDown' onChange=\"doFont(this.options[this.selectedIndex].value)\" unselectable='on'>\n";
			tmp += "<option value='0'> -- Font --</option>\n";
			for (x=0;x<=tbl_style_fonts.length-1;x++)
			{
				tmp += "<option value='" + tbl_style_fonts[x][0] + "'>" + tbl_style_fonts[x][1] + "</option>\n";
			}
			tmp += "</select>";
		}
		return tmp;
		
	}

	function style_fontsize() {
		var tmp = "";
		if (allowFontSize) {
			tmp += "<select name='fontSize' class='dropDown' onChange=\"doSize(this.options[this.selectedIndex].value)\" unselectable='on'>\n";
			tmp += "<option value=''> -- Size --</option>\n";
			for (x=0;x<=tbl_style_fontsize.length-1;x++) {
				tmp += "<option value='" + tbl_style_fontsize[x][0] + "'>" + tbl_style_fontsize[x][1] + "</option>\n";
			}
			tmp += "</select>";
		}
		return tmp;
	}
	
	function style_fontformat(){
		var tmp = "";
		if (allowFormat){
			tmp += "<select name='fontFormat' class='dropDown' onChange=\"doFormat(this.options[this.selectedIndex].value)\" unselectable='on'>\n";
			tmp += "<option value=''> -- Format --</option>\n";
			for (x=0;x<=tbl_style_fontformat.length-1;x++) {
				tmp += "<option value='" + tbl_style_fontformat[x][0] + "'>" + tbl_style_fontformat[x][1] + "</option>\n";
			}
			tmp += "</select>";
		}
		return tmp;
	}
	
	function style_styles() {
		var tmp = "";
		if (allowStyles) {
			tmp += "<select name='fontClass' class='dropDown' onChange=\"doStyleSheet(this.options[this.selectedIndex].value)\" unselectable='on'>\n";
			tmp += "<option value=''> -- Style --</option>\n";
			for (x=0;x<tbl_style_styles.length;x++) {
				tmp += "<option value='" + tbl_style_styles[x][0] + "'>" + tbl_style_styles[x][1] + "</option>\n";
			}
			tmp += "</select>";
		}
		return tmp;
	}
	
	function save_button() {
		tmp = "";
		if (allowSaveButton) {
			tmp += 	"<img src='editor/images/buttons/" + tlb_save[0][1] + "' ";
			tmp += 	"class = 'button' alt='"+ tlb_save[0][0] +"' ";
			tmp += 	"onMouseOver =\"btnOver(this)\" ";
			tmp += 	"onMouseOut  =\"btnOut(this)\" ";
			tmp += 	"onMouseDown =\"btnDown(this)\" ";
			tmp += 	"onMouseUp =\"btnUp(this)\" ";
			tmp += 	"onClick=\"savedocument()\" ";
			tmp += 	"name='" + tlb_save[0][0] + "' ";
			tmp += 	" align='absbottom' unselectable='on'>";
		}
		return tmp;
	}
	
	/*	PLEASE NOTE
		By removing or altering the info_button() function below in any way, you are breaking the conditions of the free user licence.
		Please see http://www.textarearich.com/licences/ for more information
	*/
	function info_button() {
		tmp = "";
		tmp += 	"<img src='editor/images/buttons/info.gif' ";
		tmp += 	"class = 'button' alt='About TextArea Rich' ";
		tmp += 	"onMouseOver =\"btnOver(this)\" ";
		tmp += 	"onMouseOut  =\"btnOut(this)\" ";
		tmp += 	"onMouseDown =\"btnDown(this)\" ";
		tmp += 	"onMouseUp =\"btnUp(this)\" ";
		tmp += 	"onClick=\"about()\" ";
		tmp += 	"name='desc_info' ";
		tmp += 	" align='absbottom' unselectable='on'>";
		return tmp;
	}
	
	
	function insert_drop_down() {
		var tmp = "";
		if (allowInserts) {
			tmp += 	"<img src='editor/images/buttons/" + tbl_insert_drop[0][1] + "' ";
			tmp += 	"class = 'button' alt='"+ tbl_insert_drop[0][0] +"' ";
			tmp += 	"onMouseOver =\"btnOver(this)\" ";
			tmp += 	"onMouseOut  =\"btnOut(this)\" ";
			tmp += 	"onMouseDown =\"btnDown(this)\" ";
			tmp += 	"onMouseUp =\"btnUp(this)\" ";
			tmp += 	"onClick=\"doInsert()\" ";
			tmp += 	"name='" + tbl_insert_drop[0][2] + "' ";
			tmp += 	" align='absbottom' unselectable='on'>";
		}
		return tmp;
		
	}

	function table_button() {
		//the table button uses a drop down menu which is hidden - we need to show it onclick.
		tmp = "";
		if (allowTableEdit) {
			tmp += 	"<img src='editor/images/buttons/" + tbl_table[0][1] + "' ";
			tmp += 	"class = 'button' alt='"+ tbl_table[0][0] +"' ";
			tmp += 	"onMouseOver =\"btnOver(this)\" ";
			tmp += 	"onMouseOut  =\"btnOut(this)\" ";
			tmp += 	"onMouseDown =\"btnDown(this)\" ";
			tmp += 	"onMouseUp =\"btnUp(this)\" ";
			tmp +=	"onClick = \"doTable()\" ";
			tmp += 	"name='" + tbl_table[0][0] + "' ";
			tmp += 	" align='absbottom' unselectable='on'>";
		}
		return tmp;
	}
	
	function form_button()
	{
		//the form button uses a drop down menu which is hidden - we need to show it onclick.
		tmp = "";
		if (allowFormEdit) {
			tmp += 	"<img src='editor/images/buttons/" + tbl_form[0][1] + "' ";
			tmp += 	"class = 'button' alt='"+ tbl_form[0][0] +"' ";
			tmp += 	"onMouseOver =\"btnOver(this)\" ";
			tmp += 	"onMouseOut  =\"btnOut(this)\" ";
			tmp += 	"onMouseDown =\"btnDown(this)\" ";
			tmp += 	"onMouseUp =\"btnUp(this)\" ";
			tmp +=	"onClick = \"doForm()\" ";
			tmp += 	"name='" + tbl_form[0][0] + "' ";
			tmp += 	" align='absbottom' unselectable='on'>";
		} return tmp;
	}
	
	function preview_button() {
		//preview button shows a DIV layer
		tmp = "";
		if (allowPreview) {
			tmp += 	"<img src='editor/images/buttons/preview.gif' ";
			tmp += 	"class = 'button' alt='Preview Page' ";
			tmp += 	"onMouseOver =\"btnOver(this)\" ";
			tmp += 	"onMouseOut  =\"btnOut(this)\" ";
			tmp += 	"onMouseDown =\"btnDown(this)\" ";
			tmp += 	"onMouseUp =\"btnUp(this)\" ";
			tmp +=	"onClick = \"doPreview()\" ";
			tmp += 	"name='desc_preview' ";
			tmp += 	" align='absbottom' unselectable='on'>";
		} return tmp;
	}
	
	function single_button(what,func) {
		//draw a single button
		tmp = 	"<img src='editor/images/buttons/" + what[0][1] + "' ";
		tmp += 	"class = 'button' alt='"+ what[0][0] +"' ";
		tmp += 	"onMouseOver =\"btnOver(this)\" ";
		tmp += 	"onMouseOut  =\"btnOut(this)\" ";
		tmp += 	"onMouseDown =\"btnDown(this)\" ";
		tmp += 	"onMouseUp =\"btnUp(this)\" ";
		tmp +=	"onClick = \"" + func + "\" ";
		tmp += 	"name='" + what[0][2] + "' ";
		tmp += 	" align='absbottom' unselectable='on'>";
		return tmp;
	}
	
	function font_colors(){
		tmp = "";
		for (x=0;x<=tbl_fontcolors.length-1;x++){
			tmp += "<img src='editor/images/buttons/" + tbl_fontcolors[x][2] + "' ";
			tmp += "class = 'button' alt='"+ tbl_fontcolors[x][0] +"' ";
			tmp += "onMouseOver =\"btnOver(this)\" ";
			tmp += "onMouseUp =\"btnUp(this)\" ";
			tmp += "onMouseOut  =\"btnOut(this)\" ";
			tmp += "onMouseDown =\"btnDown(this)\" ";
			tmp += "onClick=\"" + tbl_fontcolors[x][1] + "\" ";
			tmp += "name='" + tbl_fontcolors[x][3] + "' ";
			tmp += " align='absbottom' unselectable='on'>";
			tmp += "<img src='editor/images/buttons/color.gif' name='color_" + x + "'>&nbsp;";
		}
		return tmp;
	}
	
	function other_buttons()
	{
		tmp = "";
		for (x=0;x<=tbl_extraButtons.length-1;x++) {
			if (tbl_extraButtons[x][1] == "") {
					tmp += seperator();
			} else {
				tmp += "<img src='editor/images/buttons/" + tbl_extraButtons[x][2] + "' ";
				tmp += "class = 'button' alt='"+ tbl_extraButtons[x][0] +"' ";
				tmp += "onMouseOver =\"btnOver(this)\" ";
				tmp += "onMouseUp =\"btnUp(this)\" ";
				tmp += "onMouseOut  =\"btnOut(this)\" ";
				tmp += "onMouseDown =\"btnDown(this)\" ";
				tmp += "onClick=\"" + tbl_extraButtons[x][1] + "\" ";
				tmp += "name='" + tbl_extraButtons[x][3] + "' ";
				tmp += " align='absbottom' unselectable='on'>";
			}
		}
		return tmp;
	}
	
	function basic_buttons() {
		tmp = "";
		for (x=0;x<=tlb_basic.length-1;x++) {
			tmp += 	"<img src='editor/images/buttons/" + tlb_basic[x][2] + "' ";
			tmp += 	"class = 'button' alt='"+ tlb_basic[x][0] +"' ";
			tmp += 	"onMouseOver =\"btnOver(this)\" ";
			tmp += 	"onMouseUp =\"btnUp(this)\" ";
			tmp += 	"onMouseOut  =\"btnOut(this)\" ";
			tmp += 	"onMouseDown =\"btnDown(this)\" ";
			tmp +=  "onClick=\"" + tlb_basic[x][1] + "\" ";
			tmp += 	"name='" + tlb_basic[x][3] + "' ";
			tmp += 	" align='absbottom' unselectable='on'>";
		}
		return tmp;
	}
	
	function wysiwyg_frame() {
		//this will draw the actual wysiwyg frame
		tmp =	'<iframe id="iView" dir="' + textDirection + '" width="' + editorWidth + '" height="' + iFrameHeight + '" ';
		tmp +=	'onLoad="applyStyle();tableBorders(table_borders); formBorders(form_borders);setUndo(iView.document.body.innerHTML)"></iFrame>';		//tmp +=	'onLoad="applyStyle();tableBorders(table_borders); formBorders(form_borders);"></iFrame>';
		return tmp;
	}
	
	function seperator() {
		//draw the seperator
		return "<img src='editor/images/buttons/seperator.gif' align='absbottom' class='button'>";
	}
	
	function getKeyPress() {
		//handle the keypresses
		iView.focus();
		var basicKey 	= iView.event.keyCode;
		var ctrlKey		= iView.event.ctrlKey;
		var shiftKey	= iView.event.shiftKey;
		var altKey		= iView.event.altKey;
		
		//use <BR> instead of <P> ?
		
		if (basicKey == 13) {
			if (useBR) {
				iView.event.cancelBubble = true;	//stop the action
				iView.event.returnValue = false;	//stop the value
				insertHTML('<BR>');
			}
		}
		
		//keys for the backup (undo function)
		//code by http://www.codingforums.com/member.php?u=14013
		switch (basicKey) {
			case 32:
				BACKUP('New Text');
				break;    
			case 8:
				BACKUP('Backspace');
				break;    
			case 13:
				BACKUP('New Paragraph');
				break;    
			case 46:
				BACKUP('Delete Key');
				break; 
			case 255:
				BACKUP('Delete Key');
				break;
			default:
				//if there is selected text and the user presses a key, save the document.
				//this is the only way selected text can be overwritten.
				if ((iView.document.selection.type == "Text") || (iView.document.selection.type == "Control")) {
					//BACKUP('New Text');
				}
				break;
		}
		
		//stop or allow the basic formatting keys
		if (ctrlKey)
		{
			//alert("control")
			if (shiftKey) {
				if (/desc_redo/.test(tlb_basic)) {
					if (basicKey == 90) {
						redo();
					}
				}
			}
			
			
			switch (basicKey)
			{
				case 66:	//ctrl + B )if the bold button is on the toolbar, allow CTRL+B otherwise dont!
							if (! /desc_bold/.test(tlb_style_buttons)) {
								iView.event.cancelBubble = true // block the operation
								iView.event.returnValue  = false // dont return a B to the editor window.
								if (showDisabledMsg) alert(disabledMsg)
								return false;
							} else {
								BACKUP('Format (bold)');
							}
							break;
							
				case 73:	//ctrl + I )if the italic button is on the toolbar, allow CTRL+I otherwise dont!
							if (! /desc_italic/.test(tlb_style_buttons)) {
								iView.event.cancelBubble = true // block the operation
								iView.event.returnValue  = false // dont return a B to the editor window.
								if (showDisabledMsg) alert(disabledMsg)
								return false;
							} else {
								BACKUP('Format (italic)');
							}
							break;
							
				case 85:	//ctrl + U )if the underline button is on the toolbar, allow CTRL+U otherwise dont!
							if (! /desc_underline/.test(tlb_style_buttons)) {
								iView.event.cancelBubble = true // block the operation
								iView.event.returnValue  = false // dont return a B to the editor window.
								if (showDisabledMsg) alert(disabledMsg)
								return false;
							} else {
								BACKUP('Format (underline)');
							}
							break;
				
				case 88:	//ctrl + X )if the CUT button is on the toolbar, allow CTRL+X otherwise dont!
							if (! /desc_cut/.test(tlb_basic)) {
								iView.event.cancelBubble = true // block the operation
								iView.event.returnValue  = false // dont return a B to the editor window.
								if (showDisabledMsg) alert(disabledMsg)
								return false;
							} else {
								BACKUP('Cut Text');
							}
							break;
							
				case 67:	//ctrl + C )if the copy button is on the toolbar, allow CTRL+C otherwise dont!
							if (! /desc_copy/.test(tlb_basic)) {
								iView.event.cancelBubble = true // block the operation
								iView.event.returnValue  = false // dont return a B to the editor window.
								if (showDisabledMsg) alert(disabledMsg)
								return false;
							}
							break;
							
				case 86:	//ctrl + V )if the paste button is on the toolbar, allow CTRL+V otherwise dont!
							if (! /desc_copy/.test(tlb_basic)) {
								iView.event.cancelBubble = true // block the operation
								iView.event.returnValue  = false // dont return a B to the editor window.
								if (showDisabledMsg) alert(disabledMsg)
								return false;
							} else {
								BACKUP('Paste Text');
							}
							break;
							
				case 90:	//ctrl + Z )if the undo button is on the toolbar, allow CTRL+Z otherwise dont!
							if (! /desc_undo/.test(tlb_basic)) {
								alert("not in array");
								iView.event.cancelBubble = true // block the operation
								iView.event.returnValue  = false 
								if (showDisabledMsg) alert(disabledMsg)
								return false;
							} else {
								//use the custom undo function
								undo();
							}
							break;
			}
		}
	}
	
	function insertHTML(what) {
		//used for custom functions to insert any text or HTML to the editor where the cursor is.
		//what 	= 	the text to be inserted
		iView.focus();
		var sel = iView.document.selection.createRange();
		sel.pasteHTML(what);
	}
	
	function doubleClick()	{
		if (doubleClickImg)	{
			if (isImage()) {
				doImage();
			}
		}
	}
	
	function parentElement() {
		//function used to get the parent element of where the cursor currently is
		
		if (showHTMLpath) {
			
			var path 	= new Array;		//store the path
			var control = "";				//control
			var x 		= 0;
			
			//first for control types
			if (iView.document.selection.type == "Control") {
				var itself = iView.document.selection.createRange();
				switch(itself(0).tagName.toUpperCase()) {
					case "IMG"		:	control = "&lt;img&gt;";		break;
					case "INPUT"	:	control = "&lt;input&gt;";		break;
					case "TEXTAREA"	:	control = "&lt;textarea&gt;";	break;
					case "SELECT"	:	control = "&lt;select&gt;";		break;
					case "HR"		:	control = "&lt;hr&gt;"; break;
					default 		:	control = "";					break;
				}
				//we also need to get the path before this input, so move the cursor to the beginning and get the path.
				
				var element = itself(0).parentNode;
				
				while (element.nodeName.toUpperCase() != "HTML") {
					//go through the elements and build the path
					path[x] = "&lt;" + element.nodeName + "&gt;";
					if (element.parentNode) {
						element = element.parentNode;
						x++
					}
				}
				

			} else {
				
				var cursor = iView.document.selection.createRange();
				var element = cursor.parentElement();
				while (element.nodeName.toUpperCase() != "HTML") {
					//go through the elements and build the path
					path[x] = "&lt;" + element.nodeName + "&gt;";
					if (element.parentNode) {
						element = element.parentNode;
						x++;
					}
					
				}
			}
			
			path.reverse();
			newPath = "";
			for (x=0;x<path.length;x++) {
				 if (path[x] != "&lt;TBODY&gt;")
				 newPath += path[x];
			}
			
			if (control != "") {
				newPath += control;
			}
			
			document.getElementById("html_path").innerHTML = newPath.toLowerCase();
				
		}
	}
	
	function resetToolbars() {
		//this function is used to reset the toolbars etc
		if (document.all['color_1']) { document.all['color_1'].style.background = "";	} //fontbg color indicator
		if (document.all['color_0']) { document.all['color_0'].style.background = "";	}		//font color indicator
		
		//clean the buttons
		if (iView.document.selection.createRange() != "Control") {
			for (x=0;x<=tlb_style_buttons.length-1;x++) {
				if (iView.document.queryCommandState(tlb_style_buttons[x][1])) {
					doStyle('on',tlb_style_buttons[x][3])
				} else {
					doStyle('off',tlb_style_buttons[x][3])
				}
				err_rcf_report = 0;
			}
		}
	}
	
	if (document.attachEvent){
			document.attachEvent("onmousedown", hideMenu);
			document.attachEvent("onmousedown", resetToolbars);
	}