var rte;
var browser;

//object RTE
function RTE() {
    //rte elements
    this.win;       //iframe contentwindow
    this.doc;       //iframe contentWindow.document
    this.buttons;   //buttons table
    this.frame;     //iframe editor window
    this.textarea;  //rte textarea for swich mode
    this.status;    //status bar
    
    //user variable
    this.url;       //location of editor
    this.css;       //style sheet file for editor
    this.imgChooser; 	//image directory
    this.command;   //command issued for rte
    this.range;     //currently selected range
    this.rangeEl;   //parent element(node) of range 
    this.elTree;
}

// object browser
function BROWSER() {
   var ua = navigator.userAgent.toLowerCase(); 

   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isSafari    = (ua.indexOf('safari') != - 1);
   this.isOpera     = (ua.indexOf('opera') != -1); 
   this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (ua.indexOf('icab') != -1); 
   this.isAol       = (ua.indexOf('aol') != -1); 
   this.isIE5up = (this.isIE && this.versionMajor >= 5);

   this.isRTEable  = (document.getElementById && document.designMode && !this.isSafari && !this.isKonqueror);   
}

function File(fid,fname,furl,ficon,fdesc,fw,fh) {
	
    this.id=fid;
    this.name=fname;
    this.url=furl;
    this.icon=ficon;

    this.description=fdesc;
    this.width=fw;
    this.height=fh;
    this.opened=0;
    
	this.toString = function() {
        alert("opened="+this.opened +", id="+this.id +", name="+this.name
	        +", url="+this.url +", icon="+this.icon +", description="+this.description 
            +", width="+this.width +", height="+this.height
	        );
    }                
}
var file = new File();

function replaceTextarea(taid, rteUrl, rteCSS, imgChooser, width, height) {
	if (!width) width="99%";
    if (!height) height="400px";
    if (!imgChooser) imgChooser=false;
    
    var ta = document.getElementById(taid);
    var divid = "rte_"+taid;
    
    browser=new BROWSER();
    if (!browser.isRTEable)
	    return false;
    
    rte = new RTE(taid);
    rte.url = rteUrl;
    rte.css = rteCSS;
    rte.imgChooser = imgChooser;
    document.writeln('<div class="rteDiv" id="'+divid+'" style="background-color:#cccccc">');
    writeRTE();
    document.writeln('</div>');
    
    ta.style.display = 'none';
    if (!initRTE(divid, ta.value, width, height))
    	return false;
    
    if (typeof ta.form.onsubmit == "function") {
        var frmstr = ta.form.onsubmit.toString();
        frmstr = frmstr.substring( frmstr.indexOf("{")+1 , frmstr.lastIndexOf("}") );
    }
    ta.form.onsubmit = new Function("rtePresubmit('"+taid+"');" + frmstr);   

}

//move richtext contents to textarea before submit
function rtePresubmit (taid) {
    //find RTE text area and window
    var rteEls = document.getElementById('rte_'+taid).childNodes;
    for (var i=0; i<rteEls.length; i++) {
        if ( rteEls[i].id == "rteWin" )		rte.frame    = rteEls[i];
        if ( rteEls[i].id == "rteTxt" )     rte.textarea = rteEls[i];
    }  
    rte.win = rte.frame.contentWindow;
    rte.doc = rte.win.document;
    
    //set textarea value by rteTxt value
    if (rte.textarea.style.display=="none")
	    document.getElementById(taid).value = rte.doc.body.innerHTML;
    else	      
    	document.getElementById(taid).value = rte.textarea.value;
}

