	//全局变量声明 
	var CurrDesignMode=""; //当前编辑器的设计模式 :Code代码模式 :Design设计模式 :VIEW预览模式 :Text文本模式
	// 浏览器版本检测
	var sLinkFieldName = "content1" ;
	var sLinkSourceFileName = "" ;
	var sLinkSaveFileName = "" ;
	var FullHandle,PreViewHandle;
	var availHeight=window. screen.availHeight;
	
	
	var BrowserInfo = new Object() ;
	BrowserInfo.MajorVer = navigator.appVersion.match(/MSIE (.)/)[1] ;
	BrowserInfo.MinorVer = navigator.appVersion.match(/MSIE .\.(.)/)[1] ;
	BrowserInfo.IsIE55OrMore = BrowserInfo.MajorVer >= 6 || ( BrowserInfo.MajorVer >= 5 && BrowserInfo.MinorVer >= 5 ) ;
	var sBaseUrl = document.location.protocol + '//' + document.location.host ;
	var Contentid = URLParams['id'] ;
	var isfullscreen = URLParams['fullscreen'];
	
	function Check(t,n)
	{
		if(n==1) t.className ="Up";
		else
		if(n==2) t.className ="Down";
		else t.className ="None";
	}	


	// 格式化编辑器中的内容
	function format(what,opt) {
		if (CurrDesignMode!="Design") return;
		frames.eyeEditor.focus();
		if (opt=="RemoveFormat") {
			what=opt;
			opt=null;
		}
	
		if (opt==null) frames.eyeEditor.document.execCommand(what);
		else frames.eyeEditor.document.execCommand(what,"",opt);
		
		frames.eyeEditor.focus();
	}
	// 缩放操作
	var nCurrZoomSize = 100;
	var aZoomSize = new Array(10, 25, 50, 75, 100, 150, 200, 500);
	function doZoom(size) {
		frames.eyeEditor.document.body.runtimeStyle.zoom = size + "%";
		nCurrZoomSize = size;
	}
	// 粘贴纯文本
	function PasteText(){
		if (CurrDesignMode!="Design") return;
		frames.eyeEditor.focus();
		try{
			var sText = HTMLEncode( clipboardData.getData("Text") ) ;
			insertHTML(sText);
		}catch(e){
			alert("没有要粘贴的文本!");
		}
		frames.eyeEditor.focus();
	}
	// 替换特殊字符
	function HTMLEncode(text){
		text = text.replace(/&/g, "&amp;") ;
		text = text.replace(/"/g, "&quot;") ;
		text = text.replace(/</g, "&lt;") ;
		text = text.replace(/>/g, "&gt;") ;
		text = text.replace(/'/g, "&#146;") ;
		text = text.replace(/\ /g,"&nbsp;");
		text = text.replace(/\n/g,"<br>");
		text = text.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");
		return text;
	}
	
	// 在当前文档位置插入.
	function insertHTML(html) {
		if (CurrDesignMode=="VIEW") return;
		if (frames.eyeEditor.document.selection.type.toLowerCase() != "none"){
			frames.eyeEditor.document.selection.clear() ;
		}
		if (CurrDesignMode!="Design"){
			html=HTMLEncode(html);
		}
		frames.eyeEditor.document.selection.createRange().pasteHTML(html) ; 
	}
	// 从Word中粘贴，去除格式
	function PasteWord(){
		if (CurrDesignMode!="Design") return;
		frames.eyeEditor.focus();
		if (BrowserInfo.IsIE55OrMore)
			cleanAndPaste(GetClipboardHTML() ) ;
		else if ( confirm( "此功能要求IE5.5版本以上，你当前的浏览器不支持，是否按常规粘贴进行？" ) )
			format("paste") ;
		frames.eyeEditor.focus();
	}
	
	// 取剪粘板中的HTML格式数据
	function GetClipboardHTML() {
		var oDiv = document.getElementById("eWebEditor_Temp_HTML")
		oDiv.innerHTML = "" ;
		
		var oTextRange = document.body.createTextRange() ;
		oTextRange.moveToElementText(oDiv) ;
		oTextRange.execCommand("Paste") ;
		
		var sData = oDiv.innerHTML ;
		oDiv.innerHTML = "" ;
		
		return sData ;
	}
	
	// 清除WORD冗余格式并粘贴
	function cleanAndPaste( html ) {
		// Remove all SPAN tags
		html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
		// Remove Class attributes
		html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
		// Remove Style attributes
		html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
		// Remove Lang attributes
		html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
		// Remove XML elements and declarations
		html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
		// Remove Tags with XML namespace declarations: <o:p></o:p>
		html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
		// Replace the &nbsp;
		html = html.replace(/&nbsp;/, " " );
		// Transform <P> to <DIV>
		var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;	// Different because of a IE 5.0 error
		html = html.replace( re, "<div$2</div>" ) ;
		
		insertHTML( html ) ;
	}
	
	// 查找替换
	function findReplace(){
		ShowDialog('dialog/findreplace.htm', 320, 175, true)
	}
	// 显示无模式对话框
	function ShowDialog(url, width, height, optValidate) {
		if (CurrDesignMode=="VIEW") return;
		frames.eyeEditor.focus();
		var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
		frames.eyeEditor.focus();
	}
	
	// 相对(absolute)或绝对位置(static)
	function absolutePosition(){
		var objReference	= null;
		var RangeType		= frames.eyeEditor.document.selection.type;
		if (RangeType != "Control") return;
		var selectedRange	= frames.eyeEditor.document.selection.createRange();
		for (var i=0; i<selectedRange.length; i++){
			objReference = selectedRange.item(i);
			if (objReference.style.position != 'absolute') {
				objReference.style.position='absolute';
			}else{
				objReference.style.position='static';
			}
		}
	}

	// 上移(forward)或下移(backward)一层
	function zIndex(action){
		var objReference	= null;
		var RangeType		= frames.eyeEditor.document.selection.type;
		if (RangeType != "Control") return;
		var selectedRange	= frames.eyeEditor.document.selection.createRange();
		for (var i=0; i<selectedRange.length; i++){
			objReference = selectedRange.item(i);
			if (action=='forward'){
				objReference.style.zIndex  +=1;
			}else{
				objReference.style.zIndex  -=1;
			}
			objReference.style.position='absolute';
		}
	}
	
	
	
	// 菜单常量
	var sMenuHr="<tr><td align=center valign=middle height=2><TABLE border=0 cellpadding=0 cellspacing=0 width=128 height=2><tr><td height=1 class=HrShadow><\/td><\/tr><tr><td height=1 class=HrHighLight><\/td><\/tr><\/TABLE><\/td><\/tr>";
	var sMenu1="<TABLE border=0 cellpadding=0 cellspacing=0 class=Menu width=150><tr><td width=18 valign=bottom align=center style='background:url(sysimage/contextmenu.gif);background-position:bottom;'><\/td><td width=132 class=RightBg><TABLE border=0 cellpadding=0 cellspacing=0>";
	var sMenu2="<\/TABLE><\/td><\/tr><\/TABLE>";
	
	// 取菜单行
	function getMenuRow(s_Disabled, s_Event, s_Image, s_Html) {
		var s_MenuRow = "";
		s_MenuRow = "<tr><td align=center valign=middle><TABLE border=0 cellpadding=0 cellspacing=0 width=132><tr "+s_Disabled+"><td valign=middle height=20 class=MouseOut onMouseOver=this.className='MouseOver'; onMouseOut=this.className='MouseOut';";
		if (s_Disabled==""){
			s_MenuRow += " onclick=\"parent."+s_Event+";parent.oPopupMenu.hide();\"";
		}
		s_MenuRow += ">"
		if (s_Image !=""){
			s_MenuRow += "&nbsp;<img border=0 src='ButtonImage/"+s_Image+"' width=20 height=20 align=absmiddle "+s_Disabled+">&nbsp;";
		}else{
			s_MenuRow += "&nbsp;";
		}
		s_MenuRow += s_Html+"<\/td><\/tr><\/TABLE><\/td><\/tr>";
		return s_MenuRow;
	
	}
	
	// 取标准的format菜单行
	function getFormatMenuRow(menu, html, image){
		var s_Disabled = "";
		if (!eyeEditor.document.queryCommandEnabled(menu)){
			s_Disabled = "disabled";
		}
		var s_Event = "format('"+menu+"')";
		var s_Image = menu+".gif";
		if (image){
			s_Image = image;
		}
		return getMenuRow(s_Disabled, s_Event, s_Image, html)
	}

	// 是否选中表格
	function isTableSelected() {
		if (eyeEditor.document.selection.type == "Control") {
			var oControlRange = eyeEditor.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() == "TABLE") {
				selectedTable = eyeEditor.document.selection.createRange()(0);
				return true;
			}	
		}
	} 

	// 光标是否在表格中
	function isCursorInTableCell() {
		if (eyeEditor.document.selection.type != "Control") {
			var elem = eyeEditor.document.selection.createRange().parentElement()
			while (elem.tagName.toUpperCase() != "TD" && elem.tagName.toUpperCase() != "TH"){
				elem = elem.parentElement
				if (elem == null)
					break
			}
			if (elem) {
				selectedTD = elem
				selectedTR = selectedTD.parentElement
				selectedTBODY =  selectedTR.parentElement
				selectedTable = selectedTBODY.parentElement
				return true
			}
		}
	}
	
	// 取表格菜单行
	function getTableMenuRow(what){
		var s_Menu = "";
		var s_Disabled = "disabled";
		switch(what){
		case "TableInsert":
			if (!isTableSelected()) s_Disabled="";
			s_Menu += getMenuRow(s_Disabled, "TableInsert()", "TableInsert.gif", "插入表格...")
			break;
		case "TableProp":
			if (isTableSelected()||isCursorInTableCell()) s_Disabled="";
			s_Menu += getMenuRow(s_Disabled, "TableProp()", "TableProp.gif", "表格属性...")
			break;
		case "TableCell":
			if (isCursorInTableCell()) s_Disabled="";
			s_Menu += getMenuRow(s_Disabled, "TableCellProp()", "TableCellProp.gif", "单元格属性...")
			s_Menu += getMenuRow(s_Disabled, "TableCellSplit()", "TableCellSplit.gif", "拆分单元格...")
			s_Menu += sMenuHr;
			s_Menu += getMenuRow(s_Disabled, "TableRowProp()", "TableRowProp.gif", "表格行属性...")
			s_Menu += getMenuRow(s_Disabled, "TableRowInsertAbove()", "TableRowInsertAbove.gif", "插入行（在上方）");
			s_Menu += getMenuRow(s_Disabled, "TableRowInsertBelow()", "TableRowInsertBelow.gif", "插入行（在下方）");
			s_Menu += getMenuRow(s_Disabled, "TableRowMerge()", "TableRowMerge.gif", "合并行（向下方）");
			s_Menu += getMenuRow(s_Disabled, "TableRowSplit(2)", "TableRowSplit.gif", "拆分行");
			s_Menu += getMenuRow(s_Disabled, "TableRowDelete()", "TableRowDelete.gif", "删除行");
			s_Menu += sMenuHr;
			s_Menu += getMenuRow(s_Disabled, "TableColInsertLeft()", "TableColInsertLeft.gif", "插入列（在左侧）");
			s_Menu += getMenuRow(s_Disabled, "TableColInsertRight()", "TableColInsertRight.gif", "插入列（在右侧）");
			s_Menu += getMenuRow(s_Disabled, "TableColMerge()", "TableColMerge.gif", "合并列（向右侧）");
			s_Menu += getMenuRow(s_Disabled, "TableColSplit(2)", "TableColSplit.gif", "拆分列");
			s_Menu += getMenuRow(s_Disabled, "TableColDelete()", "TableColDelete.gif", "删除列");
			break;
		}
		return s_Menu;
	}
	
	// 右键菜单
	var oPopupMenu = null;
	if (BrowserInfo.IsIE55OrMore){
		oPopupMenu = window.createPopup();
	}
	function showContextMenu(event){
		if (CurrDesignMode!="Design") return false;
	
		var width = 150;
		var height = 0;
		var lefter = event.clientX;
		var topper = event.clientY;
	
		var oPopDocument = oPopupMenu.document;
		var oPopBody = oPopupMenu.document.body;
	
		var sMenu="";
		
		sMenu += getFormatMenuRow("cut", "剪切");
		sMenu += getFormatMenuRow("copy", "复制");
		sMenu += getFormatMenuRow("paste", "常规粘贴");
		sMenu += getFormatMenuRow("delete", "删除");
		sMenu += getFormatMenuRow("selectall", "全选");
		sMenu += sMenuHr;
		height += 102;
	
		if (isCursorInTableCell()){
			sMenu += getTableMenuRow("TableProp");
			sMenu += getTableMenuRow("TableCell");
			sMenu += sMenuHr;
			height += 286;
		}
	
		if (isControlSelected("TABLE")){
			sMenu += getTableMenuRow("TableProp");
			sMenu += sMenuHr;
			height += 22;
		}
	
		if (isControlSelected("IMG")){
			sMenu += getMenuRow("", "ShowDialog('dialog/img.htm', 350, 315, true)", "img.gif", "图片属性...");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "zIndex('forward')", "forward.gif", "上移一层");
			sMenu += getMenuRow("", "zIndex('backward')", "backward.gif", "下移一层");
			sMenu += sMenuHr;
			height += 64;
		}
	
		sMenu += getMenuRow("", "findReplace()", "findreplace.gif", "查找替换...");
		height += 20;
	
		sMenu = sMenu1 + sMenu + sMenu2;
	
		oPopDocument.open();
		oPopDocument.write("<head><link href=\"css/blue/MenuArea.css\" type=\"text/css\" rel=\"stylesheet\"></head><body scroll=\"no\" onConTextMenu=\"event.returnValue=false;\">"+sMenu);
		oPopDocument.close();
	
		height+=2;
		if(lefter+width > document.body.clientWidth) lefter=lefter-width;
		//if(topper+height > document.body.clientHeight) topper=topper-height;
	
		oPopupMenu.show(lefter, topper, width, height, eyeEditor.document.body);
		return false;
	
	}
	
	// 工具栏菜单
	function showToolMenu(menu){
		if (CurrDesignMode!="Design") return;
		var sMenu = ""
		var width = 150;
		var height = 0;
	
		var lefter = event.clientX;
		var leftoff = event.offsetX
		var topper = event.clientY;
		var topoff = event.offsetY;
	
		var oPopDocument = oPopupMenu.document;
		var oPopBody = oPopupMenu.document.body;
	
		switch(menu){
		case "font":		// 字体菜单
			sMenu += getFormatMenuRow("bold", "粗体", "bold.gif");
			sMenu += getFormatMenuRow("italic", "斜体", "italic.gif");
			sMenu += getFormatMenuRow("underline", "下划线", "underline.gif");
			sMenu += getFormatMenuRow("strikethrough", "中划线", "strikethrough.gif");
			sMenu += sMenuHr;
			sMenu += getFormatMenuRow("superscript", "上标", "superscript.gif");
			sMenu += getFormatMenuRow("subscript", "下标", "subscript.gif");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "ShowDialog('dialog/selcolor.htm?action=forecolor', 280, 250, true)", "forecolor.gif", "字体颜色");
			sMenu += getMenuRow("", "ShowDialog('dialog/selcolor.htm?action=backcolor', 280, 250, true)", "backcolor.gif", "字体背景色");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "insert('big')", "tobig.gif", "字体增大");
			sMenu += getMenuRow("", "insert('small')", "tosmall.gif", "字体减小");
			height = 206;
			break;
		case "paragraph":	// 段落菜单
			sMenu += getFormatMenuRow("JustifyLeft", "左对齐", "JustifyLeft.gif");
			sMenu += getFormatMenuRow("JustifyCenter", "居中对齐", "JustifyCenter.gif");
			sMenu += getFormatMenuRow("JustifyRight", "右对齐", "JustifyRight.gif");
			sMenu += getFormatMenuRow("JustifyFull", "两端对齐", "JustifyFull.gif");
			sMenu += sMenuHr;
			sMenu += getFormatMenuRow("insertorderedlist", "编号", "insertorderedlist.gif");
			sMenu += getFormatMenuRow("insertunorderedlist", "项目符号", "insertunorderedlist.gif");
			sMenu += getFormatMenuRow("indent", "增加缩进量", "indent.gif");
			sMenu += getFormatMenuRow("outdent", "减少缩进量", "outdent.gif");
			sMenu += sMenuHr;
			sMenu += getFormatMenuRow("insertparagraph", "插入段落", "insertparagraph.gif");
			sMenu += getMenuRow("", "insert('br')", "br.gif", "插入换行符");
			height = 204;
			break;
		case "edit":		// 编辑菜单
			sMenu += getFormatMenuRow("Undo", "撤消", "undo.gif");
			sMenu += getFormatMenuRow("Redo", "恢复", "redo.gif");
			sMenu += sMenuHr;
			sMenu += getFormatMenuRow("Cut", "剪切", "cut.gif");
			sMenu += getFormatMenuRow("Copy", "复制", "copy.gif");
			sMenu += getFormatMenuRow("Paste", "常规粘贴", "paste.gif");
			sMenu += getMenuRow("", "PasteText()", "pastetext.gif", "纯文本粘贴");
			sMenu += getMenuRow("", "PasteWord()", "pasteword.gif", "从Word中粘贴");
			sMenu += sMenuHr;
			sMenu += getFormatMenuRow("delete", "删除", "delete.gif");
			sMenu += getFormatMenuRow("RemoveFormat", "删除文字格式", "removeformat.gif");
			sMenu += sMenuHr;
			sMenu += getFormatMenuRow("SelectAll", "全部选中", "selectall.gif");
			sMenu += getFormatMenuRow("Unselect", "取消选择", "unselect.gif");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "findReplace()", "findreplace.gif", "查找替换");
			height = 248;
			break;
		case "object":		// 对象效果菜单
			sMenu += getMenuRow("", "ShowDialog('dialog/selcolor.htm?action=bgcolor', 280, 250, true)", "bgcolor.gif", "对象背景颜色");
			sMenu += getMenuRow("", "ShowDialog('dialog/backimage.htm', 350, 210, true)", "bgpic.gif", "背景图片");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "absolutePosition()", "abspos.gif", "绝对或相对位置");
			sMenu += getMenuRow("", "zIndex('forward')", "forward.gif", "上移一层");
			sMenu += getMenuRow("", "zIndex('backward')", "backward.gif", "下移一层");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "showBorders()", "showborders.gif", "显示隐藏指导方针");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "insert('quote')", "quote.gif", "引用样式");
			sMenu += getMenuRow("", "insert('code')", "code.gif", "代码样式");
			height = 166;
			break;
		case "component":	// 组件菜单
			sMenu += getMenuRow("", "ShowDialog('dialog/img.htm', 350, 315, true)", "img.gif", "插入或修改图片");
			sMenu += getMenuRow("", "ShowDialog('dialog/flash.htm', 350, 200, true)", "flash.gif", "插入Flash动画");
			sMenu += getMenuRow("", "ShowDialog('dialog/media.htm', 350, 200, true)", "media.gif", "插入自动播放媒体");
			sMenu += getMenuRow("", "ShowDialog('dialog/file.htm', 350, 150, true)", "file.gif", "插入其他文件");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "ShowDialog('dialog/fieldset.htm', 350, 170, true)", "fieldset.gif", "插入或修改栏目框");
			sMenu += getMenuRow("", "ShowDialog('dialog/iframe.htm', 350, 200, true)", "iframe.gif", "插入或修改网页帧");
			sMenu += getFormatMenuRow("InsertHorizontalRule", "插入水平尺", "inserthorizontalrule.gif");
			sMenu += getMenuRow("", "ShowDialog('dialog/marquee.htm', 395, 150, true)", "marquee.gif", "插入或修改字幕");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "createLink()", "createlink.gif", "插入或修改超链接");
			sMenu += getMenuRow("", "mapEdit()", "map.gif", "图形热点链接");
			sMenu += getFormatMenuRow("UnLink", "取消超链接或标签", "unlink.gif");
			height = 224;
			break;
		case "tool":		// 工具菜单
			sMenu += getMenuRow("", "ShowDialog('dialog/symbol.htm', 350, 220, true)", "symbol.gif", "插入特殊字符");
			sMenu += getMenuRow("", "insert('excel')", "excel.gif", "插入Excel表格");
			sMenu += getMenuRow("", "ShowDialog('dialog/emot.htm', 300, 180, true)", "emot.gif", "插入表情图标");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "insert('nowdate')", "date.gif", "插入当前日期");
			sMenu += getMenuRow("", "insert('nowtime')", "time.gif", "插入当前时间");
			height = 102;
			break;
		case "file":		// 文件视图菜单
			sMenu += getMenuRow("", "format('Refresh')", "refresh.gif", "新建");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "setMode('CODE')", "modecodebtn.gif", "代码状态");
			sMenu += getMenuRow("", "setMode('Design')", "modeeditbtn.gif", "编辑状态");
			sMenu += getMenuRow("", "setMode('TEXT')", "modetextbtn.gif", "文本状态");
			sMenu += getMenuRow("", "setMode('VIEW')", "modeviewbtn.gif", "预览状态");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "format('Print')", "print.gif", "打印");
			sMenu += sMenuHr;
			sMenu += getMenuRow("", "ShowDialog('dialog/help.htm','400','300')", "help.gif", "查看使用帮助");
			sMenu += getMenuRow("", "ShowDialog('dialog/about.htm','400','220')", "about.gif", "关于eWebEditor");
			height = 208;
			break;
		case "table":		// 表格菜单
			sMenu += getTableMenuRow("TableInsert");
			sMenu += getTableMenuRow("TableProp");
			sMenu += sMenuHr;
			sMenu += getTableMenuRow("TableCell");
			height = 306;
			break;
		case "form":		// 表单菜单
			sMenu += getFormatMenuRow("InsertInputText", "插入输入框", "FormText.gif");
			sMenu += getFormatMenuRow("InsertTextArea", "插入输入区", "FormTextArea.gif");
			sMenu += getFormatMenuRow("InsertInputRadio", "插入单选钮", "FormRadio.gif");
			sMenu += getFormatMenuRow("InsertInputCheckbox", "插入复选钮", "FormCheckBox.gif");
			sMenu += getFormatMenuRow("InsertSelectDropdown", "插入下拉框", "FormDropdown.gif");
			sMenu += getFormatMenuRow("InsertButton", "插入按钮", "FormButton.gif");
			height = 120;
			break;
		case "zoom":		// 缩放菜单
			for (var i=0; i<aZoomSize.length; i++){
				if (aZoomSize[i]==nCurrZoomSize){
					sMenu += getMenuRow("", "doZoom("+aZoomSize[i]+")", "checked.gif", aZoomSize[i]+"%");
				}else{
					sMenu += getMenuRow("", "doZoom("+aZoomSize[i]+")", "space.gif", aZoomSize[i]+"%");
				}
				height += 20;
			}
			break;
		}
		
		sMenu = sMenu1 + sMenu + sMenu2;
		
		oPopDocument.open();
		oPopDocument.write("<head><link href=\"css/blue/MenuArea.css\" type=\"text/css\" rel=\"stylesheet\"></head><body scroll=\"no\" onConTextMenu=\"event.returnValue=false;\">"+sMenu);
		oPopDocument.close();
	
		height+=2;
		if(lefter+width > document.body.clientWidth) lefter=lefter-width;
		//if(topper+height > document.body.clientHeight) topper=topper-height;
	
		oPopupMenu.show(lefter - leftoff - 2, topper - topoff + 22, width, height, document.body);
	
		return false;
	}
	
	// 显示或隐藏指导方针
	var borderShown = "no";
	function showBorders() {
		if (CurrDesignMode!="Design") return;
		
		var allForms = eyeEditor.document.body.getElementsByTagName("FORM");
		var allInputs = eyeEditor.document.body.getElementsByTagName("INPUT");
		var allTables = eyeEditor.document.body.getElementsByTagName("TABLE");
		var allLinks = eyeEditor.document.body.getElementsByTagName("A");
	
		// 表单
		for (a=0; a < allForms.length; a++) {
			if (borderShown == "no") {
				allForms[a].runtimeStyle.border = "1px dotted #FF0000"
			} else {
				allForms[a].runtimeStyle.cssText = ""
			}
		}
	
		// Input Hidden类
		for (b=0; b < allInputs.length; b++) {
			if (borderShown == "no") {
				if (allInputs[b].type.toUpperCase() == "HIDDEN") {
					allInputs[b].runtimeStyle.border = "1px dashed #000000"
					allInputs[b].runtimeStyle.width = "15px"
					allInputs[b].runtimeStyle.height = "15px"
					allInputs[b].runtimeStyle.backgroundColor = "#FDADAD"
					allInputs[b].runtimeStyle.color = "#FDADAD"
				}
			} else {
				if (allInputs[b].type.toUpperCase() == "HIDDEN")
					allInputs[b].runtimeStyle.cssText = ""
			}
		}
	
		// 表格
		for (i=0; i < allTables.length; i++) {
				if (borderShown == "no") {
					allTables[i].runtimeStyle.border = "1px dotted #BFBFBF"
				} else {
					allTables[i].runtimeStyle.cssText = ""
				}
	
				allRows = allTables[i].rows
				for (y=0; y < allRows.length; y++) {
					allCellsInRow = allRows[y].cells
						for (x=0; x < allCellsInRow.length; x++) {
							if (borderShown == "no") {
								allCellsInRow[x].runtimeStyle.border = "1px dotted #BFBFBF"
							} else {
								allCellsInRow[x].runtimeStyle.cssText = ""
							}
						}
				}
		}
	
		// 链接 A
		for (a=0; a < allLinks.length; a++) {
			if (borderShown == "no") {
				if (allLinks[a].href.toUpperCase() == "") {
					allLinks[a].runtimeStyle.border = "1px dashed #000000"
					allLinks[a].runtimeStyle.width = "20px"
					allLinks[a].runtimeStyle.height = "16px"
					allLinks[a].runtimeStyle.backgroundColor = "#FFFFCC"
					allLinks[a].runtimeStyle.color = "#FFFFCC"					
				}
			} else {
				allLinks[a].runtimeStyle.cssText = ""		
			}
		}
	
		if (borderShown == "no") {
			borderShown = "yes"
		} else {
			borderShown = "no"
		}
	
		scrollUp()
	}
	// 返回页面最上部
	function scrollUp() {
		eyeEditor.scrollBy(0,0);
	}

	// 创建或修改超级链接
	function createLink(){
		if (CurrDesignMode!="Design") return;
		
		if (eyeEditor.document.selection.type == "Control") {
			var oControlRange = eyeEditor.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() != "IMG") {
				alert("链接只能是图片或文本");
				return;
			}
		}
		
		ShowDialog("dialog/hyperlink.htm", 350, 150, true);
	}

	// 热点链接
	function mapEdit(){
		if (CurrDesignMode!="Design") return;
		
		var b = false;
		if (eyeEditor.document.selection.type == "Control") {
			var oControlRange = eyeEditor.document.selection.createRange();
			if (oControlRange(0).tagName.toUpperCase() == "IMG") {
				b = true;
			}
		}
		if (!b){
			alert("热点链接只能作用于图片");
			return;
		}
	
		window.open("dialog/map.htm", 'mapEdit'+sLinkFieldName, 'toolbar=no,location=no,directories=no,status=not,menubar=no,scrollbars=no,resizable=yes,width=450,height=300');
	}
	
	// 插入特殊对象
	function insert(what) {
		if (CurrDesignMode!="Design") return;
		eyeEditor.focus();
		var sel = eyeEditor.document.selection.createRange();
	
		switch(what){
		case "excel":		// 插入EXCEL表格
			insertHTML("<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:宋体;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>");
			break;
		case "nowdate":		// 插入当前系统日期
			var d = new Date();
			insertHTML(d.toLocaleDateString());
			break;
		case "nowtime":		// 插入当前系统时间
			var d = new Date();
			insertHTML(d.toLocaleTimeString());
			break;
		case "br":			// 插入换行符
			insertHTML("<br>")
			break;
		case "code":		// 代码片段样式
			insertHTML('<table width=95% border="0" align="Center" cellpadding="6" cellspacing="0" style="border: 1px Dotted #CCCCCC; TABLE-LAYOUT: fixed"><tr><td bgcolor=#FDFDDF style="WORD-WRAP: break-word"><font style="color: #990000;font-weight:bold">以下是代码片段：</font><br>'+HTMLEncode(sel.text)+'</td></tr></table>');
			break;
		case "quote":		// 引用片段样式
			insertHTML('<table width=95% border="0" align="Center" cellpadding="6" cellspacing="0" style="border: 1px Dotted #CCCCCC; TABLE-LAYOUT: fixed"><tr><td bgcolor=#F3F3F3 style="WORD-WRAP: break-word"><font style="color: #990000;font-weight:bold">以下是引用片段：</font><br>'+HTMLEncode(sel.text)+'</td></tr></table>');
			break;
		case "big":			// 字体变大
			insertHTML("<big>" + sel.text + "</big>");
			break;
		case "small":		// 字体变小
			insertHTML("<small>" + sel.text + "</small>");
			break;
		default:
			alert("错误参数调用！");
			break;
		}
		sel=null;
	}
	
	// 全屏编辑
	function Maximize() {
		if (CurrDesignMode!="Design") return;
		if(FullHandle!=null)
		{
			FullHandle.close();
		}
		FullHandle=window.open("Dialog/fullscreen.htm", 'FullScreen','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,fullscreen=yes');
	}

	function Minimize() {
		if (CurrDesignMode=="VIEW") return;
		
		parent.opener.setHTML(parent.EditorFullScreen.getHTML());
		parent.close();
	}
	// 设置编辑器的内容
	function setHTML(html) {
		if (CurrDesignMode=="VIEW") return;
		ContentEdit.value = html;
		if(CurrDesignMode=="Design"){
			eyeEditor.document.body.innerHTML = html;
		}else{
			eyeEditor.document.body.innerText = html;
		}
	}
	
	// 取编辑器的内容
	function getHTML() {
		var html;
		if((CurrDesignMode=="Design")||(CurrDesignMode=="VIEW")){
			html = eyeEditor.document.body.innerHTML;
		}else{
			html = eyeEditor.document.body.innerText;
		}
		if (CurrDesignMode!="TEXT"){
			if (true){
				var re = new RegExp(sBaseUrl.replace(/\//,"\/"),"gi");
				html = html.replace(re, "");
			}
			if ((html.toLowerCase()=="<p>&nbsp;</p>")||(html.toLowerCase()=="<p></p>")){
				html = "";
			}
		}
		return html;
	}
	
	// 在尾部追加内容
	function appendHTML(html) {
		if (CurrDesignMode=="VIEW") return;
		if(CurrDesignMode=="Design"){
			eyeEditor.document.body.innerHTML += html;
		}else{
			eyeEditor.document.body.innerText += html;
		}
	}

	// 改变编辑区高度
	function sizeChange(size){
	    var h;
		h=parseInt(document.all.tdEditArea.height)+size;
		if(h<=60)
		{
			h=60;
		}
		document.all.tdEditArea.height=h;
	//	parent.document.all.TDTOP.height=h+128;
	}

	// 改变模式：代码、编辑、文本、预览
	function setMode(NewMode){
		// 换图片
		HeadStyle="<head><link href=\"css/blue/EditorArea.css\" type=\"text/css\" rel=\"stylesheet\"></head><body MONOSPACE>";
		try
		{
				document.all["eWebEditor_CODE"].className = "StatusBarBtnOff";
				document.all["eWebEditor_Design"].className = "StatusBarBtnOff";
				document.all["eWebEditor_TEXT"].className = "StatusBarBtnOff";
				document.all["eWebEditor_VIEW"].className = "StatusBarBtnOff";
				document.all["eWebEditor_"+NewMode].className = "StatusBarBtnOn";
		}catch(e){}
		if (NewMode!=CurrDesignMode)
		{
			if (!BrowserInfo.IsIE55OrMore)
			{
				if ((NewMode=="CODE") || (NewMode=="Design") || (NewMode=="VIEW"))
				{
					alert("HTML编辑模式需要IE5.5版本以上的支持！");
					return false;
				}
			}
			if (NewMode=="TEXT")
			{
				if (CurrDesignMode!="TEXT")
				{
					if (!confirm("警告！切换到纯文本模式会丢失您所有的HTML格式，您确认切换吗？"))
					{
						return false;
					}
				}
			}
			
		}
		var sBody = "";
		try
		{
		switch(CurrDesignMode)
		{
			case "CODE":
				if (NewMode=="TEXT")
				{
					eWebEditor_Temp_HTML.innerHTML = eyeEditor.document.body.innerText;
					sBody = eWebEditor_Temp_HTML.innerText;
				}else{
					sBody = eyeEditor.document.body.innerText;
				}
				break;
			case "TEXT":
				sBody = eyeEditor.document.body.innerText;
				sBody = HTMLEncode(sBody);
				break;
			case "Design":
			case "VIEW":
				if (NewMode=="TEXT")
				{
					sBody = eyeEditor.document.body.innerText;
				}else{
					sBody = eyeEditor.document.body.innerHTML;
				}
				break;
			default:
				if(isfullscreen==null)
				{
					//不是全屏模式
					ContentEdit.value=parent.document.all.Content.value;
					sBody = ContentEdit.value;
				}else{
					//进入到全屏模式
					sBody = eyeEditor.document.body.innerHTML;
				}
				break;
		}
		}catch(e)
		{
			sBody="";
		}
// 换内容
		switch (NewMode)
		{
			case "CODE":
				eyeEditor.document.designMode="On";
				eyeEditor.document.open();
				eyeEditor.document.write(HeadStyle);
				eyeEditor.document.body.innerText=sBody;
				eyeEditor.document.close();
				break;
			case "Design":
				eyeEditor.document.designMode="On";
				eyeEditor.document.open();
				eyeEditor.document.write(HeadStyle+sBody);
				eyeEditor.document.close();
				break;
			case "TEXT":
				eyeEditor.document.designMode="On";
				eyeEditor.document.open();
				eyeEditor.document.write(HeadStyle);
				eyeEditor.document.body.innerText=sBody;
				eyeEditor.document.close();
				break;
			case "VIEW":
				eyeEditor.document.designMode="off";
				eyeEditor.document.open();
				eyeEditor.document.write(HeadStyle+sBody);
				eyeEditor.document.close();
				break;
		}		
		
		CurrDesignMode=NewMode;

		disableChildren(eWebEditor_Toolbar);
		
		eyeEditor.focus();
	}
	
	// 使工具栏无效
	function disableChildren(obj){
		if (obj){
			if (CurrDesignMode=="Design")
			{
				obj.disabled=false;
			}else{
				obj.disabled=true;
			}
			for (var i=0; i<obj.children.length; i++){
				disableChildren(obj.children[i]);
			}
		}
	}
	
	// 粘贴时自动检测是否来源于Word格式
	function onPaste() {
		if (CurrDesignMode=="VIEW") return false;
	
		if (CurrDesignMode=="Design"){
				var sHTML = GetClipboardHTML() ;
				var re = /<\w[^>]* class="?MsoNormal"?/gi ;
				if ( re.test(sHTML)){
					if ( confirm( "你要粘贴的内容好象是从Word中拷出来的，是否要先清除Word格式再粘贴？" ) ){
						cleanAndPaste( sHTML ) ;
						return false ;
					}
				}
		}else{
			eyeEditor.document.selection.createRange().pasteHTML(HTMLEncode( clipboardData.getData("Text"))) ;
			return false;
		}
		
	}
	
	function PreView()
	{
		if(PreViewHandle!=null)
		{
			PreViewHandle.close();
		}
		PreViewHandle=window.open("","","");
		PreViewHandle.document.open();
		PreViewHandle.document.write("<html><head><title>页面效果预览---蓝锋网站管理系统</title></head><body></body>" + eyeEditor.document.body.innerHTML + "</html>");
	}