Include("System.Shared");
Include("System.Array");
Include("System.KeyObject");
Include("System.FilterManager");
Include("System.Web.Elements");
Include("System.Web.UI.WebControls.EventHandler");
Include("System.Web.UI.WebControls.Bounds");
Include("System.Web.UI.WebControls.Rule");
Include("System.Web.UI.WebControls.ModeButton");
Include("System.Web.UI.WebControls.Popups");
Include("System.Web.UI.WebControls.Module");
Include("System.Web.UI.WebControls.CssClass");
Include("System.Web.UI.WebControls.Selections");
Include("System.Web.UI.WebControls.WebHtmlEditorToolBarsCommon");
Include("System.Web.UI.WebControls.ContextMenusManager");
Include("System.Web.UI.WebControls.WebHtmlEditorToolBars");
Include("System.Web.UI.WebControls.WebHtmlEditorToolButton");
Include("System.Web.UI.WebControls.WebHtmlEditorToolDropDown");
Include("System.Web.UI.WebControls.WebHtmlEditorAlignmentSelector");
Include("System.Web.UI.WebControls.WebHtmlEditorToolDropDownColor");
Include("System.Web.UI.WebControls.WebHtmlEditorToolDropDownCSS");
Include("System.Web.UI.WebControls.WebHtmlEditorToolDropDownEmot");
Include("System.Web.UI.WebControls.WebHtmlEditorToolDropDownHistory");
Include("System.Web.UI.WebControls.WebHtmlEditorToolDropDownTable");


Include("System.Web.UI.WebControls.EventHandler");
Include("System.Web.UI.WebControls.EventHandlerObject");
Include("System.Web.UI.WebControls.EventHandlerButton");
Include("System.Web.UI.WebControls.EventHandlerAttribute");
Include("System.Web.UI.WebControls.EventHandlerCss");
Include("System.Web.UI.WebControls.EventHandlerFormatBlock");
Include("System.Web.UI.WebControls.EventHandlerInput");
Include("System.Web.UI.WebControls.EventHandlerStyle");
Include("System.Web.UI.WebControls.EventHandlerTableColumn");
Include("System.Web.UI.WebControls.EventHandlerTableDeleteCell");
Include("System.Web.UI.WebControls.EventHandlerTableDeleteColumn");
Include("System.Web.UI.WebControls.EventHandlerTableDeleteRow");
Include("System.Web.UI.WebControls.EventHandlerTableMerge");
Include("System.Web.UI.WebControls.EventHandlerTableMergeColumns");
Include("System.Web.UI.WebControls.EventHandlerTableRow");
Include("System.Web.UI.WebControls.EventHandlerTableSplitCell");

var WebHtmlEditorGlobalArray = []; 


function lionsky(id, runTimeSystemFilePath, themePath, width, height, license, upLoadImagesPaths, upLoadImagesFilter, upLoadImagesSize, upLoadImagesAllowUpLoadSize, upLoadFlashPaths, upLoadFlashFilter, upLoadFlashSize, upLoadFlashAllowUpLoadSize, upLoadMediaPaths, upLoadMediaFilter, upLoadMediaSize, upLoadMediaAllowUpLoadSize, upLoadOtherFilePaths, upLoadOtherFileFilter, upLoadOtherFileSize, upLoadOtherFileAllowUpLoadSize, upLoadTemplatePaths, upLoadTemplateFilter, upLoadTemplateSize, upLoadTemplateAllowUpLoadSize, emotPath, emotArray, licenseKey, useCommonToolbar, toolsOnPage, toolBarOnPageWidth, toolBarOnPageHeight, showAddColorOption, toolBarCollection, enableContextMenus, enableTab, convertFontTagsToSpanTags, convertTagsToLower, allowScript, stripAbsoluteLinkPaths, stripAbsoluteImagesPaths, linkPathToStrip, imagesPathToStrip, stripFormattingOnPaste, showEditMode, showViewMode, showHeightenButton, showMinishButton, upLoadImages_EnabledNewFolder, upLoadImages_EnabledDelete, upLoadImages_EnabledUpLoad, upLoadFlash_EnabledNewFolder, upLoadFlash_EnabledDelete, upLoadFlash_EnabledUpLoad, upLoadMedia_EnabledNewFolder, upLoadMedia_EnabledDelete, upLoadMedia_EnabledUpLoad, upLoadOtherFile_EnabledNewFolder, upLoadOtherFile_EnabledDelete, upLoadOtherFile_EnabledUpLoad, upLoadTemplate_EnabledNewFolder, upLoadTemplate_EnabledDelete, upLoadTemplate_EnabledUpLoad, version, currentCulture, onClientUpLoadImagesEnd, onClientLoad, onClientCommandExecuting, onClientCommandExecuted, onClientModeChange, enabledThumbnailImage, onClientUpLoadFlashEnd, onClientUpLoadMediaEnd, onClientUpLoadOtherFileEnd, onClientUpLoadTemplateEnd, copyStyleToFormatBlockTool, useWebHtmlEditorDialog, convertHtmlToXhtmlFilter, onLoadFocus, showBorder, moduleArrayString, enableTabChar, upLoadImagesExistsName, upLoadFlashExistsName, upLoadMediaExistsName, upLoadOtherFileExistsName, upLoadTempleteExistsName, upLoadImagesWaterMarkText, upLoadImagesWaterMarkImagePath, upLoadImagesWaterMarkImageAlign, upLoadImagesAndInsert)
{				
    IanEditor = this;
	IanEditor.Id = id;
	IanEditor.UniqueID = "";
	IanEditor.ClientID = "";
	IanEditor.CurrMode = EDIT_MODE;
	IanEditor.EventArray = [];
	IanEditor.DefaultStyle = null;
	IanEditor.Width = "600px";
	IanEditor.Height = "600px";
	IanEditor.License = "";
	IanEditor.CurrentContentAreaCssClass = "";
	IanEditor.SystemEventArray=[];
	IanEditor.ToolBarManager=null; 
	IanEditor.History = null;
	IanEditor.ToolBarButtonArray = []; 
	IanEditor.ModulesArray = []; 
	IanEditor.Shadows = new Array();
	IanEditor.IsIE = (null != document.all) && (window.opera == null);
	IanEditor.EmptyList="";
	IanEditor.FiltersManager	= new FiltersManage();
	IanEditor.FontNameArray=eval(LR["FontNameArray.options"]); 
	IanEditor.FormatBlockArray=eval(LR["FormatBlock.options"]); 
	IanEditor.LocalResources = LR;  
	IanEditor.KeyObject = new KeyObject();
	IanEditor.RunTimeSystemFilePath = runTimeSystemFilePath;
	IanEditor.DefaultStyle = themePath;
	IanEditor.ThemePath = IanEditor.RunTimeSystemFilePath + "Theme/" + themePath;
	IanEditor.EmotPath = emotPath;
	IanEditor.EmotArray = eval(emotArray);
	IanEditor.Width = width?width:"450px";
	IanEditor.Height =  height?height:"400px";
	IanEditor.LicenseKey =  licenseKey;
	IanEditor.UseCommonToolbar= useCommonToolbar != null?useCommonToolbar: false;
	IanEditor.ToolBarArrayArg = toolBarCollection;
	IanEditor.ToolBarOnPageWidth=toolBarOnPageWidth?toolBarOnPageWidth:this.Width;
	IanEditor.ToolBarOnPageHeight=toolBarOnPageHeight?toolBarOnPageHeight: "";
	IanEditor.ShowAddColorOption=showAddColorOption?showAddColorOption: false; 
	IanEditor.StripFormattingOnPaste = stripFormattingOnPaste;
	IanEditor.ToolsOnPage = toolsOnPage?toolsOnPage: false;
	IanEditor.ShowEditMode = showEditMode;
	IanEditor.ShowViewMode = showViewMode;
	IanEditor.ShowHeightenButton = showHeightenButton;
	IanEditor.ShowMinishButton = showMinishButton;
	IanEditor.Version = version;
	IanEditor.CurrentCulture = currentCulture;	
	IanEditor.OnLoadFocus = onLoadFocus;
	IanEditor.License = "";
	IanEditor.ConvertFontTagsToSpanTags = convertFontTagsToSpanTags?convertFontTagsToSpanTags:false;
	IanEditor.ConvertTagsToLower = convertTagsToLower?convertTagsToLower:false;
	IanEditor.AllowScript = allowScript?allowScript:false;
	IanEditor.StripAbsoluteLinkPaths = stripAbsoluteLinkPaths?stripAbsoluteLinkPaths:false;
	IanEditor.StripAbsoluteImagesPaths = stripAbsoluteImagesPaths?stripAbsoluteImagesPaths:false;
	IanEditor.ConvertHtmlToXhtmlFilter = convertHtmlToXhtmlFilter;
	IanEditor.EnabledThumbnailImage = enabledThumbnailImage;
	IanEditor.UseClassicDialogs=( true != useWebHtmlEditorDialog); 
	IanEditor.LinkPathToStrip = linkPathToStrip;
	IanEditor.ImagesPathToStrip = imagesPathToStrip;
	IanEditor.UpLoadImagesPaths = upLoadImagesPaths;
	IanEditor.UpLoadImagesFilter = upLoadImagesFilter;
	IanEditor.UpLoadImagesSize = upLoadImagesSize;
	IanEditor.UpLoadImagesAllowUpLoadSize = upLoadImagesAllowUpLoadSize;
	IanEditor.UpLoadImagesEnabledNewFolder = upLoadImages_EnabledNewFolder;
	IanEditor.UpLoadImagesEnabledDelete = upLoadImages_EnabledDelete;
	IanEditor.UpLoadImagesEnabledUpLoad = upLoadImages_EnabledUpLoad;
	IanEditor.UpLoadImagesExistsName = upLoadImagesExistsName;
	IanEditor.UpLoadImagesWaterMarkText = upLoadImagesWaterMarkText;
	IanEditor.UpLoadImagesWaterMarkImagePath = upLoadImagesWaterMarkImagePath;
	IanEditor.UpLoadImagesWaterMarkImageAlign = upLoadImagesWaterMarkImageAlign;
	IanEditor.UpLoadImagesAndInsert = upLoadImagesAndInsert;
	IanEditor.UpLoadFlashPaths = upLoadFlashPaths;
	IanEditor.UpLoadFlashFilter = upLoadFlashFilter;
	IanEditor.UpLoadFlashSize = upLoadFlashSize;
	IanEditor.UpLoadFlashAllowUpLoadSize = upLoadFlashAllowUpLoadSize;
	IanEditor.UpLoadFlashEnabledNewFolder = upLoadFlash_EnabledNewFolder;
	IanEditor.UpLoadFlashEnabledDelete = upLoadFlash_EnabledDelete;
	IanEditor.UpLoadFlashEnabledUpLoad = upLoadFlash_EnabledUpLoad;
	IanEditor.UpLoadFlashExistsName = upLoadFlashExistsName;
	IanEditor.UpLoadMediaPaths = upLoadMediaPaths;
	IanEditor.UpLoadMediaFilter = upLoadMediaFilter;
	IanEditor.UpLoadMediaSize = upLoadMediaSize;
	IanEditor.UpLoadMediaAllowUpLoadSize = upLoadMediaAllowUpLoadSize;
	IanEditor.UpLoadMediaEnabledNewFolder = upLoadMedia_EnabledNewFolder;
	IanEditor.UpLoadMediaEnabledDelete = upLoadMedia_EnabledDelete;
	IanEditor.UpLoadMediaEnabledUpLoad = upLoadMedia_EnabledUpLoad;
	IanEditor.UpLoadMediaExistsName = upLoadMediaExistsName;
	IanEditor.UpLoadOtherFilePaths = upLoadOtherFilePaths;
	IanEditor.UpLoadOtherFileFilter = upLoadOtherFileFilter;
	IanEditor.UpLoadOtherFileSize = upLoadOtherFileSize;
	IanEditor.UpLoadOtherFileAllowUpLoadSize = upLoadOtherFileAllowUpLoadSize;
	IanEditor.UpLoadOtherFileEnabledNewFolder = upLoadOtherFile_EnabledNewFolder;
	IanEditor.UpLoadOtherFileEnabledDelete = upLoadOtherFile_EnabledDelete;
	IanEditor.UpLoadOtherFileEnabledUpLoad = upLoadOtherFile_EnabledUpLoad;
	IanEditor.UpLoadOtherFileExistsName = upLoadOtherFileExistsName;
	IanEditor.UpLoadTemplatePaths = upLoadTemplatePaths;
	IanEditor.UpLoadTemplateFilter = upLoadTemplateFilter;
	IanEditor.UpLoadTemplateSize = upLoadTemplateSize;
	IanEditor.UpLoadTemplateAllowUpLoadSize = upLoadTemplateAllowUpLoadSize;
	IanEditor.UpLoadTemplateEnabledNewFolder = upLoadTemplate_EnabledNewFolder;
	IanEditor.UpLoadTemplateEnabledDelete = upLoadTemplate_EnabledDelete;
	IanEditor.UpLoadTemplateEnabledUpLoad = upLoadTemplate_EnabledUpLoad;
	IanEditor.UpLoadTempleteExistsName = upLoadTempleteExistsName;
	IanEditor.EnableTabChar = enableTabChar;
	IanEditor.Progress = null;
	var className;
	IanEditor.ShowBorder=showBorder != null?showBorder: true;
	IanEditor.ContentAreaCssClass = className?className: "WheContent"; 
	//
	var WheWrapperId = "WheWrapper" + id;
	IanEditor.WheWrapperTable = getElementById(WheWrapperId);	
	IanEditor.WheWrapperTable["removeAttribute"]("style",0); 
	//	
	IanEditor.RemoteUpLoad = getElementById("WheRemoteUpLoad"+id);
	//	
	IanElement.addClassName(WheWrapperId, "WheWrapperTable");
	//IanEditor.WheWrapperTable.className = "WheWrapperTable";
	IanEditor.WheWrapperTable.style["height"] = IanEditor.Height?IanEditor.Height:"350px";
	IanEditor.WheWrapperTable.style["width"] = IanEditor.Width?IanEditor.Width:"550px";
	IanEditor.WheContentHiddenTextArea = getElementById(id);
	IanEditor.WheContentHiddenTextArea.style.display="none";
	IanEditor.WheContentTextarea = getElementById("WheContentTextArea"+id); 
	IanEditor.WheContentTextarea["removeAttribute"]("rows",0); 
	IanEditor.WheContentTextarea["removeAttribute"]("cols",0); 
	IanEditor.WheStateBar = getElementById("WheStateBar" + id);	
	IanEditor.WheTopDiv = getElementById("WheTopDiv"+id);
	IanEditor.History = new HistorysManager(IanEditor); 
	if (IanEditor.IsIE)
	{
		IanEditor.WhePasteContainer=getElementById("WhePasteContainer"+id); 
		IanEditor.WhePasteContainer.contentEditable= true;
	}
	IanEditor.DockingZone = new Object();
	var dockZoone=IanEditor.DockingZone; 
	dockZoone.Top=getElementById("WheTop"+id); 
	dockZoone.Left=getElementById("WheLeft"+id); 
	dockZoone.Right=getElementById("WheRight"+id); 
	dockZoone.Bottom=getElementById("WheBottom"+id); 
	dockZoone.Module=getElementById("WheModuleHolder"+id); 
	if (dockZoone.Top)
	{
	    dockZoone.Top["setAttribute"]("DockingMode","Horizontal"); 
	}
	if (dockZoone.Left)
	{
	    dockZoone.Left["setAttribute"]("DockingMode","Vertical"); 
	}
	if (dockZoone.Right)
	{
	    dockZoone.Right["setAttribute"]("DockingMode","Vertical"); 
	}
	if (dockZoone.Bottom)
	{
	    dockZoone.Bottom["setAttribute"]("DockingMode","Horizontal"); 
	}
	if (dockZoone.Module)
	{
	    dockZoone.Module["setAttribute"]("DockingMode","Horizontal"); 
	}
	//
	IanEditor.ModeButton = new WebHtmlEditorModeButtonManage(IanEditor);
	//
	if (onClientLoad && typeof(onClientLoad)=="string")
	{
		IanEditor.RegisterPrototype("OnClientLoad", eval(onClientLoad)); 
	}	 
	if (onClientCommandExecuting && typeof(onClientCommandExecuting)=="string")
	{
		IanEditor.RegisterPrototype("OnClientCommandExecuting", eval(onClientCommandExecuting)); 
	}
	if (onClientCommandExecuted && typeof(onClientCommandExecuted)=="string")
	{
		IanEditor.RegisterPrototype("OnClientCommandExecuted", eval(onClientCommandExecuted)); 
	}	 
	if (onClientModeChange && typeof(onClientModeChange)=="string")
	{
		IanEditor.RegisterPrototype("OnClientModeChange", eval(onClientModeChange));
	}
	if(onClientUpLoadImagesEnd && typeof(onClientUpLoadImagesEnd)=="string")
	{
	    IanEditor.OnClientUpLoadImagesEnd = eval(onClientUpLoadImagesEnd);
	}	
	if(onClientUpLoadFlashEnd && typeof(onClientUpLoadFlashEnd)=="string")
	{
	    IanEditor.OnClientUpLoadFlashEnd = eval(onClientUpLoadFlashEnd);
	}
	if(onClientUpLoadMediaEnd && typeof(onClientUpLoadMediaEnd)=="string")
	{
	    IanEditor.OnClientUpLoadMediaEnd = eval(onClientUpLoadMediaEnd);
	}
	if(onClientUpLoadOtherFileEnd && typeof(onClientUpLoadOtherFileEnd)=="string")
	{
	    IanEditor.OnClientUpLoadOtherFileEnd = eval(onClientUpLoadOtherFileEnd);
	}
	if(onClientUpLoadTemplateEnd && typeof(onClientUpLoadTemplateEnd)=="string")
	{
	    IanEditor.OnClientUpLoadTemplateEnd = eval(onClientUpLoadTemplateEnd);
	}
	IanEditor.RegisterDockingZone();
	IanEditor.RegisterKey(WHECOMMAND_HELP,"F1"); 
	IanEditor.RegisterKey(WHECOMMAND_UNDO,"CTRL+Z"); 
	IanEditor.RegisterKey(WHECOMMAND_REDO,"CTRL+Y"); 
	IanEditor.RegisterKey(WHECOMMAND_BOLD,"CTRL+B"); 
	IanEditor.RegisterKey(WHECOMMAND_SELECT_ALL,"CTRL+A");
	IanEditor.RegisterKey(WHECOMMAND_ITALIC,"CTRL+I");
	IanEditor.RegisterKey(WHECOMMAND_UNDERLINE,"CTRL+U");	
	IanEditor.RegisterKey(WHECOMMAND_COPY,"CTRL+C"); 
	IanEditor.RegisterKey(WHECOMMAND_PASTE,"CTRL+V"); 
	IanEditor.RegisterKey(WHECOMMAND_CUT,"CTRL+X"); 
	IanEditor.RegisterKey(WHECOMMAND_SHOW_LINK_DIALOG,"CTRL+K"); 
	IanEditor.RegisterKey(WHECOMMAND_COPY,"CTRL+INS");  	
	IanEditor.RegisterKey(WHECOMMAND_SHOW_FIND_DIALOG,"CTRL+F"); 
	IanEditor.RegisterKey(WHECOMMAND_SHOW_IMAGE_DIALOG,"CTRL+G"); 	
	IanEditor.RegisterKey(WHECOMMAND_TOGGLE_SCREEN_MODE,"F11"); 
	if (IanEditor.IsIE)
	{
		IanEditor.RegisterKey(WHECOMMAND_ENTER,"ENTER"); 
		IanEditor.RegisterKey(WHECOMMAND_SHIFTENTER,"SHIFT+ENTER"); 
		IanEditor.RegisterKey(WHECOMMAND_INSERT_PARAGRAPH,"CTRL+ENTER"); 
	}
	IanEditor.EnableTab = enableTab;
	if (IanEditor.EnableTab)
	{
		IanEditor.RegisterKey(WHECOMMAND_ENABLETAB,"TAB"); 
	}
		

	IanEditor.WheMainTable=getElementById("WheWrapper"+id); 
	IanEditor.ToolBarManager = new ToolBarsManager(IanEditor);   
	
	IanEditor.OnLoad( false);
	  
	Util_AddStyleSheet(IanEditor.ThemePath +"/WebHtmlEditor.css", document);
	var div = getElementById("WheContentDiv"+id); 
	var iframe = getElementById("WheContentIframe" + id);	
	if(true)
	{
		if (div)
		{
		    div.style.display="none"; 
		}
		IanEditor.EditArea = iframe; 
		var tempdocument = IanEditor.EditArea.contentWindow.document; 
		var headString = "<head><style></style></head><body></body>";
		var strHiddenText = IanEditor.WheContentHiddenTextArea["value"];
		if (strHiddenText.toLowerCase().indexOf("<html>") != -1)
		{
			headString = strHiddenText;
			IanEditor.FullPage= true;
		}
		tempdocument.open(); 
		tempdocument.write(headString); 
		tempdocument.close(); 
		IanEditor.ContentWindow=IanEditor.EditArea.contentWindow; 
		IanEditor.Document=IanEditor.EditArea.contentWindow.document; 
		IanEditor.Body=IanEditor.Document.body; 
		IanEditor.Body.className = "WheContentBordered";
		Util_AddStyleSheet(IanEditor.ThemePath +"/EditorArea.css", IanEditor.Document);
		//
//		var documents=WebHtmlEditor.Document; 		
//	    var baseHeader=documents.createElement("base"); 
//	    baseHeader.setAttribute("href",document.location.protocol + "//" + document.location.host+"App_Themes/Default/Images/"); 
//	    var head=documents.getElementsByTagName("head")[0]; 		
//	    if (Util_DetectBrowser("safari"))
//	    {
//		    var ADDHEAD= function ()
//		    {
//			    head.appendChild(baseHeader); 
//		    };
//		    window.setTimeout(ADDHEAD,0310); 
//	    }
//	    else 
//	    {
//		    head.appendChild(baseHeader); 
//	    } 
	    //
		if (Util_DetectBrowser("safari"))
		{
			IanEditor.EditArea.style["height"]=IanEditor.Height; 
			IanEditor.FullPage= true;
		}
	}
	else
	{
		IanEditor.EditArea = div;
		IanEditor.Body = div;
		IanEditor.Document=document; 
		IanEditor.ContentWindow=window;
		if (iframe)
		{
		    iframe.style.display="none"; 
		}
	}
	
	IanEditor.CreateEditAreaEvent();
	IanEditor.WheContentHiddenTextArea["setAttribute"]("id",IanEditor.Id); 
	IanEditor.SetCurrentModeEditAreaValue();
	//
	var BCCM=BCssClassManager();  
	BCCM.AddStyleSheet(IanEditor.ThemePath +"/EditorArea.css", IanEditor.Document); 
	if(copyStyleToFormatBlockTool)
	{
	    BCCM.Copy(document, IanEditor.Document);
	}
	IanEditor.SetBodyShowBorder(); 
	/*
	模块设置	
	var moduleObject = 
	[
	    ['WebHtmlEditorStatistics','Bottom',true, true, 50, 0.33,true],
	    ['WebHtmlEditorViewDom','Module',true, true, 50, 0.33,true],
	    ['WebHtmlEditorViewRuntimeHtml','Module',true, true, 50, 0.33,true],
	    ['WebHtmlEditorPropertyInspector','Module',false, true, 50, 0.33,true]
	];
	[
	    ['WebHtmlEditorViewDom',Bottom, 1,true, true, 50, 0.33, true],
	    ['WebHtmlEditorPropertyInspector',Right, 3, false, true, 50, 0.33, true]
	]
	*/
	IanEditor.ModuleObject = eval(moduleArrayString);
	var moduleObjectLen=IanEditor.ModuleObject.length; 
	if (moduleObjectLen>0)
	{
		for (var i=0; i<moduleObjectLen; i++)
		{
			var item=IanEditor.ModuleObject[i]; 
			var step=0; 
			var name=item[step++];  
			var place=item[step++];
			var cellsLen = item[step++]; 
			var dockable=item[step++]; 
			var effectsEnable=item[step++];
			var effectsUpdateRate=item[step++];
			var effectsDuration=item[step++];
			var enabled=item[step++];
			var id=null; 
			try 
			{
			    IanEditor.RegisterModule(name,place,dockable, cellsLen, effectsEnable, effectsUpdateRate, effectsDuration, enabled, id);
			}
			catch (e){} ; 
		}
		var tempFunc= function (editor)
		{
			editor.AttachEventHandler(WHEEVENT_MODE_CHANGED, function (){var mode=(editor.CurrMode == EDIT_MODE);editor.SetModulesVisible(mode); } ); 
		} ; 
		tempFunc(IanEditor); 
	}
	
	IanEditor.EnableContextMenus=enableContextMenus != null?enableContextMenus: true;
	customContextMenuArray = [];
	IanEditor.CustomContextMenuArray= (!customContextMenuArray?[]:customContextMenuArray); 
	if (IanEditor.EnableContextMenus)
	{	  
		var InitializeContextMenusManager = function (editor)
		{
			var bContextMenusManager = new ContextMenusManager(editor,editor.CustomContextMenuArray); 
			editor.ContextMenusManager=bContextMenusManager; 
			editor.AttachEventHandler(WHEEVENT_CONTEXTMENU, function (editor,e){if (editor.CurrMode == EDIT_MODE){bContextMenusManager.ShowContextMenu(e); e.cancelBubble= true; CancelSelect() }} ); 
		} ; 
		InitializeContextMenusManager(IanEditor);
	}
	
	var popup=BPopupsManager.GetPopupsManager(); 
	popup.AddStyleSheet(IanEditor.ThemePath +"/WebHtmlEditor.css"); 
	popup.AddStyleSheet(IanEditor.ThemePath +"/Dialog.Css"); 
	if(IanEditor.ConvertFontTagsToSpanTags)
	{
	    IanEditor.FiltersManager.Add(new Font2SpanFilter()); 
	}
	if(IanEditor.ConvertTagsToLower)
	{
	    IanEditor.FiltersManager.Add(new TagsNameToLowerFilter());
	}
	if(IanEditor.AllowScript!=true)
	{
	    IanEditor.FiltersManager.Add(new StripScriptTagsFilter()); 
	}
	if (IanEditor.StripAbsoluteLinkPaths)
	{
	    IanEditor.FiltersManager.Add(new StripPathFilter("A", IanEditor.LinkPathToStrip));
	} 
	if (IanEditor.StripAbsoluteImagesPaths)
	{
	    IanEditor.FiltersManager.Add(new StripPathFilter("IMG", IanEditor.ImagesPathToStrip)); 
	}
	if (IanEditor.ConvertHtmlToXhtmlFilter)
	{
	    IanEditor.FiltersManager.Add(new ConvertHtmlToXhtmlFilter()); 
	}
	
	if (0 == WebHtmlEditorGlobalArray.length)
	{
		IanEditor.attachEvent(window,"unload", function (){WindowOnUnLoad(); } ); 
	};
	//
	WebHtmlEditorGlobalArray.add(IanEditor);	
	IanEditor.ExecuteClientCommand("OnClientLoad");
	DefaultSetDocumentEdit(IanEditor);
	if(IanEditor.OnLoadFocus)
	{ 
	    IanEditor.SetFocus(); 
	}
	
	IanEditor.Initialize();
}
lionsky.prototype.GetResources= function (command1,command2)
{
	var command=this.LocalResources[command1]; 
	if (!command)
	{
	    return command2; 
	}
	else
	{
	    return command; 
	}
};
lionsky.prototype.RegisterModule= function (name,place,dockable, cellsLen, effectsEnable, effectsUpdateRate, effectsDuration, enable,id)
{		
	var title=this.GetResources(name,name); 
	var moduleArgs = new Object(); 
	moduleArgs.Editor = this;
	moduleArgs.Document = document;
	moduleArgs.Title = title;
	moduleArgs.Id = id;
	moduleArgs.Place = place;
	moduleArgs.Dockable = dockable;
	moduleArgs.CellsLen = cellsLen;
	
	var module;
	if(name=="WebHtmlEditorViewDom")
	{
	    module = new WebHtmlEditorViewDom(moduleArgs);
	}
	else if(name=="WebHtmlEditorStatistics")
	{
	    module = new WebHtmlEditorStatistics(moduleArgs);
	}
	else if(name=="WebHtmlEditorViewRuntimeHtml")
	{
	    module = new WebHtmlEditorViewRuntimeHtml(moduleArgs);
	}
	else if(name == "WebHtmlEditorPropertyInspector")
	{
	    module = new WebHtmlEditorPropertyInspector(moduleArgs);
	}
	if(!module)
	{
	    return ;
	}
	this.ModulesArray[this.ModulesArray.length]=module; 
	if (!module.IsCreated)
	{
		var elem=module.Create(); 		
		var parentNode=this.GetPlacedToolBarHtmlElement(module.Place); 
		parentNode.appendChild(elem); 
		if (module.Dockable)
		{
		    this.RegisterDockableObject(elem, true, false, false, effectsUpdateRate, effectsDuration, effectsEnable); 
		}
	}
	module.Show(enable); 
	return module; 
} ;
lionsky.prototype.SetModulesVisible= function (flag)
{
	var array=this.ModulesArray; 
	for (var count=0; count<array.length; count++)
	{
		array[count].SetVisible(flag); 
	}
} ; 
lionsky.prototype.GetToolBarTableObjectByName= function (name)
{
	var toolbar; 
	for (var j=0; j<this.ToolBarManager.ToolBarTableObjectArray.length; j++)
	{
		toolbar=this.ToolBarManager.ToolBarTableObjectArray[j]; 
		if (toolbar.Name == name)
		{
			return toolbar;
		}
	}
	return null; 
} ;


