//需要的基础变量
var sd_edit;
var sd_RangeType;
var sd_selection;
var sd_filterScript = false;
var sd_charset="gb2312";
var sd_bLoad=false;
var sd_pureText=true;
var sd_bTextMode=1;
var sd_colour;

//这里是编辑器css的样式
document.write('<body onLoad="return load_edit();">');
document.write("<style>#PostiFrame{border:1px solid #"+sy+";padding:3px;font-size:12px;}.pm{padding:0px;margin:0px;}.stt{position:absolute;background-color:#"+by+";border:#"+sy+" 1px solid;font-size:12px;padding:5px;FILTER:alpha(opacity=88)progid:DXImageTransform.Microsoft.Shadow(Color=#"+sy+",Direction=120,strength=4);}.stt a{cursor:pointer;}.as1{margin:1px;border:1px solid #"+sy+";background-color:#"+qy+";font-size:12px;cursor:pointer;}.as2{margin:1px;border:1px solid #"+by+";cursor:pointer;}.Ab{margin:2px;float:left;width:66px;height:22px;line-height:22px;text-align:center;font-size:13px;cursor:pointer;border:1px solid #"+sy+";background-color: #"+qy+";}.Aba{margin:2px;float:left;width:66px;height:22px;line-height:22px;text-align:center;font-size:13px;font-weight:bold;cursor:pointer;border:1px solid #"+sy+";background-color: #"+by+";}#Ar{background-color:#"+by+";border-top:1px solid #"+sy+";border-left:1px solid #"+sy+";border-right:1px solid #"+sy+";padding:2px;}#Ac{border:1px solid #"+sy+";padding:2px;}#At{background-color:#"+by+";border-bottom:1px solid #"+sy+";border-left:1px solid #"+sy+";border-right:1px solid #"+sy+";padding:2px;height:27px;}.Aj{float:right;margin:2px;width:32px;height:22px;line-height:22px;text-align:center;cursor:pointer;border:1px solid #"+sy+";background-color: #"+qy+";}#sdfontselect{width:auto;float:left;}#sdfontselect select{margin:2px 1px 1px 1px ;padding:0px;height:20px;}</style>");

//段落样式
function sd_FontHBsty(asty){
if(asty==1){sd_specialtype("<h1>","</h1>");}
else if(asty==2){sd_specialtype("<h2>","</h2>");}
else if(asty==3){sd_specialtype("<h3>","</h3>");}
else if(asty==4){sd_specialtype("<h4>","</h4>");}
else if(asty==5){sd_specialtype("<h5>","</h5>");}
else if(asty==6){sd_specialtype("<h6>","</h6>");}
else if(asty==7){sd_specialtype("<h7>","</h7>");}
else if(asty==8){sd_specialtype("<p>","</p>");}
else if(asty==9){sd_specialtype("<dd>","</dd>");}
else if(asty==10){sd_specialtype("<dt>","</dt>");}
else if(asty==11){sd_specialtype("<dir>","</dir>");}
else if(asty==12){sd_specialtype("<menu>","</menu>");}
else if(asty==13){sd_specialtype("<PRE>","</PRE>");}
else if(asty==21){sd_specialtype("<span style='width:100%;filter:blur(add=1, direction=45, strength=2)'>","</span>");}
else if(asty==22){sd_specialtype("<span style='width:100%;filter:glow(color=#ffff00, strength=10)'>","</span>");}
else if(asty==23){sd_specialtype("<span style='width:100%;filter:dropshadow(color=#999999, offx=2, offy=2, positive=1)'>","</span>");}
else if(asty==24){sd_specialtype("<SPAN style='BACKGROUND-IMAGE:URL(Logo.gif);'><DIV style='FILTER:Chroma(Color=#CCCCCC);COLOR:#CCCCCC; BACKGROUND-COLOR:#FFFFFF;font-size:66px;font-family:黑体;WIDTH:100%;'>","</DIV></SPAN>");}
else if(asty==25){sd_specialtype("<SPAN style='font-size:5px;cursor:pointer;' onmouseover= this.style.font='12px'; onmouseout= this.style.font='5px';>","</SPAN>");}
else if(asty==26){sd_specialtype("<span style='font-family:@宋体;'>","</span>");}
else if(asty==27){sd_specialtype("<span style='layout-flow:vertical-ideographic;float:right;'>","</span>");}
else if(asty==28){sd_specialtype("<span style='position:absolute;filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);float:right;'>","</span>");}
else if(asty==29){sd_specialtype("<SPAN style='FILTER:glow(color=red);width:100%;'>","</span>");}
else if(asty==30){sd_specialtype("<SPAN style='FILTER:blur;width:100%;'>","</span>");}
else if(asty==31){sd_specialtype("<SPAN style='FILTER:shadow(color=blue);width:100%;'>","</span>");}
else if(asty==32){sd_specialtype("<SPAN style='FILTER:alpha(opacity=10);width:100%;'>","</span>");}
else if(asty==33){sd_specialtype("<SPAN style='FILTER:dropshadow(color=D8D8D8);width:100%;'>","</span>");}
else if(asty==91){sd_specialtype("<div style='margin:18px;border:1px dotted #CCCCCC;padding:5px;background:#FDFDDF;font-size:12px;font-family:Tahoma;line-height:normal;cursor:pointer;' title='提示：点击运行该代码，观看即时演示！' onclick=\"preWin=window.open('','','');preWin.document.open();preWin.document.write(this.innerText);preWin.document.close();\">","</div>");}
else if(asty==92){sd_specialtype("<div style='margin:18px;border:1px dotted #CCCCCC;padding:5px;background:#EAF7EC;font-size:12px;font-family:Tahoma;line-height:normal;' title='提示：这是一段引用的内容！'>","</div>");}
else if(asty==93){sd_specialtype("<div style='text-align:center;clear:both;width:100%;'><div style='margin:8px 8px 8px 18px;border:#CCCCCC 1px solid;background-color:#F5F5F5;font-size:12px;width:180px;text-align:center;padding:8px;cursor:pointer;'><a onclick=sdTab.style.display='';><b>[ 显 示 ]</b></a> <a onclick=sdTab.style.display='none';><b>[ 隐 藏 ]</b></a></div><table id='sdTab' style='display:none;margin:18px;border:#CCCCCC 1px dotted;background-color:#F5F5F5;font-size:12px;' cellpadding='8' title='提示：这是一段隐藏的内容！'><tr><td align=left>","</td></tr></table></div>");}
}

