DECMD_BOLD =                      5000;
DECMD_COPY =                      5002;
DECMD_CUT =                       5003;
DECMD_DELETE =                    5004;
DECMD_DELETECELLS =               5005;
DECMD_DELETECOLS =                5006;
DECMD_DELETEROWS =                5007;
DECMD_FINDTEXT =                  5008;
DECMD_FONT =                      5009;
DECMD_GETBACKCOLOR =              5010;
DECMD_GETBLOCKFMT =               5011;
DECMD_GETBLOCKFMTNAMES =          5012;
DECMD_GETFONTNAME =               5013;
DECMD_GETFONTSIZE =               5014;
DECMD_GETFORECOLOR =              5015;
DECMD_HYPERLINK =                 5016;
DECMD_IMAGE =                     5017;
DECMD_INDENT =                    5018;
DECMD_INSERTCELL =                5019;
DECMD_INSERTCOL =                 5020;
DECMD_INSERTROW =                 5021;
DECMD_INSERTTABLE =               5022;
DECMD_ITALIC =                    5023;
DECMD_JUSTIFYCENTER =             5024;
DECMD_JUSTIFYLEFT =               5025;
DECMD_JUSTIFYRIGHT =              5026;
DECMD_LOCK_ELEMENT =              5027;
DECMD_MAKE_ABSOLUTE =             5028;
DECMD_MERGECELLS =                5029;
DECMD_ORDERLIST =                 5030;
DECMD_OUTDENT =                   5031;
DECMD_PASTE =                     5032;
DECMD_REDO =                      5033;
DECMD_REMOVEFORMAT =              5034;
DECMD_SELECTALL =                 5035;
DECMD_SEND_BACKWARD =             5036;
DECMD_BRING_FORWARD =             5037;
DECMD_SEND_BELOW_TEXT =           5038;
DECMD_BRING_ABOVE_TEXT =          5039;
DECMD_SEND_TO_BACK =              5040;
DECMD_BRING_TO_FRONT =            5041;
DECMD_SETBACKCOLOR =              5042;
DECMD_SETBLOCKFMT =               5043;
DECMD_SETFONTNAME =               5044;
DECMD_SETFONTSIZE =               5045;
DECMD_SETFORECOLOR =              5046;
DECMD_SPLITCELL =                 5047;
DECMD_UNDERLINE =                 5048;
DECMD_UNDO =                      5049;
DECMD_UNLINK =                    5050;
DECMD_UNORDERLIST =               5051;
DECMD_PROPERTIES =                5052;

// OLECMDEXECOPT  
OLECMDEXECOPT_DODEFAULT =         0;
OLECMDEXECOPT_PROMPTUSER =        1;
OLECMDEXECOPT_DONTPROMPTUSER =    2;

// DHTMLEDITCMDF
DECMDF_NOTSUPPORTED =             0;
DECMDF_DISABLED =                 1;
DECMDF_ENABLED =                  3;
DECMDF_LATCHED =                  7;
DECMDF_NINCHED =                  11;

// DHTMLEDITAPPEARANCE
DEAPPEARANCE_FLAT =               0;
DEAPPEARANCE_3D =                 1;

// OLE_TRISTATE
OLE_TRISTATE_UNCHECKED =          0;
OLE_TRISTATE_CHECKED =            1;
OLE_TRISTATE_GRAY =               2;

//var displayMode = 'RICH';	//display mode
//var swapToMode = 'CODE';	// the mode to which the swapping is made 

var activeForm ;
var activeFormName;
var activeDOMPropertyName;
var selectableNodes = new Array();
var svdSelection;

var errorString = "Sorry but this web page needs\nWindows95 and Internet Explorer 5 or above to view."
var Ok = "false";
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && parseFloat(navigator.appVersion) >= 4){
	Ok = "true";
} else {
	Ok = "false";
}
if (Ok == "false") {
	alert(errorString);
}

function logic_checkSubmit2() {
	nm = activeElementName;
	var aaa = eval("document.forms[0]."+nm.replace(/_htmlObject/,"")+"");
	tmp = util_remSpaces(activeElement.FilterSourceCode(activeElement.DOM.body.innerHTML));
	if (aaa.value != tmp ) {
		aaa.value = tmp;
	}
}

function cookie_deleteCookie (name, path, domain) {
   if (cookie_getCookie(name)) {
        document.cookie = name + "=" +
                                       ((path) ? "; path=" + path : "") +
                                       ((domain) ? "; domain=" + domain : "") +
                                       "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
} 
function cookie_getCookie(name) {
   var prefix = name + "=";
   var begin = document.cookie.indexOf(prefix);
   if (begin == -1) return null;
   var end = document.cookie.indexOf(";", begin);
   if (end == -1) end = document.cookie.length;
   return unescape(document.cookie.substring(begin + prefix.length, end));
}

function cookie_setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) +
                                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                                ((path) ? "; path=" + path : "") +
                                ((domain) ? "; domain=" + domain : "") +
                                ((secure) ? "; secure" : "");
}

function util_debug() {
	activeElement.DOM.body.normalize();
}

function util_saveSelection() {
	if (!activeElement.busy) {
	svdSelection = activeElement.DOM.selection.createRange();
}
	return true;
}

function util_restoreSelection() {	
	if (svdSelection) {
		svdSelection.select();
		svdSelection = null;
	}
}

function util_getVar(varName) {
	return eval(activeElementName.replace(/_htmlObject/,"")+"_"+varName);
}

function util_setVar(varName, varValue, varType) {
	var delimiter = "'";
	switch ( varType ) {
		case "numeric":
			delimiter = "";
		break;
		case "string":
		break
	}
	return eval(activeElementName.replace(/_htmlObject/,"")+"_"+varName+" = "+ delimiter + varValue + delimiter + ";");
}