WindowOnUnLoad= function ()
{
	var globalArray=WebHtmlEditorGlobalArray; 
	for (var index=0; index<globalArray.length; index++)
	{
		try 
		{
			var editor=globalArray[index];
			if ( true == editor.unload)
			{
			    continue; 
			}
			editor.unload= true;
			try
			{
			    var array = this.ModulesArray;
			    for (var i=0; i<array.length; i++)
				{
					if(array[i].Clear)
					{
					    array[i].Clear(); 
					}
					array[i]=null;
				}
			}
			catch(e){}
			try 
			{
				var toolBarButtonArray=editor.ToolBarButtonArray; 
				for (var i=0; i<toolBarButtonArray.length; i++)
				{
					if(toolBarButtonArray[i].Clear)
					{
					    toolBarButtonArray[i].Clear(); 
					}
					toolBarButtonArray[i]=null;
				}
			}
			catch (e){} ;
			try
			{
			    var dockingManager = this.DockingManager;
			    for (var i=0; i<dockingManager.DockableObjects.length; i++)
                { 
	                if(dockingManager.DockableObjects[i].Clear)
	                {
		                dockingManager.DockableObjects[i].Clear(); 
	                }
	                dockingManager.DockableObjects[i]=null; 
                }
                for (var i=0; i<dockingManager.DockingZones.length; i++)
                { 
	                if(dockingManager.DockingZones[i].Clear)
	                {
		                dockingManager.DockingZones[i].Clear(); 
	                }
	                dockingManager.DockingZones[i]=null; 
                } 
                dockingManager.DockableObjects=null; 
                dockingManager.DockingZones=null; 
                dockingManager.Editor=null;
                dockingManager.DragHelperElem=null;
                dockingManager.DragHelperTooltip=null;
                dockingManager.DragHelperTooltipElem=null;
                Cache_DragImage = null;
			}
			catch(e){};
			try 
			{
				if(editor.ToolBarManager.Clear)
				{
				    editor.ToolBarManager.Clear();
				}
				if (editor.History.Clear)
				{
				    editor.History.Clear(); 
				}
				if (editor.KeyObject.Clear)
				{
				    editor.KeyObject.Clear(); 
				}
				if (editor.ContextMenusManager)
				{
				    editor.ContextMenusManager.Clear(); 
				}
			}
			catch (e){} ; 
			editor.RemoveAllDocumentEvent(); 
			for (var item in editor)
			{
				if (typeof(editor[item]) != "function")
				{
				    editor[item]=null; 
				}
			}
		}
		catch (e){} ; 
	}
};