//字体大小
function sd_FontHsize(asty){
if(asty>7){sd_specialtype("<font style='font-size:"+asty+"pt'>","</font>");}
else{sd_specialtype("<font size="+asty+">","</font>");}}

//字体颜色
function sd_foreColor()
{if (!sd_validateMode()) return;
if (sd_bIsIE5){
var arr = showModalDialog(""+Sm+""+Se+"HtmPop/selcolor.htm", "", "dialogWidth:299px; dialogHeight:300px; status:0; help:0");
if (arr != null) FormatText('forecolor', arr);
else sdIFrame.focus();
}else
{FormatText('forecolor', '');}}

//字体背景
function sd_backColor()
{if (!sd_validateMode()) return;
if (sd_bIsIE5){
var arr = showModalDialog(""+Sm+""+Se+"HtmPop/selcolor.htm", "", "dialogWidth:299px; dialogHeight:300px; status:0; help:0");
if (arr != null) FormatText('backcolor', arr);
else sdIFrame.focus();
}else{FormatText('backcolor', '');}
}

// 粘贴纯文本
function PasteText(){
if (!sd_validateMode()) return;
sdIFrame.focus();
var sText = HTMLEncode(clipboardData.getData("TEXT"));
sdIFrame.document.body.innerHTML+=sText;
sdIFrame.focus();}

// HTMLEncode文本格式化
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;}

//FLASH
function sd_forswf()
{var arr = showModalDialog(""+Sm+""+Se+"HtmPop/swf.htm", "", "dialogWidth:333px; dialogHeight:240px; status:0; help:0");
if (arr != null){
var ss;
ss=arr.split("*")
path=ss[0];
row=ss[1];
col=ss[2];
var string;
string="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'  codebase='http://download.macromedia.com/pub/shockwave/cabs/flashflash.cab#version=5,0,0,0' width="+row+" height="+col+"><param name=movie value="+path+"><param name=quality value=high><embed src="+path+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width="+row+" height="+col+"></embed></object>"

sdIFrame.document.body.innerHTML+=string;
}else sdIFrame.focus();}



//emot
function sd_foremot()
{var arr = showModalDialog(""+Sm+""+Se+"HtmPop/emot.htm", "", "dialogWidth:760px; dialogHeight:380px; status:0; help:0");
if (arr != null)
{sd_InsertSymbol(arr);
sdIFrame.focus();}
else sdIFrame.focus();}

//qq
function sd_qq()
{var arr = showModalDialog(""+Sm+""+Se+"HtmPop/face.htm", "", "dialogWidth:520px; dialogHeight:480px; status:0; help:0");
if (arr != null){
sd_InsertSymbol(arr);
sdIFrame.focus();}
else sdIFrame.focus();}

//link
function sd_forlink()
{if (sd_bIsIE5){
var arr = showModalDialog(""+Sm+""+Se+"HtmPop/link.htm", "", "dialogWidth:24em; dialogHeight:12em; status:0; help:0");
sdIFrame.focus();
if (arr != null)
{sd_InsertSymbol(arr);
sdIFrame.focus();}
else sdIFrame.focus();
}else {sd_UserDialog('CreateLink');}}

//关于我们
function sd_about()
{var arr = showModalDialog(""+Sm+""+Se+"HtmPop/about.htm", window, "dialogWidth:555px; dialogHeight:282px; status:0; help:0");
if (arr){
sdIFrame.document.body.innerHTML+=arr;}
sdIFrame.focus();}

//查找替换
function sd_replace()
{var arr = showModalDialog(""+Sm+""+Se+"HtmPop/replace.htm", "", "dialogWidth:333px; dialogHeight:222px; status:0; help:0");
if (arr != null){
var ss;
ss = arr.split("*")
a = ss[0];
b = ss[1];
i = ss[2];
con = sdIFrame.document.body.innerHTML;
if (i == 1)
{con = sd_rCode(con,a,b,true);
}else{
con = sd_rCode(con,a,b);
}sdIFrame.document.body.innerHTML = con;
}else sdIFrame.focus();}

