<!--

	var RichText = {
		
		enableTimeout: 10,
		config: new Array(),
		blocks: new Array(),
		
		actions: {
			
			boldText: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("bold", false, null);
			},
			
			italicText: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("italic", false, null);
			},
			
			underlineText: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("underline", false, null);
			},
			
			strikethroughText: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("strikethrough", false, null);
			},
			
			undoAction: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("undo", false, null);
			},
			
			redoAction: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("redo", false, null);
			},
			
			indentText: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("indent", false, null);
			},
			
			outdentText: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("outdent", false, null);
			},
			
			justifyLeft: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("justifyleft", false, null);
			},
			
			justifyRight: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("justifyright", false, null);
			},
			
			justifyCenter: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("justifycenter", false, null);
			},
			
			justifyFull: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("justifyfull", false, null);
			},
			
			subScript: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("subscript", false, null);
			},
			
			superScript: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("superscript", false, null);
			},
			
			clipboardCut: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("cut", false, null);
			},
			
			clipboardCopy: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("copy", false, null);
			},
			
			clipboardPaste: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("paste", false, null);
			},
			
			unorderedList: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("insertunorderedlist", false, null);
			},
			
			orderedList: function(blockname)
			{
				document.getElementById(blockname).contentWindow.document.execCommand("insertorderedlist", false, null);
			},
			
			showCode: function(blockname)
			{
				var thecode = document.createElement("div");
				thecode.setAttribute("id", "richTextHTMLEdit");
				thecode.setAttribute("blockname", blockname);
				
				var thetextarea = document.createElement("textarea");
				thetextarea.setAttribute("id", "richTextHTMLEditCode");
				thetextarea.value = document.getElementById(blockname).contentWindow.document.body.innerHTML;
				
				var thesavebutton = document.createElement("input");
				thesavebutton.setAttribute("value", "Apply");
				thesavebutton.setAttribute("type", "button");
				Extend.addEvent(thesavebutton, "click", function()
														{
															var thetextedit = document.getElementById('richTextHTMLEdit');
															
															document.getElementById(thetextedit.getAttribute("blockname")).contentWindow.document.body.innerHTML = document.getElementById('richTextHTMLEditCode').value;
															
															document.getElementById('richTextHTMLEdit').removeNode(true);
														});
				
				var thecancelbutton = document.createElement("input");
				thecancelbutton.setAttribute("value", "Cancel");
				thecancelbutton.setAttribute("type", "button");
				Extend.addEvent(thecancelbutton, "click", function()
															{
																document.getElementById('richTextHTMLEdit').removeNode(true);
															});
				
				thecode.appendChild(thetextarea);
				thecode.appendChild(thesavebutton);
				thecode.appendChild(thecancelbutton);
				
				document.body.appendChild(thecode);
				thetextarea.focus();
			}
			
		},
		
		init: function()
		{
			
		},
		
		enableDesignMode: function(blockname, innerText)
		{
			var block = document.getElementById(blockname);
			
			block.contentWindow.document.designMode = "on";
			
			block.contentWindow.document.open();
			block.contentWindow.document.write("<html><head><link rel='stylesheet' type='text/css' href='css/style.css'></head><body class='richTextIFrame'>");
			
			if(innerText.length > 0)
			{
				block.contentWindow.document.write(unescape(innerText));
			}
			
			block.contentWindow.document.write("</body></html>");
			
			block.contentWindow.document.close();
		},
		
		enableOn: function(blockid)
		{
			var block = document.getElementById(blockid);
			var richTextID = blockid + "_richText";
			
			if(block.getAttribute("richText") == "enabled")
			{
				//Update content
				setTimeout("RichText.enableDesignMode('" + richTextID + "', '" + escape(block.value) + "')", this.enableTimeout);
				
				return false;
			}
			else
			{
				var currentBlockID = RichText.blocks.length;
				
				this.blocks[this.blocks.length] = richTextID;
			}
			
			block.setAttribute("richText", "enabled");
			block.style.display = 'none';
			
			// Overall DIV
			var richTextDiv = document.createElement("div");
			richTextDiv.className = 'richText';
			
			var toolBarDiv = document.createElement("div");
			toolBarDiv.className = 'toolBar';
			
			// Creating buttons toolbar
			for(var i=0;i<this.buttons.length;i++)
			{
				var thediv = document.createElement("div");
				thediv.className = 'toolBarButton';
				
				var theimage = document.createElement("img");
				theimage.setAttribute("src", "images/richText/" + this.buttons[i].image);
				
				if(this.buttons[i].attachedFunction != false)
				{
					Extend.addEvent(theimage, "click", new Function("RichText.buttons[" + i + "].attachedFunction(RichText.blocks[" + currentBlockID + "])"));
				}
				else
				{
					thediv.className = 'toolBarSpacer';
				}
				
				thediv.appendChild(theimage);
				toolBarDiv.appendChild(thediv);
			}
			
			richTextDiv.appendChild(toolBarDiv);
			
			// Create iFrame
			var iframe = document.createElement("iframe");
			
			if(BrowserDetect.browser == "Explorer")
			{
				iframe.style.width = block.currentStyle.width;
				iframe.style.height = block.currentStyle.height;
			}
			else
			{
				iframe.style.width = document.defaultView.getComputedStyle(block, null).getPropertyValue('width');
				iframe.style.height = document.defaultView.getComputedStyle(block, null).getPropertyValue('height');
			}
				
			iframe.setAttribute("id", this.blocks[currentBlockID]);
			iframe.frameBorder = 0;
			
			// Add new iFrame to the page
			richTextDiv.appendChild(iframe);
			block.parentNode.insertBefore(richTextDiv, block.nextSibling);
			
			setTimeout("RichText.enableDesignMode('" + this.blocks[currentBlockID] + "', '" + escape(block.value) + "')", this.enableTimeout);
		},
		
		storeContent: function(blockid)
		{
			var block = document.getElementById(blockid);
			var block_rich = document.getElementById(blockid + "_richText");
			
			block.value = block_rich.contentWindow.document.body.innerHTML;
		}
		
	};
	
	RichText.buttons = 
	[	
		{
			image: 'bold.gif',
			attachedFunction: RichText.actions.boldText
		},
		{
			image: 'italic.gif',
			attachedFunction: RichText.actions.italicText
		},
		{
			image: 'underline.gif',
			attachedFunction: RichText.actions.underlineText
		},
		{
			image: 'strikethrough.gif',
			attachedFunction: RichText.actions.strikethroughText
		},
		{
			image: 'justifyleft.gif',
			attachedFunction: RichText.actions.justifyLeft
		},
		{
			image: 'justifycenter.gif',
			attachedFunction: RichText.actions.justifyCenter
		},
		{
			image: 'justifyright.gif',
			attachedFunction: RichText.actions.justifyRight
		},
		{
			image: 'justifyfull.gif',
			attachedFunction: RichText.actions.justifyFull
		},
		{
			image: 'numlist.gif',
			attachedFunction: RichText.actions.orderedList
		},
		{
			image: 'bullist.gif',
			attachedFunction: RichText.actions.unorderedList
		},
		{
			image: 'separator.gif',
			attachedFunction: false
		},
		{
			image: 'indent.gif',
			attachedFunction: RichText.actions.indentText
		},
		{
			image: 'outdent.gif',
			attachedFunction: RichText.actions.outdentText
		},
		{
			image: 'separator.gif',
			attachedFunction: false
		},
		{
			image: 'sub.gif',
			attachedFunction: RichText.actions.subScript
		},
		{
			image: 'sup.gif',
			attachedFunction: RichText.actions.superScript
		},
		{
			image: 'separator.gif',
			attachedFunction: false
		},
		{
			image: 'cut.gif',
			attachedFunction: RichText.actions.clipboardCut
		},
		{
			image: 'copy.gif',
			attachedFunction: RichText.actions.clipboardCopy
		},
		{
			image: 'paste.gif',
			attachedFunction: RichText.actions.clipboardPaste
		},
		{
			image: 'separator.gif',
			attachedFunction: false
		},
		{
			image: 'undo.gif',
			attachedFunction: RichText.actions.undoAction
		},
		{
			image: 'redo.gif',
			attachedFunction: RichText.actions.redoAction
		},
		{
			image: 'code.gif',
			attachedFunction: RichText.actions.showCode
		}
	];

//-->