lionsky.prototype.Initialize = function()
{	  
	this.Browser_Agt = (navigator==null||navigator.userAgent==null)?'':navigator.userAgent.toLowerCase();
	this.Browser_App = (navigator==null||navigator.appVersion==null)?'':navigator.appVersion;
	this.Browser_Major = parseInt(this.Browser_App);
	this.Browser_Opera = this.Browser_Agt.indexOf('opera')!=-1;
	this.Browser_IE = !this.Browser_Opera&&(this.Browser_Agt.indexOf('msie')!=-1);
	this.Browser_IEmac = this.Browser_IE&&(this.Browser_Agt.indexOf('mac')!=-1);
	this.Browser_Safari = this.Browser_Agt.indexOf('safari')!=-1;
	this.Browser_Konqueror = this.Browser_Agt.indexOf('konqueror')!=-1;
	this.Browser_Mozilla = !this.Browser_IE&&!this.Browser_Opera&&((this.Browser_Agt.indexOf('netscape')!=-1)||(this.Browser_Agt.indexOf('mozilla')!=-1))&&(this.Browser_Major>=5);
	this.Browser_IE3 = this.Browser_IE&&(this.Browser_Major<4);
	this.Browser_IE4 = this.Browser_IE&&(this.Browser_Major==4)&&(this.Browser_Agt.indexOf("msie 4")!=-1);
	this.Browser_IE5point5 = this.Browser_IE&&(this.Browser_Major==4)&&(this.Browser_Agt.indexOf("msie 5.5")!=-1);
	this.Browser_IE5 = this.Browser_IE&&(this.Browser_Major==4)&&(this.Browser_Agt.indexOf("msie 5")!=-1)&&!this.Browser_IE5point5;
	this.Browser_IE5point5plus = this.Browser_IE&&!this.Browser_IE3&&!this.Browser_IE4&&!this.Browser_IE5;
	this.Browser_Transitions = this.Browser_IE5point5plus&&(this.Browser_Agt.indexOf('nt 4')==-1);
	this.Browser_IE6plus = this.Browser_IE&&!this.Browser_IE3&&!this.Browser_IE4&&!this.Browser_IE5&&!this.Browser_IE5point5;
	this.Browser_NS6 = getElementById&&!document.all;
	this.Browser_Shadows = this.Browser_IE6plus;
	this.Browser_Slides = !this.Browser_Konqueror&&(this.Browser_Agt.indexOf('Netscape6')==-1);
	this.Browser_Overlays = this.Browser_IE5point5plus;
	this.Browser_Hideselects = this.Browser_IE&&!this.Browser_IEmac;
	this.Browser_Addeventhandlers = !this.Browser_IEmac;
	this.Browser_Contextmenus = this.Browser_Addeventhandlers;
	this.Browser_Noncustomcontextmenus = this.Browser_Contextmenus&&!this.Browser_Opera&&!this.Browser_Safari;
	this.Browser_Expandonclick = this.Browser_Addeventhandlers;
	this.Browser_Recyclegroups = !this.Browser_IEmac;		
	
}
lionsky.prototype.OnLoad= function (flag)
{
	var list=new Array("%","<",">","!","\"","#","$","&","'","(",")",",",":",";","=","?","[","\\","]","^","`","{","|","}","~","+"); 
	if (flag)
	{
		var html=this.GetHtml();		 
		if (this.FullPage)
		{
			var HTMLElem=this.Document["getElementsByTagName"]("HTML")[0]; 			
			var BODYElem=this.Document["getElementsByTagName"]("BODY")[0]; 
			BODYElem["removeAttribute"]("contentEditable"); 
			var className=BODYElem.className.toLowerCase(); 
			if ("radecontentbordered" == className||"radecontent" == className)
			{
				BODYElem["removeAttribute"]("class"); 
			}
			var HEADElem=this.Document["getElementsByTagName"]("HEAD")[0]; 
			if (HEADElem)
			{
				var HEADLinkElemArray=this.Document["getElementsByTagName"]("LINK"); 
				for (var i=0; i<HEADLinkElemArray.length; i++)
				{
					HEADLinkElemArray[i].parentNode.removeChild(HEADLinkElemArray[i]);
				}
			}
			html=("<html>"+HTMLElem.innerHTML+"</html>"); 
		}
		try
		{
			html=this.FiltersManager.GetHtmlContent(html);
		}
		catch (e){ ; }
		for (var i=0; i<list.length; i++)
		{
			html=html.replace(new RegExp("\x5c\x78"+list[i].charCodeAt(0).toString(020),"\x69\x67"),"\x25"+list[i].charCodeAt(0).toString(020)); 
		} 
		this.WheContentTextarea["value"]=""; 
		this.WheContentHiddenTextArea["value"]=html; 
	}
	else 
	{
		var html=this.WheContentHiddenTextArea["value"]; 
		for (var i=list.length-1; i>=0; i--)
		{
			html=html.replace(new RegExp("\x25"+list[i].charCodeAt(0).toString(020),"ig"),list[i]); 
		}
		try 
		{
			html=this.FiltersManager.GetDesignContent(html); 
		}
		catch (e){ ; } 
		this.WheContentHiddenTextArea["value"]=html; 
	}
} ; 
lionsky.prototype.SelectDom= function (elem,fireEvent)
{
    if (CreateElemContainer(this.ContentWindow,elem)&& false != fireEvent)
    { 
        this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
    }
} ;
lionsky.prototype.GetImagePath = function (imageName)
{
	return (this.ThemePath+"/Images/ButtonImage/"+imageName); 
} ;
lionsky.prototype.GetCustomToolbarButton = function (command, controller, documents, imagePath, dropDownImageUseShowTitleText,showTitleText, dropDownImageShowTitleTextPlaced)
{ 
	if (!controller)
	{
	    controller=this ; 
	}
	if (!documents)
	{
	    documents=this.Document; 
	}
	var resourcesText=this.LocalResources[command]; 
	if (!resourcesText)
	{
	    resourcesText=command; 	
	}
	if ( false != dropDownImageUseShowTitleText)
	{
		if (!imagePath)
		{
		    imagePath=this.GetImagePath(command+".gif"); 
		}
	}		
	var oTool=new Object(); 
	oTool.Controller=controller;
	oTool.Document=documents;
	oTool.Name=command;
	oTool.Title=resourcesText;
	oTool.ImagePath=imagePath;
	oTool.DropDownImageUseShowTitleText=( false == dropDownImageUseShowTitleText? false : true);
	oTool.ShowTitleText=( false == showTitleText? false : true);
	oTool.DropDownImageShowTitleTextPlaced=dropDownImageShowTitleTextPlaced; 			
	toolBarButton=new WebHtmlEditorToolButton(oTool); 
	toolBarButton.Create(); 
	return toolBarButton; 
} ;

 
lionsky.prototype.SetToolState= function (oToolArray)
{
	var oTool=null; 
	var systemCommand=null; 
	var contentWindow=this.ContentWindow;	
    for (var i=0; i<oToolArray.length; i++)
    {	   
	    oTool=oToolArray[i];
	    var buttonName=oTool.Name; 
	    systemCommand=WHEEditorCommandEventList[buttonName];  
	    if (buttonName == WHECOMMAND_UNDO)
	    {
		    oTool.SetState(this.History.GetUndoState()); 
	    }
	    else if (buttonName == WHECOMMAND_REDO)
	    {
		    oTool.SetState(this.History.GetRedoState()); 
	    }
	    else if (buttonName == WHECOMMAND_REPLACELASTCOMMAND)
	    {
		    oTool.SetState(this.History.CheckLastHistoryIsNotNull()?WHECOMMAND_STATE_OFF:WHECOMMAND_STATE_DISABLED); 
	    }
	    else if (oTool.SetState&&systemCommand&&systemCommand.GetState)
	    {
		    oTool.SetState(systemCommand.GetState(contentWindow)); 
	    }
	    if (oTool.AlwayCheckEvent)
	    {		  	
		    oTool.AlwayCheckEvent(systemCommand.AlwayCheckEvent(contentWindow));
		    oTool=systemCommand=null; 
	    }
    }
	
} ;

lionsky.prototype.RegisterKey= function (command,shortCutKey)
{
	if (this.KeyObject)
	{ 
		this.KeyObject.Register(command, shortCutKey); 
	}
} ;
lionsky.prototype.RegisterPrototype= function (command, eventFunction)
{
	if (!eventFunction)
	{
		return; 
	}
	else
	{
		this[command]=eventFunction; 
	}
};

lionsky.prototype.PasteHtml= function (content,title,select,isSetState)
{
	if (VIEW_MODE == this.CurrMode){return; }
	if (EDIT_MODE == this.CurrMode)
	{ 	 
		this.SetFocus(); 
		this.SaveHistory(new WebHtmlEditorObjectEventHandle(title,this.ContentWindow,content,select));
		if (isSetState != false){this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); }
	}
	else if (CODE_MODE == this.CurrMode)
	{
		if (this.IsIE)
		{ 
			this.WheContentTextarea.setActive(); 
			var createRange=document.selection.createRange(); 
			createRange.text=content; 
		}
		else 
		{
			var contentTextarea=this.WheContentTextarea; 
			if (contentTextarea.ATO)
			{
				var selectionStart=contentTextarea.selectionStart; 
				var selectionEnd=contentTextarea.selectionEnd; 
				var str=contentTextarea["value"].substring(selectionStart,selectionEnd); 
				contentTextarea["value"]=contentTextarea["value"].substring(0,selectionStart)+content+contentTextarea["value"].substring(selectionEnd); 
				contentTextarea.ATO(selectionStart+content.length,selectionStart+content.length); 
				this.SetFocus(); 
				return false; 
			}
		}
	}
} ; 
lionsky.prototype.GetPlacedToolBarHtmlElement= function (place)
{
	var placeElem=null; 
	if (place)
	{
		str=place.toLowerCase(); 
		switch (str)
		{
			case "top":
				placeElem=this.DockingZone.Top; 
				break; 
			case "left":
				placeElem=this.DockingZone.Left; 
				break; 
			case "right":
				placeElem=this.DockingZone.Right; 
				break; 
			case "bottom":
				placeElem=this.DockingZone.Bottom; 
				break; 
			case "module":
				placeElem=this.DockingZone.Module; 
				break; 
			default:
				placeElem=getElementById(place); 
				break; 
		}
	}
	return placeElem; 
};

lionsky.prototype.FontSizeArray=[1,2,3,4,5,6,7];
lionsky.prototype.CheckPlacedToolBarHtmlElementIsVertical= function (elem)
{
	if (!elem)
	{
	    return null; 
	}
	var dockingMode = elem["getAttribute"]("DockingMode"); 
	if (dockingMode&&"Vertical" == dockingMode)
	{
		return true; 
	}
};

lionsky.prototype.GetRuleArrayByDocument= function (doc)
{
	if (null == doc)
	{
	    doc=document; 
	}
	var BCCM=BCssClassManager(); 
	var ruleArray = BCCM.InitializeDocumentRules(doc); 
	return ruleArray; 
} ; 

lionsky.prototype.RegisterDockableObject= function (dockableObject,allowShowDragHelper,attachDragHelperProperty,attachDragResizeProperty, effectsUpdateRate, effectsDuration, effectsEnable)
{	    
	if(this.DockingManager)
	{
	    this.DockingManager.RegisterDockableObject(dockableObject,allowShowDragHelper,attachDragHelperProperty,attachDragResizeProperty, effectsUpdateRate, effectsDuration, effectsEnable); 
	}
};



 



lionsky.prototype.Add2ToolBarButtonArray= function (toolBarButton)
{
	this.ToolBarButtonArray.add(toolBarButton); 
};




 








lionsky.prototype.ExecuteClientCommand= function (command)
{
	try 
	{
		var pro=this[command];
		if (!pro)
		{
			return; 
		}
		else if (typeof(pro) == "string")
		{
			pro=eval(pro); 
		}
		var arglen=this.ExecuteClientCommand.arguments.length; 
		if (arglen<2)
		{
			return pro(this); 
		}
		else 
		{
			var args = this.ExecuteClientCommand.arguments; 
			var args_1 = args[1]; 
			var args_2 = arglen>2?args[2]:null; 
			var args_3 = arglen>3?args[3]:null; 
			return pro(this, args_1, args_2, args_3); 
		}
	}
	catch (e)
	{   
	    alert(LR["ExecuteClientCommandErrorMsg"].Format(command, e.message));
	} ; 
	return true; 
} ; 
lionsky.prototype.ALoadImgFromPath  = function(area, path)
{	
	if (!path || !area)
	{
	    return;	
	}
	var img = document.createElement("IMG");
	img.src = path;	
	img["border"] = 0;	
	if (img.complete)
	{
		area.appendChild(img);
	}
	else
	{
		if (document.all)
		{
			img.onload = function an()
			{
				area.appendChild(this);
			}
		}
		else
		{
			area.appendChild(img);
		}
	}
}


lionsky.prototype.InsertRow= function (arg)
{
	var title="Insert row"; 
	if (arg == "above"){title=this.LocalResources[WHECOMMAND_INSERT_ROW_ABOVE]; }
	else if (arg == "below"){title=this.LocalResources[WHECOMMAND_INSERT_ROW_BELOW]; }
	this.SaveHistory(new WebHtmlEditorEventTableRow(title,this.ContentWindow,arg)); 
} ;
lionsky.prototype.CreateHtmlElement= function (tagName, width, height, id, name, value, innerHTML)
{
	var elem=this.Document.createElement(tagName); 
	elem.style["width"]=GetDefaultValue(width,""); 
	elem.style["height"]=GetDefaultValue(height,""); 
	if (null != id)
	{
	    elem.id=id; 
	}
	if (null != name)
	{
	    elem.name=name; 
	}
	if (null != value)
	{
	    elem["value"]=value; 
	}
	if(null != innerHTML)
	{
	    elem["innerHTML"] = innerHTML;
	}
	return elem; 
} ; 
lionsky.prototype.IndentHtml= function ()
{
	var text=this.WheContentTextarea["value"]; 
	var textHtml=text; 
	if (this.IsIndentHtml)
	{
		var onePoint=OnePoint; 
		var reg=new RegExp("["+onePoint+"\x0d\x0a]+","ig"); 
		var textHtml=text.replace(reg,"\x20"); 
	} 
	this.WheContentTextarea["value"]=textHtml; 
};
lionsky.prototype.SetHtml= function (content,title,focuse)
{
    var inputEvent=new InputBaseEvent(title,this.ContentWindow);
	this.WheContentHiddenTextArea.value=content; 
	this.SetCurrentModeEditAreaValue(); 
	this.SaveHistory(inputEvent,focuse); 
	this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null);
} ;

lionsky.prototype.SetSize= function (width,height)
{
	width=(""+width); 
	height=(""+height); 
	if (-1 == width.indexOf("%"))
	{
		width=parseInt(width); 
		if (isNaN(width))
		{
			width=0450; 
		}
		width=width+"px"; 
	}
	if (-1 == height.indexOf("%"))
	{
		height=parseInt(height); 
		if (isNaN(height))
		{
			height=0400; 
		}
		height=height+"px"; 
	} ; 
	if (this.IsIE&&"CSS1Compat" == document.compatMode)
	{ 
		this.WheContentTextarea.style["width"]=width; 
		this.WheContentTextarea.style["height"]=height; 
	} 
	this.WheWrapperTable.style["width"]=width; 
	this.WheWrapperTable.style["height"]=height
	this.Width=width; 
	this.Height=height; 
} ; 
lionsky.prototype.GetText= function ()
{
	var content=""; 
	switch (this.CurrMode)
	{
		case EDIT_MODE:
		case VIEW_MODE:	
			if (this.IsIE)
			{
				content=this.Body.innerText; 
			}
			else 
			{
				var str=this.Body.innerHTML; 
				content=str.replace(/<\/?[^>]*>/ig,""); 
			}
			break; 
		case CODE_MODE: 
			if (this.IsIE)
			{
				var span=document.createElement("SPAN"); 
				span.innerHTML=this.WheContentTextarea["value"]; 
				content=span.innerText; 
			}
			else 
			{
				var str=this.WheContentTextarea["value"]; 
				content=str.replace(/<\/?[^>]*>/ig,""); 
			}
			break; 
	}
	return content; 
} ; 
lionsky.prototype.GetHtml= function (filterHtml)
{
	var content=""; 
	switch (this.CurrMode)
	{
		case EDIT_MODE:
		case VIEW_MODE:
			content=this.Body.innerHTML; 
			if (this.IsIE&&this.Body.firstChild&&("P" == this.Body.firstChild.tagName)&&(this.Body.childNodes.length == 1)&&(this.Body.innerHTML.substring(0,3).toLowerCase() == "<p>"))
			{
				content=this.Body.innerHTML; 
			}
			break; 
		case CODE_MODE: 
			this.IndentHtml();
			content=this.WheContentTextarea["value"]; 
			break; 
	}
	if ( true == filterHtml)
	{
		content=this.FiltersManager.GetHtmlContent(content); 
	}
	return content; 
} ;
lionsky.prototype.SetCurrentModeEditAreaValue= function ()
{
	var content=this.WheContentHiddenTextArea["value"]; 
	var html;
	if (this.CurrMode == EDIT_MODE||this.CurrMode == VIEW_MODE)
	{
		html=this.CurrMode == EDIT_MODE?this.FiltersManager.GetDesignContent(content):this.FiltersManager.GetPreviewContent(content);
		try 
		{
			var bodyElem=this.Body;
			//alert(html);
			bodyElem.innerHTML=html;
			//alert(bodyElem.innerHTML);
		}catch (e){ ; }
	}
	else if (CODE_MODE)
	{
		html=this.FiltersManager.GetHtmlContent(content);
		if(html=="<br>\r\n") 
		{
		    html = "";
		}
		this.WheContentTextarea["value"]=html;
	}
	this.WheContentHiddenTextArea["value"] = html;//added by tph,2007-09-06
	return; 
};
lionsky.prototype.ExecuteCommandStripFormatEmpty= function (content,title,focuse)
{
	var commandEvent=new WebHtmlEditorEvent(title,this.ContentWindow);
	this.WheContentHiddenTextArea["value"]=content; 
	this.SetCurrentModeEditAreaValue(); 
	this.SaveHistory(commandEvent,focuse); 
	this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
} ;
lionsky.prototype.SetActive= function ()
{
	if (this.IsIE)
	{
		var item=null; 
		var array=[this.EditArea,this.WheContentTextarea]; 
		for (var i=0; i<array.length; i++)
		{
			if (array[i]&&array[i].style.display != "none")
			{
				item=array[i]; 
			}
		}
		if (item&&item.setActive)
		{
			item.setActive(); 
		}
	}
} ; //
lionsky.prototype.ExecuteButtonCommand= function (command,isNotSelectAll,value,i27)
{
	var resourcesText=this.LocalResources[command]; 
	this.SaveHistory(new WebHtmlEditorEventButton(resourcesText,command,this.ContentWindow,value, this)); 
	this.SetActive(); 
	this.SetFocus(); 
	if ( true == isNotSelectAll){this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null);}
} ;

lionsky.prototype.RegisterDockingZone = function()
{
	this.DockingManager = new lionskyDockingManager(document, this);
	var dockingZone=this.DockingZone; 
	for (var item in dockingZone)
	{		
		if(dockingZone[item])
		{
		    this.DockingManager.RegisterDockingZone(dockingZone[item]);
		}
	}
	this.DockingManager.EnableDocking(this.ThemePath+"/Images/ButtonImage/transp.gif"); 
}
lionsky.prototype.ExecuteCommand= function (command, tool)
{	
	if ( false == this.ExecuteClientCommand("OnClientCommandExecuting", command, tool))
	{
	    return; 
	}
	if (this.IsIE)
	{
	    this.Body.contentEditable= true; 
	}
	this.CurrInputEvent=null; 
	var commandEvent=WHEEditorCommandList[command];
	   
	var isExecuteCommand= false; 
	if (commandEvent)
	{
		isExecuteCommand=( false != commandEvent(command, this, tool)); 
	}
	else 
	{		
	    alert(LR["NoFindCommandErrorMsg"].Format(command));
	}
	if (isExecuteCommand)
	{ 
		this.SetFocus();
		this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
	} 
	this.ExecuteClientCommand("OnClientCommandExecuted", command, tool); 
} ; 
lionsky.prototype.CreateRestorePoint= function ()
{
	return GetDocumentChange(this.ContentWindow); 
}
lionsky.prototype.GetClipboardAsHtml= function ()
{
	var pasteContainer=this.WhePasteContainer; 
	pasteContainer.innerHTML=""; 
	pasteContainer.setActive(); 
	document.execCommand("Paste",null); 
	var html = pasteContainer.innerHTML; 
	pasteContainer.innerHTML = "";
	return html;
} ;
lionsky.prototype.ExecuteCommandInsertImage= function (returnValue)
{ 
	var html = "";
	if(this.IsIE)
	{
		html = returnValue.outerHTML;
	}
	else
	{
		var span = this.Document.createElement("SPAN"); 
		span.appendChild(returnValue);
		html = span.innerHTML;
	}
	this.PasteHtml(html);
} ;

