function UtilBeginScript(){
return String.fromCharCode(60,115,99,114,105,112,116,62);
}

function UtilEndScript(){
return String.fromCharCode(60,47,115,99,114,105,112,116,62);
}

function IDGenerator(nextID){
	this.nextID=nextID;
	this.GenerateID=IDGeneratorGenerateID;
}

function IDGeneratorGenerateID(){
	return this.nextID++;
}

var BUTTON_IMAGE_PREFIX="buttonImage";
var BUTTON_DIV_PREFIX="buttonDiv";
var BUTTON_PAD1_PREFIX="buttonPad1";
var BUTTON_PAD2_PREFIX="buttonPad2";
var buttonMap=new Object();

function Button(idGenerator,caption,action,image){
	this.idGenerator=idGenerator;
	this.caption=caption;
	this.action=action;
	this.image=image;
	this.enabled=true;
	this.Instantiate=ButtonInstantiate;
	this.Enable=ButtonEnable;
}

function ButtonInstantiate(){
	this.id=this.idGenerator.GenerateID();
	buttonMap[this.id]=this;
	var html="";
	html+='<div id="'+BUTTON_DIV_PREFIX+this.id+'" class="ButtonNormal"';
	html+=' onselectstart="ButtonOnSelectStart()"';
	html+=' ondragstart="ButtonOnDragStart()"';
	html+=' onmousedown="ButtonOnMouseDown(this)"';
	html+=' onmouseup="ButtonOnMouseUp(this)"';
	html+=' onmouseout="ButtonOnMouseOut(this)"';
	html+=' onmouseover="ButtonOnMouseOver(this)"';
	html+=' onclick="ButtonOnClick(this)"';
	html+=' ondblclick="ButtonOnDblClick(this)">';
	html+='<table cellpadding=0 cellspacing=0 border=0><tr><td>';
	html+='<img id="'+BUTTON_PAD1_PREFIX+this.id+'" width=1 height=1></td><td></td><td></td></tr><tr><td></td><td>';
	html+='<img id="'+BUTTON_IMAGE_PREFIX+this.id+'" src="'+this.image+'" title="'+this.caption+'" class="Image"></td><td></td></tr><tr><td></td><td></td><td>';
	html+='<img id="'+BUTTON_PAD2_PREFIX+this.id+'" width=1 height=1></td></tr></table>';
	html+='</div>';
	document.write(html);
}

function ButtonEnable(enabled){
	this.enabled=enabled;
	if (this.enabled){
		document.all[BUTTON_DIV_PREFIX+this.id].className="ButtonNormal";
	}else{
		document.all[BUTTON_DIV_PREFIX+this.id].className="ButtonDisabled";
	}
}

function ButtonOnSelectStart(){
	window.event.returnValue=false;
}

function ButtonOnDragStart(){
	window.event.returnValue=false;
}

function ButtonOnMouseDown(element){
	if (event.button == 1){
		var id=element.id.substring(BUTTON_DIV_PREFIX.length,element.id.length);
		var button=buttonMap[id];
		if (button.enabled){
			ButtonPushButton(id);
		}
	}
}

function ButtonOnMouseUp(element){
	if (event.button == 1){
		var id=element.id.substring(BUTTON_DIV_PREFIX.length,element.id.length);
		var button=buttonMap[id];
		if (button.enabled){
			ButtonReleaseButton(id);
		}
	}
}

function ButtonOnMouseOut(element){
	var id=element.id.substring(BUTTON_DIV_PREFIX.length,element.id.length);
	var button=buttonMap[id];
	if (button.enabled){
		ButtonReleaseButton(id);
	}
}

function ButtonOnMouseOver(element){
	var id=element.id.substring(BUTTON_DIV_PREFIX.length,element.id.length);
	var button=buttonMap[id];
	if (button.enabled){
		ButtonReleaseButton(id);
		document.all[BUTTON_DIV_PREFIX+id].className="ButtonMouseOver";
	}
}

function ButtonOnClick(element){
	var id=element.id.substring(BUTTON_DIV_PREFIX.length,element.id.length);
	var button=buttonMap[id];
	if (button.enabled){
		eval(button.action);
	}
}

function ButtonOnDblClick(element){
	ButtonOnClick(element);
}