function util_cleanHTMLContent() {
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}	
	var tmp = activeElement.DOM.body.innerHTML;
	tmp = tmp.replace(/<\?xml:.*?>/ig, "");
	tmp = tmp.replace(/<H[0-9]+\s?([^>]*)>/ig, "<P $1>");
	tmp = tmp.replace(/<\/H[0-9]+>/ig, "</P>");
	tmp = tmp.replace(/(<[^>]+)lang=[a-z]*([^>]*>)/ig, "$1$2");
	tmp = tmp.replace(/("|\s)MARGIN:.*?(;|")/ig, "$1$2");
	tmp = tmp.replace(/("|\s)TEXT-INDENT:.*?(;|")/ig, "$1$2");
	tmp = tmp.replace(/("|\s)FONT-WEIGHT:.*?(;|")/ig, "$1$2");
	tmp = tmp.replace(/("|\s)tab-stops:.*?(;|")/ig, "$1$2");
	tmp = tmp.replace(/("|\s)mso-.*?:.*?(;|")/ig, "$1$2");
	tmp = tmp.replace(/\sclass=Mso.*?\s/ig, " ");
	tmp = tmp.replace(/<\/?o:p>/ig, "");
	tmp = tmp.replace(/(style="[^"]*)TEXT-ALIGN:\s?([a-z]*)([^"]*")/ig, "align=$2 $1$3");
	tmp = tmp.replace(/(style="[^"]*)BACKGROUND:\s?([a-z0-9#]*)([^"]*")/ig, "bgcolor=$2 $1$3");
	tmp = tmp.replace(/<SPAN style="FONT-FAMILY: Symbol">\s*<FONT\s+size=[0-9]*>\·<\/FONT>/ig, "<li>");
	tmp = tmp.replace(/(<font[^>]*)>\s*<font/ig, "$1");
	tmp = tmp.replace(/<dir>/ig, "<BLOCKQUOTE>");
	tmp = tmp.replace(/<\/dir>/ig, "</BLOCKQUOTE>");

	tmp = tmp.replace(/style="[^"]*"/ig, "");
	tmp = tmp.replace(/class=[A-Z0-9_]*/ig, "");
	tmp = tmp.replace(/class="[^"]*"/ig, "");
	tmp = tmp.replace(/(<td[^>]*)(width|height)=["'a-z0-9_]*([^>]*>)/ig, '$1$3');
	tmp = tmp.replace(/(<table[^>]*)(width|height)=["'a-z0-9_]*([^>]*>)/ig, '$1$3');
	tmp = tmp.replace(/<font[^>]*><\/font>/ig, '');
	activeElement.DOM.body.innerHTML = tmp;
}

function util_cleanHTMLContent2() {
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}
	var tmp = activeElement.DOM.body.innerHTML;
	tmp = tmp.replace(/<H[0-9]+\s?(.*)>/ig, "<P $1>");
	tmp = tmp.replace(/style="[^"]*"/ig, "");
	tmp = tmp.replace(/<font[^>]*>/ig, "");
	tmp = tmp.replace(/<\/font>/ig, "");
	tmp = tmp.replace(/\xFE/g, "Å£");
	tmp = tmp.replace(/\xDE/g, "Å¢");

	tmp = tmp.replace(/\xE2/g, "Ã¢");
	tmp = tmp.replace(/\xC2/g, "Ã‚");
	
	tmp = tmp.replace(/\xEE/g, "Ã®");
	tmp = tmp.replace(/\xCE/g, "ÃŽ");
	
	tmp = tmp.replace(/\xBA/g, "ÅŸ");
	tmp = tmp.replace(/\xAA/g, "Åž");
	
	tmp = tmp.replace(/\xE3/g, "Äƒ"); 
	tmp = tmp.replace(/\xC3/g, "Ä‚"); 

	tmp = tmp.replace(/class=[^ ]*/ig, "");
	tmp = tmp.replace(/class="[^"]*"/ig, "");

	tmp = tmp.replace(/(<td[^>]*)(width|height)=[^ >]*([^>]*>)/ig, '$1$3');
	tmp = tmp.replace(/(<table[^>]*)(width|height)=[^ >]*([^>]*>)/ig, '$1$3');

	tmp = tmp.replace(/<font[^>]*><\/font>/ig, '');

	activeElement.DOM.body.innerHTML = tmp;
}

function util_getValueFromActiveForm(frmName, fieldName, fieldType, returnType) {
  var aFrm = document.getElementById(frmName);
  switch (fieldType) {
    case "SELECT": var containers = aFrm.getElementsByTagName("SELECT");
      break;
    case "TEXT": var containers = aFrm.getElementsByTagName("INPUT");
      break;
    case "CHECKBOX": var containers = aFrm.getElementsByTagName("INPUT");
      break;      
  }
  var valToReturn = false;
  for (var i=0;i<containers.length;i++) {
    if (containers[i].name == fieldName || containers[i].id == fieldName ) {
      if (fieldType == "TEXT") {
      	if (returnType == "value") {
        	valToReturn = containers[i].value;
        } else if (returnType == "all") {
        	valToReturn = containers[i];
        }
      } else if (fieldType == "SELECT") {
    		if (returnType == "value") {
      		valToReturn = containers[i].options[containers[i].selectedIndex].value;
      	} else if (returnType == "all") {
      		valToReturn = containers[i];
      	}
      } else if (fieldType == "CHECKBOX") {
    		if (returnType == "value") {
      		valToReturn = containers[i].checked;
      	} else if (returnType == "all") {
      		valToReturn = containers[i];
      	}      	
      }
    }
  }
  return valToReturn;
}
///////////////////////////////////////////
// DOM utility functions
//////////////////////////////////////////
function util_insertRawHtml(sHTML){ 
  if(activeElement.DOM.selection.type == "Control") {
    activeElement.DOM.selection.clear();
  }  
  activeElement.DOM.selection.createRange().pasteHTML(sHTML);
}

function util_openWnd(u,n,w,h) {
  args="width="+w+",height="+h+",resizable=no,scrollbars=no,status=1";
  remote=window.open(n, u,args);
  if (remote != null) {
    if (remote.opener == null)
      remote.opener = self;
  }
  return remote;
}

function util_remSpaces(tmpstr) {
	if(tmpstr == "<p>&nbsp;</p>" || tmpstr == "<div>&nbsp;</div>") {
		tmpstr = "";
	}
	return tmpstr;
}

function logic_putTargetTag(){
	var str=new String();
	var strnou = new String();
	
	if(activeElement.DOM.selection.type == "Control" ) {
		var selText = activeElement.DOM.body.createTextRange(); //the image that is selected
		var tmp1 = activeElement.DOM.selection.createRange();
		selText.moveToElementText(tmp1.item(0));
	} else {
		var selText = activeElement.DOM.selection.createRange(); //the text that is selected
	}  	
	
  sel = activeElement.DOM.selection;
  propertyTargets = util_getValueFromActiveForm(activeFormName, "property_targets", "SELECT", "value");
  if ("None" != sel.type) {
		if (propertyTargets!="") {
			if (sel.type == "Control") {
				var range = activeElement.DOM.body.createTextRange(); 
				var tmp1 = sel.createRange();
				range.moveToElementText(tmp1.item(0));
			} else {
				range = sel.createRange();
			}			
			str = range.htmlText;
			strnou = str.replace("<A","<A target=\""+propertyTargets+"\"");
			range.pasteHTML(strnou);
		}	
  } else {
    alert("No text selected");
	}		
}
function hndlr_onkeypressUrl(){
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}	
	if (event.keyCode == 13) {
		logic_InsertLink();
		return false;
	} 
	return true;
}


function ui_getLink() {
	if (!activeElement.busy) {
	if(activeElement.DOM.selection.type == "Control" ) {
		var selText = activeElement.DOM.body.createTextRange(); /* the image that is selected */
		var tmp1 = activeElement.DOM.selection.createRange();
		selText.moveToElementText(tmp1.item(0));
	} else { 
		var selText = activeElement.DOM.selection.createRange(); //the text that is selected
	}
	var linkCollection = activeElement.DOM.all.tags("A"); //all a tags in text >:) 
	var tmptst=false; 
	for(i=0 ; i < linkCollection.length && !tmptst ; i++) { 
		linkPiece=activeElement.DOM.body.createTextRange(); 
		linkPiece.moveToElementText(linkCollection[i]); //expand the textrange to entire a tag contents
		if( (selText.compareEndPoints("EndToStart",linkPiece)==1) && (selText.compareEndPoints("StartToEnd",linkPiece)==-1) ) { //if the seltext is included in the linkPiece textrange
			if(selText.compareEndPoints("StartToStart",linkPiece)==1) {
				selText.setEndPoint("StartToStart",linkPiece); // set the start of the selection 
			}
			if(selText.compareEndPoints("EndToEnd", linkPiece)==-1) {
				selText.setEndPoint("EndToEnd", linkPiece); // set the end of the selection 
			}
			var conText = false;
			var str = new String();
			var urlContainer = util_getValueFromActiveForm(activeFormName, "property_url", "TEXT", "all");			
			var urlTarget = util_getValueFromActiveForm(activeFormName, "property_targets", "SELECT", "all");
			var urlProtocol = util_getValueFromActiveForm(activeFormName, "property_protocol_type", "SELECT", "all");
			str = linkCollection[i].href;
			strtarget = linkCollection[i].target;
			regs = str.match(/^(?:(\w+?):\/{0,2}|\/+)(.+)$/); //applies a regexp to separate the url into protocol and url
			if (!regs) {
				return;
			}
			if (regs[2]) {
				if (regs[2]!="") { //put the url value
					conText = true;
					urlContainer.value = regs[2];
				} else {
					conText = false;
					urlContainer.value = linkCollection[i].href;
				}
			}
			if (conText) { //select the protocol value
				if (regs[1]!="") {
					var newre = eval("/"+regs[1]+"/");
					var cond = false;
					for (var i=0;i < urlProtocol.options.length;i++) {
						var a = urlProtocol.options[i].value ;
						if (a.match(newre)) {
							urlProtocol.selectedIndex = i;
							cond = true;						
							break;						
						}
					}
					if (cond == false) {
						urlProtocol.selectedIndex = 0;
					}
				} else {
					urlProtocol.selectedIndex = 1;//the none stuff
				}
			} else {
				urlProtocol.selectedIndex = 0;
			}
			if (strtarget !="") { //select the target tag value
				var cond = false;
				for ( var i=0;i< urlTarget.options.length;i++) {
					if (urlTarget.options[i].value == strtarget) {
						urlTarget.selectedIndex = i;
						cond = true;
					}
				}
				if (cond == false) {
					urlTarget.selectedIndex = 0;
				}
			} else {
				urlTarget.selectedIndex = 0;
			}
			tmptst=true;
			//KT_onLink = true;
			util_setVar("onLink", "true", "numeric");
		}
	}
	if(!tmptst) { //no link found
		//KT_onLink = false;
		util_setVar("onLink", "false", "numeric");
		//logic_InsertLink();
	}
	} else {
		setTimeout("ui_getLink();", 30);
	}
	return true;
}
function logic_removeTag() {
	if (activeElement) {
		if (activeElement.DOM.selection.type =='Text' || activeElement.DOM.selection.type =="None") {
			var txtRange = activeElement.DOM.selection.createRange(); //the text that is selected
			var tmpel = txtRange.parentElement();
			var tmpelParent = tmpel.parentElement; //modify this innerHTML property			
			tmpel.outerHTML = tmpel.innerHTML;
		} else if (activeElement.DOM.selection.type == "Control" ) {
			var ctrlRange = activeElement.DOM.selection.createRange(); //the text that is selected
			var tmpel = ctrlRange.commonParentElement();
			var tmpelParent = tmpel.parentElement;
			tmpel.outerHTML = tmpel.innerHTML;
		}
		logic_updateDOMHierarchy();
	}
}
function logic_domSelect(o,ind) {
	if (ind == 1) {
		tmp1 = activeElement.DOM.body.createTextRange();
		sl = activeElement.DOM.selection.createRange();
		tmp1.moveToElementText(selectableNodes[o]);
		if((sl.compareEndPoints("EndToStart",tmp1)==1) && (sl.compareEndPoints("StartToEnd",tmp1)==-1) ) { 
			if(sl.compareEndPoints("StartToStart",tmp1)==1) {
				sl.setEndPoint("StartToStart",tmp1); // set the start of the selection 
			}
			if(sl.compareEndPoints("EndToEnd",tmp1)==-1) {
				sl.setEndPoint("EndToEnd",tmp1); // set the end of the selection 
			}
			sl.select();
			activeElement.DOM.focus();
		}
	} else if (ind == 2) {
		tmp1 = activeElement.DOM.body.createTextRange();
		sl = activeElement.DOM.selection.createRange();
		tmp1.moveToElementText(selectableNodes[o]);
		tmp1.select();
		activeElement.DOM.focus();
	}
}
function logic_updateDOMHierarchy() {
	if (activeElement) {
		if( !activeElement.busy ) {
		toUpd = document.getElementById(activeDOMPropertyName); //the span to update 
		toUpd.innerHTML = "";
		while (selectableNodes.length) {
			selectableNodes.pop();
		}
		var cnt = 0;
		if (activeElement.DOM.selection.type =='Text' || activeElement.DOM.selection.type =='None') {
			var txtRange = activeElement.DOM.selection.createRange(); //the text that is selected
			var tmpprs = txtRange.parentElement();
			var cElement = "&nbsp;";
			while (tmpprs && (tmpprs.tagName!="HTML")) {
				if (tmpprs.tagName!="BODY") {
					cElement = ('<a class="domInspector" href="javascript:logic_domSelect('+cnt+', 1);">'+tmpprs.tagName+'</a>&nbsp;>&nbsp;') + cElement;
				}
				selectableNodes.push(tmpprs); cnt++ ;
				tmpprs = tmpprs.parentElement;
			}
			toUpd.innerHTML = cElement.replace(/>&nbsp;&nbsp;$/, "");
			toUpd.innerHTML+='&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:logic_removeTag();">Remove Tag</a>';
		} else if (activeElement.DOM.selection.type == "Control" ) {
			var ctrlRange = activeElement.DOM.selection.createRange(); //the text that is selected
			var tmpprs = ctrlRange.commonParentElement();
			var cElement = "&nbsp;";
			while (tmpprs && (tmpprs.tagName!="HTML")) {
				if (tmpprs.tagName!="BODY") {
					cElement = ('<a class="domInspector" href="javascript:logic_domSelect('+cnt+', 2);">'+tmpprs.tagName+'</a>&nbsp;>&nbsp;') + cElement;
				}
				selectableNodes.push(tmpprs); cnt++ ;
				tmpprs = tmpprs.parentElement;
			}
			toUpd.innerHTML = cElement.replace(/>&nbsp;&nbsp;$/, "");
			toUpd.innerHTML+='&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:logic_removeTag();">Remove Tag</a>';			
		}
		} else {
			setTimeout("logic_updateDOMHierarchy();", 30);
		}
		return true;
	} else {
			toUpd = document.getElementById(activeDOMPropertyName); //the span to update 
			toUpd.innerHTML = "<INPUT type='button'>";
	}
}

function init_fillCssClasses() {
	if (activeElement.busy) {
	    setTimeout("init_fillCssClasses();", 400);		
	} else {
	  if (activeElement.DOM.stilu.rules.length == 0) {
	    setTimeout("init_fillCssClasses();", 400);
	  } else {
	  	cssuri = util_getValueFromActiveForm(activeFormName, "property_styler", "SELECT", "all");
	    if (cssuri.options.length==1) {
	      for(var i=0;i<activeElement.DOM.stilu.rules.length;i++){
	        v = activeElement.DOM.stilu.rules[i].selectorText;
	        if(v.substring(0, 1)=="."){
	          o = new Option(v.substring(1), v.substring(1));
	          cssuri.options[cssuri.options.length]=o;
	        }
	      }
	    }
	  }
	}
}

function init_createStyleSelect() {
	if (activeElement.busy || window.status == "Filling CSS Styles") {
		setTimeout("init_createStyleSelect()", 100);
  } else { 
	  str1 = new String;
	  the_path = document.location.pathname;
	  str = the_path.split('/');
	  str1 = the_path.replace(str[str.length-1], eval(activeElementName.replace(/_htmlObject/,"")+"_pathToStyle"));
	  cale = document.location.protocol+'//'+document.location.hostname;	  
	  if (document.location.port!="") {
	  	cale += ":"+document.location.port;
	  }
	  cale += str1;
	  activeElement.DOM.stilu = activeElement.DOM.createStyleSheet(cale);
    window.status = "Filling CSS Styles";
	  init_fillCssClasses();
    window.status = "Done";
	}
}


function logic_makeJustify() {
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}
	cnt = 0;rez = 0;
	activeElement.ExecCommand(DECMD_JUSTIFYCENTER,OLECMDEXECOPT_DODEFAULT);
	logic_updateDOMHierarchy();
	rez = null;

	for (var i=selectableNodes.length-1;i>=0;i--) {
		if (selectableNodes[i].tagName =="P" || selectableNodes[i].tagName =="DIV") {
			rez = i;
		}
	}
	if (rez != null) {
		selectableNodes[rez].align = "justify";
		tmp = selectableNodes[rez].innerHTML;
		selectableNodes[rez].innerHTML = tmp.replace(/align\s*=\s*"?center"?/ig, "align=justify");
		var txtRange = activeElement.DOM.selection.createRange();	
	} else {
		var tmp = activeElement.DOM.body.innerHTML;
		activeElement.DOM.body.innerHTML = tmp.replace(/align\s*=\s*"?center"?/ig, "align=justify");
	}
}
//////////////////////////////////////
// end other utility functions section
//////////////////////////////////////

function util_fix4NS(instr){
	var re  = /STYLE=\"WIDTH\s*:\s*(\d+)px;\s*HEIGHT:\s*(\d+)px;*\s*\"/gi;
        var re1 = /<A\s+href=".*?"\s*>\s*<\/A>/gi; // for taking out blank links
        instr=instr.replace(re1, "");
	return(instr.replace(re, "width=$1 height=$2"));
}	

var MENU_SEPARATOR = ""; 
var docComplete = false;
var initialDocComplete = false;
var QueryStatusToolbarButtons = new Array();
var QueryStatusEditMenu = new Array();
var QueryStatusFormatMenu = new Array();
var QueryStatusHTMLMenu = new Array();
var QueryStatusTableMenu = new Array();
var QueryStatusZOrderMenu = new Array();
var ContextMenu = new Array();
var GeneralContextMenu = new Array();
var TableContextMenu = new Array();
var AbsPosContextMenu = new Array();
//constructor for context menu


function KT_Initialize(obiectul, oName) {
  GeneralContextMenu[0] = new ContextMenuItem("Cut", DECMD_CUT);
  GeneralContextMenu[1] = new ContextMenuItem("Copy", DECMD_COPY);
  GeneralContextMenu[2] = new ContextMenuItem("Paste", DECMD_PASTE);
  TableContextMenu[0] = new ContextMenuItem(MENU_SEPARATOR, 0);
  TableContextMenu[1] = new ContextMenuItem("Insert Row", DECMD_INSERTROW);
  TableContextMenu[2] = new ContextMenuItem("Delete Rows", DECMD_DELETEROWS);
  TableContextMenu[3] = new ContextMenuItem(MENU_SEPARATOR, 0);
  TableContextMenu[4] = new ContextMenuItem("Insert Column", DECMD_INSERTCOL);
  TableContextMenu[5] = new ContextMenuItem("Delete Columns", DECMD_DELETECOLS);
  TableContextMenu[6] = new ContextMenuItem(MENU_SEPARATOR, 0);
  TableContextMenu[7] = new ContextMenuItem("Insert Cell", DECMD_INSERTCELL);
  TableContextMenu[8] = new ContextMenuItem("Delete Cells", DECMD_DELETECELLS);
  TableContextMenu[9] = new ContextMenuItem("Merge Cells", DECMD_MERGECELLS);
  TableContextMenu[10] = new ContextMenuItem("Split Cell", DECMD_SPLITCELL);
  AbsPosContextMenu[0] = new ContextMenuItem(MENU_SEPARATOR, 0);
  AbsPosContextMenu[1] = new ContextMenuItem("Send To Back", DECMD_SEND_TO_BACK);
  AbsPosContextMenu[2] = new ContextMenuItem("Bring To Front", DECMD_BRING_TO_FRONT);
  AbsPosContextMenu[3] = new ContextMenuItem(MENU_SEPARATOR, 0);
  AbsPosContextMenu[4] = new ContextMenuItem("Send Backward", DECMD_SEND_BACKWARD);
  AbsPosContextMenu[5] = new ContextMenuItem("Bring Forward", DECMD_BRING_FORWARD);
  AbsPosContextMenu[6] = new ContextMenuItem(MENU_SEPARATOR, 0);
  AbsPosContextMenu[7] = new ContextMenuItem("Send Below Text", DECMD_SEND_BELOW_TEXT);
  AbsPosContextMenu[8] = new ContextMenuItem("Bring Above Text", DECMD_BRING_ABOVE_TEXT);

  activeElement = obiectul;
  activeElementName = oName;
  activeFormName = "Property_"+oName.replace(/_htmlObject/,"");
  util_setVar("onLink", "false", "numeric");
  activeDOMPropertyName = "DOMProperty_"+oName.replace(/_htmlObject/,"");
  window.status = "Loading Styles";
  document.forms[0].onsubmit = logic_checkSubmit2;
  init_createStyleSelect();
  eval(activeElementName.replace(/_htmlObject/,"")+"_pathToStyle");
  //util_setVar("displayMode", "RICH", "string");
  //util_setVar("setButtons", "true", "string");
}
/////////////////////////
//event handlers section
/////////////////////////
function hndlr_onError (msg, url, line) {
	alert("The following error occured:\n"+msg+"\n"+url+"\n"+line);
  return true;
}	


function ContextMenuItem(string, cmdId) {
  this.string = string;
  this.cmdId = cmdId;
}

function KT_ShowContextMenu() {
  var menuStrings = new Array();
  var menuStates = new Array();
  var state;
  var i;
  var idx = 0;
  ContextMenu.length = 0;
  for (i=0; i<GeneralContextMenu.length; i++) {
    ContextMenu[idx++] = GeneralContextMenu[i];
  }
  if (activeElement.QueryStatus(DECMD_INSERTROW) != DECMDF_DISABLED) {
    for (i=0; i<TableContextMenu.length; i++) {
      ContextMenu[idx++] = TableContextMenu[i];
    }
  }
  if (activeElement.QueryStatus(DECMD_LOCK_ELEMENT) != DECMDF_DISABLED) {
    for (i=0; i<AbsPosContextMenu.length; i++) {
      ContextMenu[idx++] = AbsPosContextMenu[i];
    }
  }
  for (i=0; i<ContextMenu.length; i++) {
    menuStrings[i] = ContextMenu[i].string;
    if (menuStrings[i] != MENU_SEPARATOR) {
      state = activeElement.QueryStatus(ContextMenu[i].cmdId);
    } else {
      state = DECMDF_ENABLED;
    }
    if (state == DECMDF_DISABLED || state == DECMDF_NOTSUPPORTED) {
      menuStates[i] = OLE_TRISTATE_GRAY;
    } else if (state == DECMDF_ENABLED || state == DECMDF_NINCHED) {
      menuStates[i] = OLE_TRISTATE_UNCHECKED;
    } else { // DECMDF_LATCHED
      menuStates[i] = OLE_TRISTATE_CHECKED;
    }
  }
  activeElement.SetContextMenu(menuStrings, menuStates);
}

function KT_ContextMenuAction(itemIndex) {  
  if (ContextMenu[itemIndex].cmdId == DECMD_INSERTTABLE) {
    InsertTable();
  } else {
    activeElement.ExecCommand(ContextMenu[itemIndex].cmdId, OLECMDEXECOPT_DODEFAULT);
  }
}

function ui_isUpdateUI(o) {
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}	
	if (!o.checked) {
		if (activeElement) {
			toUpd = document.getElementById(activeDOMPropertyName); //the span to update 
			toUpd.innerHTML = "";
		}
		toolbarHandler = eval(activeFormName);
		for(var i=0;i<toolbarHandler.all.length;i++) {
			pbtn = toolbarHandler.all(i);
			if(pbtn.tagName == "IMG") {
				pbtn.className = "edit_flat";
				pbtn.state = 1;
			}
		}		
		if (cookie_getCookie(activeElementName.replace(/_htmlObject/,"")+"_updateUI")) {
			cookie_deleteCookie(activeElementName.replace(/_htmlObject/,"")+"_updateUI","/", null);
		}
		var expdate = new Date();
		expdate.setDate(expdate.getDate() + 720); //2 years		
		cookie_setCookie(activeElementName.replace(/_htmlObject/,"")+"_updateUI", "0", expdate, "/", null, false);
	} else {
		if (cookie_getCookie(activeElementName.replace(/_htmlObject/,"")+"_updateUI")) {
			cookie_deleteCookie(activeElementName.replace(/_htmlObject/,"")+"_updateUI","/", null);
		}
		var expdate = new Date();
		expdate.setDate(expdate.getDate() + 720); //2 years
		cookie_setCookie(activeElementName.replace(/_htmlObject/,"")+"_updateUI", "1", expdate, "/", null, false);
	}
}

function hndlr_toolbarFocus() {
}

function hndlr_DisplayChanged() {
	var setButton = util_getVar("setButtons");//s
	var cbox = util_getValueFromActiveForm(activeFormName, activeElementName.replace(/_htmlObject/,"")+"_updateUIcb", "CHECKBOX", "value");
	if (util_getVar("displayMode") != "CODE") {
		if (setButton && cbox) {
	  	ui_setButtonState();
	  } else {
	  }
  } else {
  	var toUpd = document.getElementById(activeDOMPropertyName);
  	toUpd.innerHTML == "";
  }
}

function hndlr_onkeypress() {
}

function hndlr_onkeydown() {
//	var cd = activeElement.DOM.parentWindow.event.keyCode;
//	var shft = activeElement.DOM.parentWindow.event.shiftKey;
//	switch (cd) {
//		case 9:
//			if (shft == true) {
//				logic_doFormat('Outdent');
//			} else {
//				logic_doFormat('Indent');
//			}
//			break;
//	}
}

function hndlr_onmousedown() {

}

function hndlr_onclick() {
	var urlContainer = util_getValueFromActiveForm(activeFormName, "property_url", "TEXT", "all");
	urlContainer.value="";
	var cbox = util_getValueFromActiveForm(activeFormName, "updateUIcb", "CHECKBOX", "value");
	if (cbox) {
		ui_setButtonState();
	}
}

function hndlr_buttonMouseOver(src) {
	if(src.state==0) return;
	if(src.state==2) return;	
	if(src.type=="btn") {
		src.className="edit_outset";
	}
}
function hndlr_buttonMouseOut(src) {
	if(src.state==0) return;	
	if(src.state==2) { 
		src.className="edit_latched"; return; 
	}
	if(src.type=="btn") {
		window.status="";
		src.className="edit_flat";
	}
}

function hndlr_buttonMouseDown(src) {
	if(src.state==0) return;
	if(src.type=="btn") {
		src.className="edit_inset";
	}
}

function hndlr_buttonMouseUp(src) {
	if(src.state==0) return;
	if(src.state==2) { src.className="edit_latched"; return; }
		
	if(src.type=="btn") {
		src.className="edit_outset";
	}
}

function ui_setButtonState() {
	var pbtn;
	var cid;
	var state;
	if(util_getVar("displayMode") == "CODE") {
		return true;
	}
	toolbarHandler = eval(activeFormName);
	if(activeElement.QueryStatus(5002) != activeElement.QueryStatus(5003)) return;
	for(var i=0;i<toolbarHandler.all.length;i++) {
		pbtn = toolbarHandler.all(i);
		commandId = pbtn.cid;
		if(commandId < 6000 && commandId!=DECMD_HYPERLINK) {
			state=activeElement.QueryStatus(commandId)
   		if(state == DECMDF_DISABLED || state == DECMDF_NOTSUPPORTED) {
				if(pbtn.state!=0) {
					pbtn.className = "edit_disabled"; pbtn.state = 0;
				}
			} else if(state == DECMDF_ENABLED || state == DECMDF_NINCHED) {
				if(pbtn.state!=1) {
					pbtn.className = "edit_flat"; pbtn.state = 1;
				}
			} else {
				if(pbtn.state!=2) {
					pbtn.className = "edit_latched"; pbtn.state = 2;
				}
			}
		} else if(commandId==6004) {
			if(activeElement.ShowDetails) {
				if(pbtn.state!=2) {
					pbtn.className = "edit_latched"; pbtn.state = 2;
				}
			} else {
				if(pbtn.state!=1) {
					pbtn.className = "edit_flat"; pbtn.state = 1;
				}
			}
		}
	}
	ui_updateFontFace();
	ui_updateFontSize();
	ui_updateBlockFormat();
	logic_updateDOMHierarchy();
	ui_updateStyle();
	ui_getLink();
}

function ui_updateFontFace() {
	if (!activeElement.busy) {
	if(oSel = util_getValueFromActiveForm(activeFormName, "property_font_type", "SELECT", "all")) { 
		if(activeElement.QueryStatus(DECMD_SETFONTNAME)!=DECMDF_DISABLED && activeElement.DOM.selection.type!="control") {
			if(oSel.disabled) oSel.disabled=false;
			fontname=activeElement.ExecCommand(DECMD_GETFONTNAME);
			if((fontname !="") && (fontname != null)) {
				fCreateNew=true;
				for(i=0;i<oSel.options.length;i++) {
					var regxp = new RegExp(fontname);
					var nm = new String(oSel.options[i].text);
					if(oSel.options[i].value==fontname || nm.match(regxp)) {
						if(!oSel.options[i].selected) {
							oSel.options[i].selected=true;
						}
						fCreateNew=false;
					}
				}
				if(fCreateNew) {
					var oOption = document.createElement("OPTION");
					oSel.options.add(oOption);
					oOption.text = fontname;
					oOption.name = fontname;
					oOption.value = fontname;					
					oOption.selected=true;
				}
			} else {
				oSel.selectedIndex=-1;
			}
		} else {
			if(!oSel.disabled) oSel.disabled=true;
		}
	}	
	} else {
		setTimeout("ui_updateFontFace()", 30);
	}
	return true;
}

function ui_updateFontSize() {
	if (!activeElement.busy) {
	if(fsSel = util_getValueFromActiveForm(activeFormName, "property_size", "SELECT", "all") )  { //font size updating
		if(activeElement.QueryStatus(DECMD_SETFONTSIZE)!=DECMDF_DISABLED && activeElement.DOM.selection.type!="control") {
			if(fsSel.disabled) fsSel.disabled=false; 
			fs=activeElement.ExecCommand(DECMD_GETFONTSIZE);
			if(fs!=null && fs!="") {
				fsCreateNew = true;
				for(i=0;i<fsSel.options.length;i++) {
					if(fsSel.options[i].value == fs )
						fsSel.options[i].selected=true;
					fsCreateNew = false;
				}
				if(fsCreateNew) {
					var oOption = document.createElement("OPTION");
					fsSel.options.add(fsOption,0);
					fsOption.text = fs;
					fsOption.name = fs;
					fsOption.value = fs;
					fsOption.selected=true;
				}				
			} else {
				fsSel.selectedIndex=-1;
			}
		} else {
			if(!fsSel.disabled) fsSel.disabled=true;
		}
	}		
	} else {
		setTimeout("ui_updateFontSize();", 30);
	}
	return true;
}

function ui_updateBlockFormat() {
	if (!activeElement.busy) {
	if(fsBlc = util_getValueFromActiveForm(activeFormName, "property_blockformat", "SELECT", "all") )  { //font size updating
		if(activeElement.QueryStatus(DECMD_SETBLOCKFMT)!=DECMDF_DISABLED && activeElement.DOM.selection.type!="control") {
			if(fsBlc.disabled) fsBlc.disabled=false; 
			fs=activeElement.ExecCommand(DECMD_GETBLOCKFMT);
			if(fs!=null && fs!="") {
				for(i=0;i<fsBlc.options.length;i++) {
					if(fsBlc.options[i].value == fs )
						fsBlc.options[i].selected=true;
				}		
			} else {
				fsBlc.selectedIndex=-1;
			}
		} else {
			if(!fsBlc.disabled) fsBlc.disabled=true;
		}
	}
	} else {
		setTimeout("ui_updateBlockFormat();", 30);
	}
	return true;
}

function ui_updateStyle() {	
	toA = document.getElementById(activeDOMPropertyName);
	var tmptst = false;
	if (toA.innerHTML!="") {
		var alsoUpd = util_getValueFromActiveForm(activeFormName, "property_styler", "SELECT", "all");
		for (var h=0;h<selectableNodes.length;h++) {
			if (selectableNodes[h].className != "") {
				for (var hh=0;hh<alsoUpd.options.length;hh++) {
					if (alsoUpd.options[hh].value == selectableNodes[h].className) {
						alsoUpd.selectedIndex = hh;
						tmptst = true;
					}
				}
			}
		}
		if (!tmptst) {
			alsoUpd.selectedIndex = -1;
		}
	}
}

function logic_openPalette(cmd){	
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}
  var arr = showModalDialog(  NEXT_ROOT+"includes/ktedit/selcolor.php",
                             "",
                             "font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:30em" );
  if (arr != null) {
  	if (cmd == 'b') {
	    activeElement.ExecCommand(DECMD_SETBACKCOLOR,OLECMDEXECOPT_DODEFAULT, arr);
	  } else if (cmd == 'f') {
	  	activeElement.ExecCommand(DECMD_SETFORECOLOR,OLECMDEXECOPT_DODEFAULT, arr);
	  }
  }
  activeElement.DOM.focus();
}