lionsky.prototype.ColorsArray=["","#ffff00","#00ff00","#add8e6","#008000","#808080","#ffd700","#ffe4e1","#00ffff","#87ceeb","#0000ff","#a9a9a9","#ffa500","#ffc0cb","#a52a2a","#008080","#000080","#c0c0c0","#ff0000","#c71585","#8b0000","#4b0082","#000000","#ffffff"]; 
lionsky.prototype.ShowDialog= function (url, argument, width, height, callBackFunctions, ParamObject, resourcesText)
{	
	var editor=this ; 
	if (!ParamObject)
	{
		ParamObject=new Object(); 
	}
	ParamObject.Editor=this ; 
	if (this.Document.selection)
	{
		ParamObject.createRange=this.Document.selection.createRange(); 
	}
	ParamObject.Functions=callBackFunctions; 
	if (document.selection&&document.selection.type.toLowerCase() == "control")
	{
		document.selection.empty(); 
		document.body.focus(); 
		window.focus(); 
	}
	if (!argument)
	{
		argument=new Object(); 
	}
	argument.Editor = this; 
	argument.ColorsArray=this.ColorsArray; 
	var temp = new WebHtmlEditorWindowInfo_Model(); 
	temp.Url=url; 
	temp.Width=width; 
	temp.Height=height; 
	temp.Caption=(resourcesText?resourcesText: ""); 
	temp.IsVisible= true; 
	temp.Argument=argument; 
	temp.CallbackFunc= function (returnValue, paramObject)
	{
		if (paramObject.createRange&&paramObject.createRange.select)
		{
			paramObject.createRange.select(); 
		}
		if (paramObject.Functions)
		{
			paramObject.Functions(returnValue,paramObject); 
		}
		paramObject.Editor.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
	} ; 
	temp.OnLoadFunc=null; 
	temp.Param=ParamObject; 
	temp.Resizable= true; 
	temp.Movable= true; 
	temp.UseClassicDialogs=editor.UseClassicDialogs; 
	temp.BlankIFrameLocation=editor.BlankIFrameLocation; 	
	var wnd; 
	wnd=GetWebHtmlEditorWindowManager().ShowModalWindow(temp); 
	return wnd; 
} ;


lionsky.prototype.RemoveAllDocumentEvent= function ()
{
	var srcElement=this.IsIE?this.Document.body: this.Document; 
	var eventArray=this.EventArray; 
	for (var item in eventArray)
	{
		this.detachEvent(srcElement,item,eventArray[item]); 
	} 
	this.EventArray=null; 
} ; 
lionsky.prototype.AttachEventHandler= function (eventName, events)
{
	if (WHESYSTEMEVENTNAME[eventName])
	{	 
		var obj=this.SystemEventArray[eventName]; 
		if (null == obj)
		{ 
			this.SystemEventArray[eventName]=[]; 
			obj=this.SystemEventArray[eventName]; 
		} 
		if (null != obj)
		{
			if (null != events&&"function" == typeof(events))
			{	 
				obj.add(events); 
			}
		}
	}
	else 
	{
		var obj=WHEBODYEVENTNAME[eventName]?WHEBODYEVENTNAME[eventName]:eventName; 		
		var srcElement=this.IsIE?this.Document.body: this.Document; 		
		this.EventArray[obj]=events; 
		this.attachEvent(srcElement,obj,events); 
	}
} ;
lionsky.prototype.DetachEventHandler= function (eventName,events)
{
	if (WHESYSTEMEVENTNAME[eventName])
	{
		var obj=this.SystemEventArray[eventName]; 
		RemoveArrayItem(obj,events); 
	}
	else 
	{
		var obj=WHEBODYEVENTNAME[eventName]?WHEBODYEVENTNAME[eventName]:eventName; 
		var srcElement=this.IsIE?this.Document.body: this.Document; 
		this.detachEvent(srcElement,obj,events); 
	}
} ; 
lionsky.prototype.ExecSystemEvent= function (eventName, obj)
{
	var event=this.SystemEventArray[eventName]; 
	
	if (null != event)
	{
		for (var i=0; i<event.length; i++)
		{
			event[i](this,obj); 
		}
	}
} ;
lionsky.prototype.OnDrag= function (e)
{
	var title=this.LocalResources[WHEEVENT_DROP]||"Drop external content"; 
	this.OnDragEvent=new WebHtmlEditorEvent(title,this.ContentWindow); 
} ;
lionsky.prototype.OnDragEnd= function (e)
{
	if (!this.OnDragEvent){return; }
	this.SaveHistory(this.OnDragEvent); 
	this.OnDragEvent=null; 
	this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
} ;	 
lionsky.prototype.CreateEditAreaEvent= function ()
{  	   	
	this.AttachEventHandler(WHEEVENT_SEL_CHANGED, function (editor,e){editor.SetToolState(editor.ToolBarButtonArray); } );
	var editor=this ;  
	if (document.all)
	{
		//this.attachEvent(editor.WheContentTextarea,"onkeydown", function (e){window.setTimeout("getElementById('"+ editor.WheContentHiddenTextArea.id +"').value=getElementById('"+ editor.WheContentTextarea.id +"').value",100);if ( true == e.ctrlKey&&e.keyCode == 0106){e.cancelBubble= true; e.keyCode=0173;e.returnValue= false; editor.ExecuteCommand(WHECOMMAND_SHOW_FIND_DIALOG); return false;}} ); 
		this.attachEvent(editor.WheContentTextarea,"onkeydown", function (e){if ( true == e.ctrlKey&&e.keyCode == 0106){e.cancelBubble= true; e.keyCode=0173;e.returnValue= false; editor.ExecuteCommand(WHECOMMAND_SHOW_FIND_DIALOG); return false;}} ); //modified by tph,2007-09-07
		this.attachEvent(editor.WheContentTextarea,"onblur", function (e){editor.OnBlur(e);}); //added by tph,2007-09-07
	} 
	
	this.AttachEventHandler("onmouseup", function (e){editor.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null);} );
	
	this.AttachEventHandler("oncontextmenu", function (e){editor.ExecSystemEvent(WHEEVENT_CONTEXTMENU,e);if (editor.IsIE&& true == e.cancelBubble)return false; }); 
	
	this.AttachEventHandler("ondrop", function (e){editor.OnDrag(e);}); 
	this.AttachEventHandler("dragdrop", function (e){editor.OnDrag(e);}); 
	this.attachEvent(document.body,"ondragend", function (e){editor.OnDragEnd(e);}); 
	if (!document.all)
	{
		editor.AttachEventHandler("onkeypress", function (e){if (null != editor&&editor.OnKeyPress(e)){e.preventDefault();return false;}}); 
	} 
	
	this.AttachEventHandler("onblur", function (e){editor.OnBlur(e);});	
	this.AttachEventHandler(WHEEVENT_KEYDOWN, function (e){editor.OnKeyDown(e); } ); 
	this.AttachEventHandler(WHEEVENT_KEYUP, function (e){editor.OnKeyUp(e); } ); 
	this.AttachEventHandler(WHEEVENT_PASTE, function (e){editor.OnPasteEvent(e); } ); 
	this.AttachEventHandler(WHEEVENT_RESIZE_START, function (e){editor.OnResize_Start(e); } ); 
	this.AttachEventHandler(WHEEVENT_RESIZE_END, function (e){editor.OnResize_End(e); } ); 
	this.AttachEventHandler(WHEEVENT_BEFORE_EDIT_FOCUS, function (e){editor.OnBefore_Edit_Focus(e); } ); 
	this.AttachEventHandler(WHEEVENT_DRAG_START, function (e){editor.OnDragStart(e); } ); 
	this.AttachEventHandler(WHEEVENT_DRAG_END, function (e){editor.OnDrag_End(e); } ); 
} ;
//modified by tph,2007-09-07
lionsky.prototype.OnBlur= function (e)
{
    var content = "";
    if(this.CurrMode == CODE_MODE) content = this.WheContentTextarea["value"];
    else content=this.GetHtml();

	if (content != null){content=this.FiltersManager.GetHtmlContent(content);if(content=="<br>\r\n"){content="";} this.WheContentHiddenTextArea["value"]=content; }	
}
lionsky.prototype.GetSelection= function ()
{
	return new SelectionsManager(this.ContentWindow); 
} ;
lionsky.prototype.OnDrag_End= function (e)
{
	if (this.OnMoveEventFunctions)
	{
		if (this.OnDrag_MovieObj)
		{
			var range=this.ContentWindow.document.selection.createRange(); 
			if (range.length)
			{
				var createRange=this.ContentWindow.document.body.createTextRange(); 
				createRange.moveToElementText(range.item(0)); 
				range=createRange; 
			}
			try 
			{
				if (range.compareEndPoints&&0 != range.compareEndPoints("StartToStart",this.OnDrag_MovieObj)&&0 != range.compareEndPoints("EndToEnd",this.OnDrag_MovieObj))
				{ 
					this.OnDrag_MovieObj.execCommand("Delete", false ,null); 
				}
			}
			catch (e){ ; }
		} 
		this.SaveHistory(this.OnMoveEventFunctions); 
		this.OnMoveEventFunctions=null; 
		this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
	}
} ;
lionsky.prototype.OnDragStart= function (e)
{ 
	this.OnMoveEventFunctions=new WebHtmlEditorEvent(this.LocalResources[WHEEVENT_MOVE],this.Body); 
	this.OnDrag_MovieObj=null; 
	if (!e.ctrlKey&&!e.ctrlLeft)
	{ 
		this.OnDrag_MovieObj=this.ContentWindow.document.selection.createRange(); 
		if (this.OnDrag_MovieObj.length)
		{
			var createRange=this.ContentWindow.document.body.createTextRange(); 
			var elem=this.OnDrag_MovieObj.item(0); 
			if ("IMG" == elem.tagName&&"A" == elem.parentNode.tagName)
			{
				elem=elem.parentNode; 
			}
			createRange.moveToElementText(elem); 
			this.OnDrag_MovieObj=createRange; 
		}
	}
} ; 
lionsky.prototype.OnBefore_Edit_Focus= function (e)
{
	if (e&&e.srcElement&&"BODY" != e.srcElement.tagName)
	{
		if (null != (this.SelectionElement=this.GetSelection().GetParentElement()))
		{ 
			this.SelectionElementValue=this.SelectionElement["value"]; 
		} 
		this.OnFocusSelectionIsElement=(null != this.SelectionElement&&null != this.SelectionElementValue); 
	}
	else if (this.OnFocusSelectionIsElement)
	{ 
		this.OnFocusSelectionIsElement= false; 
		try 
		{
			var src=this.SelectionElement.cloneNode(); 
			this.SelectionElement["value"]=this.SelectionElementValue; 
			this.SelectionElement=null; 
		}
		catch (ex){}
	}
} ; 
lionsky.prototype.OnResize_Start= function (e)
{ 
	var elem=this.GetSelection().GetParentElement(); 
	if (elem == e.srcElement)
	{ 
		this.OnResizeElem=new WebHtmlEditorEvent(this.LocalResources[WHECOMMAND_RESIZECOMMAND],this.ContentWindow); 
	}
} ;
lionsky.prototype.GetToolByName= function (name)
{
	var toolbarButtonArray=this.ToolBarButtonArray; 
	var length=toolbarButtonArray.length; 
	for (var i=0; i<length; i++)
	{
		if (name == toolbarButtonArray[i].Name)return toolbarButtonArray[i]; 
	}
	return null; 
} ; 
lionsky.prototype.SetBodyShowBorder = function ()
{
	if (!this.ShowBorder)
	{ 
		this.SetBodyCssClass(this.ContentAreaCssClass);
		this.ShowBorder= true; 
	}
	else 
	{ 
		this.SetBodyCssClass("WheContentBordered"); 
		this.ShowBorder= false; 
	}
	var oTool=this.GetToolByName(WHECOMMAND_SHOW_BORDERS); 
	if (oTool&&oTool.SetState){oTool.SetState(!this.ShowBorder?WHECOMMAND_STATE_ON:WHECOMMAND_STATE_OFF);}
} ;
lionsky.prototype.SetBodyCssClass = function (className)
{ 
	this.Body.className = className;
	this.CurrentContentAreaCssClass = className; 
} ;
lionsky.prototype.EventTableColumn= function (arg)
{
	var title="Insert column"; 
	if (arg == "left"){title=this.LocalResources[WHECOMMAND_INSERT_COLUMN_LEFT]; }
	else if (arg == "right"){title=this.LocalResources[WHECOMMAND_INSERT_COLUMN_RIGHT]; }
	this.SaveHistory(new WebHtmlEditorEventTableColumn(title,this.ContentWindow,arg)); 
} ;
lionsky.prototype.DeleteRow= function ()
{ 
	this.SaveHistory(new WebHtmlEditorEventTableDeleteRow(this.LocalResources[WHECOMMAND_DELETE_ROW],this.ContentWindow));
} ; 
lionsky.prototype.DeleteColumn= function ()
{ 
	this.SaveHistory(new WebHtmlEditorEventTableDeleteColumn(this.LocalResources[WHECOMMAND_DELETE_COLUMN],this.ContentWindow)); 
} ; 
lionsky.prototype.DeleteCell= function ()
{ 
	this.SaveHistory(new WebHtmlEditorEventTableDeleteCell(this.LocalResources[WHECOMMAND_DELETE_CELL],this.ContentWindow));
} ; 
lionsky.prototype.MergeColumns= function ()
{ 
	this.SaveHistory(new WebHtmlEditorEventTableMergeColumns(this.LocalResources[WHECOMMAND_MERGE_COLUMNS],this.ContentWindow)); 
} ; 
lionsky.prototype.MergeRows= function ()
{ 
	this.SaveHistory(new WebHtmlEditorEventTableMergeRows(this.LocalResources[WHECOMMAND_MERGE_ROWS],this.ContentWindow)); 
} ; 
lionsky.prototype.SplitCell= function ()
{ 
	this.SaveHistory(new WebHtmlEditorEventTableSplitCell(this.LocalResources[WHECOMMAND_SPLIT_CELL],this.ContentWindow)); 
} ;
lionsky.prototype.OnResize_End= function (e)
{
	if (this.OnResizeElem)
	{ 
		this.SaveHistory(this.OnResizeElem); 
	}
} ;
lionsky.prototype.Undo= function (undoStep){ this.History.Undo(undoStep); } ; 
lionsky.prototype.Redo= function (redoStep){ this.History.Redo(redoStep); } 
lionsky.prototype.CreateRestorePoint= function ()
{
	return GetDocumentChange(this.ContentWindow); 
} ;
lionsky.prototype.OnPasteEvent= function (e)
{
	if (this.IsIE)
	{
		var createRestorePoint=this.CreateRestorePoint(); 
		var clipboardContent=this.GetClipboardAsHtml(); 
		var clipboardFormatHtml=""; 
		if (this.StripFormattingOnPaste == StripFormattingOptions.None)
		{
			if ((clipboardContent.match(/style="[^"]*?mso[^"]*?"/ig)||clipboardContent.match(/class="?[^"]*?mso[^"]*?"?/ig))&&confirm(this.LocalResources["AskWordCleaning"]))
			{
				clipboardFormatHtml=HtmlClearFormat(clipboardContent,"WORD_ALL"); 
			}
			else 
			{}
		}
		else if (this.StripFormattingOnPaste == StripFormattingOptions.All)
		{
			clipboardFormatHtml=HtmlClearFormat(clipboardContent,"ALL"); 
		}
		else 
		{
			clipboardFormatHtml=clipboardContent; 
			if ((this.StripFormattingOnPaste == StripFormattingOptions.MSWordRemoveAll)||(this.StripFormattingOnPaste == StripFormattingOptions.MSWordNoFonts)||(this.StripFormattingOnPaste == StripFormattingOptions.MSWord))
			{
				if (this.StripFormattingOnPaste == StripFormattingOptions.MSWordRemoveAll)
				{
					clipboardFormatHtml=HtmlClearFormat(clipboardFormatHtml,"WORD_ALL"); 
				}
				else if (this.StripFormattingOnPaste == StripFormattingOptions.MSWordNoFonts)
				{
					clipboardFormatHtml=HtmlClearFormat(clipboardFormatHtml,"WORD_NO_FONTS"); 
				}
				else 
				{
					clipboardFormatHtml=HtmlClearFormat(clipboardFormatHtml,"WORD"); 
				}
			}
			if (this.StripFormattingOnPaste == StripFormattingOptions.Css)
			{
				clipboardFormatHtml=HtmlClearFormat(clipboardFormatHtml,"CSS"); 
			}
			if (this.StripFormattingOnPaste == StripFormattingOptions.Font)
			{
				clipboardFormatHtml=HtmlClearFormat(clipboardFormatHtml,"FONT"); 
			}
			if (this.StripFormattingOnPaste == StripFormattingOptions.Span)
			{
				clipboardFormatHtml=HtmlClearFormat(clipboardFormatHtml,"SPAN"); 
			}
		}
		if (clipboardFormatHtml)
		{
			createRestorePoint.Select(); 
			var editor=this ; 
			var fun= function ()
			{
				editor.PasteHtml(clipboardFormatHtml); 
			};
			this.ContentWindow.setTimeout(fun,5); 
		}
		else 
		{
			createRestorePoint.Select(); return true; 
		}
		e.returnValue= false; 
		if (e.stopPropagation){e.stopPropagation(); }
		return false; 
	}
} ; 
lionsky.prototype.GetMap= function (editor,useMapType)
{
	var mapArr=editor.Document.getElementsByTagName("map"); 
	if (editor.Document.getElementById(useMapType)!=null)
	{
		return editor.Document.getElementById(useMapType);
	}
	for (var i=0; i<mapArr.length; i++)
	{
		if (mapArr[i].getAttribute("name")==useMapType)
		{
			return mapArr[i]; 
		}
	}
	return null; 
}
lionsky.prototype.OnKeyUp= function (e)
{		
	if (this.CurrInputEvent)
	{ 
		this.CurrInputEvent.Update(); 
		return; 
	}
	if (this.CurrDeleteEvent)
	{ 
		this.SaveHistory(this.CurrDeleteEvent); 
		this.CurrDeleteEvent=null; 
		//如果是删除命令，则清空多余的<p>&nbsp;</p>内容
		var html = this.GetHtml().toLowerCase();
		if(html=="<p>&nbsp;</p>".toLowerCase() || html=="<br>".toLowerCase() || html=="<br />".toLowerCase())
		{
		    this.WheContentHiddenTextArea.value="";
		    this.SetCurrentModeEditAreaValue();
	        this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null);
		};
	}
	if (this.CurrKeyCodeIsDelete)
	{
		return false; 
	} 
	this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null);
	
} ; 
lionsky.prototype.OnKeyDown= function (e)
{
	switch (e.keyCode)
	{
		case Key_NoPrint_08:
		case Key_Print_056: 
			this.CurrKeyCodeIsDelete= true; 
			if (!this.CurrDeleteEvent)
			{ 
				this.ExecuteCommand(Key_NoPrint_08 == e.keyCode?WHECOMMAND_BACK:WHECOMMAND_DELETE); 
			}
			return; 
	}
	var srcElement = GetSrcElement(e); 
	if (this.KeyObject&&srcElement&&"INPUT" != srcElement.tagName)
	{
		var keyStateObject=this.KeyObject.GetKeyStateObject(e.keyCode,e.ctrlKey,(null != e.ctrlLeft?e.ctrlLeft:e.ctrlKey),e.shiftKey,(null != e.shiftLeft?e.shiftLeft:e.shiftKey),e.altKey,(null != e.altLeft?e.altLeft:e.altKey)); 
		
		this.CurrKeyCodeIsDelete= false; 
		if (!document.all&&null != keyStateObject&&keyStateObject.Name == WHECOMMAND_COPY)
		{ 
			this.CurrKeyCodeIsDelete= false; 
			return; 
		} 
		this.CurrKeyCodeIsDelete=(null != keyStateObject); 
		if (this.CurrKeyCodeIsDelete&&null != keyStateObject)
		{ 
			this.ExecuteCommand(keyStateObject.Name); 
		}  
		e.returnValue=!this.CurrKeyCodeIsDelete; 
		if (this.CurrKeyCodeIsDelete)
		{
			if (document.all)
			{
				e.keyCode=0173; 
			}
			e.cancelBubble= true; 
			if (e.stopPropagation)
			{
				e.stopPropagation(); 
			}
		}
		if (!this.CurrKeyCodeIsDelete)
		{
			if (!this.CurrInputEvent&&(Key_Print_040 == e.keyCode||Key_NoPrint_015 == e.keyCode||!CheckInputKeyCode(e.keyCode)))
			{ 
				this.CurrInputEvent = new InputEvent(this.LocalResources["Typing"],this.ContentWindow);	
				this.SaveHistory(this.CurrInputEvent); 
				this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
			}
		}
	}
} ;