function ButtonPushButton(id){
	document.all[BUTTON_PAD1_PREFIX+id].width=2;
	document.all[BUTTON_PAD1_PREFIX+id].height=2;
	document.all[BUTTON_PAD2_PREFIX+id].width=0;
	document.all[BUTTON_PAD2_PREFIX+id].height=0;
	document.all[BUTTON_DIV_PREFIX+id].className="ButtonPressed";
}

function ButtonReleaseButton(id){
	document.all[BUTTON_PAD1_PREFIX+id].width=1;
	document.all[BUTTON_PAD1_PREFIX+id].height=1;
	document.all[BUTTON_PAD2_PREFIX+id].width=1;
	document.all[BUTTON_PAD2_PREFIX+id].height=1;
	document.all[BUTTON_DIV_PREFIX+id].className="ButtonNormal";
}

var EDITOR_COMPOSITION_PREFIX="editorComposition";
var EDITOR_PARAGRAPH_PREFIX="editorParagraph";
var EDITOR_LIST_AND_INDENT_PREFIX="editorListAndIndent";
var EDITOR_TOP_TOOLBAR_PREFIX="editorTopToolbar";
var EDITOR_MIDDLE_TOOLBAR_PREFIX="editorMiddleToolbar";
var EDITOR_BOTTOM_TOOLBAR_PREFIX="editorBottomToolbar";
var EDITOR_SMILEY_BUTTON_PREFIX="editorSmileyButton";
var EDITOR_IMAGE_CHOOSER_PREFIX="editorImageChooser";
var editorMap=new Object();
var editorIDGenerator=null;

function Editor(idGenerator,value,height){
	this.idGenerator=idGenerator;
	this.textMode=false;
	this.brief=false;
	this.instantiated=false;
	this.Instantiate=EditorInstantiate;
	this.GetText=EditorGetText;
	this.SetText=EditorSetText;
	this.GetHTML=EditorGetHTML;
	this.SetHTML=EditorSetHTML;
	this.GetBrief=EditorGetBrief;
	this.SetBrief=EditorSetBrief;
	//--new properties------------------------
	this.value=value;
	this.height=height;
}

