//Note by tog000
//This cryptic script can be used with the following code:
// <input type="button" onclick="Format('Underline')" value="U" />
// It will apply the changes to an iframe called "textbox"

/*
var Editor; function Format(action) { Editor.execCommand(action, false, null); } function Colour(colour) { Editor.execCommand("forecolor",false, colour); } window.onload = function() { Editor = document.getElementById('textbox').contentWindow.document; Editor.designMode = "on"; 
document.getElementById('textbox').contentWindow.document.innerHTML="<span style=\"font-size:11px;color:rgb(255,255,255);\"><br/></span>"
document.getElementById('textbox').contentWindow.document.style.backgroundColor="red";
//forms = document.getElementsById('editor').onsubmit = function() { var text = document.getElementById('text'); text.value = Editor.body.innerHTML; } 
} */

var Editor; 

function Format(action) {Editor.execCommand(action, false, null);} 
function Colour(colour) {Editor.execCommand("forecolor",false, colour);} 


//window.addEvent('domready',function(){
window.onload=function(){
//function initializeIframe(){
	if($('textbox')){
		Editor = $('textbox').contentWindow.document; 
		Editor.designMode = "on";
		try{
			Editor.body.innerHTML=tmpContent;
		}catch(err){
			window.status="[e] IFRAME";
		}
		//alert($('textbox').contentWindow.document.designMode)
		//$('textbox').contentWindow.document.designMode="on";
		//$('textbox').contentWindow.document.body.innerHTML="<span style=\"font-size:11px;color:blue;			\">Write your text here<br/></span>"
	}
};

function initializeIframe(){
			Editor = $('textbox').contentWindow.document;
			Editor.designMode = "on";
			//alert("DesignMode: "+Editor.designMode+", content: "+tmpContent)
			try{
				$('textbox').contentWindow.document.body.innerHTML=tmpContent;
			}catch(e){
				//alert("wtf: "+e);
				void(0);
			}
}