lionsky.prototype.SaveHistory= function (commandObj,focuse)
{
	if (null != this.History)
	{
		if ( false != focuse){this.SetFocus(); }
		this.History.Execute(commandObj); 
	}
} ;



/*
WebHtmlEditorSelectControl
*/
function WebHtmlEditorSelectControl(windows,Elem)
{ 
	this.Window=windows; 
	this.ElemDepthStr=this.RecursionGetElemDepthStr(this.Window.document.body,Elem); 
}
WebHtmlEditorSelectControl.prototype.Select= function ()
{
	var Elem=this.GetElemByDepthStr(this.Window.document.body,this.ElemDepthStr); 
	try 
	{
		CreateElemContainer(this.Window,Elem); 
	}catch (ex){}
	return Elem; 
} ; 
WebHtmlEditorSelectControl.prototype.RecursionGetElemDepthStr= function (parent,Elem)
{
	var tempElem;
	var tempElem1; 
	for (var i=0; i<parent.childNodes.length; i++)
	{
		tempElem=parent.childNodes[i]; 
		tempElem1=this.RecursionGetElemDepthStr(tempElem,Elem);
		if ("" != tempElem1)
		{
			return ""+i+","+tempElem1; 
		}
		if (tempElem == Elem)
		{
		    return ""+i; 
		}
	}
	return ""; 
} ; 
WebHtmlEditorSelectControl.prototype.GetElemByDepthStr= function (parent,elemDepthStr)
{
	var array=elemDepthStr.split(","); 
	for (var i=0; i<array.length; i++)
	{
		parent=parent.childNodes[array[i]]; 
	}
	return parent; 
} ;













lionsky.prototype.ExecuteInsertObjectCommand= function (elem,title)
{ 
	this.SetFocus(); 
	if (!title)title="InsertObject: Did you forget the title?!"; 
	return this.SaveHistory(new WebHtmlEditorObjectEventHandle(title,this.ContentWindow,OuterHTML(elem))); 
} ; 




WHEEditorCommandEventList=new Array();
WHEEditorCommandEventList[WHECOMMAND_INSERT_ORDERED_LIST]=new WebHtmlEditorEventButton(null,WHECOMMAND_INSERT_ORDERED_LIST); 
WHEEditorCommandEventList[WHECOMMAND_INSERT_UNORDERED_LIST]=new WebHtmlEditorEventButton(null,WHECOMMAND_INSERT_UNORDERED_LIST); 
WHEEditorCommandEventList[WHECOMMAND_UNLINK]=new WebHtmlEditorEventButton(null,WHECOMMAND_UNLINK);
WHEEditorCommandEventList[WHECOMMAND_BOLD]=new WebHtmlEditorEventButton(null,WHECOMMAND_BOLD);
WHEEditorCommandEventList[WHECOMMAND_ITALIC]=new WebHtmlEditorEventButton(null,WHECOMMAND_ITALIC);
WHEEditorCommandEventList[WHECOMMAND_UNDERLINE]=new WebHtmlEditorEventButton(null,WHECOMMAND_UNDERLINE);
WHEEditorCommandEventList[WHECOMMAND_JUSTIFY_LEFT]=new WebHtmlEditorEventButton(null,WHECOMMAND_JUSTIFY_LEFT); 
WHEEditorCommandEventList[WHECOMMAND_JUSTIFY_RIGHT]=new WebHtmlEditorEventButton(null,WHECOMMAND_JUSTIFY_RIGHT); 
WHEEditorCommandEventList[WHECOMMAND_JUSTIFY_CENTER]=new WebHtmlEditorEventButton(null,WHECOMMAND_JUSTIFY_CENTER); 
WHEEditorCommandEventList[WHECOMMAND_JUSTIFY_FULL]=new WebHtmlEditorEventButton(null,WHECOMMAND_JUSTIFY_FULL); 
WHEEditorCommandEventList[WHECOMMAND_JUSTIFY_NONE]=new WebHtmlEditorEventButton(null,WHECOMMAND_JUSTIFY_NONE); 
WHEEditorCommandEventList[WHECOMMAND_SUBSCRIPT]=new WebHtmlEditorEventButton(null,WHECOMMAND_SUBSCRIPT); 
WHEEditorCommandEventList[WHECOMMAND_SUPERSCRIPT]=new WebHtmlEditorEventButton(null,WHECOMMAND_SUPERSCRIPT);
WHEEditorCommandEventList[WHECOMMAND_STRIKETHROUGH]=new WebHtmlEditorEventButton(null,WHECOMMAND_STRIKETHROUGH); 
WHEEditorCommandEventList[WHECOMMAND_INDENT]=new WebHtmlEditorEventButton(null,WHECOMMAND_INDENT); 
WHEEditorCommandEventList[WHECOMMAND_OUTDENT]=new WebHtmlEditorEventButton(null,WHECOMMAND_OUTDENT); 
WHEEditorCommandEventList[WHECOMMAND_CUT]=new WebHtmlEditorEventButton(null,WHECOMMAND_CUT);
WHEEditorCommandEventList[WHECOMMAND_PASTE]=new WebHtmlEditorEventButton(null,WHECOMMAND_PASTE);
WHEEditorCommandEventList[WHECOMMAND_FONTNAME]=new WebHtmlEditorEventButton(null,WHECOMMAND_FONTNAME); 
WHEEditorCommandEventList[WHECOMMAND_FONTSIZE]=new WebHtmlEditorEventButton(null,WHECOMMAND_FONTSIZE);
WHEEditorCommandEventList[WHECOMMAND_INSERT_ROW_ABOVE]=new WebHtmlEditorEventTableRow(null,null,"above"); 
WHEEditorCommandEventList[WHECOMMAND_INSERT_ROW_BELOW]=new WebHtmlEditorEventTableRow(null,null,"below"); 
WHEEditorCommandEventList[WHECOMMAND_INSERT_COLUMN_LEFT]=new WebHtmlEditorEventTableColumn(null,null,"left"); 
WHEEditorCommandEventList[WHECOMMAND_INSERT_COLUMN_RIGHT]=new WebHtmlEditorEventTableColumn(null,null,"right");
WHEEditorCommandEventList[WHECOMMAND_DELETE_ROW]=new WebHtmlEditorEventTableDeleteRow(null,null); 
WHEEditorCommandEventList[WHECOMMAND_DELETE_COLUMN]=new WebHtmlEditorEventTableDeleteColumn(null,null);    
WHEEditorCommandEventList[WHECOMMAND_DELETE_CELL]=new WebHtmlEditorEventTableDeleteCell(null,null); 
WHEEditorCommandEventList[WHECOMMAND_MERGE_COLUMNS]=new WebHtmlEditorEventTableMergeColumns(null,null); 
WHEEditorCommandEventList[WHECOMMAND_MERGE_ROWS]=new WebHtmlEditorEventTableMergeRows(null,null); 
WHEEditorCommandEventList[WHECOMMAND_SPLIT_CELL]=new WebHtmlEditorEventTableSplitCell(null,null); 
WHEEditorCommandEventList[WHECOMMAND_FORMAT_BLOCK]=new WebHtmlEditorEventFormatBlock(null,null,null);
WHEEditorCommandEventList[WHECOMMAND_APPLY_CLASS]=new WebHtmlEditorEventCss();
WHEEditorCommandEventList[WHECOMMAND_FORECOLOR]=new WebHtmlEditorEventButton(null,WHECOMMAND_FORECOLOR); 
WHEEditorCommandEventList[WHECOMMAND_BACKCOLOR]=new WebHtmlEditorEventButton(null,WHECOMMAND_BACKCOLOR); 


if ("undefined" == typeof(WHEEditorToolInitializer))
{
	var WHEEditorToolInitializer=[]; 
} 
var WHEEditorCommandList=[]; 


WHEEditorCommandList[WHECOMMAND_PRINT]= function I3d(command, editor, oTool)
{
	if (this.IsIE)
	{
		editor.ExecuteButtonCommand(command, false ,null); 
	}
	else if (editor.ContentWindow.print)
	{
		editor.ContentWindow.print(); 
	}
	return false;
} ;
WHEEditorCommandList[WHECOMMAND_REPLACELASTCOMMAND]= function (command, editor, oTool)
{
	editor.SetFocus(); 
	editor.History.RepeatLastHistory(); 
} ;

WHEEditorCommandList[WHECOMMAND_ENTER]= function (command, editor, oTool)
{
	if (!document.all)
	{
		editor.CurrKeyCodeIsDelete= false; 
		return false; 
	}
	else 
	{
		try 
		{
			var documentSelection=editor.GetSelection(); 
			if (documentSelection)
			{
				var elem=documentSelection.GetParentElement(); 
				if ("LI" == elem.tagName||GetSrcElementByTagName(elem,"LI") != null)
				{
					editor.CurrKeyCodeIsDelete= false; 
					return false; 
				}
			}
			var commandEvent=new WebHtmlEditorEvent(editor.LocalResources[command],editor.ContentWindow); 
			var range=editor.Document.selection.createRange(); 
			if (range.pasteHTML)
			{
				range.pasteHTML("<br />"); 
				range.select(); 
				range.moveEnd("character",1); 
				range.moveStart("character",1); 
				range.collapse( false); 
			}
			else 
			{
				if (range(0))
				{
					range.execCommand("Delete"); 
					if(editor.GetHtml().toLowerCase()=="<p>&nbsp;</p>".toLowerCase())
					{
					    editor.WheContentHiddenTextArea.value="";
					    editor.SetCurrentModeEditAreaValue();
					};
				}
			}
			editor.SaveHistory(commandEvent); 
		}
		catch (ex)
		{
			alert(ex.message); 
		}
	}
} ;
WHEEditorCommandList[WHECOMMAND_SHIFTENTER]= function (command, editor, oTool)
{
	if (!document.all)
	{
		editor.CurrKeyCodeIsDelete= false; 
		return false; 
	}
	var documentSelection=editor.GetSelection(); 
	if (documentSelection)
	{
		elem=documentSelection.GetParentElement(); 
		if ("LI" == elem.tagName||GetSrcElementByTagName(elem,"LI") != null)
		{
			var commandEvent=new WebHtmlEditorEvent(editor.LocalResources[command],editor.ContentWindow); 
			var range=editor.Document.selection.createRange(); 
			range.pasteHTML("<br />"); 
			range.select(); 
			range.moveEnd("character",1); 
			range.moveStart("character",1); 
			range.collapse( false); 
			editor.SaveHistory(commandEvent); 
			return false; 
		}
	}
	editor.CurrKeyCodeIsDelete= false; 
	return false; 
};
WHEEditorCommandList[WHECOMMAND_INSERT_EMOT]= function (command, editor, oTool)
{
    var value = oTool.GetSelectedValue();
    if(!value || value == "&nbsp;"){return;}
    elem=editor.CreateHtmlElement("IMG"); 
	if (elem)
	{
	    elem.src = value;
	    editor.ExecuteInsertObjectCommand(elem,editor.LocalResources[command]); 
	}	
}
WHEEditorCommandList[WHECOMMAND_INSERT_FORM_ELEMENT]= function (command, editor, oTool)
{
	var value=oTool.GetSelectedValue(); 
	var elem=null; 
	switch (value)
	{
		case "FORM":
			elem=editor.CreateHtmlElement("FORM","150px","150px"); 
			break; 
		case "TEXTAREA":
			elem=editor.CreateHtmlElement("TEXTAREA"); 
			break; 
		case "SELECT":
			elem=editor.CreateHtmlElement("SELECT","100px","22px"); 
			break; 
		case "CHECKBOX":
		case "RADIO":
			elem=editor.CreateHtmlElement("INPUT"); 
			elem.type=value; 
			break; 
		case "DIV":	
			elem=editor.CreateHtmlElement("DIV", "104px", "104px", null, null, null, "Type text here");	
			break; 
		case "BUTTON":
		case "RESET":
		case "SUBMIT":
			elem=editor.CreateHtmlElement("INPUT","50px","22px"); 
			elem.type=value; 
			break; 
		case "HIDDEN":
		case "PASSWORD":
		case "TEXT":
			elem=editor.CreateHtmlElement("INPUT","100px","22px"); 
			elem.type=value; 
			break; 
	}
	if (elem){editor.ExecuteInsertObjectCommand(elem,editor.LocalResources[command]); }
} ; 
WHEEditorCommandList[WHECOMMAND_INSERT_COLUMN_LEFT]=WHEEditorCommandList[WHECOMMAND_INSERT_COLUMN_RIGHT]= function (command, editor, oTool)
{
	editor.EventTableColumn(command == WHECOMMAND_INSERT_COLUMN_LEFT?"left": "right"); 
} ;
WHEEditorCommandList[WHECOMMAND_INSERT_DATE]=WHEEditorCommandList[WHECOMMAND_INSERT_TIME]=WHEEditorCommandList[WHECOMMAND_INSERT_EXECL] = WHEEditorCommandList[WHECOMMAND_INSERT_QUOTE] = WHEEditorCommandList[WHECOMMAND_INSERT_FIELDSET] = function (command, editor, oTool)
{
	var value=""; 
	switch (command)
	{
		case WHECOMMAND_INSERT_DATE:
			var date=new Date(); 
			value="&nbsp;"+date.toLocaleDateString(); 
			break; 
		case WHECOMMAND_INSERT_TIME:
			var date=new Date(); 
			value="&nbsp;"+date.toLocaleTimeString(); 
			break; 
		case WHECOMMAND_INSERT_FIELDSET:
			selectionHtml = editor.GetSelection().GetHTML();
			selectionHtml = (selectionHtml && selectionHtml!=""?selectionHtml:editor.LocalResources["InsertFieldsetContent"])
			value = "<fieldset><legend>"+ editor.LocalResources["InsertFieldsetTitle"] +"</legend>"+ selectionHtml +"</fieldset>";
			break;
		case WHECOMMAND_INSERT_EXECL:
			if(editor.IsIE)
			{
				value = "<object classid='clsid:0002E510-0000-0000-C000-000000000046' id='Spreadsheet1' codebase='file:\\Bob\software\office2000\msowc.cab' width='100%' height='250'><param name='HTMLURL' value><param name='HTMLData' value='&lt;html xmlns:x=&quot;urn:schemas-microsoft-com:office:excel&quot;xmlns=&quot;http://www.w3.org/TR/REC-html40&quot;&gt;&lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;!--tr{mso-height-source:auto;}td{black-space:nowrap;}.wc4590F88{black-space:nowrap;font-family:宋体;arial,sans-serif;mso-number-format:General;font-size:auto;font-weight:auto;font-style:auto;text-decoration:auto;mso-background-source:auto;mso-pattern:auto;mso-color-source:auto;text-align:general;vertical-align:bottom;border-top:none;border-left:none;border-right:none;border-bottom:none;mso-protection:locked;}--&gt;&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt;&lt;x:ExcelWorksheet&gt;&lt;x:OWCVersion&gt;9.0.0.2710&lt;/x:OWCVersion&gt;&lt;x:Label Style='border-top:solid .5pt silver;border-left:solid .5pt silver;border-right:solid .5pt silver;border-bottom:solid .5pt silver'&gt;&lt;x:Caption&gt;Microsoft Office Spreadsheet&lt;/x:Caption&gt; &lt;/x:Label&gt;&lt;x:Name&gt;Sheet1&lt;/x:Name&gt;&lt;x:WorksheetOptions&gt;&lt;x:Selected/&gt;&lt;x:Height&gt;7620&lt;/x:Height&gt;&lt;x:Width&gt;15240&lt;/x:Width&gt;&lt;x:TopRowVisible&gt;0&lt;/x:TopRowVisible&gt;&lt;x:LeftColumnVisible&gt;0&lt;/x:LeftColumnVisible&gt; &lt;x:ProtectContents&gt;False&lt;/x:ProtectContents&gt; &lt;x:DefaultRowHeight&gt;210&lt;/x:DefaultRowHeight&gt; &lt;x:StandardWidth&gt;2389&lt;/x:StandardWidth&gt; &lt;/x:WorksheetOptions&gt; &lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt; &lt;x:MaxHeight&gt;80%&lt;/x:MaxHeight&gt;&lt;x:MaxWidth&gt;80%&lt;/x:MaxWidth&gt;&lt;/x:ExcelWorkbook&gt;&lt;/xml&gt;&lt;![endif]--&gt;&lt;table class=wc4590F88 x:str&gt;&lt;col width=&quot;56&quot;&gt;&lt;tr height=&quot;14&quot;&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;'> <param name='DataType' value='HTMLDATA'> <param name='AutoFit' value='0'><param name='DisplayColHeaders' value='-1'><param name='DisplayGridlines' value='-1'><param name='DisplayHorizontalScrollBar' value='-1'><param name='DisplayRowHeaders' value='-1'><param name='DisplayTitleBar' value='-1'><param name='DisplayToolbar' value='-1'><param name='DisplayVerticalScrollBar' value='-1'> <param name='EnableAutoCalculate' value='-1'> <param name='EnableEvents' value='-1'><param name='MoveAfterReturn' value='-1'><param name='MoveAfterReturnDirection' value='0'><param name='RightToLeft' value='0'><param name='ViewableRange' value='1:65536'></object>";
			}
			else
			{
				value = "";
				alert(editor.LocalResources["ToolNotSupportedByNetscape"]);
			}
			break;
		case WHECOMMAND_INSERT_QUOTE:
			value = '<table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellSpacing=0 cellPadding=6 width="95%" align=center border=0><tbody><tr><td style="WORD-WRAP: break-word" bgColor=#f3f3f3><span style="FONT-WEIGHT: bold; COLOR: #990000">'+ editor.LocalResources["InsertQuoteTitle"] +'</span><br />&nbsp;&nbsp;&nbsp;&nbsp;'+ editor.GetSelection().GetHTML() +'</td></tr></tbody></table>';
	}
	if(value!=""){editor.PasteHtml(value,editor.LocalResources[oTool.Name]); }
} ;
WHEEditorCommandList[WHECOMMAND_INSERTHORIZONTALRULE]=WHEEditorCommandList[WHECOMMAND_INSERT_PARAGRAPH] = function (command, editor, oTool)
{
	if (WHECOMMAND_INSERTHORIZONTALRULE == command)
	{
		editor.ExecuteInsertObjectCommand(editor.CreateHtmlElement("HR"),editor.LocalResources[oTool.Name]); 
	}
	else 
	{
		editor.ExecuteButtonCommand("InsertParagraph", false);
	}
} ; 
WHEEditorCommandList[WHECOMMAND_DELETE_ROW]= function (command, editor, oTool)
{
	editor.DeleteRow(); 
} ; 
WHEEditorCommandList[WHECOMMAND_DELETE_COLUMN]= function (command, editor, oTool)
{
	editor.DeleteColumn(); 
} ; 
WHEEditorCommandList[WHECOMMAND_DELETE_CELL]= function (command, editor, oTool)
{
	editor.DeleteCell(); 
} ; 
WHEEditorCommandList[WHECOMMAND_MERGE_COLUMNS]= function (command, editor, oTool)
{
	editor.MergeColumns(); 
} ; 
WHEEditorCommandList[WHECOMMAND_MERGE_ROWS]= function (command, editor, oTool)
{
	editor.MergeRows(); 
} ; 
WHEEditorCommandList[WHECOMMAND_SPLIT_CELL]= function (command, editor, oTool)
{
	editor.SplitCell(); 
} ; 
WHEEditorCommandList[WHECOMMAND_INSERT_ROW_ABOVE]=WHEEditorCommandList[WHECOMMAND_INSERT_ROW_BELOW]
= function (command, editor, oTool)
{
	editor.InsertRow(command == WHECOMMAND_INSERT_ROW_ABOVE?"above": "below"); 
} ; 