//插入图片
function sd_Img()
{var arr = showModalDialog(""+Sm+""+Se+"HtmPop/img.htm", window, "dialogWidth:366px; dialogHeight:380px; status:0; help:0");
if (arr != null){
var ss;
ss=arr.split("*")
a=ss[0];//地址.
b=ss[1];//alt.
c=ss[2];//提示
d=ss[3];//效果.
e=ss[4];//位置.
f=ss[5];//长.
g=ss[6];//宽.
h=ss[7];//上下.
i=ss[8];//左右.
j=ss[9];//边框.
k=ss[10];//颜色.
var strpic;
strpic=""
if(e.value!="")strpic=strpic+"<p align="+e+">"
strpic=strpic+"<img src="+a+""
strpic=strpic+" style='"
if(h.value!='')strpic=strpic+"padding-top:"+h+"px;padding-bottom:"+h+"px;"
if(i.value!='')strpic=strpic+"padding-top:"+i+"px;padding-bottom:"+i+"px;"
if(j.value!='')strpic=strpic+"border:"+j+"px "+k+" solid;"
if(f.value!='')strpic=strpic+"width:"+f+"px;"
if(g.value!='')strpic=strpic+"height:"+g+"px;"
if(d.value!='')strpic=strpic+""+d+";"
strpic=strpic+"'"
if(b.value!="")strpic=strpic+" alt='"+b+"' "
strpic=strpic+">"
if(c.value!="")strpic=strpic+"<br>"+c+""
if(e.value!="")strpic=strpic+"</p>"

sdIFrame.document.body.innerHTML+=strpic;
}sdIFrame.focus();}

//插入特殊符号
function insertSpecialChar()
{var arr = showModalDialog(""+Sm+""+Se+"HtmPop/specialchar.htm", "","dialogWidth:555px; dialogHeight:432px; status:0; help:0");
if (arr != null) sd_InsertSymbol(arr);
sdIFrame.focus() ;}

//插入表格
function sd_fortable()
{if (!sd_validateMode())	return;
sdIFrame.focus();
var arr = showModalDialog(""+Sm+""+Se+"HtmPop/table.htm", window, "dialogWidth:333px; dialogHeight:380px; status:0; help:0;scroll:no;");
if (arr){sdIFrame.document.body.innerHTML+=arr;}
sdIFrame.focus();}

//修改表格、插入列+行等 begin
function sd_InsertRow()
{editor = sdIFrame;
	objReference = sd_GetRangeReference(editor);
	objReference = sd_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
	switch(objReference.tagName)
	{
	case 'TABLE' :
		var newTable = objReference.cloneNode(true);
		var newRow = newTable.insertRow();
		for(x = 0; x<newTable.rows[0].cells.length; x++)
			{
			var newCell = newRow.insertCell();
			}
		objReference.outerHTML = newTable.outerHTML;
		break;
	case 'TBODY' :
		var newTable = objReference.cloneNode(true);
		var newRow = newTable.insertRow();
		for(x = 0; x<newTable.rows[0].cells.length; x++)
			{
			var newCell = newRow.insertCell();
			}
		objReference.outerHTML=newTable.outerHTML;
		break;
	case 'TR' :
		var rowIndex = objReference.rowIndex;
		var parentTable = objReference.parentElement.parentElement;
		var newTable = parentTable.cloneNode(true);
		var newRow = newTable.insertRow(rowIndex+1);
		for(x = 0; x< newTable.rows[0].cells.length; x++)
		{
			var newCell = newRow.insertCell();
		}
		parentTable.outerHTML = newTable.outerHTML;
		break;
	case 'TD' :
		var parentRow = objReference.parentElement;
		var rowIndex = parentRow.rowIndex;
		var cellIndex = objReference.cellIndex;
		var parentTable = objReference.parentElement.parentElement.parentElement;
		var newTable = parentTable.cloneNode(true);
		var newRow = newTable.insertRow(rowIndex+1);
		for(x = 0; x< newTable.rows[0].cells.length; x++)
			{
			var newCell = newRow.insertCell();
			if (x == cellIndex)newCell.id='ura';
			}
		parentTable.outerHTML = newTable.outerHTML;
		var r = editor.document.body.createTextRange();
		var item = editor.document.getElementById('ura');
		item.id = '';
		r.moveToElementText(item);
		r.moveStart('character',r.text.length);
		r.select();
		break;
	default :
	return;
	}
}

function sd_DeleteRow()
{
	editor=sdIFrame;
	objReference=sd_GetRangeReference(editor);
	objReference=sd_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
	switch(objReference.tagName)
	{
	case 'TR' :var rowIndex = objReference.rowIndex;
	var parentTable=objReference.parentElement.parentElement;
	parentTable.deleteRow(rowIndex);
	break;
	case 'TD' :var cellIndex=objReference.cellIndex;
	var parentRow=objReference.parentElement;
	var rowIndex = parentRow.rowIndex;
	var parentTable=objReference.parentElement.parentElement.parentElement;
	parentTable.deleteRow(rowIndex);
	if (rowIndex>=parentTable.rows.length)
	{
	rowIndex=parentTable.rows.length-1;
	}
	if (rowIndex>=0)
	{
	var r = editor.document.body.createTextRange();
	r.moveToElementText(parentTable.rows[rowIndex].cells[cellIndex]);
	r.moveStart('character',r.text.length);
	r.select();
	}
	else
	{
	parentTable.removeNode(true);
	}
	break;
	default :return;
	}
}