//set width, set height, and turn on RTE mode
function initRTE(divid, html, width, height) {
    //set width and height of table, window, and textarea
    var rteEls = document.getElementById(divid).childNodes;
    for (var i=0; i<rteEls.length; i++) {
        if ( rteEls[i].id == "rteWin" )		rte.frame    = rteEls[i];
        if ( rteEls[i].id == "rteTxt" )     rte.textarea = rteEls[i];
        if ( rteEls[i].id == "rteButtons" ) rte.buttons  = rteEls[i];
        if ( rteEls[i].id == "rteStatus" )  rte.status  = rteEls[i];
    }
    rte.win = rte.frame.contentWindow;
    rte.doc = rte.win.document;
    
    document.getElementById(divid).style.width= width;
    if (width.indexOf("%")>0)
	    rte.frame.style.width = (parseInt(width)) + "%";
    else
    	rte.frame.style.width = (parseInt(width)) + "px";
    rte.frame.style.height = height;  
    rte.textarea.style.width = width;  
    rte.textarea.style.height = height;  
    
    var kim = document.getElementById('__kim');
    if (kim==null || kim.tagName != "A" || kim.innerHTML<="" ) {
        alert("Rich-Textarea requires a small copyright link.");
        return false;
    }
    
    var imgEls = document.getElementById(divid).getElementsByTagName("img");
    for (var i=0; i<imgEls.length; i++) {
        if (!rte.url) break;
        var x = imgEls[i].src.lastIndexOf("/");
        var imgFile = imgEls[i].src.substring(x+1,imgEls[i].src.length);
        imgEls[i].src = rte.url + "/img/" + imgFile;
    } 
    
    //turn on RTE mode
    try {
        if (browser.isGecko)
	        rte.frame.contentDocument.designMode = "on";
        rte.doc.open();
        if (rte.css)
            rte.doc.write("<head>"
                +"<link rel='stylesheet' type='text/css' href='"+rte.css+"' />"
                +"<style>td {border:1px dotted #cccccc}</style>"
                +"</head>");
        rte.doc.write("<body class=rteBody>"+html+"</body>");
        rte.doc.close();
        if (browser.isIE)
	        rte.doc.designMode = "On";
    } catch (e) {
        //gecko may take some time to enable design mode.
        //Keep looping until able to set.
        if (browser.isGecko) { 
	        setTimeout("setupRTE('"+divid+"','"+html+"','+width+','+height+');", 10);
        } else { 
	        return false;
        }
    } //end catch
    
    runTimer4CurrentCursor();
    return true;
}

function getCursorEl() {
    var pEl;
    rte.win = rte.frame.contentWindow;
    rte.doc = rte.win.document;
        
    try {
        var sel  = (browser.isIE)?
        	rte.win.document.selection : rte.win.getSelection();
        var range = (browser.isIE)? 
        	sel.createRange():sel.getRangeAt(sel.rangeCount - 1).cloneRange();
    }
    catch (e) {  //it continues although error occurs when no range
	    return false;
    }
    
    if (browser.isIE) {
        switch (sel.type) {
            case "Text":case "None":
	            pEl= range.parentElement(); break;
            case "Control":
	            pEl = range.item(0); break;
            default:
	            pEl = rte.doc;
        }
    } 
    else {
        try {
            var p = range.commonAncestorContainer;
            
            if (!range.collapsed && range.startContainer == range.endContainer 
                && range.startOffset - range.endOffset <= 1 
                && range.startContainer.hasChildNodes())
	            p = range.startContainer.childNodes[range.startOffset];
    	        while (p.nodeType == 3)
        		    p = p.parentNode;
            pEl = p;
        } catch (e) {
	        pEl = rte.doc;
        }
    }
    
    return pEl;
} //end function

function runTimer4CurrentCursor() {
    var pEl = getCursorEl();
    rte.rangeEl = pEl;
    
    showTagTree();
    setTimeout("runTimer4CurrentCursor()", 500 );
}

function showTagTree() {  
    pEl = rte.rangeEl;
   	if (pEl.tagName == "HTML" || pEl.tagName == "HEAD" )
    	return;
    if (pEl) {
        var i=0; 
        rte.elTree = new Array();
        rte.elTree[i] = pEl;   
        if (pEl) {
            while(pEl.tagName != "BODY") {
                rte.elTree[i++] = pEl;
                pEl = pEl.parentNode;
            }
        }
        
        var elTagTree="";
        for (i=0; i<rte.elTree.length; i++) {
            var	elTag = 
                    "<a href='javascript:void(0)' "
                    +"onclick='selectNodeContents(rte.elTree["+i+"])'>"
                    +rte.elTree[i].tagName.toLowerCase()+"</a>";
            elTagTree = (i==0)?elTag : elTag + "-" + elTagTree; 
        }
        rte.status.innerHTML = elTagTree;
    }
    
}

