
function initCompactRTE(imgPath, incPath, css, genXHTML){
	// CM 05/04/05 check args for compatibility with old RTE implementations
	if (arguments.length == 3) {
		genXHTML = generateXHTML;
	}
	//set paths vars
	imagesPath = imgPath;
	includesPath = incPath;
	cssFile = css;
	generateXHTML = genXHTML;
	if(isRichText) document.writeln('<style type="text/css">@import "' + includesPath + 'rte.css";</style>');
	if(isIE){
	  document.onmouseover = ie_btnfx;
	  document.onmouseout  = ie_btnfx;
	  document.onmousedown = ie_btnfx;
	  document.onmouseup   = ie_btnfx;
  }else{
	  minWidth = minWidth-48;
	  wrapWidth = wrapWidth-102;
  }
}

function writeCompactRichText(rte, html, css, width, height, buttons, readOnly, fullscreen) {
	
	currentRTE = rte;
	if(allRTEs.length > 0) allRTEs += ";";
	allRTEs += rte;
	// CM 06/04/05 stops single quotes from messing everything up
	html=replaceIt(html,'\'','&apos;');
	// CM 05/04/05 a bit of juggling for compatibility with old RTE implementations
	if (arguments.length == 6) {
		fullscreen = false;
		readOnly = buttons;
		buttons = height;
		height = width;
		width = css;
		css = "";
	}
	var iconWrapWidth = wrapWidth;
	if(readOnly) buttons = false;
	if(fullscreen)
	{
		readOnly = false; // fullscreen is not readOnly and must show buttons
    buttons = true;
		// resize rte on resize if the option resize_fullsrcreen = true.
		if(isRichText && resize_fullsrcreen) window.onresize = resizeRTE;
		document.body.style.margin = "0px";
    document.body.style.overflow = "hidden";
  	//adjust maximum table widths
		findSize("");
		width = obj_width;
  	if(width < iconWrapWidth) {
			height = (obj_height - 83);
		}else{
      height = (obj_height - 55);
		}
		if (width < minWidth){
      document.body.style.overflow = "auto";
      if(isIE){
				height = obj_height-22;
		  }else{
        height = obj_height-24;
	    }
      width = minWidth;
		}
		var tablewidth = width;
  }else{
	  fullscreen = false;
	  iconWrapWidth = iconWrapWidth-25;
		//adjust minimum table widths
		if (buttons && (width < minWidth)) width = minWidth;
		if(isIE){
	    var tablewidth = width;
	  }else{
		  var tablewidth = width + 4;
	  }
  }
	if(isRichText){
		var rte_css = "";
		if(css.length > 0) {
	    rte_css = css;
		}else{
      rte_css = cssFile;
		}
		document.writeln('<span class="rteDiv">');
		if(buttons){
				document.writeln('<table class="rteBk" cellpadding="0" cellspacing="0" id="Buttons1_'+rte+'" width="' + tablewidth + '">');
				document.writeln('<tbody><tr>');
    			document.writeln('<td><select id="formatblock_'+rte+'" onchange="selectFont(\''+rte+'\', this.id);" style="font-size:14px;width:80px;height:20px;margin:1px;">');
			document.writeln(lblFormat);
			document.writeln('</select></td><td>');
				insertImg(lblTextColor,"textcolor.gif","dlgColorPalette('"+rte+"','forecolor',event)","forecolor_"+rte);
    
			insertImg(lblBold,"bold.gif","rteCommand('"+rte+"','bold')");
     		insertImg(lblItalic,"italic.gif","rteCommand('"+rte+"','italic')");
      		insertImg(lblUnderline,"underline.gif","rteCommand('"+rte+"','underline')");
			
     		 insertImg(lblInsertLink,"hyperlink.gif","dlgLaunch('"+rte+"','link')");
     		 insertImg(lblAddImage,"image.gif","dlgLaunch('"+rte+"','image')");
     		 insertImg(lblAddFile,"attach.gif","dlgLaunch('"+rte+"','file')");
     		 
    	  
     		 document.writeln('<td width="100%"></td></tr></tbody></table>');
      }
		document.writeln('<iframe id="'+rte+'" width="' + (tablewidth - 2) + 'px" height="' + height + 'px" frameborder=0 style="border: 1px solid #d2d2d2" src="' + includesPath + 'blank.htm" onfocus="dlgCleanUp();"></iframe>');
		if(!readOnly){
		  document.writeln('<table id="vs'+rte+'" name="vs'+rte+'" class="rteBk" cellpadding=0 cellspacing=0 border=0 width="' + tablewidth + '" style="display: none;"><tr>');
			document.writeln('<td onclick="toggleHTMLSrc(\''+rte+'\', ' + buttons + ');" nowrap><img class="rteBar" src="'+imagesPath+'bar.gif" alt="" align=absmiddle><span id="imgSrc'+rte+'"><img src="'+imagesPath+'code.gif" alt="" title="" style="margin:1px;" align=absmiddle></span><span id="txtSrc'+rte+'" style="font-family:tahoma,sans-serif;font-size:12px;color:#0000ff;CURSOR: default;">'+lblModeHTML+'</span></td>');
			document.writeln('<td width="100%" nowrap>&nbsp;</td></tr></table>');
		}
		document.writeln('<iframe width="142" height="98" id="cp'+rte+'" src="' + includesPath + 'palette.htm" scrolling="no" frameborder=0 style="margin:0;border:0;visibility:hidden;position:absolute;border:1px solid #cdcdcd;top:-1000px;left:-1000px"></iframe>');
		document.writeln('<input type="hidden" id="hdn'+rte+'" name="'+rte+'" value="" style="position: absolute;left:-1000px;top:-1000px;">');
		if(!fullscreen) document.writeln('<input type="hidden" id="size'+rte+'" name="size'+rte+'" value="'+height+'" style="position: absolute;left:-1000px;top:-1000px;">');
		document.writeln('</span>');
    document.getElementById('hdn'+rte).value = html;
    enableDesignMode(rte, html, rte_css, readOnly);
	}else{
		buttons = false;
		if(fullscreen && height > 90) height = (height - 75);tablewidth=tablewidth-30;
		// CM non-designMode() UI
		html = parseBreaks(html);
		document.writeln('<div style="font:12px Verdana, Arial, Helvetica, sans-serif;width: ' + tablewidth + 'px;padding:15px;">');
		if(!readOnly){
		  document.writeln('<div style="color:gray">'+lblnon_designMode+'</div><br>');
		  document.writeln('<input type="radio" name="' + rte + '_autobr" value="1" checked="checked" onclick="autoBRon(\'' + rte + '\');" /> '+lblAutoBR+'<input type="radio" name="' + rte + '_autobr" value="0" onclick="autoBRoff(\'' + rte + '\');" />'+lblRawHTML+'<br>');
		  document.writeln('<textarea name="'+rte+'" id="'+rte+'" style="width: ' + tablewidth + 'px; height: ' + height + 'px;">' + html + '</textarea>');
		}else{
			document.writeln('<textarea name="'+rte+'" id="'+rte+'" style="width: ' + tablewidth + 'px; height: ' + height + 'px;" readonly=readonly>' + html + '</textarea>');
		}
		if(fullscreen) document.writeln('<br><input type="submit" value="'+btnText+'" />');
		document.writeln('</div>');
	}
}