function sd_InsertColumn()
{
	editor = sdIFrame;
	objReference= sd_GetRangeReference(editor);
	objReference=sd_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
	switch(objReference.tagName)
	{
	case 'TABLE' :
	var newTable=objReference.cloneNode(true);
	for(x=0; x<newTable.rows.length; x++)
	{
	var newCell = newTable.rows[x].insertCell();
	}
	newCell.focus();
	objReference.outerHTML=newTable.outerHTML;
	break;
	case 'TBODY' :
	var newTable=objReference.cloneNode(true);
	for(x=0; x<newTable.rows.length; x++)
	{
	var newCell = newTable.rows[x].insertCell();
	}
	objReference.outerHTML=newTable.outerHTML;
	break;
	case 'TR' :
	objReference=objReference.parentElement.parentElement;
	var newTable=objReference.cloneNode(true);
	for(x=0; x<newTable.rows.length; x++)
	{
	var newCell = newTable.rows[x].insertCell();
	}
	objReference.outerHTML=newTable.outerHTML;


	break;
	case 'TD' :
	var cellIndex = objReference.cellIndex;
	var rowIndex=objReference.parentElement.rowIndex;
	var parentTable=objReference.parentElement.parentElement.parentElement;
	var newTable=parentTable.cloneNode(true);
	for(x=0; x<newTable.rows.length; x++)
	{
	var newCell = newTable.rows[x].insertCell(cellIndex+1);
	if (x==rowIndex)newCell.id='ura';
	}
	parentTable.outerHTML=newTable.outerHTML;
	var r = editor.document.body.createTextRange();
	var item=editor.document.getElementById('ura');
	item.id='';
	r.moveToElementText(item);
	r.moveStart('character',r.text.length);
	r.select();
	break;
	default :
	return;
	}
}

function sd_DeleteColumn()
{
	editor = sdIFrame;
	objReference=sd_GetRangeReference(editor);
	objReference=sd_CheckTag(objReference,'/^(TABLE)|^(TR)|^(TD)|^(TBODY)/');
	switch(objReference.tagName)
	{
	
	case 'TD' :var rowIndex=objReference.parentElement.rowIndex;
	var cellIndex = objReference.cellIndex;
	var parentTable=objReference.parentElement.parentElement.parentElement;
	var newTable=parentTable.cloneNode(true);
	if (newTable.rows[0].cells.length==1)
	{
	parentTable.removeNode(true);
	return;
	}
	for(x=0; x<newTable.rows.length; x++)
	{
	if (newTable.rows[x].cells[cellIndex]=='[object]')
	{
	newTable.rows[x].deleteCell(cellIndex);
	}
	}
	if (cellIndex>=newTable.rows[0].cells.length)
	{
	cellIndex=newTable.rows[0].cells.length-1;
	}
	if (cellIndex>=0)  newTable.rows[rowIndex].cells[cellIndex].id='ura';
	parentTable.outerHTML=newTable.outerHTML;
	if (cellIndex>=0){
	var r = editor.document.body.createTextRange();
	var item=editor.document.getElementById('ura');
	item.id='';
	r.moveToElementText(item);
	r.moveStart('character',r.text.length);
	r.select();
	}
	break;
	default :return;
	}
}
//修改表格、插入列+行等 end


//直接用到的过程 begin

// 插入换行
function sd_InBR(){
if (!sd_validateMode()) return;
sd_InsertSymbol('<BR>');
}

//清空
function ClearReset()
{sdIFrame.document.body.innerHTML='';
sdIFrame.focus();}

//增加、减小编辑器大小
function sd_Size(num)
{var obj=document.getElementById("sd_Composition");
if (parseInt(obj.offsetHeight)+num>=100){
obj.height = (parseInt(obj.offsetHeight) + num);}
if (num>0){
obj.width="100%";}}

//编辑器的设计、预览、源码模式切换
function sd_setMode(n)
{sd_setStyle();
var cont;
var arsty=document.getElementById("Ar");
switch (n){
case 1:
arsty.style.display="";
if (document.getElementById("sd_TabHtml").className=="Aba"){
if (sd_bIsIE5){
cont=sdIFrame.document.body.innerText;
cont=sd_correctUrl(cont);
if (sd_filterScript)
cont=sd_FilterScript(cont);
sdIFrame.document.body.innerHTML="<a>　</a>"+cont;
}else{
var html = sdIFrame.document.body.ownerDocument.createRange();
html.selectNodeContents(sdIFrame.document.body);
sdIFrame.document.body.innerHTML = html.toString();
}}break;
case 2:
arsty.style.display="none";
sd_cleanHtml();
cont=sdIFrame.document.body.innerHTML;
cont=sd_rCode(sdIFrame.document.body.innerHTML,"<a>　</a>","");
cont=sd_correctUrl(cont);
if (sd_filterScript){cont=sd_FilterScript(cont);}
if (sd_bIsIE5){
sdIFrame.document.body.innerText=cont;
}else{
var html=document.createTextNode(cont);
sdIFrame.document.body.innerHTML = "";
sdIFrame.document.body.appendChild(html);
}break;}
sd_setTab(n);
sd_bTextMode=n}

//选择后的样式变化
function sd_setTab(n)
{var mhtml=document.getElementById("sd_TabHtml");
var mdesign=document.getElementById("sd_TabDesign");
if (n==1)
{mhtml.className="Ab";
mdesign.className="Aba";}
else if (n==2)
{mhtml.className="Aba";
mdesign.className="Ab";}
}