//toggle between textarea and RTE window
function toggleMode(e) {
    el = e.target || e.srcElement;
    
    //show or hide
    rte.buttons.style.visibility= (el.checked)? "hidden" : "visible";
    rte.frame.style.display= (el.checked)? "none": "block";
    rte.textarea.style.display= (el.checked)? "block": "none";
    
    //synchronize rteWindow, and textarea
    if (el.checked)   
    	rte.textarea.value = rte.doc.body.innerHTML;
    else {
	    rte.doc.body.innerHTML = rte.textarea.value;
        if (browser.isGecko)
	        rte.frame.contentDocument.designMode = "on";
        if (browser.isIE)
    	    rte.doc.designMode = "On";
    }
}

//Function to format text in the text box
function formatText(e, command, option) {
    
    rte.command = command;
    
    try {
        //when about color
        if ((command == "forecolor") || (command == "hilitecolor")) {
            var colorImg = e.target || e.srcElement;
            x = getPosX(colorImg)+20 + "px";
            y = getPosY(colorImg)+70 + "px";
            window.open(rte.url+"/palette.htm","rtepopup",
                "left="+x+",top="+y+",width=220,height=196").focus();
        }
        //when about background
        else if (command == "bgstyle"){
            var colorImg = e.target || e.srcElement;
            x = getPosX(colorImg)+20 + "px";
            y = getPosY(colorImg)+70 + "px";
            window.open(rte.url+"/background.htm","rtepopup",
    			"left="+x+",top="+y+",width=200,height=200").focus();
        } 
        //when about adding a image
        else if (command == "addImage"){
        	if (rte.imgChooser) {
                var x= (screen.availWidth/2)-(600/2);
                var y = (screen.availHeight/2)-(400/2);
                window.open(rte.imgChooser,"rtepopup",
                    "left="+x+",top="+y+",width=600,height=400").focus();
			}
            else {
	            var imgUrl = prompt("Enter an Image URL:", "");
                try {
                	rte.doc.execCommand("InsertImage", false, imgUrl);
                	rte.win.focus();
				} catch (e) {}                    
            }                
        } 
        //when about style
        else if (command == "style"){
            var colorImg = e.target || e.srcElement;
            x = getPosX(colorImg)+20 + "px";
            y = getPosY(colorImg)+70 + "px";
            window.open(rte.url+"/style.htm","rtepopup",
	            "left="+x+",top="+y+",width=200,height=350").focus();        } 
        else if (command == "createlink") {
            var szURL = prompt("Enter a URL:", "");
            try {
             	rte.doc.execCommand("Unlink", false, null);
             	rte.doc.execCommand("CreateLink", false, szURL);
            } catch (e) {
              	//do nothing although blank url is given
            }
		}         
        //for all commands
        else {
            rte.win.focus();
            rte.doc.execCommand(command, false, option);
            rte.win.focus();
        }
    } catch (e) {
	    alert(e);
    }
}

function getPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)	{
		while (obj.offsetParent)		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function getPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)	{
		while (obj.offsetParent)		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function addImage(imgUrl) {
    rte.win = rte.frame.contentWindow;
    rte.doc = rte.win.document;

    var sel  = (browser.isIE)?
	    rte.win.document.selection : rte.win.getSelection();
    var range = (browser.isIE)? 
    	sel.createRange():sel.getRangeAt(sel.rangeCount - 1).cloneRange();
    
	rte.win.focus();
    if (file.iconOnly) {
	    var fileLink = document.createElement("a");
	    var fileIcon = document.createElement("img");
	    var fileLinkText = document.createTextNode(file.name);
        fileIcon.src = file.icon;
	    fileIcon.style.verticalAlign = "middle";
        fileLink.href = file.url;
        fileLink.appendChild(fileIcon);
        fileLink.appendChild(fileLinkText);

        //insert to selected range 
        if (range && browser.isIE) 
    	    range.pasteHTML(fileLink.outerHTML);
        else 
        	range.insertNode(fileLink);
	}        
	else        
		rte.doc.execCommand("InsertImage", false, file.url);
	rte.win.focus();
}

// Called when the user clicks the Insert Table button
function insertTable(e) {
    var rows =  parseInt(prompt('Rows   :', 2));
    var cols =  parseInt(prompt('Columns:', 3));
    
    if (rows && cols && rows>0 && cols>0);
    else
	    return false;
    
    //make a table 
    var table = document.createElement("table");
    table.width=200; table.height=50
    var tbody = document.createElement("tbody");
    table.appendChild(tbody);
    for (var i = 0; i < rows; ++i) {
        var tr = document.createElement("tr");
        tbody.appendChild(tr);
        for (var j = 0; j < cols; ++j) {
            var td = document.createElement("td");
            tr.appendChild(td);
            if (browser.isGecko) 
            td.appendChild(document.createElement("br")); //no br, no display
        }
    }
    
    rte.win = rte.frame.contentWindow;
    rte.doc = rte.win.document;

    var sel  = (browser.isIE)?
	    rte.win.document.selection : rte.win.getSelection();
    var range = (browser.isIE)? 
    	sel.createRange():sel.getRangeAt(sel.rangeCount - 1).cloneRange();
    
    //insert to selected range 
    if (range && browser.isIE) 
	    range.pasteHTML(table.outerHTML);
    else 
    	range.insertNode(table);
    
};

//Function to set color
function setColor(color) {
    rte.win = rte.frame.contentWindow;
    rte.doc = rte.win.document;
        
	if (browser.isIE) {
		if (rte.command == "hilitecolor") 
        	rte.command = "backcolor";

		//retrieve selected range
        var sel  = rte.win.document.selection;
        var range = sel.createRange();
        range.select();
	}
	rte.win.focus();
	rte.doc.execCommand(rte.command, false, color);
	rte.win.focus();
}

function setStyle(prop, val) {
	rte.rangeEl.style[prop] = val;

 	if (browser.isIE) 
    	redisplay();
}

function setAttribute(attr,val ) {
	rte.rangeEl.setAttribute(attr,val);
 	if (browser.isIE) 
    	redisplay();
}

function resizeWin(e,height) {
    rte.frame.style.height = height;
    rte.textarea.style.height = height;
}

function redisplay() {  //this is for IE
  rte.frame.style.visibility="hidden";
  rte.frame.style.visibility="visible";
}

function selectNodeContents(node,pos) {
	var range;
	var collapsed = typeof pos == "undefined" ? false : true;
	if (browser.isIE) {
        if(collapsed && node.tagName 
    		&& node.tagName.toLowerCase().match(/table|img|input|select|textarea/)) {
          range = rte.doc.body.createControlRange();
          range.add(node);
        }
        else    {
            rte.win = rte.frame.contentWindow;
            rte.doc = rte.win.document;

            range = rte.doc.body.createTextRange();
            range.moveToElementText(node);
	        (collapsed) && range.collapse(pos);
        }
        range.select();
	}
	else {
        var sel = rte.win.getSelection();
        range = rte.doc.createRange();
        // Tables and Images get selected as "objects" rather than the text contents
        if(collapsed && node.tagName 
			&& node.tagName.toLowerCase().match(/table|img|input|textarea|select/))         {
          range.selectNode(node);
        }
        else  {
          range.selectNodeContents(node);
          (collapsed) && range.collapse(pos);
        }
        sel.removeAllRanges();
        sel.addRange(range);	
	}
	
}

function writeRTE() {
   document.writeln('<style>#rteButtons img {vertical-align:bottom;}</style>');
   document.writeln('<style>#rteButtons select {height:21px;}</style>');
   document.writeln('<iframe id="rteWin" marginwidth=0 marginheight=0 style="margin:1px;background-color:#ffffff;border:1px inset grey;"></iframe>');
   document.writeln('<textarea id="rteTxt" style="display:none;font-size:12px;"></textarea>');

   document.writeln('<a id="__kim" style="font-size:8px;font-weight:bolder;font-family:verdana;float:right;text-decoration:none;" href="http://tailoredweb.com">&copy;</a>');
   document.writeln('&nbsp; <select onchange="resizeWin(event, this.value);">');
   document.writeln('		<option value="">Editor Height</option>');
   document.writeln('		<option value="100px">100 pixel</option>');
   document.writeln('		<option value="200px">200 pixel</option>');
   document.writeln('		<option value="300px">300 pixel</option>');
   document.writeln('		<option value="400px">400 pixel</option>');
   document.writeln('		<option value="500px">500 pixel</option>');
   document.writeln('		<option value="600px">600 pixel</option>');
   document.writeln('</select>');
   document.writeln('<input id="view_source" type="checkbox" onclick="toggleMode(event);" />View Source');
   document.writeln('<span id="rteStatus"></span>');
   
   document.writeln('<br><span id="rteButtons" >');
   document.writeln('&nbsp;<select onchange="formatText(event, \'formatblock\', this.options[this.selectedIndex].value)">');
   document.writeln('		<option value="">[Style]</option>');
   document.writeln('		<option value="<p>">Paragraph</option>');
   document.writeln('		<option value="<h1>"><h1>Heading 1</h1></option>');
   document.writeln('		<option value="<h2>"><h2>Heading 2</h2></option>');
   document.writeln('		<option value="<h3>"><h3>Heading 3</h3></option>');
   document.writeln('		<option value="<h4>"><h4>Heading 4</h4></option>');
   document.writeln('		<option value="<h5>"><h5>Heading 5</h5></option>');
   document.writeln('		<option value="<h6>"><h6>Heading 6</h6></option>');
   document.writeln('		<option value="<address>"><addr>Address</addr></option>');
   document.writeln('		<option value="<pre>"><pre>Formatted</pre></option>');
   document.writeln('	</select>');
   document.writeln('	<select onchange="formatText(event, \'fontname\', this.options[this.selectedIndex].value);">');
   document.writeln('		<option value="">[Font]</option>');
   document.writeln('           <option style="font-family:Andale Mono IPA;" value="Andale Mono IPA">Andale Mono IPA');
   document.writeln('           <option style="font-family:Arial;" value="Arial">Arial');
   document.writeln('           <option style="font-family:Arial Narrow;" value="Arial Narrow">Arial Narrow');
   document.writeln('           <option style="font-family:Arial Black;" value="Arial Black">Arial Black');
   document.writeln('           <option style="font-family:Arial Unicode MS;" value="Arial Unicode MS">Arial Unicode MS');
   document.writeln('           <option style="font-family:Batang;" value="Batang">Batang');
   document.writeln('           <option style="font-family:Book Antiqua;" value="Book Antiqua">Book Antiqua');
   document.writeln('           <option style="font-family:Bookman Old Style;" value="Bookman Old Style">Bookman Old Style');
   document.writeln('           <option style="font-family:Century;" value="Century">Century');
   document.writeln('           <option style="font-family:Century Gothic;" value="Century Gothic">Century Gothic');
   document.writeln('           <option style="font-family:Comic Sans MS;" value="Comic Sans MS">Comic Sans MS');
   document.writeln('           <option style="font-family:Courier;" value="Courier">Courier');
   document.writeln('           <option style="font-family:Fantasy;" value="Fantasy">Fantasy');
   document.writeln('           <option style="font-family:Fixedsys;" value="Fixedsys">Fixedsys');
   document.writeln('           <option style="font-family:Garamond;" value="Garamond">Garamond');
   document.writeln('           <option style="font-family:Haettenschweiler;" value="Haettenschweiler">Haettenschweiler');
   document.writeln('           <option style="font-family:Impact;" value="Impact">Impact');
   document.writeln('           <option style="font-family:Lucida Console;" value="Lucida Console">Lucida Console');
   document.writeln('           <option style="font-family:Lucida Sans Unicode;" value="Lucida Sans Unicode">Lucida Sans Unicode');
   document.writeln('           <option style="font-family:Microsoft Sans Serif;" value="Microsoft Sans Serif">Microsoft Sans Serif');
   document.writeln('           <option style="font-family:Monotype Corsiva;" value="Monotype Corsiva">Monotype Corsiva');
   document.writeln('           <option style="font-family:Monospace;" value="Monospace">Monospace');
   document.writeln('           <option style="font-family:MT Extra;" value="MT Extra">MT Extra');
   document.writeln('           <option style="font-family:Palatino Linotype;" value="Palatino Linotype">Palatino Linotype');
   document.writeln('           <option style="font-family:Roman;" value="Roman">Roman');
   document.writeln('           <option style="font-family:Script;" value="Script">Script');
   document.writeln('           <option style="font-family:Small Font;" value="Small Font">Small Font');
   document.writeln('           <option style="font-family:SimSun;" value="SimSun">SimSun');
   document.writeln('           <option style="font-family:Symbol;" value="Symbol">Symbol');
   document.writeln('           <option style="font-family:System;" value="System">System');
   document.writeln('           <option style="font-family:Tahoma;" value="Tahoma">Tahoma');
   document.writeln('           <option style="font-family:Terminal;" value="Terminal">Terminal');
   document.writeln('           <option style="font-family:Times New Roman;" value="Times New Roman">Times New Roman');
   document.writeln('           <option style="font-family:Trebuchet MS;" value="Trebuchet MS">Trebuchet MS');
   document.writeln('           <option style="font-family:Verdana;" value="Verdana">Verdana');
   document.writeln('           <option style="font-family:Wingdings;" value="Wingdings">Wingdings');
   document.writeln('	</select>');
   document.writeln('	<select onchange="formatText(event, \'fontsize\', this.options[this.selectedIndex].value);">');
   document.writeln('		<option value="">[Size]</option>');
   document.writeln('		<option value="1">1</option>');
   document.writeln('		<option value="2">2</option>');
   document.writeln('		<option value="3">3</option>');
   document.writeln('		<option value="4">4</option>');
   document.writeln('		<option value="5">5</option>');
   document.writeln('		<option value="6">6</option>');
   document.writeln('		<option value="7">7</option>');
   document.writeln('	</select>');
   document.writeln('	<br>');
   document.write('<img src="img/bold.gif" title="bold" onClick="formatText(event,  \'bold\', \'\')" ');
   document.write('/><img src="img/italic.gif" title="Italic" onClick="formatText(event,  \'italic\', \'\')"');
   document.write('/><img src="img/underline.gif" title="Underline" onClick="formatText(event,  \'underline\', \'\')"/>');
   document.write('|');
   document.write('<img src="img/left_just.gif" title="Align Left" onClick="formatText(event,  \'justifyleft\', \'\')"');
   document.write('/><img src="img/centre.gif" title="Center" onClick="formatText(event,  \'justifycenter\', \'\')"');
   document.write('/><img src="img/right_just.gif" title="Align Right" onClick="formatText(event,  \'justifyright\', \'\')"');
   document.write('/><img src="img/justifyfull.gif" title="Justify Full" onclick="formatText(event,  \'justifyfull\', \'\')"/>');
   document.write('|');
   document.write('<img src="img/hr.gif" title="Horizontal Rule" onClick="formatText(event,  \'inserthorizontalrule\', \'\')"/>');
   document.write('|');
   document.write('<img src="img/numbered_list.gif" title="Ordered List" onClick="formatText(event,  \'insertorderedlist\', \'\')"');
   document.write('/><img src="img/list.gif" title="Unordered List" onClick="formatText(event,  \'insertunorderedlist\', \'\')"/>');
   document.write('|');
   document.write('<img src="img/outdent.gif" title="Outdent" onClick="formatText(event,  \'outdent\', \'\')"');
   document.write('/><img src="img/indent.gif" title="Indent" onClick="formatText(event,  \'indent\', \'\')"');
   document.write('/><img src="img/textcolor.gif" title="Text Color" onClick="formatText(event,  \'forecolor\', \'\')"');
   document.write('/><img src="img/bgcolor.gif" title="Background Color" onClick="formatText(event,  \'hilitecolor\', \'\')"/>');
   document.write('|');
   document.write('<img src="img/hyperlink.gif" title="Insert Link" onClick="formatText(event,  \'createlink\')"');
   //document.write('/><img src="img/image.gif" title="Add Image" onClick="addImage(event)"');
   document.write('/><img src="img/image.gif" title="Add Image" onClick="formatText(event, \'addImage\')"');
   document.write('/><img src="img/table.gif" title="Insert Table" onClick="insertTable(event)"/>');
   document.write('|');
   document.write('<img src="img/style.gif" title="Set Style" onClick="formatText(event,  \'style\')"');
   document.write('/>');
   document.write('</span>');
}