var __aspxHEIsDocumentDragOver = false;
var __aspxHEDragDropDelay = 100;
var __aspxHEMarkID = "dxMID";
var __aspxHEMarkClassName = "dxMClassName";
var __aspxHEMarkFontAttr = "dxattr";
var __aspxHEMarkFontFace = "ABC";
var __aspxHEDesignViewDocumentCssClassName = "dxheDesignViewDoc";
var __aspxHEPreviewDocumentCssClassName = "dxhePreviewDoc";
var __aspxHEPreservedTagNamePrefix = "ASPxPreservedTag_";
ASPxClientHtmlEditorIDSuffix = {
 ContentHtmlHiddenField: "_Html",
 CurrentDialogHiddenField: "_CurDialog",
 DesignViewIFrame: "_DesignIFrame",
 DesignViewCell: "_DesignViewCell",
 EditAreaCell: "_EdtCell",
 FakeFocusInput: "_FFI",
 HtmlViewEdit: "_HtmlViewEdit",
 MainCell: "_MainCell",
 PopupDialogControl: "_DPP",
 PopupMenu: "_PPM",
 PreviewIFrame: "_PreviewIFrame",
 PreviewCell: "_PreviewCell",
 TabControl: "_TC",
 Toolbar: "_TD",
 ToolbarRow: "_TBRow",
 StatusBarCell: "_SBarCell",
 SpellChecker : "_SC"
};
var __aspxHESaveImageToServerCallbackPrefix = "ImageToServer";
var __aspxHEThumbnailImageWidthCallbackPrefix = "TNIW";
var __aspxHEThumbnailImageHeightCallbackPrefix = "TNIH";
var __aspxHEThumbnailImageFileNameCallbackPrefix = "TNIF";
var __aspxHESwitchToDesignViewCallbackPrefix = "ProcessHtml_Design";
var __aspxHESwitchToHtmlViewCallbackPrefix = "ProcessHtml_Html";
var __aspxHESwitchToPreviewCallbackPrefix = "ProcessHtml_Preview";
var __aspxHESpellCheckingCallbackPrefix = "SpellCheck";
var __aspxSaveImageToServerErrorCallbackPrefix = "ISE";
var __aspxSaveImageToServerNewUrlCallbackPrefix = "ISU";
var __aspxJSEventHadlersRegExpPattern = "(\\s(\\bon[a-zA-Z][a-z]+)\\s?\=\\s?[\'\"]?(javascript\:)?[\\w\(\\),\\' ]*;?[\\'\\\"]?)+";
var __aspxJSTagsRegExpPattern = "<(script)([^>]*)>[\\s\\S]*?</(script)([^>]*)>";
var __aspxHEEmptyTagsRegExpPattern = "^<(p|div|address|h\\d|center|strong)(?=[ >])[^>]*>(?:\\s*|&nbsp;|<br\\/\\>|<br \\/\\>|<br>)(<\\/\\1>)?$";
var __aspxHEEmptyHtmlRegExpPattern = "^(<br\\/\\>|<br \\/\\>|<br>|&nbsp;)?$";
ASPxClientHtmlEditorView = {
 Design: "D",
 Html: "H",
 Preview: "P"
};
ASPxClientHtmlEditorCommandEventArgs = _aspxCreateClass(ASPxClientEventArgs, {
 constructor: function(commandName, parameter, isSuccessful) {
  this.constructor.prototype.constructor.call(this);
  this.commandName = commandName;
  this.parameter = parameter;
  this.isSuccessful = isSuccessful;
 }
});
ASPxHtmlEditorsCollection = _aspxCreateClass(null, {
 constructor: function() {
  this.htmlEditors = [ ];
  aspxGetPostHandler().Post.AddHandler(function(s, e) {
   aspxGetHtmlEditorsCollection().Synchronize();
  });
 },
 Push: function(htmlEditor) {
  for(var i = 0; i < this.htmlEditors.length; i++) {
   if (this.htmlEditors[i].name == htmlEditor.name) {
    this.htmlEditors[i] = htmlEditor;
    return;
   }
  }
  this.htmlEditors.push(htmlEditor);
 },
 AdjustSizeToContainer: function() {
  for (var i = 0; i < this.htmlEditors.length; i++)
   this.htmlEditors[i].AdjustSizeToContainer();
 },
 Synchronize: function() {
  for (var i = 0; i < this.htmlEditors.length; i++) {
   var htmlEditor = this.htmlEditors[i];
   htmlEditor.Synchronize();
  }
 },
 FocusActiveEditorToolbar: function() {
  for (var i = 0; i < this.htmlEditors.length; i++)
   if(this.htmlEditors[i].isInFocus)
    this.htmlEditors[i].FocusToolbar();
 }
});
function aspxGetHtmlEditorsCollection() {
 if (!_aspxIsExistsType(typeof(window.__aspxHEHtmlEditorsCollection))) {
  window.__aspxHEHtmlEditorsCollection = new ASPxHtmlEditorsCollection();
 }
 return window.__aspxHEHtmlEditorsCollection;
}
ASPxHtmlEditorLayoutCalculator = _aspxCreateClass(null, {
 UpdateLayout: function(htmlEditor, activeView, isInitializing) {
  if (!htmlEditor.IsVisible())
   return;
  if (isInitializing)
   this.FixHtmlEditMainElementWidth(htmlEditor);
  if (__aspxIE && isInitializing)
   this.CalculateTableCellsHeight(htmlEditor, activeView);
  this.HideViewAreas(htmlEditor);
  if (__aspxIE) {
   var contentCellHeight = this.CalculateContentCellHeight(htmlEditor, activeView);
   this.CollapseContentCell(htmlEditor);
  }
  this.UpdateToolbarRowDisplay(htmlEditor, activeView);
  this.CollapseViewAreas(htmlEditor);
  this.ShowHideViewAreasDependingOnActiveView(htmlEditor, activeView);
  if (__aspxIE)
   this.SetContentCellCalculatedHeight(htmlEditor, contentCellHeight);
  this.CorrectActiveViewAreaHeight(htmlEditor, activeView);
  if (__aspxNetscapeFamily && !htmlEditor.IsHtmlView(activeView))
   this.FixToolbarTableBorder_NS(htmlEditor);
 },
 CalculateTableCellsHeight: function(htmlEditor, activeView) {
  htmlEditor.calculatedToolbarCellHeight = 0;
  htmlEditor.calculatedStatusBarCellHeigth = 0;
  var toolbarCell = htmlEditor.GetToolbarCell();
  if (_aspxIsExists(toolbarCell)) {
   var savedToolbarIsVisible = this.IsToolbarRowVisible(htmlEditor, activeView);
   this.ShowHideToolbarRow(htmlEditor, true);
   htmlEditor.calculatedToolbarCellHeight = _aspxGetClearClientHeight(toolbarCell);
   this.ShowHideToolbarRow(htmlEditor, savedToolbarIsVisible);
  }
  var statusBarCell = htmlEditor.GetStatusBarCell();
  if (_aspxIsExists(statusBarCell))
   htmlEditor.calculatedStatusBarCellHeigth = _aspxGetClearClientHeight(statusBarCell);
 },
 FixHtmlEditMainElementWidth: function(htmlEditor) {
  var mainElement = htmlEditor.GetMainElement();
  mainElement.style.width = (mainElement.offsetWidth > 0) ? (mainElement.offsetWidth + "px") : "100%";
 },
 ShowHideViewAreas: function(htmlEditor, showDesignView, showHtmlView, showPreview) {
  var designViewTable = htmlEditor.GetDesignViewTable();
  var htmlViewEdit = htmlEditor.GetHtmlViewEdit();
  var previewTable = htmlEditor.GetPreviewTable();
  if (_aspxIsExists(designViewTable))
   _aspxSetElementDisplay(designViewTable, showDesignView);
  if (_aspxIsExists(htmlViewEdit))
   htmlViewEdit.SetVisible(showHtmlView);
  if (_aspxIsExists(previewTable))
   _aspxSetElementDisplay(previewTable, showPreview);
 },
 HideViewAreas: function(htmlEditor) {
  this.ShowHideViewAreas(htmlEditor, false, false, false);
 },
 UpdateToolbarRowDisplay: function(htmlEditor, activeView) {
  this.ShowHideToolbarRow(htmlEditor, this.IsToolbarRowVisible(htmlEditor, activeView));
 },
 IsToolbarRowVisible: function(htmlEditor, activeView) {
  return htmlEditor.IsDesignView(activeView);
 },
 ShowHideToolbarRow: function(htmlEditor, isDisplayed) {
  var toolbarRow = htmlEditor.GetToolbarRow();
  if (_aspxIsExists(toolbarRow)) {
   _aspxSetElementDisplay(toolbarRow, isDisplayed);
  }
 },
 CalculateContentCellHeight: function(htmlEditor, activeView) {
  var mainCell = htmlEditor.GetMainCell();
  var mainCellHeight = _aspxGetClearClientHeight(mainCell);
  var toolbarCellHeight = htmlEditor.IsDesignView(activeView) ? htmlEditor.calculatedToolbarCellHeight : 0;
  return (mainCellHeight - toolbarCellHeight - htmlEditor.calculatedStatusBarCellHeigth);
 },
 CollapseContentCell: function(htmlEditor) {
  this.SetContentCellCalculatedHeight(htmlEditor, 0);
 },
 SetContentCellCalculatedHeight: function(htmlEditor, height) {
  var contentCell = htmlEditor.GetEditAreaCell();
  if (height != null)
   _aspxSetOffsetHeight(contentCell, height);
  else
   contentCell.style.height = "";
 },
 CollapseViewAreas: function(htmlEditor) {
  var designViewCell = htmlEditor.GetDesignViewCell();
  var htmlEdit = htmlEditor.GetHtmlViewEdit();
  var previewCell = htmlEditor.GetPreviewCell();
  if (_aspxIsExists(designViewCell))
   designViewCell.style.height = "0";
  if (_aspxIsExists(htmlEdit))
   htmlEdit.GetInputElement().style.height = "0";
  if (_aspxIsExists(previewCell))
   previewCell.style.height = "0";
 },
 ShowHideViewAreasDependingOnActiveView: function(htmlEditor, activeView) {
  this.ShowHideViewAreas(htmlEditor, htmlEditor.IsDesignView(activeView), htmlEditor.IsHtmlView(activeView), htmlEditor.IsPreview(activeView));
 },
 CorrectActiveViewAreaHeight: function(htmlEditor, activeView) {
  if (htmlEditor.IsDesignView(activeView))
   this.CorrectDesignViewAreaHeight(htmlEditor);
  else if (htmlEditor.IsHtmlView(activeView))
   this.CorrectHtmlViewAreaHeight(htmlEditor);
  else if (htmlEditor.IsPreview(activeView))
   this.CorrectPreviewAreaHeight(htmlEditor);
 },
 CorrectDesignViewAreaHeight: function(htmlEditor) {
  this.CorrectIFrameContainingAreaHeight(htmlEditor, htmlEditor.GetDesignViewCell(), htmlEditor.GetDesignViewIFrameElement());
 },
 CorrectHtmlViewAreaHeight: function(htmlEditor) {
  var htmlViewEdit = htmlEditor.GetHtmlViewEdit();
  if (_aspxIsExists(htmlViewEdit))
   htmlViewEdit.AdjustControl(false, true );
 },
 CorrectPreviewAreaHeight: function(htmlEditor) {
  this.CorrectIFrameContainingAreaHeight(htmlEditor, htmlEditor.GetPreviewCell(), htmlEditor.GetPreviewIFrameElement());
 },
 CorrectIFrameContainingAreaHeight: function(htmlEditor, viewCell, viewIFrameElement) {
  var contentCell = htmlEditor.GetEditAreaCell();
  _aspxSetElementDisplay(viewIFrameElement, false);
  if (__aspxNetscapeFamily || __aspxOpera) {
   var height = _aspxGetClearClientHeight(contentCell);
   var viewCellCalculatedStyle = _aspxGetCurrentStyle(viewCell);
   height -= Math.round((_aspxPxToInt(viewCellCalculatedStyle.borderTopWidth) + _aspxPxToInt(viewCellCalculatedStyle.borderBottomWidth)) / 2.0);
   _aspxSetOffsetHeight(viewCell, height);
  } else {
   _aspxSetOffsetHeight(viewCell, _aspxGetClearClientHeight(contentCell));
  }
  viewIFrameElement.style.height = "100%";
  _aspxSetElementDisplay(viewIFrameElement, true);
 },
 FixToolbarTableBorder_NS: function(htmlEditor) {
  var table = htmlEditor.GetToolbarTable();
  if (_aspxIsExists(table)) {
   var borderCollapse = table.style.borderCollapse;
   table.style.borderCollapse = "";
   table.style.borderCollapse = borderCollapse;
  }
 }
});
__aspxHtmlEditorLayoutCalculator = null;
function aspxGetHtmlEditorLayoutCalculator() {
 if (__aspxHtmlEditorLayoutCalculator == null)
  __aspxHtmlEditorLayoutCalculator = new ASPxHtmlEditorLayoutCalculator();
 return __aspxHtmlEditorLayoutCalculator;
}
var __aspxHEClientStateInputIDSuffix = "_ClientState";
var __aspxHEClientStateRecordSeparator = '|';
ASPxClientHtmlEditorClientState = _aspxCreateClass(null, {
 constructor: function(htmlEditor) {
  this.htmlEditor = htmlEditor;
  this.clientStateInput = null;
  this.fieldsNameValueCollection = this.ParseStateStr();
 },
 GetClientStateInput: function() {
  if (this.clientStateInput == null)
   this.clientStateInput = this.FindClientStateInput();
  return this.clientStateInput;
 },
 FindClientStateInput: function() {
  return _aspxGetElementById(this.htmlEditor.name + __aspxHEClientStateInputIDSuffix);
 },
 SetFieldValue: function(name, value) {
  this.fieldsNameValueCollection[name] = value;
  this.Save(this.fieldsNameValueCollection);
 },
 ParseStateStr: function() {
  var state = this.GetClientStateInput().value;
  collection = {};
  var startIndex = 0;
  while(startIndex < state.length)
   startIndex = this.ParseFieldRecord(state, startIndex, collection);
  return collection;
 },
 ParseFieldRecord: function(state, startIndex, collection) {
  var indexOfFirstSeparator = state.indexOf(__aspxHEClientStateRecordSeparator, startIndex);
  var fieldName = state.substr(startIndex, indexOfFirstSeparator - startIndex);
  startIndex += fieldName.length + 1;
  var indexOfSecondSeparator = state.indexOf(__aspxHEClientStateRecordSeparator, startIndex);
  var fieldValueLengthStr = state.substr(startIndex, indexOfSecondSeparator - startIndex);
  startIndex += fieldValueLengthStr.length + 1;
  var fieldValueLength = parseInt(fieldValueLengthStr);
  var fieldValue = state.substr(startIndex, fieldValueLength);
  startIndex += fieldValueLength;
  collection[fieldName] = fieldValue;
  return startIndex;
 },
 Save: function(collection) {
  var result = [];
  for(var fieldName in collection) {
   var value = collection[fieldName];
   if (typeof(value) == "string")
    result.push(fieldName + __aspxHEClientStateRecordSeparator + value.length + __aspxHEClientStateRecordSeparator + value);
  }
  this.GetClientStateInput().value = result.join('');
 }
});
ASPxClientHtmlEditor = _aspxCreateClass(ASPxClientControl, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.allowDesignView = true;
  this.allowHtmlView = true;
  this.allowPreview = true;
  this.allowContextMenu = true;
  this.allowScripts = false;
  this.allowInsertDirectImageUrls = true;
  this.cssFileLinkArray = [];
  this.designViewIFrameDocumentStyleCssText = "";
  this.previewIFrameDocumentStyleCssText = "";
  this.html = "";
  this.activeView = ASPxClientHtmlEditorView.Design;
  this.uploadImageFileDirectoryPath = "";
  this.updateDeprecatedElements = true;
  this.areDictionariesAssigned = true; 
  this.clientState = new ASPxClientHtmlEditorClientState(this);
  this.callbackOwner = null;
  this.spellCheckerCallback = false;
  this.isDraggingInsideEditor = false;
  this.isDropExternalContentExecuted = false;
  this.dragDropTimerID = null;
  this.beforePopupSelection = null;
  this.CustomCommand = new ASPxClientEvent();
  this.CommandExecuted = new ASPxClientEvent();
  this.GotFocus = new ASPxClientEvent();
  this.LostFocus = new ASPxClientEvent();
  this.SelectionChanged = new ASPxClientEvent();
  this.HtmlChanged = new ASPxClientEvent();
  this.currentBgColor = null;
  this.currentFontColor = null;
  this.isWidthDefinedInPercent = false;
  this.initialMainElementWidth = -1;
  this.mainElementParentNodeWidthHashTable = {};
  this.layoutCalculator = aspxGetHtmlEditorLayoutCalculator();
  this.eventListener = null;
  this.commandManager = null;
  this.isErrorOnCallback = false;
  this.isMouseDown = false;
  this.isInFocus = false;
  this.keyboardManager = null;
  this.toolbar = null;
  this.shortcutCmdID = null;
  this.executingCommandName = null;
  this.pasteContainer = null;
  this.savedPreviewHtmlAfterSet = ""; 
  this.cachedElementsManager = new ASPxCachedElementsManager(this);
  this.sizingConfig.correction = true;
  this.sizingConfig.adjustControl = true;
 },
 InlineInitialize: function() {
  if (!__aspxOpera || !this.allowDesignView) {
   this.InitAreas();
   this.UpdateLayout(this.activeView, false);
  }
  this.InitializeSpellChecker();
 },
 Initialize: function() {
  ASPxClientControl.prototype.Initialize.call(this);
  aspxGetHtmlEditorsCollection().Push(this);
  if (!__aspxOpera && this.allowDesignView)
   this.InitializeManagers();
  this.InitializeMainElementParentNodeInfo();
 },
 InitializeManagers: function() {
  if (this.allowDesignView) {
   this.commandManager = new CommandManager(this);
   this.keyboardManager = new KeyboardManager();
   this.toolbar = this.GetToolbar();
   this.InitializeEventListner();
   this.InitializeShortcuts();
  }
 },
 InitializeMainElementParentNodeInfo: function() {
  this.SaveMainElementParentNodeWidth();
  this.initialMainElementWidth = this.GetMainElement().style.width;
  this.isWidthDefinedInPercent = this.initialMainElementWidth.indexOf("%") != -1;
 },
 InitAreas: function() {
  if (this.allowDesignView)
   this.InitDesignViewIFrame();
  if (this.allowPreview)
   this.InitPreviewIFrame();
  if (this.allowHtmlView)
   this.InitHtmlViewArea();
  var name = this.name;
  window.setTimeout(function() { 
   var htmlEditor = aspxGetControlCollection().Get(name);
   if(htmlEditor.html != "")
    htmlEditor.SetHtmlInternal(htmlEditor.html);
  }, 0);
 },
 InitializeSpellChecker: function() {
  var spellChecker = this.GetSpellCheckerClientInstance();
  if (_aspxIsExists(spellChecker)) {
   var method = new Function("sender", "args", "aspxHESpellCheckerWordChanged(\"" + this.name + "\", sender, args);");
   spellChecker.WordChanged.AddHandler(method);
   spellChecker.ReCheck = this.ReCheck;
   spellChecker.htmlEditor = this;
  }
 },
 InitDesignViewIFrame: function() {
  this.InitIFrame(this.GetDesignViewIFrameName(), "", this.cssFileLinkArray);
  this.InitDesignViewIFrameStyle();
 },
 InitPreviewIFrame: function() {
  this.InitIFrame(this.GetPreviewIFrameName(), "", this.cssFileLinkArray);
  this.InitPreviewIFrameStyle();
 },
 InitHtmlViewArea: function() {
  this.DisableSpellCheckerAttribute(this.GetHtmlViewEdit().GetInputElement());
 },
 InitializeEventListner: function() {
  this.eventListener = new EventListener(this);
 },
 InitializeShortcuts: function() {
  this.shortcutCmdID = null;
  for (var i = 0; i < ASPxShortcuts.length; i++)
   this.keyboardManager.AddShortcut(ASPxShortcuts[i][1], ASPxShortcuts[i][0]);
 },
 InitIFrame: function(iframeName, bodyContentHtml, cssFileLinkArray) {
  var doc = _aspxIFrameDocument(iframeName);
  var element = _aspxIFrameElement(iframeName);
  if (doc != null && element != null) {
   this.InitIFrameDocument(doc, bodyContentHtml, cssFileLinkArray);
   if (__aspxOpera)
    doc.body.style.height = "100%";
   element.style.height = "100%";
   doc.body.className = element.className;
  }
 },
 InitIFrameDocument: function(doc, bodyContentHtml, cssFileLinkArray) {
  doc.open();
  doc.write(this.GetIFrameDocumentHtml(bodyContentHtml));
  doc.close();
  doc.body.style.borderWidth = 0;
  this.DisableSpellCheckerAttribute(doc.body);
  this.AddCssFileLinksToDocument(doc, cssFileLinkArray);
 },
 InitDesignViewIFrameStyle: function() {
  if (this.designViewIFrameDocumentStyleCssText != "") {
   var designViewIFrameDocumentStyleSheet = _aspxCreateStyleSheetInDocument(this.GetDesignViewIFrameDocument());
   _aspxAddStyleSheetRule(designViewIFrameDocumentStyleSheet,
      "." + __aspxHEDesignViewDocumentCssClassName, this.designViewIFrameDocumentStyleCssText);
   this.GetDesignViewIFrameDocumentBody().className += " " + __aspxHEDesignViewDocumentCssClassName;
  }
 },
 InitPreviewIFrameStyle: function() {
  if (this.previewIFrameDocumentStyleCssText != "") {
   var previewIFrameDocumentStyleSheet = _aspxCreateStyleSheetInDocument(this.GetPreviewIFrameDocument());
   _aspxAddStyleSheetRule(previewIFrameDocumentStyleSheet,
      "." + __aspxHEPreviewDocumentCssClassName, this.previewIFrameDocumentStyleCssText);
   this.GetPreviewIFrameDocumentBody().className += " " + __aspxHEPreviewDocumentCssClassName;
  }
 },
 AddCssFileLinksToDocument: function(doc, linkArray) {
  for (var i = 0; i < linkArray.length; i++) {
   _aspxAddStyleSheetLinkToDocument(doc, linkArray[i]);
  }
 },
 SetClientStateFieldValue: function(name, value) {
  this.clientState.SetFieldValue(name, value);
 },
 GetCurrentDialogHiddenInput: function() {
  return _aspxGetElementById(this.name + ASPxClientHtmlEditorIDSuffix.CurrentDialogHiddenField);
 },
 GetDesignViewCell: function() {
  return _aspxGetElementById(this.name + ASPxClientHtmlEditorIDSuffix.DesignViewCell);
 },
 GetDesignViewTable: function() {
  return _aspxGetParentByTagName(this.GetDesignViewCell(), "table");
 },
 GetPreviewTable: function() {
  return _aspxGetParentByTagName(this.GetPreviewCell(), "table");
 },
 GetPreviewCell: function() {
  return _aspxGetElementById(this.name + ASPxClientHtmlEditorIDSuffix.PreviewCell);
 },
 GetDesignViewIFrameDocument: function() {
  return _aspxIFrameDocument(this.GetDesignViewIFrameName());
 },
 GetDesignViewIFrameDocumentBody: function() {
  return _aspxIFrameDocumentBody(this.GetDesignViewIFrameName());
 },
 GetDesignViewIFrameWindow: function() {
  return _aspxIFrameWindow(this.GetDesignViewIFrameName());
 },
 GetEditAreaCell: function() {
  return _aspxGetElementById(this.name + ASPxClientHtmlEditorIDSuffix.EditAreaCell);
 },
 GetDialogPopupControl: function() {
  return aspxGetControlCollection().Get(this.name + ASPxClientHtmlEditorIDSuffix.PopupDialogControl);
 },
 GetDesignViewIFrameElement: function() {
  return _aspxIFrameElement(this.GetDesignViewIFrameName());
 },
 GetDesignViewIFrameName: function() {
  return this.name + ASPxClientHtmlEditorIDSuffix.DesignViewIFrame;
 },
 GetActualMainElementParentNodeWidth: function() {
  return this.GetMainElement().parentNode.offsetWidth;
 },
 GetSavedMainElementParentNodeWidth: function(view) {
  return this.mainElementParentNodeWidthHashTable[view];
 },
 GetPreviewIFrameName: function() {
  return this.name + ASPxClientHtmlEditorIDSuffix.PreviewIFrame;
 },
 GetPreviewIFrameElement: function() {
  return _aspxIFrameElement(this.GetPreviewIFrameName());
 },
 GetPreviewIFrameDocument: function() {
  return _aspxIFrameDocument(this.GetPreviewIFrameName());
 },
 GetPreviewIFrameDocumentBody: function() {
  return _aspxIFrameDocumentBody(this.GetPreviewIFrameName());
 },
 GetElementDocument: function(element) {
  return element.ownerDocument || element.document;
 },
 GetFakeFocusInputElement: function() {
  return _aspxGetElementById(this.name + ASPxClientHtmlEditorIDSuffix.FakeFocusInput);
 },
 GetHtmlViewEdit: function() {
  return aspxGetControlCollection().Get(this.name + ASPxClientHtmlEditorIDSuffix.HtmlViewEdit);
 },
 GetMainCell: function() {
  return _aspxGetElementById(this.name + ASPxClientHtmlEditorIDSuffix.MainCell);
 },
 GetContextMenu: function() {
  return aspxGetControlCollection().Get(this.name + ASPxClientHtmlEditorIDSuffix.PopupMenu);
 },
 GetToolbar: function() { 
  return aspxGetControlCollection().Get(this.name + ASPxClientHtmlEditorIDSuffix.Toolbar);
 },
 GetTabControl: function() {
  return aspxGetControlCollection().Get(this.name + ASPxClientHtmlEditorIDSuffix.TabControl);
 },
 GetToolbarRow: function() {
  return this.GetChild(ASPxClientHtmlEditorIDSuffix.ToolbarRow);
 },
 GetToolbarTable: function() {
  return _aspxGetParentByTagName(this.GetToolbarRow(), "table");
 },
 GetToolbarCell: function() {
  return _aspxGetChildByTagName(this.GetToolbarRow(), "td", 0);
 },
 GetStatusBarCell: function() {
  return _aspxGetElementById(this.name + ASPxClientHtmlEditorIDSuffix.StatusBarCell);
 },
 GetSpellCheckerClientInstance: function() {
  return aspxGetControlCollection().Get(this.name + ASPxClientHtmlEditorIDSuffix.SpellChecker);
 },
 GetHtmlSyncHiddenField: function() {
  return _aspxGetElementById(this.name + ASPxClientHtmlEditorIDSuffix.ContentHtmlHiddenField);
 },
 SaveMainElementParentNodeWidth: function(view) {
  if (!_aspxIsExists(view))
   view = this.activeView;
  this.mainElementParentNodeWidthHashTable[view] = this.GetActualMainElementParentNodeWidth();
 },
 UpdateLayout: function(activeView, isInitializing) {
  if (!_aspxIsExists(isInitializing))
   isInitializing = false;
  this.layoutCalculator.UpdateLayout(this, activeView, isInitializing);
 },
 UpdateToolbarAndMenu: function() {
  if (this.allowDesignView && this.IsDesignView()) {
   this.UpdateToolbarImmediately();
   this.UpdateContextMenu();
  }
 },
 AdjustSizeToContainer: function(view) {
  if(!_aspxIsExistsElement(this.GetMainElement()))
   return;
  if (!this.isWidthDefinedInPercent) return;
  if (!_aspxIsExists(view))
   view = this.activeView;
  this.AdjustSizeToContainerCore(view);
 },
 AdjustSizeToContainerCore: function(view) {
  if (this.NeedWidthCorrection(view)) {
   this.GetMainElement().style.width = this.initialMainElementWidth;
   if(this.IsHtmlView() && __aspxIE
    && __aspxBrowserVersion < 8 )
    this.GetHtmlViewEdit().GetInputElement().style.width = "0px";
   this.AdjustControl();
  }
  this.SaveMainElementParentNodeWidth(view);
 },
 NeedWidthCorrection: function(view) {
  if (__aspxIE && __aspxBrowserMajorVersion == 6) return true;
  return this.GetActualMainElementParentNodeWidth() != this.GetSavedMainElementParentNodeWidth(view);
 },
 AdjustControlCore: function() {
  var needSetFocus = !(__aspxNetscapeFamily);
  var scrollX = _aspxGetDocumentScrollLeft();
  var scrollY = _aspxGetDocumentScrollTop();
  if (this.IsDesignView()) {
   this.SetDesignModeAttribute();
   if (needSetFocus)
    this.SetFocus();
  }
  this.UpdateToolbarAndMenu();
  this.UpdateLayout(this.activeView, true);
  if (this.IsDesignView() && needSetFocus) {
   this.RemoveFocus();
   window.scrollTo(scrollX, scrollY);
  }
 },
 IsStatusBarShown: function() {
  return (this.allowDesignView ? 1 : 0) + (this.allowHtmlView ? 1 : 0) + (this.allowPreview ? 1 : 0) > 1;
 },
 SetDesignModeAttribute: function() {
  var doc = _aspxIFrameDocument(this.GetDesignViewIFrameName());
  if (__aspxNetscapeFamily)
   doc.designMode = "on";
  else
   doc.body.contentEditable = true;
 },
 DisableSpellCheckerAttribute: function(element) {
  if (__aspxFirefox)
   element.spellcheck = false;
 },
 ShowLoadingPanel: function() {
  var container = this.GetMainElement();
  this.CreateLoadingDiv(document.body, container);
  this.CreateLoadingPanelWithAbsolutePosition(document.body, container);
 },
 Focus: function() {
  this.SetFocus();
 },
 ClearFocusInput: function() {
  var focusInputElement = this.GetFakeFocusInputElement();
  if (_aspxIsExists(focusInputElement))
   focusInputElement.value = "";
 },
 SetActive: function() { 
  if (__aspxIE) {
   var iFrame = this.GetDesignViewIFrameElement();
   if (_aspxIsExists(iFrame))
    iFrame.setActive();
  }
 },
 SetFocus: function() {
  if (this.IsDesignView()) {
   var docObj = this.GetDesignViewIFrameWindow();
   if (__aspxWebKitFamily && !this.isInitialized)
    var docObj = this.GetDesignViewIFrameDocumentBody();
   docObj.focus();
  }
  else if (this.IsHtmlView())
   this.GetHtmlViewEdit().SetFocus();
 },
 RemoveFocus: function() {
  var inputElement = this.GetFakeFocusInputElement();
  _aspxRemoveAttribute(inputElement, "disabled");
  try {
   inputElement.focus();
  }
  catch (e) { }
  if (__aspxIE || (__aspxWebKitFamily && !this.isInitialized)) {
   try {
    window.focus();
   }
   catch (e) { }
  }
  inputElement.disabled = "disabled";
 },
 GetHtml: function() {
  return this.ProcessHtmlToGetHtml(this.GetHtmlInternal());
 },
 GetHtmlInternal: function() {
  var html = this.html;
  if (this.IsDesignView() && this.IsExistsWindowInIFrame(this.GetDesignViewIFrameName()))
   html = this.GetDesignViewIFrameDocumentBody().innerHTML;
  else if (this.IsHtmlView() && _aspxIsExistsElement(this.GetHtmlViewEdit().GetMainElement()))
   html = this.GetHtmlViewEdit().GetText();
  else if (this.IsExistsWindowInIFrame(this.GetPreviewIFrameName()))
   html = this.savedPreviewHtmlAfterSet;
  return html;
 },
 SetHtml: function(html) {
  this.ClearUndoHistory();
  this.SetHtmlInternal(html);
  this.OnHtmlChanged(false);
 },
 SetHtmlInternal: function(html, newActiveView) {
  if (!_aspxIsExists(newActiveView))
   newActiveView = this.activeView;
  html = this.ProcessHtmlToSetHtml(html, newActiveView);
  if (this.allowDesignView && this.IsDesignView(newActiveView)) {
   this.SetInnerHtmlToBody(this.GetDesignViewIFrameDocumentBody(), html);
   this.ProcessDesignViewDocumentDomAfterSetHtml();
  }
  if (this.allowHtmlView && this.IsHtmlView(newActiveView))
   this.GetHtmlViewEdit().SetText(html);
  if (this.allowPreview && this.IsPreview(newActiveView)) {
   _aspxSetInnerHtml(this.GetPreviewIFrameDocumentBody(), html);
   this.savedPreviewHtmlAfterSet = this.GetPreviewIFrameDocumentBody().innerHTML;
   this.ProcessPreviewDocumentDomAfterSetHtml();
  }
 },
 ProcessHtmlToSetHtml: function(html, newActiveView) {
  if (this.IsPreview(newActiveView) || this.IsDesignView(newActiveView)) {
   html = ASPxClientHtmlEditor.PreserveTagsByName("noscript", html);
   if (!this.allowScripts)
    html = ASPxClientHtmlEditor.CleanHtmlScripts(html);
   else
    html = ASPxClientHtmlEditor.PreserveTagsByName("script", html);
   if (this.IsDesignView(newActiveView)) {
    if (__aspxIE)
     html = ASPxClientHtmlProcessingUtils.ReplaceUnderlineSpanWithUTag(html);
    if (this.updateDeprecatedElements)
     html = ASPxClientHtmlProcessingUtils.ReplaceSpanWithFontTag(html);
   }
   html = this.DeconvertEmptyHtml(html);
  } else if (this.IsHtmlView(newActiveView))
   html = this.ConvertToEmptyHtml(html);
  return html;
 },
 ProcessDesignViewDocumentDomAfterSetHtml: function() {
  ASPxClientHtmlProcessingUtils.ReplaceTableStyleBorderByAttribute(this.GetDesignViewIFrameDocumentBody());
  ASPxClientHtmlProcessingUtils.AddEmptyBorderClassInTables(this.GetDesignViewIFrameDocumentBody());
 },
 ProcessPreviewDocumentDomAfterSetHtml: function() {
  ASPxClientHtmlProcessingUtils.ReplaceLinkTargetWithBlank(this.GetPreviewIFrameDocumentBody());
 },
 ProcessHtmlToGetHtml: function(html) {
  if (this.IsPreview() || this.IsDesignView()) {
   html = this.ConvertToEmptyHtml(ASPxClientHtmlEditor.DepreserveTagsByName("noscript", html));
   if (this.allowScripts)
    html = ASPxClientHtmlEditor.DepreserveTagsByName("script", html);
   if (this.IsDesignView()) {
    if (this.updateDeprecatedElements)
     html = ASPxClientHtmlProcessingUtils.ReplaceFontWithSpanTag(html);
    html = ASPxClientHtmlProcessingUtils.FilterHtmlToGetHtml(html);
    html = ASPxClientHtmlProcessingUtils.RemoveEmptyBorderClassName(html);
   }
  }
  return html;
 },
 SetInnerHtmlToBody: function(bodyElement, html) {
  _aspxSetInnerHtml(bodyElement, html);
  if (__aspxIE) 
   ASPxClientHtmlProcessingUtils.CleanWrongSizeAttribute(bodyElement);
 },
 Synchronize: function() {
  if(this.IsControlExist()) {
   this.SynchronizeContentHtml();
   this.ClearFocusInput();
  }
 },
 SynchronizeContentHtml: function() {
  var htmlSyncInput = this.GetHtmlSyncHiddenField();
  if (_aspxIsExistsElement(htmlSyncInput)) {
   var html = this.GetHtml();
   this.syncronizedHtml = html; 
   htmlSyncInput.value = _aspxEncodeHtml(html);
  }
 },
 IsControlExist: function() {
  return _aspxIsExistsElement(this.GetMainElement());
 },
 IsDesignView: function(view) {
  if (!_aspxIsExists(view))
   view = this.activeView;
  return view == ASPxClientHtmlEditorView.Design;
 },
 IsHtmlView: function(view) {
  if (!_aspxIsExists(view))
   view = this.activeView;
  return view == ASPxClientHtmlEditorView.Html;
 },
 IsPreview: function(view) {
  if (!_aspxIsExists(view))
   view = this.activeView;
  return view == ASPxClientHtmlEditorView.Preview;
 },
 ChangeActiveView: function(activeView) {
  if (activeView == this.activeView)
   return;
  switch (activeView) {
   case ASPxClientHtmlEditorView.Design:
    this.SetDesignActiveView();
    break;
   case ASPxClientHtmlEditorView.Html:
    this.SetHtmlActiveView();
    break;
   case ASPxClientHtmlEditorView.Preview:
    this.SetPreviewActiveView();
    break;
  }
  this.activeView = activeView;
 },
 SetDesignActiveView: function() {
  this.SetClientStateFieldValue("ActiveView", "Design");
  if (this.IsHtmlView())
   this.ClearUndoHistory();
  this.SendCallback(__aspxHESwitchToDesignViewCallbackPrefix, "", true);
 },
 SetHtmlActiveView: function() {
  this.SetClientStateFieldValue("ActiveView", "Html");
  if (this.IsDesignView())
   this.ClearUndoHistory();
  this.SendCallback(__aspxHESwitchToHtmlViewCallbackPrefix, "", true);
 },
 SetPreviewActiveView: function() {
  this.SetClientStateFieldValue("ActiveView", "Preview");
  this.ClearUndoHistory();
  this.SendCallback(__aspxHESwitchToPreviewCallbackPrefix, "", true);
 },
 SwitchToDesignViewCore: function(html) {
  this.SwitchToViewCore(ASPxClientHtmlEditorView.Design, html);
  this.SetDesignModeAttribute();
  this.OnHtmlChanged(false);
 },
 SwitchToHtmlViewCore: function(html) {
  this.SwitchToViewCore(ASPxClientHtmlEditorView.Html, html);
 },
 SwitchToPreviewCore: function(html) {
  this.SwitchToViewCore(ASPxClientHtmlEditorView.Preview, html);
 },
 SwitchToViewCore: function(view, html) {
  this.UpdateLayout(view);
  this.CorrectWidthOnSwitchToView(view);
  this.SetHtmlInternal(html, view);
  if (this.IsPreview(view))
   this.RemoveFocus();
  else
   this.SetFocus();
  if(__aspxOpera && _aspxIsExists(this.savedSetHeight))
   this.SetHeight(this.savedSetHeight);
 },
 CorrectWidthOnSwitchToView: function(view) {
  if (this.IsHtmlView(view) || this.IsPreview(view))
   this.AdjustSizeToContainer(view);
 },
 ExecuteCommand: function(commandName, parameter, addToHistory) {
  var isSuccessfully = false;
  if (this.IsDesignView()) {
   addToHistory = _aspxIsExists(addToHistory) ? addToHistory : true;
   this.RestoreSelectionForPopup();
   var cmd = ASPxHtmlEditorCommandList[commandName];
   if (cmd != null) {
    this.executingCommandName = commandName;
    var contentHtml = this.GetHtmlInternal();
    var isSuccessfully = this.commandManager.ExecuteCommand(commandName, parameter, addToHistory);
    if (!cmd.IsImmediateExecution())
     this.executingCommandName = null;
    if (contentHtml != this.GetHtmlInternal())
     this.OnHtmlChanged(false);
    else
     if (isSuccessfully)
     this.OnSelectionChanged();
    this.RaiseCommandExecuted(commandName, parameter, isSuccessfully);
   }
   else {
    if (!this.CustomCommand.IsEmpty()) {
     isSuccessfully = this.RaiseCustomCommand(commandName, parameter);
     this.RaiseCommandExecuted(commandName, parameter, isSuccessfully);
    }
    else
     alert('Command not found');
   }
  }
  return isSuccessfully;
 },
 PasteHtml: function(htmlText) {
  return this.ExecuteCommand(ASPxClientCommandConsts.PASTEHTML_COMMAND, htmlText);
 },
 InsertLink: function(url, text, target, title) {
  var value = {
   url: url,
   text: text,
   target: target,
   title: title
  };
  this.ExecuteCommand(ASPxClientCommandConsts.INSERTLINK_COMMAND, value);
 },
 InsertImage: function(src, width, height, align, alt, useFloat) {
  var value = {
   src: src,
   width: width,
   height: height,
   align: align,
   alt: alt,
   useFloat: useFloat
  };
  this.ExecuteCommand(ASPxClientCommandConsts.INSERTIMAGE_COMMAND, value);
 },
 ChangeImage: function(imageElement, src, width, height, align, alt, useFloat) {
  var value = {
   imageElement: imageElement,
   src: src,
   width: width,
   height: height,
   align: align,
   alt: alt,
   useFloat: useFloat
  };
  this.ExecuteCommand(ASPxClientCommandConsts.CHANGEIMAGE_COMMAND, value);
 },
 CheckSpelling: function() {
  var spellChecker = this.GetSpellCheckerClientInstance();
  if (_aspxIsExists(spellChecker)) {
   if (this.areDictionariesAssigned)
    this.SendCallback(__aspxHESpellCheckingCallbackPrefix, spellChecker.CreateCallbackArgumentToCheckText(""), true);
   else
    alert("The built-in spell checker doesn't have dictionaries by default. Use the SettingsSpellChecker.Dictionaries property to define the spell checker's dictionaries.");
  }
 },
 ReCheck: function(text) {
  this.htmlEditor.SendCallback(__aspxHESpellCheckingCallbackPrefix, this.CreateCallbackArgumentToCheckText(""), false);
  this.ShowLoadingPanel();
 },
 OnSpellCheckerWordChanged: function(sender, args) {
  this.ExecuteCommand(ASPxClientCommandConsts.CheckSpellingCore_COMMAND, args.checkedText);
 },
 Print: function() {
  var window = this.GetDesignViewIFrameWindow();
  if (_aspxIsExists(window)) window.print();
 },
 Undo: function() {
  if (this.IsUndoAvailable())
   return this.commandManager.Undo(1);
  return false;
 },
 Redo: function() {
  if (this.IsRedoAvailable())
   return this.commandManager.Redo(1);
  return false;
 },
 GetSelection: function() {
  return new ASPxClientHtmlEditorSelection(this);
 },
 SetSelection: function(selection) {
  if (__aspxNetscapeFamily)
   this.SetFocus();
  selection.Apply();
 },
 GetSelectedElement: function(name) {
  return this.cachedElementsManager.GetSeletedElement(name);
 },
 SetSelectedElement: function(name, element) {
  return this.cachedElementsManager.SetSelectedElement(name, element);
 },
 NeedGetElementFromSelection: function(name) {
  return this.cachedElementsManager.NeedGetElementFromSelection(name);
 },
 GetEditorSelectionInfo: function(needNestingFontElementCorrection) {
  needNestingFontElementCorrection = _aspxIsExists(needNestingFontElementCorrection) ?
            needNestingFontElementCorrection && __aspxNetscapeFamily : false;
  var ret = { allElements: [], newElements: [] };
  var fontTagName = __aspxSafari && (__aspxMacOSPlatform || __aspxWindowsPlatform && __aspxBrowserVersion < 4) ? "span" : "font"; 
  var curSelection = ASPxClientHtmlEditorSelection.Create(this);
  if (curSelection.IsControl()) {
   var controlElement = curSelection.GetParentElement();
   var fontElement = this.GetDesignViewIFrameDocument().createElement('FONT');
   fontElement.appendChild(controlElement.cloneNode(true));
   controlElement.parentNode.replaceChild(fontElement, controlElement);
   ret.allElements.push(fontElement);
   ret.newElements.push(fontElement);
  }
  else {
   var savedExistingFontElems = _aspxGetElementsByTagName(this.GetDesignViewIFrameDocument(), fontTagName);
   for (var i = 0; i < savedExistingFontElems.length; i++) {
    if (savedExistingFontElems[i].face) {
     savedExistingFontElems[i].setAttribute('_dxface', savedExistingFontElems[i].face);
    }
    savedExistingFontElems[i].setAttribute(__aspxHEMarkFontAttr, 1);
   }
   if (__aspxNetscapeFamily)
    this.GetDesignViewIFrameDocument().execCommand("useCSS", false, true);
   ASPxHtmlEditorCommandList[ASPxClientCommandConsts.FONTNAME_COMMAND].Execute(__aspxHEMarkFontFace, this, false);
   var allFontElems = _aspxGetElementsByTagName(this.GetDesignViewIFrameDocument(), fontTagName);
   for (var i = 0; i < allFontElems.length; i++) {
    if (this.IsMarkedFontElement(allFontElems[i])) {
     ret.allElements.push(allFontElems[i]);
     var childElems = _aspxGetElementsByTagName(allFontElems[i], fontTagName);
     var count = childElems.length;
     for (var j = 0; j < count; j++) {
      if (this.IsMarkedFontElement(childElems[i]))
       ret.allElements.push(childElems[i]);
     }
     if (!allFontElems[i].getAttribute(__aspxHEMarkFontAttr)) {
      var elem = allFontElems[i];
      if (needNestingFontElementCorrection) {
       elem = this.CorrectNestedFontElement(elem);
       ret.allElements[i] = elem;
       allFontElems[i] = elem;
      }
      ret.newElements.push(elem);
     }
    }
    allFontElems[i].removeAttribute(__aspxHEMarkFontAttr);
   }
   for (var i = 0; i < savedExistingFontElems.length; i++) {
    savedExistingFontElems[i].face = savedExistingFontElems[i].getAttribute('_dxface');
    savedExistingFontElems[i].removeAttribute('_dxface');
   }
   savedExistingFontElems = [];
   if (__aspxNetscapeFamily)
    this.GetDesignViewIFrameDocument().execCommand("useCSS", false, false);
  }
  return ret;
 },
 CorrectNestedFontElement: function(fontElement) {
  var ret = fontElement;
  if ((fontElement.childNodes.length == 1) && (fontElement.childNodes[0].nodeType != 3)) {
   var childNode = fontElement.childNodes[0];
   childNode.className += " " + __aspxHEMarkClassName;
   var html = childNode.innerHTML;
   _aspxRemoveOuterTags(fontElement);
   childNode = _aspxGetChildsByClassName(this.GetDesignViewIFrameDocumentBody(), __aspxHEMarkClassName)[0];
   childNode.className.replace(__aspxHEMarkClassName, "");
   childNode.innerHTML = "";
   var newFontElement = this.GetDesignViewIFrameDocument().createElement('FONT');
   newFontElement.face = __aspxHEMarkFontFace;
   _aspxSetInnerHtml(newFontElement, html);
   childNode.appendChild(newFontElement);
   ret = newFontElement;
  }
  return ret;
 },
 IsMarkedFontElement: function(elem, font) {
  return elem && (elem.getAttribute('face') == __aspxHEMarkFontFace || elem.style.fontFamily == __aspxHEMarkFontFace);
 },
 DeleteNewAddedFontElements: function(selInfo) {
  var newElements = selInfo.newElements;
  for (var i = 0; i < newElements.length; i++) {
   if (__aspxIE || __aspxOpera)
    newElements[i].removeNode(false);
   else {
    var range = this.GetDesignViewIFrameDocument().createRange();
    range.selectNodeContents(newElements[i]);
    var selectedContent = range.extractContents();
    range.selectNode(newElements[i]);
    range.deleteContents();
    range.insertNode(selectedContent);
   }
  }
 },
 CreateRestoreSelection: function() {
  return ASPxClientHtmlEditorSelection.Create(this);
 },
 RestoreLastSelection: function(selectionObj) {
  if (selectionObj != null) {
   this.SetFocus();
   selectionObj.Restore();
  }
 },
 SaveLastSelection: function() {
  var selectionObj = ASPxClientHtmlEditorSelection.Create(this);
  selectionObj.Save();
  return selectionObj;
 },
 CreateRestoreSelectionForDialog: function() {
  var selectionObj = __aspxIE ? new DialogSelectionIE(this.GetDesignViewIFrameWindow()) :
       new ASPxClientSelectionNSOpera(this.GetDesignViewIFrameWindow());
  selectionObj.Save();
  return selectionObj;
 },
 UpdateContextMenu: function() {
  if (this.allowContextMenu == true && this.GetContextMenu().GetVisible())
   this.GetContextMenu().SetVisible(false);
 },
 ShowContextMenu: function(evt) {
  this.SaveSelectionForPopup();
  if (!this.GetContextMenu().GetVisible()) {
   this.UpdateContextMenuItemsState();
   var scrollX = _aspxGetDocumentScrollLeft();
   var scrollY = _aspxGetDocumentScrollTop();
   var x = _aspxGetEventX(evt) + _aspxGetAbsoluteX(this.GetDesignViewIFrameElement()) - scrollX;
   var y = _aspxGetEventY(evt) + _aspxGetAbsoluteY(this.GetDesignViewIFrameElement()) - scrollY;
   this.GetContextMenu().ShowAtPos(x + 8, y + 8);
  }
 },
 UpdateContextMenuItemsState: function() {
  var popupMenu = this.GetContextMenu();
  for (var i = 0; i < popupMenu.GetItemCount(); i++) {
   var item = popupMenu.GetItem(i);
   if (_aspxIsExists(ASPxHtmlEditorCommandList[item.name]))
    item.SetVisible(!ASPxHtmlEditorCommandList[item.name].IsLocked(this));
  }
 },
 UpdateToolbar: function() {
  if (_aspxIsExists(this.toolbar))
   this.toolbar.UpdateItems();
 },
 UpdateToolbarImmediately: function() {
  if (_aspxIsExists(this.toolbar))
   this.toolbar.DoUpdateItems();
 },
 SendCallback: function(prefix, arg, showLoadingPanel) {
  if (showLoadingPanel)
   this.ShowLoadingPanel();
  this.CreateCallback(_aspxFormatCallbackArg(prefix, arg));
 },
 OnCallback: function(result) {
  if (this.callbackOwner != null)
   this.callbackOwner.OnCallback(result);
  else
   this.OnHtmlEditorCallback(result.action, result.html, result.spellcheck, result.allowScripts);
 },
 OnCallbackError: function(result, data) {
  if (this.callbackOwner != null)
   this.callbackOwner.OnCallbackError(result);
  else
   this.RollbackActiveView();
  this.isErrorOnCallback = true;
  this.constructor.prototype.OnCallbackError.call(this, result, data);
 },
 DoEndCallback: function() {
  this.constructor.prototype.DoEndCallback.call(this);
  if (this.callbackOwner != null && !this.isErrorOnCallback)
   this.callbackOwner.OnEndCallback();
  else if (this.spellCheckerCallback) {
   var spellChecker = this.GetSpellCheckerClientInstance();
   if (_aspxIsExists(spellChecker))
    spellChecker.DoEndCallback();
  }
  this.isErrorOnCallback = false;
 },
 OnHtmlEditorCallback: function(prefix, result, spellCheckResult, allowScripts) {
  this.allowScripts = Boolean(allowScripts);
  this.spellCheckerCallback = false;
  switch (prefix) {
   case __aspxHESwitchToDesignViewCallbackPrefix:
    this.SwitchToDesignViewCore(result);
    break;
   case __aspxHESwitchToHtmlViewCallbackPrefix:
    this.SwitchToHtmlViewCore(result);
    break;
   case __aspxHESwitchToPreviewCallbackPrefix:
    this.SwitchToPreviewCore(result);
    break;
   case __aspxHESpellCheckingCallbackPrefix:
    var spellChecker = this.GetSpellCheckerClientInstance();
    if (_aspxIsExists(spellChecker)) {
     this.ClearUndoHistory();
     this.SetHtmlInternal(result);
     spellChecker.CheckByCallbackResult(result, spellCheckResult, this.GetMainElement());
     spellChecker.HideLoadingPanelCore();
     this.RemoveFocus();
    }
    this.spellCheckerCallback = true;
    break;
   default:
    throw "Unexpected callback prefix.";
    break;
  }
 },
 RollbackActiveView: function() {
  if (this.allowDesignView) {
   this.activeView = ASPxClientHtmlEditorView.Design;
   this.SwitchToDesignViewCore(this.GetHtml());
  }
  else if (this.allowHtmlView) {
   this.activeView = ASPxClientHtmlEditorView.Html;
   this.SwitchToHtmlViewCore(this.GetHtml());
  }
  else if (this.allowPreview) {
   this.activeView = ASPxClientHtmlEditorView.Preview;
   this.SwitchToPreviewCore(this.GetHtml());
  }
  var tabControl = this.GetTabControl();
  if (tabControl != null)
   tabControl.SetActiveTab(tabControl.GetTab(0));
 },
 ConvertToEmptyHtml: function(html) {
  var emptyTagsRegExp = new RegExp(__aspxHEEmptyTagsRegExpPattern, "ig");
  var emptyHtmlRegExp = new RegExp(__aspxHEEmptyHtmlRegExpPattern, "ig");
  var processedHtml = _aspxTrim(html);
  if (emptyTagsRegExp.test(processedHtml) || emptyHtmlRegExp.test(processedHtml))
   html = "";
  return html;
 },
 DeconvertEmptyHtml: function(html) {
  if (html == "" && (__aspxWebKitFamily || __aspxNetscapeFamily))
   html = "&nbsp;";
  return html;
 },
 CreatePasteContainer: function() {
  var divElem = document.createElement("DIV");
  divElem.style.overflow = "hidden";
  divElem.style.width = "1px";
  divElem.style.height = "1px";
  divElem.contentEditable = true;
  document.body.appendChild(divElem);
  return divElem;
 },
 IsExistsWindowInIFrame: function(iframeName) {
  try {
   return _aspxIsExists(_aspxIFrameWindow(iframeName));
  }
  catch (e) {
   return false;
  }
 },
 GetIFrameDocumentHtml: function(bodyContentHtml) {
  var html = "<head>";
  if (__aspxIE)
   html += "  <scr" + "ipt type=\"text/javascript\">" +
    "    window.document.onkeydown = function() {" +
    "       if(event.keyCode == 121) {" +
    "           window.parent.FocusActiveEditorToolbar();" +
    "           event.keyCode = 0;" +
    "           return false;" +
    "       }" +
    "   }" +
    "  </scr" + "ipt>";
  html += "<style></style></head><body>";
  if (_aspxIsExists(bodyContentHtml) && bodyContentHtml != "")
   html += bodyContentHtml;
  else if (__aspxWebKitFamily || __aspxNetscapeFamily)
   html += "&nbsp;";
  html += "</body>";
  return html;
 },
 ClearUndoHistory: function() {
  if (this.allowDesignView)
   this.commandManager.ClearUndoHistory();
 },
 CreateKeyDownInfo: function(evt) { 
  this.keyDownInfo = {
   isSystemKey: this.keyboardManager.IsSystemKey(evt.keyCode),
   isDeleteOrBackSpaceKey: this.keyboardManager.IsDeleteOrBackSpaceKey(evt.keyCode),
   isBackSpaceKey: this.keyboardManager.IsBackSpaceKey(evt.keyCode),
   isCursorMovingKey: this.keyboardManager.IsCursorMovingKey(evt.keyCode)
  };
 },
 ClearKeyDownInfo: function() { 
  this.keyDownInfo = null;
 },
 IsDefaultActionCommand: function(cmdID) {
  return _aspxIsExists(ASPxHtmlEditorCommandList[cmdID]) &&
    ASPxHtmlEditorCommandList[cmdID].IsDefaultAction(this);
 },
 IsDeleting: function() {
  return this.commandManager.IsDeleting() &&
   _aspxIsExists(this.keyDownInfo) && this.keyDownInfo.isDeleteOrBackSpaceKey;
 },
 IsHtmlChangeableCommand: function(cmdID) {
  return _aspxIsExists(ASPxHtmlEditorCommandList[cmdID]) &&
   ASPxHtmlEditorCommandList[cmdID].IsHtmlChangeable();
 },
 IsShortcut: function() {
  return _aspxIsExists(this.shortcutCmdID);
 },
 IsTextTyping: function() {
  return this.executingCommandName &&
    (this.executingCommandName == ASPxClientCommandConsts.TEXTTYPE_COMMAND) &&
    _aspxIsExists(this.keyDownInfo) && !this.keyDownInfo.isSystemKey;
 },
 IsRedoAvailable: function() {
  return this.commandManager.IsRedoAvailable();
 },
 IsUndoAvailable: function() {
  return this.commandManager.IsUndoAvailable();
 },
 OnSelectionChanged: function() {
  this.cachedElementsManager.ClearSeletedElements();
  this.UpdateToolbar();
  this.UpdateContextMenu();
  this.RaiseSelectionChanged();
 },
 OnHtmlChanged: function(saveSelectionAndHtml) {
  if (saveSelectionAndHtml && this.IsDesignView())
   this.commandManager.UpdateLastRestoreSelectionAndHTML();
  this.RaiseHtmlChanged();
  if (this.IsDesignView())
   this.OnSelectionChanged();
 },
 FocusToolbar: function() {
  this.GetToolbar().Focus();
 },
 FocusLastToolbar: function() {
  this.GetToolbar().FocusLastToolbar();
 },
 ProcessTabOnKeyDown: function(evt) {
  if (__aspxIE && evt.keyCode == ASPxKey.Tab) {
   try {
    if (evt.shiftKey) {
     this.FocusLastToolbar();
     ASPxClientHtmlEditor.PreventEventIE(evt);
    }
    else
     window.focus();
   }
   catch (e) { }
  }
 },
 OnKeyDown: function(evt) {
  this.shortcutCmdID = this.keyboardManager.GetShortcutCommand(evt);
  this.isAllowToPreventShortcut = false;
  this.ProcessTabOnKeyDown(evt);
  if (!__aspxIE && evt.keyCode == ASPxKey.F10) {
   aspxGetHtmlEditorsCollection().FocusActiveEditorToolbar();
   return _aspxPreventEvent(evt);
  }
  else if (this.IsShortcut()) {
   this.ExecuteCommand(this.shortcutCmdID, null);
   this.isAllowToPreventShortcut = !this.IsDefaultActionCommand(this.shortcutCmdID);  
  }
  else {
   this.CreateKeyDownInfo(evt);
   if (this.keyDownInfo.isSystemKey) {
    if (this.keyDownInfo.isDeleteOrBackSpaceKey) {
     var curSelection = ASPxClientHtmlEditorSelection.Create(this);
     if (!this.keyDownInfo.isBackSpaceKey &&
       curSelection.GetHtmlText() != "" && (__aspxIE || __aspxOpera)) {
      this.ExecuteCommand(ASPxClientCommandConsts.DELETE_COMMAND, null);
      _aspxPreventEvent(evt);
     }
     else {
      this.ExecuteCommand(ASPxClientCommandConsts.KBDELETE_COMMAND, null);
      this.commandManager.UpdateLastRestoreHtml();
     }
    }
   }
   else
    if (!this.keyDownInfo.isCursorMovingKey) {
    if (!this.IsTextTyping())
     this.ExecuteCommand(ASPxClientCommandConsts.TEXTTYPE_COMMAND, null);
   }
  }
  if (this.IsShortcut() && (__aspxIE || __aspxWebKitFamily) && this.isAllowToPreventShortcut)
   ASPxClientHtmlEditor.PreventEventIE(evt);
 },
 OnKeyUp: function(evt) {
  if (!this.IsShortcut()) {
   if (this.IsDeleting())
    this.commandManager.CleanEmptyRestoreHtml();
   if (this.IsTextTyping() || this.IsDeleting())
    this.OnHtmlChanged(true);
   this.OnSelectionChanged();
   this.ClearKeyDownInfo();
  } else
   if (this.IsDefaultActionCommand(this.shortcutCmdID) &&
    this.IsHtmlChangeableCommand(this.shortcutCmdID)) {
   this.OnHtmlChanged(true);
  }
  else
   this.OnSelectionChanged();
 },
 OnKeyPress: function(evt) {
  if (this.IsShortcut(evt) && this.isAllowToPreventShortcut) {
   this.shortcutCmdID = null;
   return _aspxPreventEvent(evt);
  }
 },
 OnDblClick: function(evt) {
  var source = _aspxGetEventSource(evt);
  if (!_aspxIsExists(source))
   return;
  if (source.tagName == "IMG") {
   if (__aspxWebKitFamily)
    ASPxClientHtmlEditorSelection.SelectElement(source, this);
   this.ExecuteCommand(ASPxClientCommandConsts.CHANGEIMAGE_DIALOG_COMMAND);
  }
 },
 OnMouseDown: function(evt) {
  var toolBar = this.GetToolbar();
  if (_aspxIsExists(toolBar))
   toolBar.HideAllPopups();
  if (__aspxWebKitFamily && _aspxGetIsLeftButtonPressed(evt)) {
   var source = _aspxGetEventSource(evt);
   if (_aspxIsExists(source) && source.tagName == "IMG")
    ASPxClientHtmlEditorSelection.SelectElement(source, this);
  }
  this.isMouseDown = true;
 },
 OnMouseUp: function(evt) {
  this.OnSelectionChanged();
  this.isMouseDown = false;
 },
 OnFocus: function() {
  if (!this.isInitialized || (!__aspxIE && this.isMouseDown && this.isInFocus))
   return;
  this.isInFocus = true;
  this.RaiseFocus();
 },
 OnLostFocus: function() {
  if (!this.isInitialized || (__aspxWebKitFamily && !this.isInFocus))
   return;
  this.isInFocus = false;
  this.RaiseLostFocus();
 },
 OnDesignViewIframeLoad: function() {
  var designViewIframe = document.getElementById(this.GetDesignViewIFrameName());
  if (_aspxIsExists(designViewIframe) && !_aspxIsExists(designViewIframe.isLoaded)) {
   designViewIframe.isLoaded = true;
   this.InitAreas();
   this.UpdateLayout();
   this.InitializeManagers();
   this.AdjustControlCore();
  }
 },
 ClearDragDropTimer: function() {
  if (this.dragDropTimerID)
   _aspxClearTimer(this.dragDropTimerID);
 },
 OnAfterDocumentObjectDragEnd: function() {
  this.isDropExternalContentExecuted = false;
  this.OnHtmlChanged(true);
  this.ClearDragDropTimer();
 },
 OnAfterDocumentObjectDragEndCallWithDelay: function() {
  var callStr = "aspxHEAfterDocumentObjectDragEnd(\"" + this.name + "\")";
  this.dragDropTimerID = _aspxSetTimeout(callStr, __aspxHEDragDropDelay);
 },
 OnAfterObjectDragEnd: function() {
  this.OnHtmlChanged(true);
  this.ClearDragDropTimer();
 },
 OnAfterObjectDragEndWithDelay: function() {
  var callStr = "aspxHEAfterObjectDragEnd(\"" + this.name + "\")";
  this.dragDropTimerID = _aspxSetTimeout(callStr, __aspxHEDragDropDelay);
 },
 OnDocumentObjectDragEnd: function() {
  if (this.isDropExternalContentExecuted)
   this.OnAfterDocumentObjectDragEnd();
 },
 OnObjectDragStart: function(evt) {
  if (!this.isDraggingInsideEditor && !__aspxHEIsDocumentDragOver ) {
   this.isDraggingInsideEditor = true;
   this.ExecuteCommand(ASPxClientCommandConsts.DRAGDROPOBJECT_COMMAND, null);
  }
 },
 OnObjectDrop: function(evt) {
  if (!this.isDraggingInsideEditor) {
   this.isDropExternalContentExecuted = true;
   this.ExecuteCommand(ASPxClientCommandConsts.DROPOBJECTFROMEXTERNAL_COMMAND, null);
   if (__aspxHEIsDocumentDragOver) { 
    __aspxHEIsDocumentDragOver = false;
    this.OnAfterDocumentObjectDragEndCallWithDelay();
   }
  }
  if (__aspxNetscapeFamily)
   this.OnObjectDragEnd();
 },
 OnObjectDragEnd: function() {
  if (this.isDraggingInsideEditor) {
   this.isDraggingInsideEditor = false;
   this.OnAfterObjectDragEndWithDelay();
  }
 },
 OnObjectResizeStart: function(evt) {
  this.ExecuteCommand(ASPxClientCommandConsts.RESIZEOBJECT_COMMAND, null);
 },
 OnObjectResizeEnd: function(evt) {
  this.OnHtmlChanged(true);
 },
 OnContextMenuItemClick: function(item) {
  this.RestoreSelectionForPopup();
  this.ExecuteCommand(item.name, null);
 },
 SaveSelectionForPopup: function() {
  this.beforePopupSelection = this.CreateRestoreSelection();
  if (__aspxIE)
   this.selectionBookmark = this.beforePopupSelection.GetExtendedBookmark();
  else
   this.beforePopupSelection.Save();
 },
 RestoreSelectionForPopup: function() {
  if (_aspxIsExists(this.beforePopupSelection)) {
   if (__aspxIE && this.selectionBookmark) {
    this.beforePopupSelection.SelectExtendedBookmark(this.selectionBookmark);
    this.selectionBookmark = null;
   }
   else
    this.beforePopupSelection.Restore();
   this.beforePopupSelection = null;
  }
 },
 OnContextMenuCloseUp: function() {
  if (this.beforePopupSelection)
   this.selectionBookmark = this.beforePopupSelection.RemoveExtendedBookmark(this.selectionBookmark);
 },
 OnContextMenu: function(evt) {
  if (this.allowContextMenu == true)
   this.ShowContextMenu(evt);
  if (__aspxIE)
   evt.returnValue = false;
  else
   evt.preventDefault();
 },
 OnToolbarDropDownItemCloseUp: function() {
  this.RestoreSelectionForPopup();
 },
 RaiseCommandExecuted: function(commandName, parameter, isSuccessful) {
  if (!this.CommandExecuted.IsEmpty()) {
   var args = new ASPxClientHtmlEditorCommandEventArgs(commandName, parameter, isSuccessful, this);
   this.CommandExecuted.FireEvent(this, args);
  }
 },
 RaiseCustomCommand: function(commandName, parameter) {
  if (!this.CustomCommand.IsEmpty()) {
   var args = new ASPxClientHtmlEditorCommandEventArgs(commandName, parameter, true, this);
   this.CustomCommand.FireEvent(this, args);
   return args.isSuccessful;
  }
  return true;
 },
 RaiseFocus: function() {
  if (!this.GotFocus.IsEmpty()) {
   var args = new ASPxClientEventArgs();
   this.GotFocus.FireEvent(this, args);
  }
 },
 RaiseLostFocus: function() {
  if (!this.LostFocus.IsEmpty()) {
   var args = new ASPxClientEventArgs();
   this.LostFocus.FireEvent(this, args);
  }
 },
 RaiseHtmlChanged: function() {
  if (!this.HtmlChanged.IsEmpty()) {
   var args = new ASPxClientEventArgs();
   this.HtmlChanged.FireEvent(this, args);
  }
 },
 RaiseSelectionChanged: function() {
  if (!this.SelectionChanged.IsEmpty()) {
   var args = new ASPxClientEventArgs();
   this.SelectionChanged.FireEvent(this, args);
  }
 },
 SetHeight: function(height) {
  if(__aspxIE) {
   var editAreaCell = this.GetEditAreaCell();
   var mainElement = this.GetMainElement();
   _aspxSetElementDisplay(editAreaCell, false);
   mainElement.style.height = height + "px";
   if(mainElement.offsetHeight != height)
    mainElement.style.height = (2 * height - mainElement.offsetHeight) + "px";
   this.AdjustControl();
   _aspxSetElementDisplay(editAreaCell, true);
   if(__aspxBrowserVersion < 8)
    this.AdjustControl();
  }
  else {
   if(__aspxOpera)
    this.savedSetHeight = height;
   this.constructor.prototype.SetHeight.call(this, height);
  }
 }
});
ASPxClientHtmlEditor.CleanHtmlScripts = function(html) {
 var ret = ASPxClientHtmlEditor.RemoveScriptTags(html);
 return ASPxClientHtmlEditor.RemoveScriptEventHadlers(ret);
};
ASPxClientHtmlEditor.RemoveScriptTags = function(html) {
 var ret = html;
 var rx = new RegExp(__aspxJSTagsRegExpPattern, "gi");
 if (ret != "")
  ret = ret.replace(rx, "");
 return ret;
};
ASPxClientHtmlEditor.PreserveTagsByName = function(tagName, html) {
 return _aspxApplyReplacement(html, [
  ["<" + tagName, "<" + "!--" + __aspxHEPreservedTagNamePrefix + tagName],
  ["<" + "/" + tagName + ">", "</" + __aspxHEPreservedTagNamePrefix + tagName + "--" + ">"]
 ]);
};
ASPxClientHtmlEditor.DepreserveTagsByName = function(tagName, html) {
 return _aspxApplyReplacement(html, [
  ["<" + "!--" + __aspxHEPreservedTagNamePrefix + tagName, "<" + tagName],
  ["</" + __aspxHEPreservedTagNamePrefix + tagName + "--" + ">", "<" + "/" + tagName + ">"]
 ]);
};
ASPxClientHtmlEditor.RemoveScriptEventHadlers = function(html) {
 var ret = html;
 var rx = new RegExp(__aspxJSEventHadlersRegExpPattern, "ig");
 if (ret != "")
  ret = ret.replace(rx, "");
 return ret;
};
ASPxClientHtmlEditor.PreventEventIE = function(evt) { 
 evt.keyCode = 123;
 evt.returnValue = false;
 return false;
}
EventListener = _aspxCreateClass(null, {
 constructor: function(htmlEditor) {
  this.htmlEditor = htmlEditor;
  this.AttachEventsToEditor();
 },
 AttachEventsToEditor: function() {
  var doc = this.htmlEditor.GetDesignViewIFrameDocument();
  _aspxAttachEventToElement(doc, "keydown", this.CreateEventHandlerFunction("aspxHEEditAreaKeyDown", true));
  _aspxAttachEventToElement(doc, "keyup", this.CreateEventHandlerFunction("aspxHEEditAreaKeyUp", true));
  if (!__aspxIE) 
   _aspxAttachEventToElement(doc, "keypress", this.CreateEventHandlerFunction("aspxHEEditAreaKeyPress", true));
  _aspxAttachEventToElement(doc, "mousedown", this.CreateEventHandlerFunction("aspxHEEditAreaMouseDown", true));
  _aspxAttachEventToElement(doc, "mouseup", this.CreateEventHandlerFunction("aspxHEEditAreaMouseUp", true));
  var designViewIFrame = this.htmlEditor.GetDesignViewIFrameWindow();
  _aspxAttachEventToElement(designViewIFrame, "focus", this.CreateEventHandlerFunction("aspxHEEditAreaOnFocus", false));
  _aspxAttachEventToElement(designViewIFrame, "blur", this.CreateEventHandlerFunction("aspxHEEditAreaOnLostFocus", false));
  if (!__aspxOpera)
   _aspxAttachEventToElement(doc, "dblclick", this.CreateEventHandlerFunction("aspxHEEditAreaDblClick", true));
  if (__aspxNetscapeFamily) {
   this.htmlEditor.GetDesignViewIFrameWindow().captureEvents(Event.DRAGDROP | Event.DBLCLICK);
   _aspxAttachEventToElement(this.htmlEditor.GetDesignViewIFrameWindow(), "dragdrop", 
    this.CreateEventHandlerFunction("aspxHEEditObjectDrop", true));
   _aspxAttachEventToElement(this.htmlEditor.GetDesignViewIFrameWindow(), "dragover",
    this.CreateEventHandlerFunction("aspxHEEditObjectDragStart", true));
  }
  else {
   _aspxAttachEventToElement(doc.body, "resizestart",
    this.CreateEventHandlerFunction("aspxHEEditObjectResizeStart", true));
   _aspxAttachEventToElement(doc.body, "resizeend",
    this.CreateEventHandlerFunction("aspxHEEditObjectResizeEnd", true));
   _aspxAttachEventToElement(document.body, "dragend", 
    this.CreateEventHandlerFunction("aspxHEDocumentObjectDragEnd", true));
   _aspxAttachEventToElement(doc.body, "dragstart",
    this.CreateEventHandlerFunction("aspxHEEditObjectDragStart", true));
   _aspxAttachEventToElement(doc.body, "drop",
    this.CreateEventHandlerFunction("aspxHEEditObjectDrop", true));
   _aspxAttachEventToElement(doc.body, "dragend",
    this.CreateEventHandlerFunction("aspxHEEditObjectDragEnd", true));
  }
  if (this.htmlEditor.allowContextMenu != "default")
   _aspxAttachEventToElement(doc, "contextmenu", this.CreateEventHandlerFunction("aspxHEEditAreaContextMenu", true));
 },
 CreateEventHandlerFunction: function(funcName, withHTMLEventArg) {
  return withHTMLEventArg ? new Function("event", funcName + "('" + this.htmlEditor.name + "', event);") :
   new Function(funcName + "('" + this.htmlEditor.name + "');");
 }
});
ASPxClientPath = {
 DirectorySeparatorChar: "\\",
 AltDirectorySeparatorChar: "/",
 VolumeSeparatorChar: ":",
 GetBaseUrlPath: function() {
  return window.location.protocol + "//" +  window.location.host;
 },
 GetFileName: function(path) {
  if (path) {
   var length = path.length;
   var index = length;
   while (--index >= 0) {
    var ch = path.charAt(index);
    if (((ch == ASPxClientPath.DirectorySeparatorChar) || (ch == ASPxClientPath.AltDirectorySeparatorChar)) || 
      (ch == ASPxClientPath.VolumeSeparatorChar))
     return path.substr(index + 1, (length - index) - 1);
   }
  }
  return "";
 },
 GetFileNameWithoutExtension: function(path) {
  path = ASPxClientPath.GetFileName(path);
  if (!path)
   return "";
  var length = path.lastIndexOf('.');
  if (length == -1)
   return path;
  return path.substr(0, length);
 }
};
var __aspxStyleAttributeRegEx = new RegExp("style=\"[^\"]*\"|'[^']*'", "ig");
var __aspxRGBColorCssAttrRegExp = new RegExp("rgb\\((\\d+)\\,(\\s)?(\\d+)\\,(\\s)?(\\d+)\\)", "ig");
var __aspxDefaultSafariFontSizes = ["x-small", "small", "medium", "large", "x-large", "xx-large", "-webkit-xxx-large"];
var __aspxDefaultSafariFontSizesInPixel = ["10px", "13px", "16px", "18px", "24px", "32px", "48px"];
var __aspxDefaultFontSizes = ["8pt", "10pt", "12pt", "14pt", "18pt", "24pt", "36pt"];
var __aspxDefaultSafariFontSizesHashTable = null;
var __aspxDefaultSafariFontSizesInPixelHashTable = _aspxCreateIndexHashTableFromArray(__aspxDefaultSafariFontSizesInPixel);
function _aspxGetDefaultSafariFontSizesHashTable() {
 if (!__aspxDefaultSafariFontSizesHashTable)
  __aspxDefaultSafariFontSizesHashTable = _aspxCreateIndexHashTableFromArray(__aspxDefaultSafariFontSizes);
 return __aspxDefaultSafariFontSizesHashTable;
}
function _aspxGetDefaultSafariFontSizesInPixelHashTable() {
 if (!__aspxDefaultSafariFontSizesInPixelHashTable)
  __aspxDefaultSafariFontSizesInPixelHashTable = _aspxCreateIndexHashTableFromArray(__aspxDefaultSafariFontSizesInPixel);
 return __aspxDefaultSafariFontSizesInPixelHashTable;
}
ASPxClientHtmlProcessingUtils = {
 AddEmptyBorderClassInTables: function(parentElem) {
  var tables = _aspxGetElementsByTagName(parentElem, "TABLE");
  for (var i = 0; i < tables.length; i++) {
   if (_aspxHETableHelper.IsEmptyBorder(tables[i]))
    _aspxHETableHelper.AppendEmptyBorderClassName(tables[i]);
  }
 },
 ReplaceTableStyleBorderByAttribute: function(parentElem) {
  var tables = _aspxGetElementsByTagName(parentElem, "TABLE");
  for (var i = 0; i < tables.length; i++)
   _aspxHETableHelper.ReplaceTableStyleBorderByAttribute(tables[i]);
 },
 RemoveEmptyBorderClassName: function(html) {
  var reg = new RegExp("(class=[\"\'].*)(" + __aspxEmptyBorderTableClassName + ")(.*[\"\'])", "ig");
  html = html.replace(reg, '$1$3');
  html = html.replace(new RegExp("class=\"[ ]*\"[ ]*", "ig"), ""); 
  return html.replace(new RegExp("class='[ ]*'[ ]*", "ig"), "");
 },
 ReplaceFontWithSpanTag: function(html) {
  html = _aspxApplyReplacement(html, [
   [/<font/ig, "<span"],
   [/<\/font>/ig, "</span>"]
  ]);
  var containerElement = document.createElement("DIV");
  _aspxSetInnerHtml(containerElement, html);
  var spans = _aspxGetElementsByTagName(containerElement, "SPAN");
  for (var i = 0; i < spans.length; i++) {
   var curSpan = spans[i];
   var curSpanFace = _aspxGetAttribute(curSpan, "face");
   if (_aspxIsExists(curSpanFace)) { 
    if (curSpanFace != "null")
     curSpan.style.fontFamily = curSpanFace;
    _aspxRemoveAttribute(curSpan, "face");
   }
   var size = 0;
   if (!isNaN(size = parseInt(_aspxGetAttribute(curSpan, "size")))) {
    try {
     curSpan.style.fontSize = __aspxDefaultFontSizes[size - 1];
    }
    catch (ex) { }
   }
   else {
    if (__aspxWebKitFamily) {
     var index = _aspxGetDefaultSafariFontSizesHashTable()[curSpan.style.fontSize.toLowerCase()]; ;
     if (index > -1)
      curSpan.style.fontSize = __aspxDefaultFontSizes[index];
    }
   }
   _aspxRemoveAttribute(curSpan, "size");
   if (this.IsExistAttribute(curSpan, "color")) {
    curSpan.style.color = this.CorrectColorValue(_aspxGetAttribute(curSpan, "color"));
    _aspxRemoveAttribute(curSpan, "color");
   }
  }
  var retHtml = containerElement.innerHTML;
  containerElement = null;
  return retHtml;
 },
 ReplaceSpanWithFontTag: function(html) {
  html = _aspxApplyReplacement(html, [
   [/<span/ig, "<font"],
   [/<\/span>/ig, "</font>"]
  ]);
  var defaultFontSizeReverseArray = [];
  for (var i = 0; i < __aspxDefaultFontSizes.length; i++)
   defaultFontSizeReverseArray[parseInt(__aspxDefaultFontSizes[i])] = i;
  var containerElement = document.createElement("DIV");
  _aspxSetInnerHtml(containerElement, html);
  var fonts = _aspxGetElementsByTagName(containerElement, "FONT");
  for (var i = 0; i < fonts.length; i++) {
   var curFont = fonts[i];
   if (curFont.style.fontFamily) {
    curFont.face = curFont.style.fontFamily;
    _aspxRemoveStyleAttribute(curFont, "fontFamily");
   }
   if (curFont.style.fontSize) {
    _aspxRemoveAttribute(curFont, "size");
    var size = defaultFontSizeReverseArray[parseInt(curFont.style.fontSize)];
    if (typeof (size) != 'undefined') {
     curFont.size = size + 1;
     _aspxRemoveStyleAttribute(curFont, "fontSize");
    }
   }
   if (curFont.style.color) {
    var newColor = this.CorrectColorValue(curFont.style.color);
    curFont.color = newColor;
    _aspxRemoveStyleAttribute(curFont, "color");
   }
  }
  html = containerElement.innerHTML;
  containerElement = null;
  html = html.replace(/\s*style="\s*"/gi, '');
  html = html.replace(/style=""/ig, "");
  html = html.replace(/style=''/ig, "");
  return html;
 },
 ReplaceUnderlineSpanWithUTag: function(html) {
  var containerElement = document.createElement("DIV");
  _aspxSetInnerHtml(containerElement, html);
  var spans = this.GetUnderlineSpanElements(containerElement);
  var UElement = document.createElement("U");
  while (spans.length > 0) {
   var curSpan = spans[0];
   if (this.IsUnderlineSpan(curSpan)) {
    var newUELement = UElement.cloneNode(false);
    var parentNode = curSpan.parentNode;
    newUELement.id = curSpan.id;
    newUELement.style.cssText = curSpan.style.cssText;
    newUELement.style.textDecoration = "";
    if (curSpan.className)
     newUELement.className = curSpan.className;
    _aspxSetInnerHtml(newUELement, curSpan.innerHTML);
    parentNode.replaceChild(newUELement, curSpan);
    spans = this.GetUnderlineSpanElements(containerElement);
   }
  }
  return containerElement.innerHTML;
 },
 ReplaceLinkTargetWithBlank: function(parentElem) {
  var linkArray = _aspxGetElementsByTagName(parentElem, "A");
  for (var i = 0; i < linkArray.length; i++)
   _aspxSetAttribute(linkArray[i], "target", "_blank");
 },
 ReplaceRGBToHex: function(html) {
  return html.replace(__aspxStyleAttributeRegEx,
        function(cssStyleString) {
         return cssStyleString.replace(__aspxRGBColorCssAttrRegExp, _aspxColorToHexadecimal);
        }
       );
 },
 FilterHtmlToGetHtml: function(html) {
  if (__aspxNetscapeFamily || __aspxWebKitFamily)
   html = this.ReplaceRGBToHex(html);
  return html;
 },
 CorrectColorValue: function(colorValue) {
  if (!colorValue) return null;
  var retColorValue = colorValue;
  if (typeof (colorValue) == "number" || colorValue.substr(0, 3) == "rgb")
   retColorValue = _aspxColorToHexadecimal(colorValue);
  return retColorValue;
 },
 CleanWrongSizeAttribute: function(element) {
  var fonts = _aspxGetElementsByTagName(element, "font");
  for (var i = 0; i < fonts.length; i++)
   if (fonts[i].size == "+0")
   _aspxRemoveAttribute(fonts[i], "size");
 },
 IsExistAttribute: function(element, attrName) {
  var attrObj = _aspxGetAttribute(element, attrName);
  return _aspxIsExists(attrObj) && attrObj != "null";
 },
 IsUnderlineSpan: function(element) {
  return (element.tagName.toLowerCase() == "span") &&
    (element.style.textDecoration.toLowerCase() == "underline") &&
    (element.style.fontFamily == "") &&
    (element.style.fontSize == "");
 },
 GetUnderlineSpanElements: function(element) {
  var spans = element.getElementsByTagName("SPAN");
  var ret = new Array();
  for (var i = spans.length - 1; i >= 0; i--) {
   if (this.IsUnderlineSpan(spans[i]))
    _aspxArrayPush(ret, spans[i]);
  }
  return ret;
 }
};
_aspxAttachEventToElement(window, "resize", aspxHEBodyResize);
var _aspxResizingTimerId = null;
function aspxHEBodyResize() { 
 if (!aspxGetHtmlEditorsCollection().resizingLocked) { 
  aspxGetHtmlEditorsCollection().resizingLocked = true;
  if (__aspxChrome) { 
   _aspxResizingTimerId = _aspxClearTimer(_aspxResizingTimerId);
   _aspxResizingTimerId = _aspxSetTimeout("aspxGetHtmlEditorsCollection().AdjustSizeToContainer()", 200);
  }
  else
   aspxGetHtmlEditorsCollection().AdjustSizeToContainer();
  _aspxSetTimeout("aspxGetHtmlEditorsCollection().resizingLocked = false", 100);
 }
}
function aspxHEChangeActiveView(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  htmlEdit.ChangeActiveView(evt.tab.name);
}
window.FocusActiveEditorToolbar = function() {
 aspxGetHtmlEditorsCollection().FocusActiveEditorToolbar();
}
function aspxHEEditAreaKeyDown(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnKeyDown(evt);
}
function aspxHEEditAreaKeyUp(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name); 
 if (htmlEdit != null)
  return htmlEdit.OnKeyUp(evt);
}
function aspxHEEditAreaKeyPress(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnKeyPress(evt);
}
function aspxHEEditAreaMouseDown(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  htmlEdit.OnMouseDown(evt);
}
function aspxHEEditAreaMouseUp(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  htmlEdit.OnMouseUp(evt);
}
function aspxHEEditAreaContextMenu(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  htmlEdit.OnContextMenu(evt);
}
function aspxHEEditAreaDblClick(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  htmlEdit.OnDblClick(evt);
}
function aspxHEEditAreaOnFocus(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnFocus();
}
function aspxHEEditAreaOnLostFocus(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnLostFocus();
}
function aspxHEEditObjectResizeStart(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnObjectResizeStart(evt);
}
function aspxHEEditObjectResizeEnd(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnObjectResizeEnd(evt);
}
function aspxHEAfterDocumentObjectDragEnd(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnAfterDocumentObjectDragEnd();
}
function aspxHEAfterObjectDragEnd(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnAfterObjectDragEnd();
}
function aspxHEEditObjectDragStart(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnObjectDragStart(evt);
}
function aspxHEEditObjectDragEnd(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnObjectDragEnd();
}
function aspxHEEditObjectDrop(name, evt) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnObjectDrop(evt);
}
function aspxHEDocumentObjectDragEnd(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnDocumentObjectDragEnd();
}
function aspxHESpellCheckerWordChanged(name, sender, args) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  return htmlEdit.OnSpellCheckerWordChanged(sender, args);
}
function aspxHEDesignViewIframeOnLoad(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  htmlEdit.OnDesignViewIframeLoad();
}
function aspxHEHtmlViewHtmlChanged(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null)
  htmlEdit.OnHtmlChanged();
}
function aspxHEDocumentDragOver(evt) {
 __aspxHEIsDocumentDragOver = true;
}
function aspxHEDocumentDragDrop() {
 __aspxHEIsDocumentDragOver = false;
}
if (__aspxNetscapeFamily)
 _aspxAttachEventToDocument("dragover", aspxHEDocumentDragOver);
if (__aspxNetscapeFamily)
 _aspxAttachEventToDocument("dragdrop", aspxHEDocumentDragDrop);
function aspxHEContextMenuCloseUp(name) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null) return htmlEdit.OnContextMenuCloseUp();
}
function aspxHEContextMenuItemClick(name, args) {
 var htmlEdit = aspxGetControlCollection().Get(name);
 if (htmlEdit != null) return htmlEdit.OnContextMenuItemClick(args.item);
}