//基本的格式化文本命令
function FormatText(command, option)
{var codewrite
if (sd_bIsIE5){
if (option=="removeFormat"){
command=option;
option=null;}
sdIFrame.focus();
sdIFrame.document.execCommand(command, false, option);
sd_pureText = false;
sdIFrame.focus();
}else{
if ((command == 'forecolor') || (command == 'backcolor')) {
parent.command = command;
buttonElement = document.getElementById(command);
sdIFrame.focus();
document.getElementById("colourPalette").style.left = getOffsetLeft(buttonElement) + "px";
document.getElementById("colourPalette").style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + "px";
if (document.getElementById("colourPalette").style.visibility=="hidden")
{document.getElementById("colourPalette").style.visibility="visible";
}else {
document.getElementById("colourPalette").style.visibility="hidden";}


var sel = sdIFrame.document.selection; 
if (sel != null){sd_colour = sel.createRange();}
}else{
sdIFrame.focus();
sdIFrame.document.execCommand(command, false, option);
sd_pureText = false;
sdIFrame.focus();}}}

//清理编辑器内代码
function sd_CleanCode()
{var editor=sdIFrame;
editor.focus();
if (sd_bIsIE5){
var body = editor.document.body;
for (var index = 0; index < body.all.length; index++) {
tag = body.all[index];
tag.removeAttribute("className","",0);
tag.removeAttribute("style","",0);}
var html = editor.document.body.innerHTML;
html = html.replace(/<BR><BR><BR>/g,"<BR><BR>");
html = html.replace(/<P>&nbsp;<\/P>/g,"");
html = html.replace(/<P><\/P>/g,"<BR>");
html = html.replace(/\<p>/gi,"[$p]");
html = html.replace(/\<\/p>/gi,"[$\/p]");
html = html.replace(/\<br>/gi,"[$br]");
html = html.replace(/\<[^>]*>/g,"");
html = html.replace(/　/g,"");
html = html.replace(/&nbsp;/g,"");
html = html.replace(/\[\$p\]/gi,"<p>");
html = html.replace(/\[\$\/p\]/gi,"<\/p>");
html = html.replace(/\[\$br\]/gi,"<br>");
editor.document.body.innerHTML = html;
}else{
var html = sdIFrame.document.body.ownerDocument.createRange();
html.selectNodeContents(sdIFrame.document.body);
sdIFrame.document.body.innerHTML = html.toString();}}

function sd_correctUrl(cont)
{var regExp;
var url=location.href.substring(0,location.href.lastIndexOf("/")+1);
cont=sd_rCode(cont,location.href+"#","#");
cont=sd_rCode(cont,url,"");
cont=sd_rCode(cont,"<a>　</a>","");
return cont;}

function sd_cleanHtml()
{if (sd_bIsIE5){
var fonts = sdIFrame.document.body.all.tags("FONT");
}else{
var fonts = sdIFrame.document.all("FONT");}
var curr;
for (var i = fonts.length - 1; i >= 0; i--) {
curr = fonts[i];
if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;}}

function sd_InsertSymbol(str1)
{sdIFrame.focus();
if (sd_bIsIE5) sd_selectRange();
sd_edit.pasteHTML(str1);}

function sd_selectRange(){
sd_selection =sdIFrame.document.selection;
sd_edit=sd_selection.createRange();
sd_RangeType =sd_selection.type;}

//编辑器里面插入内容用
function sd_specialtype(Mark1, Mark2){
var strHTML;
if (sd_bIsIE5){
sd_selectRange();
if (sd_RangeType == "Text"){
if (Mark2==null)
{strHTML = "<" + Mark1 + ">" + sd_edit.htmlText + "</" + Mark1 + ">"; 
}else{
strHTML = Mark1 + sd_edit.htmlText +  Mark2; 
}
sd_edit.pasteHTML(strHTML);
sdIFrame.focus();
sd_edit.select();
}else{window.alert("请选择相应内容！")}
}
else{
if (Mark2==null)
{strHTML="<" + Mark1 + ">" + sdIFrame.document.body.innerHTML + "</" + Mark1 + ">"; 
}else{
strHTML = Mark1 + sdIFrame.document.body.innerHTML +  Mark2; 
}
sdIFrame.document.body.innerHTML=strHTML
sdIFrame.focus();
}}

function sd_getText()
{if (sd_bTextMode==2)
return sdIFrame.document.body.innerText;
else
{sd_cleanHtml();
return sdIFrame.document.body.innerHTML;
}}

function getOffsetTop(elm) {
var mOffsetTop = elm.offsetTop;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent){
mOffsetTop += mOffsetParent.offsetTop;
mOffsetParent = mOffsetParent.offsetParent;
}return mOffsetTop;}

function getOffsetLeft(elm) {
var mOffsetLeft = elm.offsetLeft;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent) {
mOffsetLeft += mOffsetParent.offsetLeft;
mOffsetParent = mOffsetParent.offsetParent;
}return mOffsetLeft;}

function rand() {
return parseInt((1000)*Math.random()+1);}

//检验连接地址是不是已经输入了
function sd_UserDialog(what)
{if (!sd_validateMode()) return;
sdIFrame.focus();
if (what == "CreateLink") {
if (sd_bIsNC){
insertLink = prompt("请填写超级链接地址信息：", "http://");
if ((insertLink != null) && (insertLink != "") && (insertLink != "undefined")) {
sdIFrame.document.execCommand('CreateLink', false, insertLink);
}else{
sdIFrame.document.execCommand('unlink', false, null);
}}
else {sdIFrame.document.execCommand(what, true, null);}}
if(what == "InsertImage"){
imagePath = prompt('请填写图片链接地址信息：', 'http://');
if ((imagePath != null) && (imagePath != "")) {
sdIFrame.document.execCommand('InsertImage', false, imagePath);}
sdIFrame.document.body.innerHTML = (sdIFrame.document.body.innerHTML).replace("src=\"file://","src=\"");
}sd_pureText = false;
sdIFrame.focus();}