function logic_openInsertImage(){
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}	
	var pth = eval(activeElementName.replace(/_htmlObject/,"")+"_pathToImageDir");
	util_openWnd("uploadImage",NEXT_ROOT+"includes/ktedit/dirbrowser.php?mode=img&submode=img&KT_PATH_VAR="+escape(pth), 700, 600);
}
function logic_openInsertLink(){
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}
	var pth = eval(activeElementName.replace(/_htmlObject/,"")+"_pathToImageDir");
	util_openWnd("uploadImage",NEXT_ROOT+"includes/ktedit/dirbrowser.php?mode=img&submode=file&KT_PATH_VAR="+escape(pth), 700, 600);
}
function logic_openFileBrowser(){
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}
	var pth = eval(activeElementName.replace(/_htmlObject/,"")+"_pathToImageDir");
	util_openWnd("FileBrowser", NEXT_ROOT+"includes/ktedit/dirbrowser.php?mode=file&KT_PATH_VAR="+escape(pth), 700, 600);
}

function logic_doFormat(what) {
	
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}
  switch (what) {
    case 'Cut':  activeElement.ExecCommand(DECMD_CUT,OLECMDEXECOPT_DODEFAULT);break;
    case 'Copy':   activeElement.ExecCommand(DECMD_COPY,OLECMDEXECOPT_DODEFAULT);break;
    case 'Paste':   activeElement.ExecCommand(DECMD_PASTE,OLECMDEXECOPT_DODEFAULT);break;
    case 'toggleInvisables': activeElement.ShowBorders = !activeElement.ShowBorders;
                             activeElement.ShowDetails = !activeElement.ShowDetails;
                             break;
    case 'FontName':  activeElement.ExecCommand(DECMD_SETFONTNAME, OLECMDEXECOPT_DODEFAULT, arguments[1]);break;
    case 'SelectAll':  activeElement.ExecCommand(DECMD_SELECTALL,OLECMDEXECOPT_DODEFAULT);break;
    case 'FontSize': activeElement.ExecCommand(DECMD_SETFONTSIZE, OLECMDEXECOPT_DODEFAULT, parseInt(arguments[1]));break;
    case 'Bold': activeElement.ExecCommand(DECMD_BOLD,OLECMDEXECOPT_DODEFAULT);break;
    case 'Italic': activeElement.ExecCommand(DECMD_ITALIC,OLECMDEXECOPT_DODEFAULT);break;
    case 'Underline': activeElement.ExecCommand(DECMD_UNDERLINE,OLECMDEXECOPT_DODEFAULT);break;
    case 'JustifyLeft': activeElement.ExecCommand(DECMD_JUSTIFYLEFT,OLECMDEXECOPT_DODEFAULT);break;
    case 'JustifyCenter': activeElement.ExecCommand(DECMD_JUSTIFYCENTER,OLECMDEXECOPT_DODEFAULT);break;
    case 'JustifyRight': activeElement.ExecCommand(DECMD_JUSTIFYRIGHT,OLECMDEXECOPT_DODEFAULT);break;
    case 'InsertOrderedList':  activeElement.ExecCommand(DECMD_ORDERLIST,OLECMDEXECOPT_DODEFAULT);break;
    case 'InsertUnorderedList': activeElement.ExecCommand(DECMD_UNORDERLIST,OLECMDEXECOPT_DODEFAULT);break;
    case 'Indent': activeElement.ExecCommand(DECMD_INDENT,OLECMDEXECOPT_DODEFAULT);break;
    case 'Outdent': activeElement.ExecCommand(DECMD_OUTDENT,OLECMDEXECOPT_DODEFAULT);break;
    case 'InsertHorizontalRule': util_insertRawHtml("<HR>");break;
    case 'InsertImage': activeElement.ExecCommand(DECMD_IMAGE,OLECMDEXECOPT_DONTPROMPTUSER,arguments[1]);break;
    case 'FindText':activeElement.ExecCommand(DECMD_FINDTEXT);break;
    case 'RemoveLink':activeElement.ExecCommand(DECMD_UNLINK);break;
    case 'ChangeColor': activeElement.ExecCommand(DECMD_SETFORECOLOR,OLECMDEXECOPT_DODEFAULT, what);break;
    case 'Undo':activeElement.ExecCommand(DECMD_UNDO,OLECMDEXECOPT_DODEFAULT );break;
    case 'Redo':activeElement.ExecCommand(DECMD_REDO,OLECMDEXECOPT_DODEFAULT );break;
    case 'FontAdvanced':activeElement.ExecCommand(DECMD_FONT,OLECMDEXECOPT_PROMPTUSER );break;
    case 'InsertStyle': logic_InsertStyle(arguments[1]); break;
    case 'SetBlockFormat': activeElement.ExecCommand(DECMD_SETBLOCKFMT, OLECMDEXECOPT_DODEFAULT, arguments[1]);break;
  }
  activeElement.DOM.focus();
}
function logic_InsertTable() {
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}	
  var pVar = document.ObjTableInfo;
  var args = new Array();
  var arr = null;
     
  args["NumRows"] = document.ObjTableInfo.NumRows;
  args["NumCols"] = document.ObjTableInfo.NumCols;
  args["TableAttrs"] = document.ObjTableInfo.TableAttrs;
  args["CellAttrs"] = document.ObjTableInfo.CellAttrs;
  args["Caption"] = document.ObjTableInfo.Caption;
  arr = null;
  arr = showModalDialog( NEXT_ROOT+"includes/ktedit/instable.php",
                             args,
                             "font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:24em");
  if (arr != null) {
    for ( elem in arr ) {
      if ("NumRows" == elem && arr["NumRows"] != null) {
        document.ObjTableInfo.NumRows = arr["NumRows"];
      } else if ("NumCols" == elem && arr["NumCols"] != null) {
        document.ObjTableInfo.NumCols = arr["NumCols"];
      } else if ("TableAttrs" == elem) {
        document.ObjTableInfo.TableAttrs = arr["TableAttrs"];
      } else if ("CellAttrs" == elem) {
        document.ObjTableInfo.CellAttrs = arr["CellAttrs"];
      } else if ("Caption" == elem) {
        document.ObjTableInfo.Caption = arr["Caption"];
      }
    }
		activeElement.ExecCommand(DECMD_INSERTTABLE,OLECMDEXECOPT_DODEFAULT, pVar);  
  }
}
function logic_updateLink(o) {
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}
	var a = o.selectedIndex;
	//if(KT_onLink) {
	if(util_getVar("onLink")) {
		logic_doFormat('RemoveLink');
		o.selectedIndex = a;
		activeElement.DOM.focus();
		logic_InsertLink();
	}
	return true;
}
function logic_InsertLink(){
	if( util_getVar("displayMode") == "CODE" ) {
		return false;
	}
  var urlContainerValue = util_getValueFromActiveForm(activeFormName, "property_url", "TEXT", "value");
  var protocolType = util_getValueFromActiveForm(activeFormName, "property_protocol_type", "SELECT", "all");  
	util_restoreSelection();
	if(activeElement.DOM.selection.type == "Control" ) {
		var selText = activeElement.DOM.body.createTextRange(); //the image that is selected
		var tmp1 = activeElement.DOM.selection.createRange();
		selText.moveToElementText(tmp1.item(0));
	} else { //text selection
		var selText = activeElement.DOM.selection.createRange(); //the text that is selected
	}
  if(selText.htmlText) {
	  if(urlContainerValue!="") {
	    sUrl = protocolType.value + urlContainerValue;
		  activeElement.ExecCommand(DECMD_HYPERLINK,OLECMDEXECOPT_DONTPROMPTUSER,sUrl);
			logic_putTargetTag();
		} else {
		  activeElement.ExecCommand(DECMD_HYPERLINK,OLECMDEXECOPT_PROMPTUSER);
		}
	} else {
		alert("Please select some text");
	}
	return false;
}

