// JScript File

	var bLoad = false
	var public_description=new Editor
	
	function Editor() {
		this.put_html = put_html
		this.get_html = get_html
	
		this.checkHTML = checkHTML
	}
		
	function cleanupHTML() {
		bodyTags=idEdit.document.body.all, i
		for (i=bodyTags.tags("FONT").length-1;i >= 0;i--)
		if (bodyTags.tags("FONT")[i].style.backgroundColor="#ffffff") {
			bodyTags.tags("FONT")[i].style.backgroundColor=""
			if (bodyTags.tags("FONT")[i].outerHTML.substring(0,6)=="<FONT>")
				bodyTags.tags("FONT")[i].outerHTML=bodyTags.tags("FONT")[i].innerHTML
		}
	}
	
	function checkHTML() {
		var bAllowHead=false
		mW.click()
		var badStuff=new Array("IFRAME","SCRIPT","LAYER","ILAYER","OBJECT","APPLET","EMBED","FORM","INPUT","BUTTON","TEXTAREA")
		var headStuff=new Array("HTML","BODY","TITLE","BASE","LINK","META")
		var hasStuff=new Array()
		var bodyTags=idEdit.document.body.all
		var i=0
		for (i=0;i<badStuff.length;i++)
			if (bodyTags.tags(badStuff[i]).length>0)
				hasStuff[hasStuff.length]=badStuff[i]
		if (!bAllowHead)
			for (i=0;i<headStuff.length;i++)
				if (bodyTags.tags(headStuff[i]).length>0)
					hasStuff[hasStuff.length]=headStuff[i]
		var str=""
		if (hasStuff.length>0) {
			str="Please remove the following HTML Tags from your message and resubmit:"
			for (i=0;i<hasStuff.length;i++)
				str+="\n "+hasStuff[i]
			str+= "\nRemember, when using HTML Mode you may need to escape \nthe brackets surrounding tags (< and >) with &lt; and &gt;"
			setTimeout("mH.click()",0)
		}
		return str
	}
	
	function get_html() {
		if (bHtmlMode) {
			cleanupHTML()
			return idEdit.document.body.innerHTML 
		}
		else 
			return idEdit.document.body.innerText;
	}
	function put_html(sVal) {
		if (bHtmlMode) 
			idEdit.document.body.innerHTML=sVal 
		else 
			idEdit.document.body.innerText=sVal
	}

	var sHeader="<BODY STYLE=\"font:10pt geneva,arial,sans-serif\">"
	var bHtmlMode=true
	var sel=null

	function displayError() {alert("Formatting toolbar is only accessible in Design mode");idEdit.focus()}

	function format(what,opt) {
		if (!bHtmlMode) {
			displayError()
			return
		}
		if (opt=="removeFormat"){
			what=opt;opt=null
		}
		if (opt=="CustomFont")
			opt = prompt("Format your text with what font face?","Geneva, Arial, Sans-Serif")
		if ((opt=="") && (what=="forecolor"))
			opt = prompt("Format your text with what color?","Black")
		if (bHtmlMode) {s
			if (opt==null)
				idEdit.document.execCommand(what)
			else
				idEdit.document.execCommand(what,"",opt)
			var s=idEdit.document.selection.createRange(),p=s.parentElement()  
			idEdit.focus()
		} 
		sel=null
	}

	function getEl(sTag,start) {
		while ((start!=null) && (start.tagName!=sTag))
			start = start.parentElement
		return start
	}

	function createLink() {
		if (!bHtmlMode) {
			displayError()
			return
		}
		var isA = getEl("A",idEdit.document.selection.createRange().parentElement())
		var str=prompt("Where do you want to link to? (eg., http:\/\/www.google.com\/)",isA ? isA.href : "http:\/\/")
		if ((str!=null) && (str!="http://")) {
			if ((idEdit.document.selection.type=="None") && (!isA)) {
				var sel=idEdit.document.selection.createRange()
				sel.pasteHTML("<A HREF=\""+str+"\">"+str+"</A> ")
				sel.select()
			}
			else
				format("CreateLink",str)
		}
		else
			idEdit.focus()
	}

	function setMode(bNewMode) {
		if (bNewMode!=bHtmlMode) {
			if (bNewMode) {
				var sContents=idEdit.document.body.innerText 
				idEdit.document.open()
				idEdit.document.write(sHeader)
				idEdit.document.close()
				idEdit.document.body.innerHTML=sContents				
			}
			else {
				cleanupHTML()
				var sContents=idEdit.document.body.innerHTML
				idEdit.document.open()
				idEdit.document.write("<BODY style=\"font:10pt courier, monospace\">")
				idEdit.document.close()
				idEdit.document.body.innerText=sContents
			}
			bHtmlMode=bNewMode
			for (var i=0;i<htmlOnly.children.length;i++)
				htmlOnly.children[i].disabled=(!bHtmlMode)
		}
		modeA.className=bHtmlMode?"current":"";modeB.className=bHtmlMode?"":"current"
	}