function sd_GetRangeReference(editor)
{editor.focus();
var objReference = null;
var RangeType = editor.document.selection.type;
var selectedRange = editor.document.selection.createRange();
switch(RangeType)
{case 'Control' :
if (selectedRange.length > 0 ){
objReference = selectedRange.item(0);}
break;
case 'None' :
objReference = selectedRange.parentElement();
break;
case 'Text' :
objReference = selectedRange.parentElement();
break;}
return objReference}

function sd_CheckTag(item,tagName)
{if (item.tagName.search(tagName)!= -1)
{return item;}
if (item.tagName == 'BODY'){
return false;}
item=item.parentElement;
return sd_CheckTag(item,tagName);}

//自动排版
function AutoPB()
{window.alert("您不能这样做！")}
//商道超级自动排版
function sdPB()
{window.alert("您不能这样做！")}
function sd_rCode(s,a,b,i)
{a = a.replace("?","\\?");
if (i==null){
var r = new RegExp(a,"gi");
}else if (i) {
var r = new RegExp(a,"g");
}else{
var r = new RegExp(a,"gi");}
return s.replace(r,b); }

//编辑器内容check和提交代码 beging
//判断提交时候的状态
function sd_validateMode()
{
if (sd_bTextMode!=2) return true;
alert("请取消查看“源码”状态，调至“设计”状态再行提交，谢谢!");
sdIFrame.focus();
return false;}

//编辑器内容预览
function sd_View()
{if (sd_bTextMode==2) {
cont=sdIFrame.document.body.innerText;
} else {
cont=sdIFrame.document.body.innerHTML;}
cont=sd_correctUrl(cont);
bodyTag="<html><head></head><BODY style='font-size:12px;'>";
if (sd_filterScript)
cont=sd_FilterScript(cont);
preWin=window.open('','','');
preWin.document.open();
preWin.document.write(bodyTag);
preWin.document.write(cont);
preWin.document.close();
preWin.document.title="商道软件提示：您正在预览编辑器中的内容......";
preWin.document.charset=sd_charset;
}
//编辑器区域整体样式表现
function sd_InitDocument(hiddenid, charset)
{
if (charset!=null)
sd_charset=charset;
var sd_bodyTag="</head><BODY bgcolor=\"#ffffff\" style='font-size:9pt;'>";
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){
sdIFrame.document.designMode="On"
}
sdIFrame.document.open();
sdIFrame.document.write ('<html><head>');
if (sd_bIsIE5){
}
sdIFrame.document.write(sd_bodyTag);
sdIFrame.document.write("</body>");
sdIFrame.document.write("</html>");
sdIFrame.document.close();
sdIFrame.document.body.contentEditable = "True";
sdIFrame.document.charset=sd_charset;
sd_bLoad=true;
sd_setStyle();
}

//编辑器区域滚动条样式
function sd_setStyle()
{var bs = sdIFrame.document.body.style;
if (sd_bTextMode==2){
//bs.fontFamily="Verdana";
bs.fontSize="12px";
}else{
//bs.fontFamily="Verdana";
bs.fontSize="12px";}
bs.scrollbarShadowColor= '#'+sy+'';//立体滚动条阴影的颜色
bs.scrollbar3dLightColor= '#'+by+'';//滚动条亮边的颜色
bs.scrollbarArrowColor= '#'+sy+'';//上下按钮上三角箭头的颜色
bs.scrollbarBaseColor= '#'+by+'';//滚动条的基本颜色
bs.scrollbarDarkShadowColor= '#'+by+'';//滚动条强阴影的颜色
bs.scrollbarFaceColor= '#'+by+'';//滚动条凸出部分的颜色
bs.scrollbarHighlightColor= '#'+sy+'';//滚动条空白部分的颜色
bs.scrollbarTrackColor= '#'+qy+'';//滚动条的背景颜色
bs.border='0';}

function submits(){
var html;
html=sd_getText();
html=sd_rCode(html,"<a>　</a>","");
document.getElementById(""+an+"").value=html;}

function load_edit(){
content=document.getElementById(""+an+"").value;
sdIFrame.document.body.innerHTML=content;
document.getElementById(""+an+"").value="";}

function load_content(){
if (!sd_validateMode()){return false;}
document.getElementById(""+an+"").value=sdIFrame.document.body.innerHTML;
if(sdIFrame.document.body.innerHTML==""){
alert("内容不能为空");
sdIFrame.document.body.focus();
return false;}
return true;}

//去掉所有HTML符号检验是否为空值
function sd_ChekEmptyCode(html)
{html = html.replace(/\<[^>]*>/g,"");
html = html.replace(/&nbsp;/gi, "");
html = html.replace(/o:/gi, "");
html = html.replace(/\s/gi, "");
return html;}