function logic_InsertStyle(stName){
	if(activeElement.DOM.selection.type == "Text") {
		var sel = activeElement.DOM.selection.createRange();		
		var tmpstr = new String();
		tmpstr = sel.parentElement().outerHTML;
		regs = sel.htmlText.match(/<td/gi);
		if (regs && regs.length>1) {
			for (var i=0;i< selectableNodes.length;i++) {
				if (selectableNodes[i].tagName == "TABLE") 
					break;
			}
			arra = selectableNodes[i].all.tags("TD");
			for ( var k=0;k<arra.length;k++) {
				tdul = activeElement.DOM.body.createTextRange(); //
				tdul.moveToElementText(arra[k]); //expand the textrange to entire a tag contents
				if ( sel.inRange(tdul)) {
					arra[k].className = stName;
				}
			}
		} else { //not in a table
			if (sel.htmlText == sel.parentElement().outerHTML ) { 
				var tmpobj = sel.parentElement();
				if (stName!="") {  //other style
				tmpobj.className = stName;
				} else {
					if (tmpobj.tagName == "SPAN") {
						tmpobj.outerHTML = tmpobj.innerHTML;
					} else {
						tmpobj.className = stName;
					}
				}
			} else { 
				//introduce a new span
				if (stName!="") {
				sell = sel.htmlText;
				sel.pasteHTML("<span class=\""+stName+"\">"+sell+"</span>");
				} else {
					
				}
			}
		}
	} else if(activeElement.DOM.selection.type == "Control") {
		selectableNodes[0].className = stName;
	}
	return true;
}
function logic_InsertLinkToFile(arr) {
	var args = new Array();
	args["href"] = "";
	args["target"] = "";
	args["protocol"] = "";
	if (activeElement!=null) {
		if (arr != null) {
			var a = new String();
			a = arr["href"];
			a = a.replace(/http:\/\//, "");
		  var urlContainer = util_getValueFromActiveForm(activeFormName, "property_url", "TEXT", "all");
		  var urlTarget = util_getValueFromActiveForm(activeFormName, "property_targets", "SELECT", "all");
		  var urlProtocol = util_getValueFromActiveForm(activeFormName, "property_protocol_type", "SELECT", "all");
			urlContainer.value = a;
			urlTarget.selectedIndex = arr["target"];
			urlProtocol.selectedIndex = arr["protocol"];
			logic_InsertLink();
		}
	}
}
function logic_InsertImage(arr) {
  var args=new Array();
  if (activeElement!=null) {
  } else {
    alert("No active element to insert picture");  
  }  
  if (arr != null) {
  	strWidth = '';
  	strHeight = '';
  	if( arr["ImgWidth"] != "" && arr["ImgWidth"] != "0" ) {
  		strWidth = 'width="' + arr["ImgWidth"] +'"';
  	}
  	if( arr["ImgHeight"] != "" && arr["ImgHeight"] != "0" ) {
  		strHeight = ' height="' + arr["ImgHeight"] +'"';
  	}
    sHTML='<img src="' + arr["ImgUrl"] + '" alt="' + arr["AltText"] + '" '+ strWidth + strHeight +' vspace="' + arr["VerSpace"] + '" hspace="' + arr["HorSpace"] +  '"align="' + arr["ImgAlign"] +'"border="' + arr["ImgBorder"]+ '">';
    if ( util_getVar("displayMode") == 'RICH'){
      util_insertRawHtml(sHTML);
    }
  }
  activeElement.DOM.focus();
}

function logic_setDisplayMode(mode){
	if(mode=='CODE'){
		activeElement.DOM.body.clearAttributes;
		activeElement.DOM.body.style.fontFamily = 'Courier';
		activeElement.DOM.body.style.fontSize = '10px';
		if(activeElement.DOM.body.innerHTML != "") {
			activeElement.DOM.body.innerText = util_Transform(activeElement.FilterSourceCode(activeElement.DOM.body.innerHTML));
			activeElement.DOM.body.innerHTML = util_ccParser(activeElement.FilterSourceCode(activeElement.DOM.body.innerHTML));
		} else {
			activeElement.DOM.body.innerText="";
		}
		//displayMode = 'CODE';
		util_setVar("displayMode", "CODE", "string")
		toolbarHandler = eval(activeFormName);
		for(var i=0;i<toolbarHandler.all.length;i++) {
			var pbtn = toolbarHandler.all(i);
			if (pbtn.id != "changemode") {
				switch(pbtn.type) {
					case "btn":
						pbtn.className = "edit_disabled"; pbtn.state = 0;
						break;
					case "slc":
						pbtn.disabled = true;
						break;
					case "text":
						pbtn.disabled = true;
						break;
					case "checkbox":
						pbtn.disabled = true;
						break;						
				}
			}
		}
		toUpd = document.getElementById(activeDOMPropertyName); //the span to update 
		toUpd.innerHTML = "n/a in Source Mode";
	} else{
		activeElement.DOM.body.clearAttributes;
		activeElement.DOM.body.style.fontFamily='';
		activeElement.DOM.body.style.fontSize='';
		if(activeElement.DOM.body.innerText != "") {
			//activeElement.DOM.body.innerHTML = activeElement.FilterSourceCode(activeElement.DOM.body.innerText);
			activeElement.DOM.body.innerHTML = activeElement.DOM.body.innerText;
		} else {
			activeElement.DOM.body.innerHTML="";
		}
		//displayMode = 'RICH';
		util_setVar("displayMode", "RICH", "string")
		toolbarHandler = eval(activeFormName);
		for(var i=0;i<toolbarHandler.all.length;i++) {
			var pbtn = toolbarHandler.all(i);
			if (pbtn.id != "changemode") {
				switch(pbtn.type) {
					case "btn":
						pbtn.className = "edit_flat"; pbtn.state = 1;
						break;
					case "slc":
						pbtn.disabled = false;
						break;
					case "text":
						pbtn.disabled = false;
						break;
					case "checkbox":
						pbtn.disabled = false;
						break;
				}
			}
		}
		toUpd = document.getElementById(activeDOMPropertyName); //the span to update 
		toUpd.innerHTML = "";
	}
}

function util_checkFocus(obj, mandatory) {
	propname = obj.parentElement.id.replace(/Property_/, "");
	activname = activeElementName.replace(/_htmlObject/,"");
	var valToReturn = true;
	if (propname != activname) {
		if (mandatory) {
			alert('This is not the active editor context! ');
			valToReturn = false;
		} else {
			eval("document.all." + propname + "_htmlObject.activate()");
		}
	}
	return valToReturn;
}