WHEEditorCommandList[WHECOMMAND_REMOTEUPLOAD]= function (command, editor, oTool)
{    
    editor.ModeButton.ShowProgress();
    editor.RemoteUpLoad.contentWindow.document.getElementById("UploadText").value = editor.GetHtml();
    editor.RemoteUpLoad.contentWindow.document.forms[0].submit();
}
WHEEditorCommandList[WHECOMMAND_TOGGLE_SCREEN_MODE]= function (command, editor, oTool)
{
	if (editor.IsMaxScreenMode)
	{
		var wrapperTable=editor.WheWrapperTable; 
		wrapperTable.style["width"]=editor.Width; 
		wrapperTable.style["height"]=editor.Height; 
		document.body.scroll="auto"; 
		document["documentElement"].style.overflow="auto"; 
		editor.IsMaxScreenMode= false; 
		if (editor.IsScreenModeOnResize)
		{
			editor.detachEvent(window,"resize",editor.IsScreenModeOnResize); 
			editor.IsScreenModeOnResize=null; 
		}
	}
	else 
	{
		document.body.scroll="no"; 
		var wrapperTable=editor.WheWrapperTable; 
		var ieAddScrollTop=0; 
		var ieAddScrollLeft=0; 
		if (editor.IsIE&&"CSS1Compat" == document.compatMode)
		{		    
			document.body.scrollTop=0; 
			wrapperTable.style["width"]=document["documentElement"].clientWidth; 
			wrapperTable.style["height"]=parseInt(document["documentElement"].clientHeight); 
			ieAddScrollTop=017; 
			ieAddScrollLeft=012;
		}
		else 
		{
			document["documentElement"].style.overflow="hidden"; 
			wrapperTable.style["width"]=window.innerWidth?parseInt(window.innerWidth)+"px":parseInt(document.body.clientWidth)+"px"; 
			wrapperTable.style["height"]=window.innerHeight?parseInt(window.innerHeight)+"px":parseInt(document.body.clientHeight)+"px"; 
		}
		var wrapperTableBounds=GetBounds(wrapperTable); 
		var left=wrapperTableBounds.left; 
		var top=wrapperTableBounds.top; 
		document.body.scrollTop=top; 
		document.body.scrollLeft=left; 
		document["documentElement"].scrollTop=top+ieAddScrollTop; 
		document["documentElement"].scrollLeft=left+ieAddScrollLeft; 
		editor.IsMaxScreenMode= true; 
		if (!editor.IsScreenModeOnResize)
		{
			editor.IsScreenModeOnResize= function ()
				{
					editor.IsMaxScreenMode= false; 
					editor.ExecuteCommand(WHECOMMAND_TOGGLE_SCREEN_MODE); 
				} ; 
			editor.attachEvent(window,"resize",editor.IsScreenModeOnResize); 
		}
	}
	editor.SetDocumentEdit( true); 
	if (!oTool)
	{
		oTool=editor.GetToolByName(command); 
	}
	if (oTool)
	{
		oTool.SetState(editor.IsMaxScreenMode?WHECOMMAND_STATE_ON:WHECOMMAND_STATE_OFF); 
	}
	return false; 
} ; 
WHEEditorCommandList[WHECOMMAND_SHOW_BORDERS]= function (command, editor, oTool){editor.SetBodyShowBorder();return false;} ;

WHEEditorCommandList[WHECOMMAND_FORWRD]= WHEEditorCommandList[WHECOMMAND_BACKWARD]= function (command, editor, oTool)
{
    var elem = editor.GetSelection().GetParentElement(); 
    if(elem && elem.style)
    {
        if (command == WHECOMMAND_FORWRD) 
		{
			elem.style.zIndex = parseInt(elem.style.zIndex) + 1;
		}
		else
		{
			elem.style.zIndex = parseInt(elem.style.zIndex) - 1;
		}
    }
}

WHEEditorCommandList[WHECOMMAND_ABSOLUTE_POSITION]= function (command, editor, oTool)
{
    var elem = editor.GetSelection().GetParentElement(); 
    if(elem && elem.style)
    {
        if (elem.style.position != 'absolute') 
		{
			elem.style.position='absolute';
		}
		else
		{
			elem.style.position='static';
		}
		elem.style.zIndex = 0;
		var rect = GetObjectBounds(elem);
		elem.style.left = rect.left;
		elem.style.top = rect.top;
    }
}
WHEEditorCommandList[WHECOMMAND_SET_TABLE_PROPERTIES]= function (command, editor, oTool)
{
	command=WHECOMMAND_TABLEWIZARD;
	var htmlTableElement=null; 
	if (!oTool.GetSelectedValue)
	{
		htmlTableElement=editor.GetSelection().GetParentElement(); 
	}
	else htmlTableElement=oTool.GetSelectedValue(); 
	if (htmlTableElement&&"TABLE" != htmlTableElement.tagName)
	{
		htmlTableElement=GetSrcElementByTagName(htmlTableElement,"TABLE"); 
	}
	if (!htmlTableElement)
	{
		alert("No table selected!"); 
		return; 
	}
	var TableRule=editor.GetRuleModelArrayByTagName("TABLE",editor.Document); 
	var TDRule=editor.GetRuleModelArrayByTagName("TD",editor.Document); 
	var Argument= new Object();
	Argument.ImageCommand = WHECOMMAND_SHOW_IMAGE_DIALOG;
	Argument.UpLoadImagesPaths = editor.UpLoadImagesPaths;
	Argument.UpLoadImagesFilter = editor.UpLoadImagesFilter;
	Argument.UpLoadImagesSize = editor.UpLoadImagesSize;
	Argument.UpLoadImagesAllowUpLoadSize = editor.UpLoadImagesAllowUpLoadSize;
	Argument.tableToModify = htmlTableElement;
	Argument.CssClasses = TableRule;
	Argument.CellCssClasses = TDRule;
	Argument.EditorObj = editor;
	editor.ShowDialog(GetDialogUrl(editor,command),Argument,0620,0454,null,null, editor.LocalResources[command]); 
} ;

WHEEditorCommandList[WHECOMMAND_ZOOM]= function (command, editor, oTool)
{
    var value=oTool.GetSelectedValue(); 
	editor.Body.runtimeStyle.zoom=value; 
	return false; 
} ; 
WHEEditorCommandList[WHECOMMAND_SHOW_FIND_DIALOG]= function (command, editor, oTool)
{
    if (editor.IsIE)
    {
        var Argument = new Object();
        Argument.area = (editor.CurrMode == EDIT_MODE?editor.Body:editor.WheContentTextarea);
        editor.ShowDialog(GetDialogUrl(editor,command),Argument,0620,0454,null,null,editor.LocalResources[command]); 
    }
    else 
    {
        alert(editor.LocalResources["ToolNotSupportedByNetscape"]); 
    } ;
}
WHEEditorCommandList[WHECOMMAND_SHOW_ABOUT_DIALOG]=WHEEditorCommandList[WHECOMMAND_HELP] = function (command, editor, oTool)
{
    var Argument = new Object();
    Argument.Editor = editor;
	editor.ShowDialog(GetDialogUrl(editor,command), Argument,0x10,0x10,null,null,editor.LocalResources[command]); 
	return false; 
} ; 
WHEEditorCommandList[WHECOMMAND_SET_HR_PROPERTIES]= function (command, editor, oTool)
{
    var elem = null;
    elem=editor.GetSelection().GetParentElement(); 
    if (elem&&"HR" != elem.tagName)
	{
		var elem=GetSrcElementByTagName(tdElem,"HR"); 
	}
	if (!elem)
	{
		alert("No hr selected!"); 
		return; 
	}
	var Argument = new Object();
	Argument.Elem = elem;
	Argument.EditorObj = editor;
	editor.ShowDialog(GetDialogUrl(editor,command),Argument,0, 0,null,null, editor.LocalResources[command]); 	
}
WHEEditorCommandList[WHECOMMAND_SET_CELL_PROPERTIES]= function (command, editor, oTool)
{
	var tdElem=null; 
	if (!oTool.GetSelectedValue)
	{
		tdElem=editor.GetSelection().GetParentElement(); 
	}
	else tdElem=oTool.GetSelectedValue(); 
	if (tdElem&&"TD" != tdElem.tagName&&"TH" != tdElem.tagName)
	{
		var tempTDElem=GetSrcElementByTagName(tdElem,"TD"); 
		if (!tempTDElem)tempTDElem=GetSrcElementByTagName(tdElem,"TH"); 
		tdElem=tempTDElem; 
	}
	if (!tdElem)
	{
		alert("No cell selected!"); 
		return; 
	}
	var TDRule=editor.GetRuleModelArrayByTagName(tdElem.tagName,editor.Document);
	var Argument = new Object();
	Argument.ImageCommand = WHECOMMAND_SHOW_IMAGE_DIALOG;
	Argument.UpLoadImagesPaths = editor.UpLoadImagesPaths;
	Argument.UpLoadImagesFilter = editor.UpLoadImagesFilter;
	Argument.UpLoadImagesSize = editor.UpLoadImagesSize;
	Argument.UpLoadImagesAllowUpLoadSize = editor.UpLoadImagesAllowUpLoadSize;
	Argument.tableToModify = tdElem;
	Argument.CssClasses = TDRule;
	Argument.EditorObj = editor;
	editor.ShowDialog(GetDialogUrl(editor,command),Argument,0620,0454,null,null, editor.LocalResources[command]); 	
} ;

WHEEditorCommandList[WHECOMMAND_DELETE]=WHEEditorCommandList[WHECOMMAND_BACK]= function (command, editor, tool)
{
	editor.CurrDeleteEvent=new WebHtmlEditorEvent(editor.LocalResources[command]||command, editor.ContentWindow); 
} ; 

WHEEditorCommandList[WHECOMMAND_ENABLETAB]= function (command, editor, tool)
	{
		var element=editor.GetSelection().GetParentElement(); 
		if (element.tagName == "LI")
		{
			editor.ExecuteCommand(WHECOMMAND_INDENT); 
		}
		else 
		{
			editor.PasteHtml(editor.EnableTabChar); 
		}
		return false; 
	} ;
WHEEditorCommandList[WHECOMMAND_STRIP_FORMAT]= function (command, editor, tool)
{
	var selectedValue=tool.GetSelectedValue(); 
	var htmlText=""; 
	try 
	{
		htmlText=editor.GetSelection().GetHTML(); 
	}
	catch (e){ ; }
	var Document_selection = editor.Document.selection?editor.Document.selection:editor.ContentWindow.getSelection(); 
	var isCollapsed = Document_selection.type?Document_selection.type.toLowerCase() == "none":Document_selection.isCollapsed; 
	if (isCollapsed || htmlText == "" || editor.GetHtml() == htmlText)
	{
		editor.SetHtml(HtmlClearFormat(editor.GetHtml(),selectedValue)); 
	}
	else if (htmlText != null)
	{
		editor.PasteHtml(HtmlClearFormat(htmlText,selectedValue)); 
	}
} ;
WHEEditorCommandList[WHECOMMAND_SHOW_IMAGEMAP_DIALOG]= function (command, editor, oTool)
{
	var selectElem=editor.GetSelection().GetParentElement(); 
    var Argument = new Object();
	Argument.EditorObj = editor;
	Argument.ImageCommand = WHECOMMAND_SHOW_IMAGE_DIALOG;
	if(selectElem && selectElem.tagName == "IMG")
	{
	    Argument.MapObj = selectElem;
	    Argument.src = selectElem.src
	    Argument.width=(selectElem.style.width)?selectElem.style.width:selectElem.width; 
		Argument.height=(selectElem.style.height)?selectElem.style.height:selectElem.height; 
		if (document.all)
		{
			var range=editor.Document.body.createTextRange(); 
			range.collapse(); 
			range.moveToElementText(selectElem); 
			range.select(); 
		}
	    if (selectElem.useMap)
		{
			var useMap=selectElem.getAttribute("useMap").substr(1);
			var html=""; 
			var map=editor.GetMap(editor,useMap); 
			if (map!=null)
			{
				html="<map name = \""+useMap+"\">"+map.innerHTML+"</map>"; 
			}
			Argument.mapNode=html;
			selectElem.style.width=Argument.width; 
			selectElem.style.height=Argument.height;
		}
	}
	editor.ShowDialog(GetDialogUrl(editor,command), Argument, 0620, 0454, WebHtmlEditorCreateImageMapCallBack, null, editor.LocalResources[command]); 
} ;