function EditorInstantiate(){
	if (this.instantiated){
		return;
	}
	this.id=this.idGenerator.GenerateID();
	editorMap[this.id]=this;
	editorIDGenerator=this.idGenerator;
	var imgPath="images/";
	var html="";
	html+="<table cellpadding=0 cellspacing=0 border=0 width='100%'>";
	html+="<tr>";
	html+="<td id='"+EDITOR_TOP_TOOLBAR_PREFIX+this.id+"' class='Toolbar'>";
	html+="<table cellpadding=0 cellspacing=0 border=0>";
	html+="<tr>";
	
	html+="<td>";
	html+="<span id='"+EDITOR_PARAGRAPH_PREFIX+this.id+"' style='display:"+(this.brief ? "none" : "inline")+"'>";
	html+="<select class='List' onchange='EditorOnParagraph("+this.id+",this)'>";
	html+="<option class='Heading'>Paragraph</option>";
	html+="<option value='Normal'>Normal</option>";
	html+="<option value='Heading 1'>Heading 1</option>";
	html+="<option value='Heading 2'>Heading 2</option>";
	html+="<option value='Heading 3'>Heading 3</option>";
	html+="<option value='Heading 4'>Heading 4</option>";
	html+="<option value='Heading 5'>Heading 5</option>";
	html+="<option value='Heading 6'>Heading 6</option>";
	html+="<option value='Address'>Address</option>";
	html+="<option value='Formatted'>Formatted</option>";
	html+="</select>";
	html+="</span>";
	html+="</td>";
	html+="<td>";
	html+="<select class='List' onchange='EditorOnFont("+this.id+",this)'>";
	html+="<option class='Heading'>Font</option>";
	html+="<option value='Arial'>Arial</option>";
	html+="<option value='Arial Black'>Arial Black</option>";
	html+="<option value='Arial Narrow'>Arial Narrow</option>";
	html+="<option value='Comic Sans MS'>Comic Sans MS</option>";
	html+="<option value='Courier New'>Courier New</option>";
	html+="<option value='System'>System</option>";
	html+="<option value='Times New Roman'>Times New Roman</option>";
	html+="<option value='Verdana'>Verdana</option>";
	html+="<option value='Wingdings'>Wingdings</option>";
			
	html+="</select>";
	html+="</td>";
	html+="<td>";
	html+="<select class='List' onchange='EditorOnSize("+this.id+",this)'>";
	html+="<option class='Heading'>Size</option>";
	html+="<option value='1'>1</option>";
	html+="<option value='2'>2</option>";
	html+="<option value='3'>3</option>";
	html+="<option value='4'>4</option>";
	html+="<option value='5'>5</option>";
	html+="<option value='6'>6</option>";
	html+="<option value='7'>7</option>";
	html+="</select>";
	html+="</td>";
	html+="<td>";
	html+="<input type='checkbox' onclick='EditorOnViewHTMLSource("+this.id+",this.checked)'>";
	html+="</td>";
	html+="<td class='List'>";
	html+="View HTML Source";
	html+="</td>";
	html+="</tr>";
	html+="</table>";
	html+="</td>";
	html+="</tr>";
	html+="<tr>";
	html+="<td id='"+EDITOR_MIDDLE_TOOLBAR_PREFIX+this.id+"' class='Toolbar'>";
	html+="<table cellpadding=0 cellspacing=0 border=0>";
	html+="<tr>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var boldButton=new Button(editorIDGenerator,'Bold','EditorOnBold("+this.id+")','"+imgPath+"bold.gif');";
	html+="boldButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var italicButton=new Button(editorIDGenerator,'Italic','EditorOnItalic("+this.id+")','"+imgPath+"italic.gif');";
	html+="italicButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var underlineButton=new Button(editorIDGenerator,'Underline','EditorOnUnderline("+this.id+")','"+imgPath+"uline.gif');";
	html+="underlineButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+="<div class='Divider'></div>";
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var undoButton=new Button(editorIDGenerator,'Undo','EditorOnUndo("+this.id+")','"+imgPath+"undo.gif');";
	html+="undoButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var redoButton=new Button(editorIDGenerator,'Redo','EditorOnRedo("+this.id+")','"+imgPath+"redo.gif');";
	html+="redoButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+="<div class='Divider'></div>";
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var cutButton=new Button(editorIDGenerator,'Cut','EditorOnCut("+this.id+")','"+imgPath+"cut.gif');";
	html+="cutButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var copyButton=new Button(editorIDGenerator,'Copy','EditorOnCopy("+this.id+")','"+imgPath+"copy.gif');";
	html+="copyButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var pasteButton=new Button(editorIDGenerator,'Paste','EditorOnPaste("+this.id+")','"+imgPath+"paste.gif');";
	html+="pasteButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+="<div class='Divider'></div>";
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var foregroundColorButton=new Button(editorIDGenerator,'Text Color','EditorOnColor("+this.id+",1)','"+imgPath+"tpaint.gif');";
	html+="foregroundColorButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var backgroundColorButton=new Button(editorIDGenerator,'Background Color','EditorOnColor("+this.id+",2)','"+imgPath+"parea.gif');";
	html+="backgroundColorButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+="<div class='Divider'></div>";
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var alignLeftButton=new Button(editorIDGenerator,'Align Left','EditorOnAlignLeft("+this.id+")','"+imgPath+"aleft.gif');";
	html+="alignLeftButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var centerButton=new Button(editorIDGenerator,'Center','EditorOnCenter("+this.id+")','"+imgPath+"center.gif');";
	html+="centerButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var alignRightButton=new Button(editorIDGenerator,'Align Right','EditorOnAlignRight("+this.id+")','"+imgPath+"aright.gif');";
	html+="alignRightButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+="<div class='Divider'></div>";
	html+="</td>";
	html+="<td id='"+EDITOR_LIST_AND_INDENT_PREFIX+this.id+"' style='display:"+(this.brief ? "none" : "inline")+"'>";
	html+="<table cellpadding='0' cellspacing='0' border='0'>";
	html+="<tr>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var numberedListButton=new Button(editorIDGenerator,'Numbered List','EditorOnNumberedList("+this.id+")','"+imgPath+"nlist.gif');";
	html+="numberedListButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var bullettedListButton=new Button(editorIDGenerator,'Bulletted List','EditorOnBullettedList("+this.id+")','"+imgPath+"blist.gif');";
	html+="bullettedListButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+="<div class='Divider'></div>";
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var decreaseIndentButton=new Button(editorIDGenerator,'Decrease Indent','EditorOnDecreaseIndent("+this.id+")','"+imgPath+"ileft.gif');";
	html+="decreaseIndentButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var increaseIndentButton=new Button(editorIDGenerator,'Increase Indent','EditorOnIncreaseIndent("+this.id+")','"+imgPath+"iright.gif');";
	html+="increaseIndentButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+="<div class='Divider'></div>";
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var createHyperlinkButton=new Button(editorIDGenerator,'Create Hyperlink','EditorOnCreateHyperlink("+this.id+")','"+imgPath+"wlink.gif');";
	html+="createHyperlinkButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	/*html+="<td>";
	html+=UtilBeginScript();
	html+="var insertSmileyButton=new Button(editorIDGenerator,'Insert Images','EditorOnInsertCom("+this.id+",2,"+this.link_type+","+this.obj_id+","+this.obj_type+")','"+imgPath+"image.gif');";
	html+="insertSmileyButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";*/
	html+="<td>";
	html+="<div class='Divider'></div>";
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var insertTableButton=new Button(editorIDGenerator,'Insert Table','EditorOnInsertCom("+this.id+",3)','"+imgPath+"table.gif');";
	html+="insertTableButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="<td>";
	html+=UtilBeginScript();
	html+="var colorTableButton=new Button(editorIDGenerator,'Color Cell','EditorOnColor("+this.id+",3)','"+imgPath+"tbcolor.gif');";
	html+="colorTableButton.Instantiate();";
	html+=UtilEndScript();
	html+="</td>";
	html+="</tr>";
	html+="</table>";
	html+="</td>";
	html+="</tr>";
	html+="</table>";
	html+="</td>";
	html+="</tr>";
	html+="<tr>";
	html+="<td>";
	html+="<iframe id='"+EDITOR_COMPOSITION_PREFIX+this.id+"' width=\"100%\" height=\""+this.height+"\">";
	html+="</iframe>";
	html+="</td>";
	html+="</tr>";
	html+="</table>";
	document.write(html);
	
	html='<html>';
	html+='<head>';
//	html+='<link href="../js_style/styles.css" rel="stylesheet" type="text/css">';
	html+='</head>';
	html+='<style>';
	html+='body, td, p, input, select, option, textarea, .text {	font-family: Arial, Helvetica, sans-serif;	font-size: 12px;	font-style: normal;	font-weight: normal;	text-transform: none;	color: #000000;	text-decoration: none;}'
	html+='</style>';
	html+='<body leftmargin="1" topmargin="1" marginwidth="0" marginheight="0">';
	html+=this.value;
	html+='</body>';
	html+='</html>';
	eval(EDITOR_COMPOSITION_PREFIX+this.id).document.open();
	eval(EDITOR_COMPOSITION_PREFIX+this.id).document.write(html);
	eval(EDITOR_COMPOSITION_PREFIX+this.id).document.close();
	eval(EDITOR_COMPOSITION_PREFIX+this.id).document.designMode="on";
	editorIDGenerator=null;
	this.instantiated=true;
}

