function initEditor() {
	textEdit.document.designMode="On"
	textEdit.document.open()
	textEdit.document.write("")
	textEdit.document.close()
	textEdit.focus()
}
format="HTML";
function swapModes() {
	if (format=="HTML") {
		textEdit.document.body.innerText = textEdit.document.body.innerHTML
		textEdit.document.body.style.fontFamily = "monospace"
		textEdit.document.body.style.fontSize = "10pt"
		format="Text"
 	}
	else {
   		textEdit.document.body.innerHTML = textEdit.document.body.innerText
   		textEdit.document.body.style.fontFamily = ""
   		textEdit.document.body.style.fontSize =""
   		format="HTML"
 	}
	document.form1.btnSwapView.value = "View "+format;
}
function execCommand(command) {
textEdit.focus()
 if (format=="HTML") {
  var edit = textEdit.document.selection.createRange()
  if (arguments[1]==null){
   edit.execCommand(command)
  }
  else{
   edit.execCommand(command,false, arguments[1])
  }
  edit.select()
  textEdit.focus()
 }
}
function doFormat(what) {
	if(what == "FontName"){
		if(arguments[1] != 1){
			execCommand(what, arguments[1]);
		} 
	}
	else if(what == "FontSize"){
    	if(arguments[1] != 1){
    	  execCommand(what, arguments[1]);
    	} 
	}
	else {
	   execCommand(what, arguments[1]);
	}
}
function ColorPalette_OnClick(colorString){
	cpick.bgColor=colorString;
	doFormat('ForeColor',colorString);
}
function AddLink(){
	var sText = document.selection.createRange();
	if (!sText==""){
		 document.execCommand("CreateLink");
		 if (sText.parentElement().tagName == "A"){
		   sText.parentElement().innerText=sText.text;
		   document.execCommand("ForeColor","false","#FF0033");
		 }    
	  }
	else{
		alert("Please select some blue text!");
	}   
}