WHEEditorCommandList[WHECOMMAND_INSERT_TABLE] = WHEEditorCommandList[WHECOMMAND_TABLEWIZARD] = function (command, editor, oTool)
{
	if (WHECOMMAND_INSERT_TABLE == command)
	{
		var htmlTableElement=null; 
		var tablepro=oTool.GetSelectedValue(); 
		if (tablepro)
		{
			htmlTableElement=CreateHtmlTableElement(editor,tablepro.RowIndex,tablepro.CellIndex); 
			if (htmlTableElement)
			{
				editor.ExecuteInsertObjectCommand(htmlTableElement, editor.LocalResources[command]); 
			}
		}
	}
	else if (WHECOMMAND_TABLEWIZARD == command)
	{
		var TableRule=editor.GetRuleModelArrayByTagName("TABLE",editor.Document); 
		var TDRule=editor.GetRuleModelArrayByTagName("TD",editor.Document); 
		var Argument = new Object(); 
		Argument.ImageCommand = WHECOMMAND_SHOW_IMAGE_DIALOG;
		Argument.UpLoadImagesPaths = editor.UpLoadImagesPaths;
		Argument.UpLoadImagesFilter = editor.UpLoadImagesFilter;
		Argument.UpLoadImagesSize = editor.UpLoadImagesSize;
		Argument.UpLoadImagesAllowUpLoadSize = editor.UpLoadImagesAllowUpLoadSize;
		Argument.tableToModify = CreateHtmlTableElement(editor,2,3);
		Argument.CssClasses = TableRule;
		Argument.CellCssClasses = TDRule;
		Argument.EditorObj = editor;
		editor.ShowDialog(GetDialogUrl(editor,command), Argument,0620,0454,WebHtmlEditorCreateTable,null, editor.LocalResources[command]); 
	}
} ;
WHEEditorCommandList[WHECOMMAND_BOLD]=WHEEditorCommandList[WHECOMMAND_ITALIC]=WHEEditorCommandList[WHECOMMAND_UNDERLINE]=WHEEditorCommandList[WHECOMMAND_UNLINK]=WHEEditorCommandList[WHECOMMAND_JUSTIFY_LEFT]=WHEEditorCommandList[WHECOMMAND_JUSTIFY_RIGHT]=WHEEditorCommandList[WHECOMMAND_JUSTIFY_CENTER]=WHEEditorCommandList[WHECOMMAND_JUSTIFY_FULL]=WHEEditorCommandList[WHECOMMAND_JUSTIFY_NONE]=WHEEditorCommandList[WHECOMMAND_INDENT]=WHEEditorCommandList[WHECOMMAND_OUTDENT]=WHEEditorCommandList[WHECOMMAND_SUBSCRIPT]=WHEEditorCommandList[WHECOMMAND_SELECT_ALL]=WHEEditorCommandList[WHECOMMAND_UNSELECT]=WHEEditorCommandList[WHECOMMAND_SUPERSCRIPT]=WHEEditorCommandList[WHECOMMAND_STRIKETHROUGH]= function (command, editor, tool)
{
    if(!editor.IsIE && (command == WHECOMMAND_UNSELECT))
    {
        alert(editor.LocalResources["ToolNotSupportedByNetscape"]);
        return;
    }
	var isSelectAll=WHECOMMAND_SELECT_ALL != command; 
	editor.SetActive(); 
	editor.ExecuteButtonCommand(command, isSelectAll, null); 
} ;


WHEEditorCommandList[WHECOMMAND_INSERT_ORDERED_LIST]=WHEEditorCommandList[WHECOMMAND_INSERT_UNORDERED_LIST]= function (command, editor, tool)
	{
		var commandName=command; 
		if (!editor.EmptyList||!document.all)
		{
			ExecuteEmptyOrderedListCommand(commandName,editor); 
			return false; 
		}
		var parentElement=editor.GetSelection().GetParentElement(); 
		var createRange=editor.Document.selection.createRange(); 
		if ("OL" == parentElement.tagName||GetSrcElementByTagName(parentElement,"OL") != null||"UL" == parentElement.tagName||GetSrcElementByTagName(parentElement,"UL") != null)
		{
			ExecuteEmptyOrderedListCommand(commandName,editor); 
			return false; 
		}
		else if ("TD" == parentElement.tagName||"TR" == parentElement.tagName||"TBODY" == parentElement.tagName||"TABLE" == parentElement.tagName)
		{
			var createRange=editor.Document.selection.createRange(); 
			var tdElementArray=createRange.parentElement()["getElementsByTagName"]("TD"); 
			for (var i=tdElementArray.length-1; i>=0; i--)
			{
				createRange_TextObj_1=createRange.duplicate(); 
				createRange_TextObj_1.moveToElementText(tdElementArray[i]); 
				if (createRange.inRange(createRange_TextObj_1)&&tdElementArray[i].innerHTML != "")
				{
					createRange.moveToElementText(tdElementArray[i]); 
				}
			}
		}
		editor.Body.setActive(); 
		var document_selection=document.selection; 
		var transferred_Command=(commandName == "InsertOrderedList")?"OL": "UL"; 
		if (document_selection.type == "Control")
		{
			var tempRange=editor.Document.body.createTextRange(); 
			tempRange.moveToElementText(createRange(0)); 
			if ((tempRange.parentElement().tagName.toLowerCase().Trim() == "table")||(tempRange.parentElement().tagName.toLowerCase().Trim() == "tbody"))
			{
				var innerText=tempRange.parentElement().parentNode.outerHTML; tempRange.parentElement().parentNode.outerHTML="<"+transferred_Command+"><LI>"+innerText+"</LI></"+transferred_Command+">"; 
			}
			else 
			{
				var innerText=tempRange.htmlText; 
				editor.PasteHtml("<"+transferred_Command+"><LI>"+innerText+"</LI></"+transferred_Command+">"); 
			}
		}
		else 
		{
			var span=editor.Document.createElement("SPAN"); 
			span.innerHTML=createRange.htmlText; 
			if (createRange.htmlText == "")
			{
				ExecuteOrderedListCommand(createRange,editor,commandName); 
			}
			else if (span["getElementsByTagName"]("P").length>0)
			{
				ExecuteEmptyOrderedListCommand(commandName,editor); 
				return false; 
			}
			else 
			{
				var createRange_ParentElement_parentNode; 
				if (createRange.parentElement().tagName.toUpperCase() == "LI")
				{
					createRange_ParentElement_parentNode=createRange.parentElement().parentNode; 
				}
				else 
				{
					createRange_ParentElement_parentNode=createRange.parentElement(); 
				}
				if (createRange_ParentElement_parentNode.tagName.toUpperCase() == "OL"||createRange_ParentElement_parentNode.tagName.toUpperCase() == "UL")
				{
					var tagName = createRange_ParentElement_parentNode.tagName.toUpperCase(); 
					if (transferred_Command == tagName)
					{
						if (editor.EmptyList)
						{
							var createRange_TextObj_1 = createRange.duplicate();
							var createRange_TextObj_2 = createRange.duplicate(); 
							createRange_TextObj_2.moveToElementText(createRange_ParentElement_parentNode); 
							var createRange_TextObj_3 = createRange.duplicate(); 
							var element_LI_Array = createRange_ParentElement_parentNode["getElementsByTagName"]("LI"); 
							var zzz=0; 
							var element_LI_Array_LastElementIndex = element_LI_Array.length-1; 
							var createRange_TextObj_4 = createRange.duplicate(); 
							createRange_TextObj_4.moveToElementText(element_LI_Array[0]); 
							var createRange_TextObj_5 = createRange.duplicate(); 
							createRange_TextObj_5.moveToElementText(element_LI_Array[element_LI_Array.length-1]); 
							createRange_TextObj_3.setEndPoint("EndToEnd",createRange_TextObj_5); 
							createRange_TextObj_3.setEndPoint("StartToStart",createRange_TextObj_4); 
							while ((zzz<element_LI_Array.length) && (createRange_TextObj_3.compareEndPoints("StartToStart",createRange_TextObj_1)<=0))
							{
								createRange_TextObj_3.moveToElementText(element_LI_Array[zzz]); 
								createRange_TextObj_3.setEndPoint("EndToEnd",createRange_TextObj_5); 
								zzz++; 
							}
							zzz-=2; 
							while ((element_LI_Array_LastElementIndex>0) && (createRange_TextObj_3.compareEndPoints("EndToEnd",createRange_TextObj_1)>=0))
							{
								createRange_TextObj_3.moveToElementText(element_LI_Array[element_LI_Array_LastElementIndex]); 
								createRange_TextObj_3.setEndPoint("StartToStart",createRange_TextObj_4); 
								element_LI_Array_LastElementIndex--; 
							}
							element_LI_Array_LastElementIndex+=2; 
							var createRange_TextObj_6 = createRange.duplicate(); 
							var createRange_TextObj_7 = createRange.duplicate(); 
							createRange_TextObj_6.moveToElementText(element_LI_Array[zzz]); 
							createRange_TextObj_6.collapse( true); 
							createRange_TextObj_6.setEndPoint("StartToStart",createRange_TextObj_2); 
							createRange_TextObj_7.moveToElementText(element_LI_Array[element_LI_Array_LastElementIndex]); 
							createRange_TextObj_7.collapse( false); 
							createRange_TextObj_7.setEndPoint("EndToEnd",createRange_TextObj_2); 
							createRange.setEndPoint("StartToEnd",createRange_TextObj_6); 
							createRange.setEndPoint("EndToStart",createRange_TextObj_7); 
							var html = ""; 
							var flag1 = false; 
							var flag2 = false; 
							if (createRange_TextObj_6.htmlText.replace(/<(.*?)>/) != "")
							{
								html += "<"+tagName+">"+createRange_TextObj_6.htmlText+"</"+tagName+">"; 
							}
							else 
							{
								flag1 = true;
							}						
							html += createRange.htmlText.replace(/<LI\/?>/gi,"<BR>").replace(/<\/LI>/gi,"").replace(/^\s*<BR\/?>/gi,"").replace(/<BR\/?>\s*$/gi,""); 
							if (createRange_TextObj_7.htmlText.replace(/<(.*?)>/) != "")
							{
								html += "<"+tagName+">"+createRange_TextObj_7.htmlText+"<\/"+tagName+">"; 
						
							}
							else 
							{
								flag2 = true; 
								html +="<BR>"; 
							}
							if (flag1&&flag2)
							{
								html = html.replace(new RegExp("<\/?"+tagName+"\/?>","gi"),"").replace(/^\s*<BR\/?>/gi,"");
							}
							if (createRange_ParentElement_parentNode.parentNode.childNodes[0] == createRange_ParentElement_parentNode)
							{
								createRange_TextObj_2.collapse(); 
								createRange_ParentElement_parentNode.parentNode.removeChild(createRange_ParentElement_parentNode,html); 
							}
							else 
							{
								createRange_TextObj_2.moveStart("character",-1); 
							}
							editor.PasteHtml(html); 
						}
						else 
						{
							ExecuteEmptyOrderedListCommand(commandName,editor); 
							return false; 
						}
					}
					else 
					{
						ExecuteEmptyOrderedListCommand(commandName,editor); 
						return false; 
					}
				}
				else 
				{
					var commandEvent=new WebHtmlEditorEvent(command, editor.ContentWindow); 
					var createRange_TextObj_1=createRange.duplicate(); 
					createRange_TextObj_1.collapse( false); 
					createRange_TextObj_1.moveEnd("character",1); 
					if (createRange_TextObj_1.htmlText.match(/<BR\/?>/gi))
					{
						createRange.moveEnd("character",1); 
					}
					var html = "<"+transferred_Command+"><LI>"+createRange.htmlText.replace(/(<BR\s*>\s*)*$/gi,"").replace(/<BR\/?>$/gi,"").replace(/<BR\/?>/gi,"<\/LI><LI>")+"<\/LI><\/"+transferred_Command+">"; 
					createRange.pasteHTML(html); 
					editor.SaveHistory(commandEvent); 
				}
			}
		}
	};


lionsky.prototype.ExecuteCommandCreateLink= function (url,text,returnValue)
{ 
	this.SetActive(); 
	if (returnValue&&returnValue.name)
	{
		if (document.all)
		{ 
			this.ExecuteButtonCommand("CreateBookmark", true ,returnValue.name, true); 
		}
		else 
		{ 
			this.PasteHtml("<A name='"+returnValue.name+"'>"+text+"</A>",this.LocalResources["CreateLink"], true);
		}
	}
	else if (url)
	{
		var selection=this.GetSelection();
		var selectionText=selection.GetText(); 
		text=(text||url); 
		if (selection.GetParentElement().tagName == "IMG")
		{
			
		}
		else if (text&&(!selectionText||text != selectionText))
		{ 
			this.PasteHtml(text,null, true); 
		} 
		this.ExecuteButtonCommand("CreateLink", true ,url, true); 
	}
	if (returnValue){ this.UpdateReturnLinkElem(returnValue); }
} ; 
lionsky.prototype.UpdateReturnLinkElem= function (returnValue,title)
{
	title=title||this.LocalResources[WHECOMMAND_SET_LINK_PROPERTIES]; 
	var selection=this.GetSelection(); 
	var anchor=GetSrcElementByTagName(selection.GetParentElement(),"A"); 
	
	if (!anchor)return; 
	var aElem=this.Document.createElement("A"); 
	var flag= false; 
	if (returnValue.href&&returnValue.href.Trim())
	{
		aElem.href=returnValue.href; 
		flag |= (aElem.href != anchor.href); 
	}
	if ((returnValue.text&&returnValue.text.Trim())||(returnValue.href&&returnValue.href.Trim()))
	{
		aElem.innerHTML=(returnValue.text||returnValue.href);
		flag |= (aElem.innerHTML != anchor.innerHTML); 
	}
	if (returnValue.name&&returnValue.name.Trim())
	{
		aElem.name=returnValue.name; 
		flag |= (aElem.name != anchor.name); 
	}
	if (returnValue.title&&returnValue.title.Trim())
	{
		aElem.title=returnValue.title; 
		flag |= (aElem.title != anchor.title); 
	}
	if (returnValue.target&&returnValue.target.Trim())
	{
		aElem.target=returnValue.target; 
		flag |= (aElem.target != anchor.target);
	}
	if (returnValue.className&&returnValue.className.Trim())
	{
		aElem.className=returnValue.className; 
		flag |= (aElem.className != anchor.className); 
	}
	if (flag)
	{
		var parentElem = GetSrcElementByTagName(selection.GetParentElement(),"A"); 
		for (var i=0; i<aElem.attributes.length; i++)
		{
			var node=aElem.attributes[i]; 
			var nodeName = node.nodeName;
			if(nodeName.toLowerCase()=="title" || nodeName.toLowerCase()=="target" || nodeName.toLowerCase()=="href")
			{
			    parentElem[nodeName] = node.nodeValue;
			}
		}
		if(parentElem.innerHTML != aElem.innerHTML)
		{
			parentElem.innerHTML = aElem.innerHTML;
		}
	}
} ;



lionsky.prototype.CreateAElemContainer= function (elem,fireEvent)
{
    if (CreateElemContainer(this.ContentWindow,elem)&& false != fireEvent)
    { 
        this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
    }
} ;


lionsky.prototype.GetRuleModelArrayByTagName= function (tagName, documents)
{
    var BCCM=BCssClassManager(); 
    var ruleModelArray=BCCM.GetRuleModelArrayByTagName(tagName,documents); 
    return ruleModelArray; 
} ; 

lionsky.prototype.ExecuteApplyCssClassCommand= function (className, customCommandName)
{
	if (!customCommandName)
	{
	    customCommandName="ExecuteApplyCssClassCommand: Did you forget the title?!"; 
	}
	return this.SaveHistory(new WebHtmlEditorEventCss(customCommandName,this.ContentWindow,className)); 
} ;

lionsky.prototype.ExecuteSetAttributeCommand= function (elem,attributeKey,attributeValue,title)
{
	if (!title)
	{
	    title="ExecuteSetAttributeCommand: Did you forget the title?!"; 
	}
	return this.SaveHistory(new WebHtmlEditorEventSetAttributeHandel(title,this.ContentWindow,elem,attributeKey,attributeValue)); 
} ; 
lionsky.prototype.ExecuteSetStyleRuleCommand= function (elem,command,selectedValue,title)
{
	if (!title)
	{
	    title="ExecuteSetStyleRuleCommand: Did you forget the title?!"; 
	}
	return this.SaveHistory(new WebHtmlEditorEventStyleRultHandel(title,this.ContentWindow,elem,command,selectedValue)); 
} ; 

WHEEditorCommandList[WHECOMMAND_INSERT_SYMBOL] = function (command, editor, oTool)
{
    editor.ShowDialog(GetDialogUrl(editor,command), null,0620,0454,WebHtmlEditorInsertSymbolCallBack,null, editor.LocalResources[command]); 
}


WHEEditorCommandList[WHECOMMAND_SET_LINK_PROPERTIES] = WHEEditorCommandList[WHECOMMAND_SHOW_LINK_DIALOG]= function (command, editor, oTool)
{
	var tabIndex=null; 
	if (oTool&&oTool.TabIndex)
	{
		tabIndex=oTool.TabIndex; 
	}
	var selectionLinkArgument=WebHtmlEditorGetSelectionLinkArgument(editor, tabIndex); 
	var callBack=(null == selectionLinkArgument.realLinkObject?WebHtmlEditorCreateLink:WebHtmlEditorCreateLinkCallBack); 
	editor.ShowDialog(GetDialogUrl(editor,WHECOMMAND_SHOW_LINK_DIALOG),selectionLinkArgument,0620,0454,callBack, null ,editor.LocalResources[command]); 
} ;

WHEEditorCommandList[WHECOMMAND_APPLY_CLASS]= function (command, editor, oTool)
{
	var value = oTool.GetSelectedValue(); 
	editor.ExecuteApplyCssClassCommand(value, editor.LocalResources[command]); 
} ; 

WHEEditorCommandList[WHECOMMAND_SHOW_TEMPLATE_DIALOG]= function (command, editor, tool)
{
	var Functions=(tool&&"function" == typeof(tool)?tool:WebHtmlEditorCreateTemplate); 
	editor.ShowDialog(GetDialogUrl(editor,command),null, 0620 , 0454, Functions, null, editor.LocalResources[command]); 
	return false; 
} ;


WHEEditorCommandList[WHECOMMAND_SHOW_FILE_DIALOG]= function (command, editor, tool)
{
	var Functions=(tool&&"function" == typeof(tool)?tool:WebHtmlEditorCreateLink);
	var Argument = WebHtmlEditorGetSelectionLinkArgument(editor);
	Argument.Command = command;
	editor.ShowDialog(GetDialogUrl(editor,command), Argument, 0620, 0454, Functions, null, editor.LocalResources[command]); 
	return false; 
} ;

WHEEditorCommandList[WHECOMMAND_SHOW_FLASH_DIALOG]= function (command, editor, tool)
{
	editor.SetFocus(); 
	var selectElem=editor.GetSelection().GetParentElement(); 
	selectElem.Command = command;
	var Functions=(tool&&"function" == typeof(tool)?tool:WebHtmlEditorCreateFlash); 
	editor.ShowDialog(GetDialogUrl(editor,command), selectElem, 0620, 0454, Functions, null, editor.LocalResources[command]); 
	return false; 
} ;