function  EditorGetText(){
	return eval(EDITOR_COMPOSITION_PREFIX+this.id).document.body.innerText;
}

function  EditorSetText(text){
	text=text.replace(/\n/g,"<br>");
	eval(EDITOR_COMPOSITION_PREFIX+this.id).document.body.innerHTML=text;
}

function  EditorGetHTML(){
	if (this.textMode){
		return eval(EDITOR_COMPOSITION_PREFIX+this.id).document.body.innerText;
	}
	EditorCleanHTML(this.id);
	EditorCleanHTML(this.id);
	return eval(EDITOR_COMPOSITION_PREFIX+this.id).document.body.innerHTML;
}

function  EditorSetHTML(html){
	if (this.textMode){
		eval(EDITOR_COMPOSITION_PREFIX+this.id).document.body.innerText=html;
	}else{
		eval(EDITOR_COMPOSITION_PREFIX+this.id).document.body.innerHTML=html;
	}
}

function EditorGetBrief(){
	return this.brief;
}

function EditorSetBrief(brief){
	this.brief=brief;
	var display=this.brief ? "none" : "inline";
	if (this.instantiated){
		eval(EDITOR_PARAGRAPH_PREFIX+this.id).style.display=display;
		eval(EDITOR_LIST_AND_INDENT_PREFIX+this.id).style.display=display;
	}
}

