			//sInitColor is a global variable. It holds the value of the selected color in the color dialog box when it displays
			var sInitColor = null;
			//sPersistValue holds the value of the saved innerHTML 
			var sPersistValue;

			//This function works for all of the command identifiers used in this page
			//rich text editor formatting function
			function callFormatting(sFormatString)
			{
				document.execCommand(sFormatString);
			}
			//Fonts routines
			//getSystemFonts uses the dialog helper object to return an array of all of the fonts on the user's system, then populates a drop-down listbox in the toolbar with the array elements
			function getSystemFonts(){
				var oToolBar = document.getElementById("oToolBar");
				if(oToolBar != undefined)
				{
					var a=dlgHelper.fonts.count;
					var fArray = new Array();
					var oDropDown = oToolBar.createDropDownListAt("5");
					oDropDown.setAttribute("id","FontNameList");
					for (i = 1;i < dlgHelper.fonts.count;i++){ 
						fArray[i] = dlgHelper.fonts(i);
						var aOptions = oDropDown.getOptions();	
						var oOption = document.createElement("OPTION");
						aOptions.add(oOption);	
						oOption.text = fArray[i];
						oOption.Value = i;
					} 
					//attaching the onchange event is necessary in order to detect when a user changes the value in the drop-down listbox
					oDropDown.setAttribute("onchange",ChangeFont);
				}
			}
			//changeFontSize detects the value of the item in the drop-down listbox and applies the value to the font of the selected text
			function changeFontSize(toolbarname){
			    var oToolBar = document.getElementById(toolbarname);
				var sSelected=oToolBar.getItem(0).getOptions().item(oToolBar.getItem(0).getAttribute("selectedIndex"));
   				document.execCommand("FontSize", false, sSelected.value);
			}

			//changeFont detects the value of the item in the drop-down listbox and applies the value to the font of the selected text
			function ChangeFont(toolbarname){	
			    var oToolBar = document.getElementById(toolbarname);
				var sSelected=oToolBar.getItem(5).getOptions().item(oToolBar.getItem(5).getAttribute("selectedIndex"));
				document.execCommand("FontName", false, sSelected.text);
			}

			//BlockFormats routines
			//getBlockFormats uses the dialog helper object to return an array of all of the block formats on the user's system, then populates a drop-down listbox in the toolbar with the array elements
			function getBlockFormats(){
				// var oToolBar = document.getElementById("oToolBar");
				var oToolBar;
				var toolbarslist = document.getElementsByTagName("TOOLBAR");
				if(toolbarslist.length > 0)
				{
				    var i;
				    for(i = 0; i < toolbarslist.length; i++)
				    {
				        oToolBar = toolbarslist[i];
				        if(oToolBar != undefined)
				        {				
					        var a=dlgHelper.blockFormats.count;
					        var fArray = new Array();
					        var oDropDown = oToolBar.createDropDownListAt("6");
					        oDropDown.setAttribute("id","FormatList");
					        for (i = 1;i < dlgHelper.blockFormats.count;i++)
					        { 
						        fArray[i] = dlgHelper.blockFormats(i);
						        var aOptions = oDropDown.getOptions();	
						        var oOption = document.createElement("OPTION");
						        aOptions.add(oOption);	
						        oOption.text = fArray[i];
						        oOption.Value = i;
					        } 
					        //attach the onchange event
					        oDropDown.setAttribute("onchange",ChangeFormat);
				        }
				    }
				}
			}
			
			//ChangeFormat detects the value of the item in the drop-down listbox and applies the value to the font of the selected text
			function ChangeFormat(toolbarname){
			    var oToolBar = document.getElementById(toolbarname);
				var sSelected=oToolBar.getItem(6).getOptions().item(oToolBar.getItem(6).getAttribute("selectedIndex"));
				document.execCommand("FormatBlock", false, sSelected.text);
			} 


			//callColorDlg uses the dialog helper object's ChooseColorDlg method to open the color dialog box, then changes the font or back color of the selected text
			function callColorDlg(sColorType){

			if (sInitColor == null) 
				//display color dialog box
				var sColor = dlgHelper.ChooseColorDlg();
			else
				var sColor = dlgHelper.ChooseColorDlg(sInitColor);
				//change decimal to hex
				sColor = sColor.toString(16);
				//add extra zeroes if hex number is less than 6 digits
			if (sColor.length < 6) {
  				var sTempString = "000000".substring(0,6-sColor.length);
  				sColor = sTempString.concat(sColor);
			}
				//change color of the selected text
				document.execCommand(sColorType, false, sColor);
				sInitColor = sColor;
				//oDiv.focus();
			}
			
			function InitRichTextEditor()
			{							
				// getSystemFonts();
 				// getBlockFormats(); 				
			}