WHEEditorCommandList[WHECOMMAND_SHOW_MEDIA_DIALOG]= function (command,editor, tool)
{
	editor.SetFocus(); 
	var selectElem=editor.GetSelection().GetParentElement(); 
	selectElem.Command = command;
	var Functions=(tool&&"function" == typeof(tool)?tool: WebHtmlEditorCreateMedia); 
	editor.ShowDialog(GetDialogUrl(editor,command), selectElem, 0620, 0454, Functions, null, editor.LocalResources[command]); 
	return false; 
} ;


WHEEditorCommandList[WHECOMMAND_DELETE_TABLE]= function (command, editor, oTool)
{
    var selectedValue=oTool.GetSelectedValue(); 
    if (selectedValue&&"TABLE" != selectedValue.tagName)
    {
        selectedValue=GetSrcElementByTagName(selectedValue,"TABLE"); 
    }
    if (selectedValue)
    {
        editor.CreateAElemContainer(selectedValue); 
        editor.ExecuteButtonCommand(WHECOMMAND_DELETE); 
    }
} ;    
WHEEditorCommandList[WHECOMMAND_CODEHIGHLIGHTER]= function (command, editor, tool)
{	 			 
	var Functions=(tool&&"function" == typeof(tool)?tool:WebHtmlEditorCreateCodeHighlighter); 					
	editor.ShowDialog(GetDialogUrl(editor,command),null,0620,0454,Functions, null, editor.LocalResources[command]); 
	return false; 
} ;
WHEEditorCommandList[WHECOMMAND_SHOW_IMAGE_DIALOG]= function (command, editor, tool)
{	
	var selectElem=editor.GetSelection().GetParentElement(); 
	selectElem.Command = command;
	var Functions=(tool&&"function" == typeof(tool)?tool:WebHtmlEditorCreateImage); 					
	editor.ShowDialog(GetDialogUrl(editor,command),selectElem,0620,0454,Functions, null, editor.LocalResources[command]); 
	return false; 
} ;
; 
WHEEditorCommandList[WHECOMMAND_UNDO]=WHEEditorCommandList[WHECOMMAND_REDO]= function (command, editor, tool)
{				   
	var historyTrackIndex = (tool != null&&tool.GetSelectedValue)?tool.GetSelectedValue(): 1; 
	if (command == WHECOMMAND_REDO)
	{
		editor.Redo(historyTrackIndex); 
	}
	else 
	{
		editor.Undo(historyTrackIndex); 
	}
} ; 
WHEEditorCommandList[WHECOMMAND_FORMAT_BLOCK]= function (command, editor, tool)
{
	editor.SaveHistory(new WebHtmlEditorEventFormatBlock(editor.LocalResources[command]||command, editor.ContentWindow, tool.GetSelectedValue())); 
} ; 

WHEEditorCommandList[WHECOMMAND_PASTE_FROM_WORD]=WHEEditorCommandList[WHECOMMAND_PASTE_FROM_WORD_NOFONTSNOSIZE]=WHEEditorCommandList[WHECOMMAND_PASTE_AS_HTML] = function (command, editor, tool)
{
	if (editor.IsIE)
	{
		var createRestorePoint=editor.CreateRestorePoint(); 
		var clipboardContent=editor.GetClipboardAsHtml(); 
		var clipboardFormatHtml=""; 
		if (command == WHECOMMAND_PASTE_FROM_WORD)
		{
			clipboardFormatHtml=HtmlClearFormat(clipboardContent,"WORD"); 
		}
		else if (command == WHECOMMAND_PASTE_FROM_WORD_NOFONTSNOSIZE)
		{
			clipboardFormatHtml=HtmlClearFormat(clipboardContent,"WORD_ALL"); 
		}
		else 
		{
			clipboardFormatHtml=HTMLEncode(clipboardContent); 
		}
		createRestorePoint.Select(); 
		if (clipboardFormatHtml)
		{
			editor.PasteHtml(clipboardFormatHtml); 
		}
	}
	else 
	{
	    if (!editor.IsIE)
        {
            alert(editor.LocalResources["ToolNotSupportedByNetscape"]); 
            return;
        }
		ShowPasteHelperDlg(editor,command); 
	}
} ;
WHEEditorCommandList[WHECOMMAND_PASTE_PLAIN_TEXT]= function (command, editor, oTool)
{
	if (editor.IsIE)
	{
		var str=window.clipboardData.getData("Text"); 
		var plainText=str.replace(/\x0a/g,"<br>");; 
		if (plainText)editor.PasteHtml(plainText); 
	}
	else 
	{
		alert(editor.LocalResources["ToolNotSupportedByNetscape"]);
	}
} ;
WHEEditorCommandList[WHECOMMAND_COPY]= function (command,editor,tool)
{
	var isCommandEnabled= true; 
	try 
	{
		document.queryCommandEnabled(command); 
	}
	catch (e)
	{isCommandEnabled= false; }
	if (isCommandEnabled)
	{
		editor.ExecuteButtonCommand(command, false ,null); 
	}
	else if (null != tool)
	{
		alert(editor.LocalResources["UseCtrl_C"]); 
	}
} ;

WHEEditorCommandList[WHECOMMAND_CUT]=WHEEditorCommandList[WHECOMMAND_PASTE]= function (command, editor, tool)
{	
	var isCommandEnabled= true; 
	try 
	{
		document.queryCommandEnabled(command); 
	}
	catch (e)
	{
		isCommandEnabled= false; 
	}
	if (isCommandEnabled)
	{
	
		editor.ExecuteButtonCommand(command, true ,null); 
	}
	else if (null != tool)
	{
		var id=(command == WHECOMMAND_CUT?"Please Use Ctrl_X": "Please Use Ctrl_V"); 	
		alert(editor.LocalResources["ToolNotSupportedByNetscape"].Format(id)); 
	}
	else 
	{
		editor.CurrDeleteEvent=new WebHtmlEditorEvent(editor.LocalResources[command],editor.ContentWindow);
		
	}
} ; 

WHEEditorCommandList[WHECOMMAND_FORECOLOR]=WHEEditorCommandList[WHECOMMAND_BACKCOLOR]=WHEEditorCommandList[WHECOMMAND_FONTNAME]=WHEEditorCommandList[WHECOMMAND_FONTSIZE]= function (command, editor, tool)
{
	var value=tool.GetSelectedValue(); 
	editor.ExecuteButtonCommand(command, true ,value); 
} ;


function GetDocumentChangeI(windows)
{ 
	this.Document=windows.document; 
	this.Update(); 
}
GetDocumentChangeI.prototype.Clear= function ()
{
	if (this.IsClear)return; 
	for (var proindex in this )
	{ 
		this[proindex]=null; 
	} 
	this.IsClear= true; 
} ; 
GetDocumentChangeI.prototype.Update= function ()
{ 
	this.Html = this.Document.body.innerHTML; 
	var createRange = this.Document.selection.createRange();
	if (createRange.length)
	{ 
		this.SourceIndex=createRange.item(0).sourceIndex;
	}
	else 
	{
		if ("" == createRange.htmlText)
		{	
			createRange.collapse( false); 
		} 
		this.Bookmark=createRange.getBookmark();
	}
} ; 
GetDocumentChangeI.prototype.ClientOnSelect= function ()
{ 
	this.Document.body.innerHTML=this.Html; 
	this.Select(); 
};
GetDocumentChangeI.prototype.Select= function ()
{
	if (null != this.SourceIndex)
	{
		var createRange=this.Document.body.createControlRange(); 
		createRange.addElement(this.Document.all(this.SourceIndex)); 
		createRange.select(); 
	}
	else if (null != this.Bookmark)
	{
		var createRange=this.Document.body.createTextRange(); 
		createRange.moveToBookmark(this.Bookmark); 
		createRange.select(); 
	}
} ;
function GetDocumentChangeM(Window)
{
	this.Window=Window; 
	this.Update(); 
}
GetDocumentChangeM.prototype.ClientOnSelect= function ()
{ 
	this.Window.document.body.innerHTML=this.Html; 
	this.Select(); 
} ; 
GetDocumentChangeM.prototype.Select= function ()
{
	try 
	{ 
		this.Window.focus(); 
		this.SetSelect(this.Window.getSelection(),this.SelectionObject); 
	}catch (ex){}
} ; 
GetDocumentChangeM.prototype.AnalyseSelectionObject= function (selection)
{
    
    var obj = new Object();
    obj.AnchorNode = new AnalyseDocumentChangeM_Nodes(this.Window,selection.anchorNode);
    obj.AnchorOffset = selection.anchorOffset;
    obj.FocusNode = new AnalyseDocumentChangeM_Nodes(this.Window,selection.focusNode);
    obj.FocusOffset = selection.focusOffset;
    obj.isCollapsed = selection.isCollapsed;    
	return obj; 
} ; 
GetDocumentChangeM.prototype.SetSelect = function (selection, selectionObject)
{
	var anchorNode = selectionObject.AnchorNode.Select(); 
	var focusNode = selectionObject.FocusNode.Select(); 
	selection.collapse(anchorNode, selectionObject.AnchorOffset); 
	if (!selectionObject.isCollapsed)
	{
		selection.extend(focusNode, selectionObject.FocusOffset); 
	}
} ; 
GetDocumentChangeM.prototype.Update = function ()
{ 	
	this.Html = this.Window.document.body.innerHTML; 
	this.SelectionObject = this.AnalyseSelectionObject(this.Window.getSelection()); 
} ; 
function AnalyseDocumentChangeM_Nodes(Window, node)
{ 
	this.Window=Window; 
	this.Compages=this.AnalyseNodeSame(this.Window.document.body, node); 
}
AnalyseDocumentChangeM_Nodes.prototype.Select= function ()
{
	var CreateElemContainer=this.ParseNodeSame(this.Window.document.body,this.Compages); 
	try 
	{
		CreateElemContainer(this.Window,CreateElemContainer); 
	}catch (ex){}
	return CreateElemContainer; 
} ; 
AnalyseDocumentChangeM_Nodes.prototype.AnalyseNodeSame= function (parent, node)
{
	var parentNode,childNode; 
	for (var i=0; i<parent.childNodes.length; i++)
	{
		parentNode=parent.childNodes[i]; 
		childNode=this.AnalyseNodeSame(parentNode, node);
		if ("" != childNode)
		{
			return ""+i+","+childNode; 
		}
		if (parentNode == node)return ""+i; 
	}
	return ""; 
} ; 
AnalyseDocumentChangeM_Nodes.prototype.ParseNodeSame= function (parent, compages)
{
	var array=compages.split(","); 
	for (var i=0; i<array.length; i++)
	{
		parent=parent.childNodes[array[i]]; 
	}
	return parent; 
} ;
lionsky.prototype.OnKeyPress= function ()
{
	if (this.CurrInputEvent)
	{ 
		this.CurrInputEvent.Update(); 
	}
	else 
	{ 
		this.ExecSystemEvent(WHEEVENT_SEL_CHANGED,null); 
	}
	if (this.CurrKeyCodeIsDelete&&!this.CurrDeleteEvent)
	{
		return true; 
	}
}

lionsky.prototype.ShowCurrentModeEditArea= function (area)
{
	var array=[this.EditArea,this.WheContentTextarea]; 
	for (var i=0; i<array.length; i++)
	{
		var item=array[i]; 
		if (item)
		{
			if (item == area)
			{
				if ("iframe" == item.tagName.toLowerCase())
				{
					item.style["width"]="100%"; 
					item.style["height"]="100%"; 
				}
				else
				{
					item.style.display="block"; 
				}
			}
			else 
			{
				if ("iframe" == item.tagName.toLowerCase())
				{
					item.style["width"]="0px"; 
					item.style["height"]="0px"; 
				}
				else
				{
					item.style.display="none"; 
				}
			}
		}
	}
} ;	
lionsky.prototype.ShowNewModeEditArea= function (currentMode)
{
	if (!currentMode){currentMode=EDIT_MODE; }
	if ((currentMode != CODE_MODE&&currentMode != EDIT_MODE&&currentMode != VIEW_MODE)){return; }
	switch (currentMode)
	{
		case EDIT_MODE: 
			this.ShowCurrentModeEditArea(this.EditArea); 
			break; 
		case CODE_MODE: 
			this.ShowCurrentModeEditArea(this.WheContentTextarea); 
			break; 
		case VIEW_MODE: 
			this.ShowCurrentModeEditArea(this.EditArea); 
			break; 
	} 
	this.CurrMode=currentMode;
} ;

lionsky.prototype.CheckIndentHtml= function (flag)
{
	this.IsIndentHtml = true;
	if (!this.IsIndentHtml){return; }
	if (!this.InitializeIndentEvent)
	{
		var obj=this ; 
		var span=getElementById("WHEIndentHtml"+obj.Id); 
		if(span)
		{
			span.innerHTML+=this.LocalResources["IndentHtml"]; 
			var checkBox=span["getElementsByTagName"]("INPUT")[0]; 
			checkBox.onclick= function ()
			{
				if (this.checked)
				{
					 
				}
				else 
				{
					 
				}
			} ; 
			obj.IndentHtmlSpanElem = span; 
			obj.IndentHtmlCheckBoxElem=checkBox; 
			this.InitializeIndentEvent= true; 
		}
	}
	if (null != this.IndentHtmlSpanElem)
	{ 
		this.IndentHtmlSpanElem.style.display=flag?"block": "none"; 
		this.IndentHtmlCheckBoxElem.checked= false; 
	}
} ; 
lionsky.prototype.SetMode = function(newMode)
{		
	if (newMode == this.CurrMode||(newMode != CODE_MODE&&newMode != EDIT_MODE&&newMode != VIEW_MODE))
	{
		return; 
	}
	if ( false == this.ExecuteClientCommand("OnClientModeChange")){return; }
	//var content=this.GetHtml();
	//if (content != null){this.WheContentHiddenTextArea["value"]=content; }
	this.ShowNewModeEditArea(newMode); 
	this.SetCurrentModeEditAreaValue(); 
	if (newMode == EDIT_MODE)
	{
		this.SetBodyCssClass(this.CurrentContentAreaCssClass); 
		this.SetDocumentEdit( true); 
		this.SetActive(); 
		this.SetFocus(); 
		this.CheckIndentHtml( false); 
		this.ExecSystemEvent(WHEEVENT_SEL_CHANGED); 
	}
	else if (newMode == CODE_MODE)
	{
		if (this.IsIE)
		{
			if (this.IsMaxScreenMode)
			{
				this.WheContentTextarea.style["width"]="100%"; 				
			}
			else
			{
				this.WheContentTextarea.style["width"]=this.Width; 
			}
			if ("CSS1Compat" == document.compatMode)
			{ 
				this.WheContentTextarea.style["width"]=this.Width; 
				this.WheContentTextarea.style["height"]=this.Height; 
			}
		} 
		this.CheckIndentHtml( true); 
		this.SetDocumentEdit( false); 
		this.SetActive(); 
		this.SetFocus(); 
	}
	else if (newMode == VIEW_MODE)
	{ 
		this.Body.className=this.ContentAreaCssClass; 
		this.SetDocumentEdit( false);
		this.ActiveEdit(false);
		this.CheckIndentHtml( false); 
		//SetLinksInvalidation(this.Document, false); 
	} 
	this.ExecSystemEvent(WHEEVENT_MODE_CHANGED); 
}


lionsky.prototype.SetVisible= function (visible)
{ 
	this.WheWrapperTable.style.display=(visible?"": "none"); 
	if (visible)
	{ 
		this.SetDocumentEdit( true); 
	}
	else
	{
		this.SetDocumentEdit( false); 
	}
	
} ; 

lionsky.prototype.SetDocumentEdit = function(flag)
{
	if (this.IsIE)
	{ 
		this.Body.contentEditable=flag; 
	}
	else 
	{
		try 
		{ 
			this.Document["designMode"]=flag?"on": "off"; 
			
		}catch (e){}
	}
}


lionsky.prototype.ActiveEdit = function(flag)
{
	if (this.IsIE) 
	{
        this.Body.contentEditable = flag;
    } 
	else 
	{
        try 
		{
            this.Document.designMode = flag ? "on" : "off";
        } 
		catch (e) {}
	}
}
lionsky.prototype.SetFocus = function () 
{
    try 
	{
		if (this.CurrMode == EDIT_MODE)
		{
			if (this.IsIE)
			{ 
				this.Body.focus(); 
			}
			else if (this.ContentWindow.focus)
			{ 
				this.ContentWindow.focus(); 
			}
		}
		else if (this.CurrMode == CODE_MODE)
		{
			this.WheContentTextarea.focus(); 
		}
	}
	catch (e){} 
}
lionsky.prototype.SizeChange = function(size)
{		
	try
	{
		var height = this.WheWrapperTable.style["height"];			
		if(-1 != height.indexOf("px"))
		{
			height = height.substring(height, height.indexOf("px"))
		}
		if (isNaN(height))
		{
			height = "350";
		}		
		height = parseInt(height); 
		if ((height+size)>=300)
		{
		    this.SetSize(this.Width, (height+size));
		}
	}
	catch(ex)
	{
		alert('in the Exception!');		
	}
}


var BPopupsManager=new PopupsManager(); 

var PopupsManagerOnMouseDownEvent= function (e){BPopupsManager.OnMouseDown(e); } ;
 
if (window.addEventListener)
{
    window.addEventListener("load", OnMouseDownEvent, false); 
}
if (window.attachEvent)
{
	window.attachEvent("onunload", function (){BPopupsManager.Clear(); } ); 
}
lionsky.prototype.Hide = function()
{
	if(this.PopupMenu)
	{
		this.PopupMenu.Hide();
	}
}
lionsky.prototype.attachEvent = function(obj, eventName, e)
{
	eventName=CheckEventName(eventName); 
	if (obj.attachEvent) 
	{
		obj.attachEvent (eventName, e);
	}
	if(obj.addEventListener)
	{
		obj.addEventListener(eventName, e, true);
	}
}
lionsky.prototype.detachEvent = function(obj, eventName, e)
{
	eventName=CheckEventName(eventName); 
	if (obj.detachEvent)
	{
		obj.detachEvent(eventName, e); 
	}
	if (obj.addEventListener)
	{
		obj.removeEventListener(eventName, e, true); 
	}
}