function EditorOnUndo(id){
	EditorFormat(id,"Undo");
}

function EditorOnRedo(id){
	EditorFormat(id,"Redo");
}

function EditorOnCut(id){
	EditorFormat(id,"cut");
}

function EditorOnCopy(id){
	EditorFormat(id,"copy");
}

function EditorOnPaste(id){
	EditorFormat(id,"paste");
}

function EditorOnBold(id){
	EditorFormat(id,"bold");
}

function EditorOnItalic(id){
	EditorFormat(id,"italic");
}

function EditorOnUnderline(id){
	EditorFormat(id,"underline");
}

function EditorOnColor(id,fillType){
	if (!EditorValidateMode(id)){
		return;
	}

	var color=showModalDialog("select_color.htm","","resizable:no; help:no; status:no; scroll:no;");
	if (color==null) return;
	switch (fillType){
		case 1: EditorFormat(id,"forecolor",color); break;
		case 2: EditorFormat(id,"backcolor",color); break;
		case 3:
			var objReference=GetRangeReference(id);
			objReference=EditorCheckTag(objReference,'/^(BODY)|^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
			objReference.bgColor=color;
		break;
	}
	eval(EDITOR_COMPOSITION_PREFIX+id).focus();
}

function EditorOnAlignLeft(id){
	EditorFormat(id,"justifyleft");
}

function EditorOnCenter(id){
	EditorFormat(id,"justifycenter");
}

function EditorOnAlignRight(id){
	EditorFormat(id,"justifyright");
}

function EditorOnNumberedList(id){
	EditorFormat(id,"insertOrderedList");
}

function EditorOnBullettedList(id){
	EditorFormat(id,"insertUnorderedList");
}

function EditorOnDecreaseIndent(id){
	EditorFormat(id,"outdent");
}

function EditorOnIncreaseIndent(id){
	EditorFormat(id,"indent");
}

function EditorOnCreateHyperlink(id){
	EditorOnInsertCom(id,4)
	//EditorFormat(id,"createlink");
}

/*
function CreateHyperlink(id){
	if (!EditorValidateMode(id)) {
		return;
	}
	var anchor = EditorGetElement("A", eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange().parentElement());
	var link = prompt("Enter link location (eg. http://www.yahoo.com):", anchor ? anchor.href : "http://");
	eval(EDITOR_COMPOSITION_PREFIX+id).focus();
	if (link && link != "http://") {
		if (eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.type == "None") {
			var range = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange();
			range.pasteHTML('<A HREF="' + link + '" TARGET="_blank">' + link + '</A>');
			range.select();
		}
		else {
			EditorFormat(id, "CreateLink", link);
		}
	}
	
	if (name){
		EditorFormat(id, "CreateBookmark", name);
		insert2Editor(id,'<a name=' + name + '></a>');
	}
}
*/

function EditorOnInsertCom(id,value,link_type,obj_id,obj_type){
	var str='';
	if (!EditorValidateMode(id)){
		return;
	}
	switch (value){
	case 1:
		var url='insert_link.php?control_id='+id+'&obj_id='+obj_id+'&obj_type='+obj_type+'&link_type='+link_type;
		popWin(url,400,250,'insertLink');
	break;
	case 2:
		var url='insert_image.php?control_id='+id+'&obj_id='+obj_id+'&obj_type='+obj_type;
		popWin(url,520,480,'insertImage');
	break;
	case 3:
		str=showModalDialog("insert_table.htm","","resizable:no; help:no; status:no; scroll:no;");
		if (str!=null) insert2Editor(id,str);
		eval(EDITOR_COMPOSITION_PREFIX+id).focus();
	break;
	case 4:
		str=showModalDialog("insert_link.htm","","resizable:no; help:no; status:no; scroll:no;");
		if (str!=null) insert2Editor(id,str);
		eval(EDITOR_COMPOSITION_PREFIX+id).focus();
	break;
	}
}

function insert2Editor(id,str){
//	alert(id+";"+str);
	var editor=editorMap[id];
	editor.selectionRange=eval(EDITOR_COMPOSITION_PREFIX+id).document.selection.createRange();
	var bodyRange=eval(EDITOR_COMPOSITION_PREFIX+id).document.body.createTextRange();
	if (bodyRange.inRange(editor.selectionRange)){
		editor.selectionRange.pasteHTML(str);
	}else{
		eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerHTML+=str;
		editor.selectionRange.collapse(false);
		editor.selectionRange.select();
	}
	eval(EDITOR_COMPOSITION_PREFIX+id).focus();
}

function EditorOnParagraph(id,select){
	EditorFormat(id,"formatBlock",select[select.selectedIndex].value);
	select.selectedIndex=0;
}

function EditorOnFont(id,select){
	EditorFormat(id,"fontname",select[select.selectedIndex].value);
	select.selectedIndex=0;
}

function EditorOnSize(id,select){
	EditorFormat(id,"fontsize",select[select.selectedIndex].value);
	select.selectedIndex=0;
}

function EditorOnViewHTMLSource(id,textMode){
	var editor=editorMap[id];
	editor.textMode=textMode;
	if (editor.textMode){
		EditorCleanHTML(id);
		EditorCleanHTML(id);
		eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerText=eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerHTML;
	}else{
		eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerHTML=eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerText;
	}
	eval(EDITOR_COMPOSITION_PREFIX+id).focus();
}

function EditorValidateMode(id){
	var editor=editorMap[id];
	if (!editor.textMode){
		return true;
	}
	alert("Please uncheck the 'View HTML Source' checkbox to use the toolbars.");
	eval(EDITOR_COMPOSITION_PREFIX+id).focus();
	return false;
}

function EditorFormat(id,what,opt){
	eval(EDITOR_COMPOSITION_PREFIX+id).focus();
	if (!EditorValidateMode(id)){
		return;
	}
	if (opt == "removeFormat"){
		what=opt;
		opt=null;
	}
	if (opt == null){
		eval(EDITOR_COMPOSITION_PREFIX+id).document.execCommand(what);
	}else{
		eval(EDITOR_COMPOSITION_PREFIX+id).document.execCommand(what,"",opt);
	}
}

function EditorCleanHTML(id){
	var fonts=eval(EDITOR_COMPOSITION_PREFIX+id).document.body.all.tags("FONT");
	for (var i=fonts.length - 1; i >= 0; i--){
		var font=fonts[i];
		if (font.style.backgroundColor == "#ffffff"){
			font.outerHTML=font.innerHTML;
		}
	}
}

function EditorGetElement(tagName,start){
	while (start && start.tagName != tagName){
		start=start.parentElement;
	}
	return start;
}

function GetRangeReference(id){
	eval(EDITOR_COMPOSITION_PREFIX+id).focus();
	var objReference = null;
	var RangeType = eval(EDITOR_COMPOSITION_PREFIX+id).document.selection.type;
	var selectedRange = eval(EDITOR_COMPOSITION_PREFIX+id).document.selection.createRange();

	switch(RangeType){
		case 'Control' :
			if (selectedRange.length > 0 ){
				objReference = selectedRange.item(0);
			}
		break;

		case 'None' :
			objReference = selectedRange.parentElement();
		break;

		case 'Text' :
			objReference = selectedRange.parentElement();
		break;
	}
	return objReference
}

function EditorCheckTag(item,tagName){
	if (item.tagName.search(tagName)!=-1){
		return item;
	}

	if (item.tagName=='BODY'){
		return "BODY";
	}
	
	item=item.parentElement;
	return EditorCheckTag(item,tagName);
}

function getValue(id){
	return eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerHTML;
}
function getTextValue(id){
	return eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerText;
}

function setValue(id,value){
	value=(value) ? value : "";
	eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerHTML=value;
	return true;
}
function setTextValue(id, value){
	value = (value) ? value : "";
	eval(EDITOR_COMPOSITION_PREFIX+id).document.body.innerHTML=value;
	eval(EDITOR_COMPOSITION_PREFIX+id).document.body.focus();
	return true;
}