function getHTML()
{var html;
if (!sd_bTextMode) 
{html = sdIFrame.document.body.innerHTML}
else
{html = sdIFrame.document.body.innerText}
return html;
}
//编辑器内容check和提交代码 end
var ONMT='class="as2" onMouseOver="this.className=\'as1\';" onMouseOut="this.className=\'as2\';"'
document.writeln('<div ID="Ar" style="width:100%;">');
document.writeln('<div id="sdfontselect"><select ID="sd_formatSelect" onChange="sd_FontHBsty(this[this.selectedIndex].value)"><option>段落格式</option><option value="0">普通格式</option><option value="1">标题 1</option><option value="2">标题 2</option><option value="3">标题 3</option><option value="4">标题 4</option><option value="5">标题 5</option><option value="6">标题 6</option><option value="7">标题 7</option><option value="8">段落</option><option value="9">定义</option><option value="10">术语定义</option><option value="11">目录列表</option><option value="12">菜单列表</option><option value="13">已编格式</option><option value="21">模糊文字</option><option value="22">文字加亮</option><option value="23">阴影文字</option><option value="24">图底文字</option><option value="25">文字微缩</option><option value="26">文字左倒</option><option value="27">古书文字</option><option value="28">文字加亮</option><option value="29">光晕</option><option value="30">模糊</option><option value="31">阴影</option><option value="32">透明</option><option value="33">立体</option><option value="91">设为代码</option><option value="92">设为引用</option><option value="93">设为隐藏</option></select><select language="javascript" id="FontName" onChange="FormatText (\'FontName\',this[this.selectedIndex].value);"><option selected>字体</option><option value="宋体">宋体</option><option value="黑体">黑体</option><option value="楷体_GB2312">楷体</option><option value="仿宋_GB2312">仿宋</option><option value="隶书">隶书</option><option value="幼圆">幼圆</option><option value="新宋体">新宋体</option><option value="细明体">细明体</option><option value="Arial">Arial</option><option value="Arial Black">Arial Black</option><option value="Arial Narrow">Arial Narrow</option><option value="Bradley Hand ITC">Bradley Hand ITC</option><option value="Brush Scrip MT">Brush Script MT</option><option value="Century Gothic">Century Gothic</option><option value="Comic Sans MS">Comic Sans MS</option><option value="Courier">Courier</option><option value="Courier New">Courier New</option><option value="MS Sans Serif">MS Sans Serif</option><option value="Script">Script</option><option value="System">System</option><option value="Times New Roman">Times New Roman</option><option value="Viner Hand ITC">Viner Hand ITC</option><option value="Verdana">Verdana</option><option value="Wide Latin">Wide Latin</option><option value="Wingdings">Wingdings</option></select><select language="javascript" id="FontSize" onChange="sd_FontHsize(this[this.selectedIndex].value);"><option selected>字号</option><option value="7">一号</option><option value="6">二号</option><option value="5">三号</option><option value="4">四号</option><option value="3">五号</option><option value="2">六号</option><option value="1">七号</option>');
for(i=1;i<29;i++)document.write("<option value="+i+">"+i+" pt\n")
document.write('<option value=30>30 pt</option><option value=35>35 pt</option><option value=40>40 pt</option><option value=45>45 pt</option><option value=50>50 pt</option><option value=60>60 pt</option><option value=70>70 pt</option><option value=85>85 pt</option><option value=100>100 pt</option><option value=120>120 pt</option><option value=150>150 pt</option><option value=200>200 pt</option><option value=250>250 pt</option><option value=300>300 pt</option><option value=500>500 pt</option><option value=900>900 pt</option><option value=2000>2000 pt</option></select></div>');
document.writeln('<img '+ONMT+' alt="加粗" onClick="FormatText(\'bold\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Bold.gif"><img '+ONMT+' alt="斜体" onClick="FormatText(\'italic\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Italic.gif"><img '+ONMT+' alt="下划线" onClick="FormatText(\'underline\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Underline.gif"><img '+ONMT+' alt="上标" onClick="FormatText(\'superscript\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/ShangBiao.gif"><img '+ONMT+' alt="下标" onClick="FormatText(\'subscript\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/XiaBiao.gif"><img '+ONMT+' alt="删除线" onClick="FormatText(\'strikethrough\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Through_Line.gif"><img '+ONMT+' id="forecolor" alt="字体颜色" onClick="sd_foreColor();ondrag=\'return false;\'" src="sdedit/SysImg/Font_Color.gif"><img '+ONMT+' id="backcolor" alt="字体背景颜色" onClick="sd_backColor();ondrag=\'return false;\'" src="sdedit/SysImg/Font_BgColor.gif"><img '+ONMT+' alt="左对齐" onClick="FormatText(\'justifyleft\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Left.gif"><img '+ONMT+' alt="居中" onClick="FormatText(\'justifycenter\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Center.gif"><img '+ONMT+' alt="右对齐" onClick="FormatText(\'justifyright\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Right.gif"><img '+ONMT+' alt="编号" onClick="FormatText(\'insertorderedlist\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/List.gif"><img '+ONMT+' alt="项目符号" onClick="FormatText(\'insertunorderedlist\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/List_Tu.gif"><img '+ONMT+' alt="减少缩进量" onClick="FormatText(\'outdent\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Outdent.gif"><img '+ONMT+' alt="增加缩进量" onClick="FormatText(\'indent\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Indent.gif"><img '+ONMT+' alt="替换" onClick="sd_replace();" src="sdedit/SysImg/TiHuan.gif"><img '+ONMT+' alt="撤消" onClick="FormatText(\'undo\');ondrag=\'return false;\'" src="sdedit/SysImg/Undo.gif"><img '+ONMT+' alt="恢复" onClick="FormatText(\'redo\');ondrag=\'return false;\'" src="sdedit/SysImg/Redo.gif"><img '+ONMT+' alt="插入水平线" onClick="FormatText(\'InsertHorizontalRule\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Line.gif"><img '+ONMT+' alt="插入换行符" onClick="sd_InBR();ondrag=\'return false;\'" src="sdedit/SysImg/br.gif"><img '+ONMT+' id="selectall" alt="全选" onClick="FormatText(\'selectAll\');ondrag=\'return false;\'" src="sdedit/SysImg/SelectAll.gif"><img '+ONMT+' alt="剪切" onClick="FormatText(\'cut\');ondrag=\'return false;\'" src="sdedit/SysImg/Cut.gif"><img '+ONMT+' alt="复制" onClick="FormatText(\'copy\');ondrag=\'return false;\'" src="sdedit/SysImg/Copy.gif"><img '+ONMT+' alt="常规粘贴" onClick="FormatText(\'paste\');ondrag=\'return false;\'" src="sdedit/SysImg/NianTie.gif"><img '+ONMT+' alt="纯文本粘贴" onClick="PasteText();ondrag=\'return false;\'" src="sdedit/SysImg/pastetext.gif"><img '+ONMT+' alt="取消文字样式" onClick="FormatText(\'RemoveFormat\', \'\');ondrag=\'return false;\'" src="sdedit/SysImg/Format.gif"><img '+ONMT+' alt="清理HTML代码" onClick="sd_CleanCode();ondrag=\'return false;\'" src="sdedit/SysImg/Qing.gif"><img '+ONMT+' alt="自动排版" onClick="AutoPB();ondrag=\'return false;\'" src="sdedit/SysImg/AutoPB.gif"><img '+ONMT+' alt="商道软件排版：复制外网文章后，单击一下，即可自动完成内容排版。" onClick="sdPB();" src="sdedit/SysImg/sdPB.gif"><img '+ONMT+' alt="插入超级链接" onClick="sd_UserDialog(\'CreateLink\',\'\',\'\');ondrag=\'return false;\'" src="sdedit/SysImg/Link.gif"><img '+ONMT+' alt="去掉超级链接" onClick="FormatText(\'UnLink\');ondrag=\'return false;\'" src="sdedit/SysImg/UnLink.gif"><img '+ONMT+' alt="插入表格" onClick="sd_fortable();ondrag=\'return false;\'" src="sdedit/SysImg/Table.gif"><img '+ONMT+' alt="插入行" onClick="sd_InsertRow();ondrag=\'return false;\'" src="sdedit/SysImg/Hang_Add.gif"><img '+ONMT+' alt="删除行" onClick="sd_DeleteRow();ondrag=\'return false;\'" src="sdedit/SysImg/Hang_Del.gif"><img '+ONMT+' alt="插入列" onClick="sd_InsertColumn();ondrag=\'return false;\'" src="sdedit/SysImg/Lie_Add.gif"><img '+ONMT+' alt="删除列" onClick="sd_DeleteColumn();ondrag=\'return false;\'" src="sdedit/SysImg/Lie_Del.gif"><img '+ONMT+' id="zifu" alt="插入特殊符号" onClick="insertSpecialChar();" src="sdedit/SysImg/ZiFu.gif"><img '+ONMT+' alt="插入图片" onClick="sd_Img();ondrag=\'return false;\'" src="sdedit/SysImg/Img.gif"><img '+ONMT+' alt="插入Flash" onClick="sd_forswf();ondrag=\'return false;\'" src="sdedit/SysImg/Flash.gif"><img '+ONMT+' alt="插入大表情" onClick="sd_foremot()" src="sdedit/SysImg/Emot.gif"><img '+ONMT+' alt="插入小表情" onClick="sd_qq()" src="sdedit/SysImg/qq.gif"><img '+ONMT+' alt="关于商道HTML在线编辑器" onClick="sd_about();ondrag=\'return false;\'" src="sdedit/SysImg/about.gif"></div>');
document.writeln('<div id=Ac style="width:100%;"><iframe ID="sd_Composition" MARGINHEIGHT="2" MARGINWIDTH="2" width="100%" height="200" name="I1" style="border:0px"></iframe>');
document.writeln('</div>');
document.writeln('<div id=At style="width:100%;">');
document.writeln('<div title="所见即所得编辑模式" class="Aba" id="sd_TabDesign" onClick="if (sd_bTextMode!=1) {sd_setMode(1);}">设&nbsp;计<\/div><div title="在新窗口查看预览效果" class="Ab" id="sd_TabView" onClick="sd_View();">预&nbsp;览<\/div><div title="源码编辑模式" class="Ab" id="sd_TabHtml" onClick="if (sd_bTextMode!=2) {sd_setMode(2);}">源&nbsp;码<\/div><div title="清空编辑器内的内容" class="Ab" onClick="ClearReset();">清&nbsp;空<\/div><div title="增大编辑高度" class="Aj" onClick="javascript:sd_Size(100)">╋<\/div><div title="减小编辑高度" class="Aj" onClick="javascript:sd_Size(-100)">━<\/div><\/div>');
var sd_bIsIE5=document.all;
var canusehtml='1';
var PostType=1;
if (sd_bIsIE5){
var sdIFrame=frames["sd_Composition"];}
else{
var sdIFrame=document.getElementById("sd_Composition").contentWindow;
var sd_bIsNC=true;
}
if (sd_bLoad==false)
{sd_InitDocument("Body",sd_charset);}