<%
guidedisplay=1
copyrightend=1
%>
<!--#include file="admin_start.asp" -->
<!--#include file="edit/edit_html.asp" -->
<!--#include file="edit/active_frame.asp" -->
<%
session("FB_EM_1_SQL_c")=request.form("c")
session("FB_EM_1_SQL_c_sql")=request.form("c_sql")
tools_width="99%"
dim labels
labels=","
dim table
dim f
dim s
dim d

table=trim(request("formname"))
f=trim(request("inputname"))
s=trim(request("mark"))
d=trim(request("des"))

%>
<scrip src="edit/edit_html.js" type="text/javascript"></script>
<body   style="background-color:#EBE9ED ;margin: 0px;" onmousemove="changew(2,event.x)" onmouseup="changew(1,event.x)" onmouseout="changew(3,event.x)" onmouseover="changew(4,event.x)">
<form name='form1' method="post" action=admin_edit_html_prev.asp target=_blank>
<table style='border-bottom:0px solid #4E6071;border-top:0px solid #4E6071;' cellpadding="0" cellspacing="0"  border="0" id=label_show width="20%" height=100% align=left >
    <tr> 
      <td valign=top style='padding:0' colspan="10" bgcolor="#ffffff" >
		<%
		dim show
		dim c_show
		show=request("show")
		if show<>"" then 
			show=split(show,",")
			for i=0 to ubound(show)
				show(i)=split(show(i),"?")
				c_show=show(i)(0)
				if ubound(show(i))>0 then q_show="&"&show(i)(1)
				%>
				<table id="label_show_<%=c_show%>" cellpadding="0" cellspacing="0"  border="0" width="100%" height=<%if i<ubound(show) then%>30<%end if%> >
					<tr> 
					  <td valign=top style='padding:0' colspan="10" bgcolor="#ffffff" >
					<iframe name=f_label_show_<%=c_show%> id=f_label_show_<%=c_show%>  style='border:solid #b0b0b0 0px' marginheight=0 marginwidth=0 frameborder=0  scrolling="no"  align=middle height=100% width=100% src='admin_edit_label_<%=c_show%>.asp<%if i<ubound(show) then%>?display=none<%=q_show%><%else%>?k=1<%=q_show%><%end if%>' ></iframe>
					  </td>
					</tr>
				</table>
				<%
				if i=0 then labels=labels&"'label_show_"&c_show&"'" else labels=labels&",'label_show_"&c_show&"'"
			next
			
			labels=right(labels,len(labels)-1)
		else
			labels=""
		end if
		%>
      </td>
    </tr>
</table>

<table cellpadding="0" cellspacing="0"  border="0"  height=100% width="7" align=left>
    <tr> 
      <td align=right style="cursor:e-resize;" height="47%" width='100%'  background="images/bg_a.gif" onmouseup="changew(1,-1)"  onMousedown="changew(0,-1)"  ></td>
    </tr>
    <tr> 
      <td align="right"  width="100%"><img src="images/d_0.gif" onMouseOver='changei(this)' onMouseOut='changei(this)' onMouseDown='changeii(this)'></td>
    </tr>
    <tr> 
      <td align=right style="cursor:e-resize;"  height="47%" width='100%'  background="images/bg_a.gif"  onmouseup="changew(1,-1)"  onMousedown="changew(0,-1)" ></td>
    </tr>
</table>
<table valign=top height=100% style='border-right:2px solid #4E6071;' cellpadding="0" cellspacing="0"  border="0"  id=sql_show align=left>
    <tr style='background-color:#9DACBF'> 
      <td height=10 width=100% align=center style='color:#000000;font-family:Arial;font-size:9pt;border-bottom:2px solid #f0f0f0;border-top:3px solid #4E6071;' >
		<div style='height:29px;padding-top:7px;overflow:hidden;float:left;'>
			<table height=22 cellpadding="0" cellspacing="0">
				<tr>
					<td width=15 background="images/edit/bg_title_l.gif">
					
					</td>
					<td background="images/edit/bg_title_m.gif">
					<nobr><%=d%></nobr>
					</td>
					<td width=20 background="images/edit/bg_title_r.gif">
					
					</td>
				</tr>
			</table> 
		</div>
		
	   </td>
	   <td width=90% style='border-bottom:2px solid #f0f0f0;border-top:3px solid #4E6071;'><font color=#EBE9ED > </font></td>
    </tr>
    <tr> 
      <td height=30 width=100% valign=top style='border-bottom:1px solid #808080;padding-left:5px ' colspan="10"  >
		<div style='float:left'>
		<!-- edit bar start //--> 
		<img vspace='2' hspace="0"  src="images/edit/line_l.gif"  align="absmiddle" border="0" > 
		<img vspace='2' hspace="0"  src="images/edit/selectall_1.gif" onmouseover="this.src='images/edit/selectall_0.gif'" onmouseout="this.src='images/edit/selectall_1.gif'"  align="absmiddle" border="0" alt="全选" onClick="selectall()" style="cursor: hand;"> 
		<img vspace='2' hspace="2"  src="images/edit/cut_1.gif" onmouseover="this.src='images/edit/cut_0.gif'" onmouseout="this.src='images/edit/cut_1.gif'"   align="absmiddle" border="0" onClick="FormatText('cut');changel()" style="cursor: hand;" alt="剪切"> 
		<img vspace='2' hspace="2"  src="images/edit/copy_1.gif"  onmouseover="this.src='images/edit/copy_0.gif'" onmouseout="this.src='images/edit/copy_1.gif'"  align="absmiddle" border="0" onClick="FormatText('copy')" style="cursor: hand;" alt="复制"> 
		<img vspace='2' hspace="2"  src="images/edit/paste_1.gif" onmouseover="this.src='images/edit/paste_0.gif'" onmouseout="this.src='images/edit/paste_1.gif'"   align="absmiddle" border="0" onClick="FormatText('paste');changel()" style="cursor: hand;" alt="粘贴"> 
		<img vspace='2' hspace="2"  src="images/edit/DELETE_1.gif" onmouseover="this.src='images/edit/DELETE_0.gif'" onmouseout="this.src='images/edit/DELETE_1.gif'" align="absmiddle" border="0" alt="删除" onClick="FormatText('DELETE');changel()" style="cursor: hand;"> 
		<img vspace='2' hspace="2"  src="images/edit/undo_1.gif" onmouseover="this.src='images/edit/undo_0.gif'" onmouseout="this.src='images/edit/undo_1.gif'"  align="absmiddle" border="0" alt="撤销" onclick="FormatText('undo')" style="cursor: hand;"> 
		<img vspace='2' hspace="2"  src="images/edit/redo_1.gif" onmouseover="this.src='images/edit/redo_0.gif'" onmouseout="this.src='images/edit/redo_1.gif'"  align="absmiddle" border="0" alt="重做" onClick="FormatText('redo')" style="cursor: hand;"> 
		<img vspace='2' hspace="2"  src="images/edit/showlabels_1.gif" onmouseover="this.src='images/edit/showlabels_0.gif'" onmouseout="this.src='images/edit/showlabels_1.gif'"  align="absmiddle" border="0" alt="高亮染色代码" onClick="ColorLabels()" style="cursor: hand;"> 
		
		<img vspace='2' hspace="0"  src="images/edit/line_l.gif"  align="absmiddle" border="0" > 
		
		<%if s<>"" then%>
		<img vspace='2' hspace="2"  src="images/edit/save_1.gif" onmouseover="this.src='images/edit/save_0.gif'" onmouseout="this.src='images/edit/save_1.gif'"  align="absmiddle" border="0" alt="保存" onClick="saves()" style="cursor: hand;"> 
		<%end if%>
		<input type="button" value="提 交" onclick='send()'>
		<iframe  src="blank" frameborder=0 name="save" id="save" width="0" style='border:0px solid #808080 ;' height="0" ></iframe>
		</div>
		
		<div style='float:left;padding-top:3px;' align=left>
			 <img vspace='2' hspace="4"  src="images/download.gif"  align="absmiddle" border="0" >  
		</div>
		
		
		<!-- edit bar end //-->
      </td>
    </tr>
    <tr> 
      <td width=100%  valign=top style='border:0px solid #808080; border-top:0px;padding:0;padding-top:0px' colspan="10"  >
		<iframe  src="../admin_edit_html_ini.asp?action=s" frameborder=0 name="source_s" id="message" width="100%" style='border:0px solid #808080 ;' height="100%" ></iframe>
      </td>
    </tr>
    <tr> 
      <td width=100%  height=30 align=center style='border-top:1px solid #808080;border-bottom:3px solid #4E6071; ' colspan="10"  >
		<div style='float:left'>
			<div style='float:left;padding-left:5px;' align=left>
				<img vspace='2' hspace="0"  src="images/edit/line_l.gif"  align="absmiddle" border="0" ><img onclick='countwords()' style="cursor: hand;" alt='计算字数' vspace='2' hspace="0"  src="images/icon07_o.gif"  align="absmiddle" border="0" >  
			</div>
			
			<div id="words" style='float:left;padding-top:8px;padding-left:5px;' align=left>
				<nobr>文档大小：<%=MySys.functions.formatmoney(len(session("FB_EM_1_SQL_c")))%> 字节</nobr>
			</div>
			
			<div style='float:left;padding-left:5px;' align=left>
				<img vspace='2' hspace="2"  src="images/line_2.gif"  align="absmiddle" border="0" > 
			</div>
			
			<div id="savetime" style='float:left;padding-top:8px;padding-left:5px;' align=left>
				<nobr>最后保存于：<%=hour(now)%> 时 <%=minute(now)%> 分 <%=second(now)%> 秒</nobr>
			</div>
		</div>
		<div style='float:left; color: #112B89' align=left>
			<img vspace='2' hspace="10"  src="images/line_2.gif"  align="absmiddle" border="0" >
			<input type="hidden" name=content  >
			<%if s<>"" then%>
			<input type="button" value="保 存" onclick='saves()'>
			<%end if%>
			<input type="button" value="提 交" onclick='send()'>
			<input type="button" value="取消" onclick='window.close()'>
		</div>
      </td>
    </tr>
</table>

</form>
<%if labels<>"" then%>
<script language="javascript" >
	var ii_n=0;
	var ff_h=0
	var ff=new Array(<%=labels%>)
    document.getElementById(ff[ff.length-1]).style.height=(window.document.body.scrollHeight-30*(ff.length-1))
	
	var h_ff=new Array(ff_h)
    for (ii_n=0;ii_n<ff.length;ii_n++){h_ff.push(document.getElementById(ff[ii_n]).scrollHeight)
	}
	
	function InsertLabel(s){
	   message.focus();
	   var range =message.document.selection.createRange();
	   range.pasteHTML(s);
	   changel()
	   message.focus();
    }
	function FarmatLabel(s){
	   var bodys=frames.message.document.getElementsByTagName("pre")[0];
	   var c_f=bodys.innerHTML
	   var r_f=FarmatLabels(s,c_f)
	   if(r_f!='false')bodys.innerHTML=r_f
	   changel();
	}
</script>
<script language="vbscript">
	Function FarmatLabels(s,ss)
	
		if ss="" or s="" then 
			FarmatLabels="false"
			exit function
		end if
		
		ss=CutHtml(ss,len(ss))
		ss=replace(ss," ","")
		ss=replace(ss,vbcrlf,"")
		
		do while instr(1,ss,s&s)>0
			ss=replace(ss,s&s,s)
		loop
		
		if left(ss,4)="<br>" then ss=right(ss,len(ss)-4)
		if right(ss,5)="</br>" then ss=left(ss,len(ss)-5)

		if left(ss,1)=s then ss=right(ss,len(ss)-1)
		if right(ss,1)=s then ss=left(ss,len(ss)-1)
		
		ss=replace(ss,",","</font>,<br><font color=blue>")
		
		FarmatLabels="<font color=blue>"&ss&"</font>"
		
		
	End Function
</script>
<%end if%>
<SCRIPT LANGUAGE="JAVASCRIPT" >
	var f_now = window.frames["source_s"];
	var body;
	var rng;
	var n_line;//?????DD¨oy
	var key_ctrl=0
	
	f_now.document.designMode="on";

	f_now.document.onkeydown = function(){ 
		var  keycode=f_now.event.keyCode; 
		//alert(keycode)
		
		if(keycode==13) {
			rng=f_now.document.selection.createRange();
			rng.pasteHTML("</pre></pre><br><pre>");
			return false
		}
		if(keycode==17) {
			key_ctrl=1
		}
		if(keycode==65&&key_ctrl==1) {
			selectall()
			return false
		}
	}
	//f_now.document.onkeyup = function(){ }
	f_now.document.oncontextmenu=function(){return false}
	f_now.document.onclick = function(){
		changel()
	//ColorLabels()
	}
	f_now.document.onkeyup = function(){
		var  keycode=f_now.event.keyCode; 
		if(keycode==17)key_ctrl=0;
		changel()
	}
	
	//f_now.document.onselectstart =function(){return false} 
	//f_now.document.onselect=function(){f_now.document.selection.empty()}
	//f_now.document.onselectall =function(){return false} 
	
	window.document.onmouseover = function(){
		if(f_now.document.body){
			f_now.document.body.onscroll=function(){
				 //alert("dfd")
				 var lines=frames.message.document.getElementById("lines")
				 var left_p=frames.message.document.body.scrollLeft
				 lines.style.posLeft=left_p
			}
		}
	}
	
	function selectall(){
	    var bodys=frames.message.document.getElementsByTagName("pre")[0];
		//var node=bodys.el;
		var range=frames.message.document.body.createTextRange();
		range.moveToElementText(bodys);
		range.select();
	}
	
	function ColorLabels() {  
		var s=frames.message.document.getElementsByTagName("pre")[0];
		var c=s.innerHTML;
		frames.message.document.getElementById("source").innerHTML="<pre>"+ShowLabels(trans_s(trans_h(c)),"")+"</pre>";
	}
	
	function changel(){ 
		var n_lines
		var cc=""
		var i
	    var bodys=frames.message.document.getElementsByTagName("pre")[0];
	    var lines=frames.message.document.getElementById("lines");
		if(bodys){
			f_now.document.getElementById("lines").onselectstart =function(){return false} 
			f_now.document.getElementById("lines").onselect=function(){f_now.document.getElementById("lines").selection.empty()}
			//alert(f_now.document.body.innerHTML)
			n_lines=getlines(bodys.innerHTML)
			
			if(n_lines!=getlines(lines.innerHTML)){
				for(i=0;i<n_lines;i++)cc+=(i+1)+"<br>"
				f_now.document.getElementById("lines").innerHTML=cc
				//alert(n_lines+"vv"+getlines(lines.innerHTML))
			}
			
		}
		f_now.document.body.focus()
	}
	
</SCRIPT>
<script language="javascript" >
	
	function send(){
	    try{
			var bodys=frames.message.document.getElementsByTagName("pre")[0];
			dd=trans_s(trans_h(bodys.innerHTML));
			opener.document.<%=request("formname")%>.<%=request("inputname")%>.value=dd;
			opener.focus();
			window.close();
		}

		catch(e){
			alert('由于原窗口已关闭或者已转向，如果您想保存当前的结果请点击保存按钮以保存到服务器！')
		}

	}
	
	function saves(){
	    var bodys=frames.message.document.getElementsByTagName("pre")[0];
		var dd=trans_s(trans_h(bodys.innerHTML));
		var aaa
	    try{
			opener.document.<%=request("formname")%>.<%=request("inputname")%>.value=dd;
		}
		catch(e){

		}
		document.form1.content.value=dd;
		document.form1.target="save";
		document.form1.action='admin_edit_template_save_handle.asp?t=<%=table%>&f=<%=f%>&s=<%=s%>'
		document.form1.submit();
	}
	
	function countwords(){
	    var bodys=frames.message.document.getElementsByTagName("pre")[0];
		var dd=trans_s(trans_h(bodys.innerHTML));
		document.getElementById("words").innerHTML='<nobr>文档大小：'+ FormatNum(dd.length) +' 字节</nobr>';
	}
	
	var key_d=0
	var x_m_o=document.getElementById("label_show").scrollWidth
	function changew(nn,xx){
	
	    if(xx==-1)xx=event.x
		
		if (nn==0&&key_d==0){
			
			key_d=1
			x_m_o=xx-document.getElementById("label_show").scrollWidth
			
		}else if (nn==1&&key_d==1){
		
			key_d=0
		
		}
		else if (nn==2&&key_d==1){
		
			var x_m=xx
			var x_n=document.getElementById("label_show").scrollWidth
			document.getElementById("label_show").style.width=x_m-x_m_o;
			//document.getElementById("sql_show").style.width=document.body.scrollWidth-document.getElementById("label_show").scrollWidth;
		
		}
		else if (nn==3&&key_d==1){
			if(ined==0){
				ined=1;
				fs_s=xx
			}		
		}
		else if (nn==4&&key_d==1){
			if(ined==1)ined=0;
		}
	}
	
	var fs_m=new Array();
	var ined=0
	var fs_s=0
	fs_m[0]=window.frames["source_s"]
	fs_m[0].document.onmousemove = function(){changew(2,fs_m[0].event.x+fs_s);}	
	fs_m[0].document.onmouseup = function(){changew(1,fs_m[0].event.x+fs_s);}

</script>
<script language="vbscript" >

	function FormatNum(str)
	
		if str="" then 
			FormatNum=0
			exit function
		end if
		
		if str-int(str)>0 then FormatNum=formatnumber(str,2) else FormatNum=formatnumber(str,0)
	
	end function

	function crlf()
		crlf=vbcrlf
	end function

	function replace_to(s,s1,s2)
		replace_to=replace(s,s1,s2,1,-1,1)
	end function
	
	function trans_s(c)
		
		c=replace(c,"&nbsp;"," ")
		c=replace(c,"&amp;","&")
		
		c=replace(c,"&#39;","'")
		c=replace(c,"&quot;","""")
		
		c=replace(c,"&lt;","<")
		c=replace(c,"&gt;",">")
		
		trans_s= c
	
	end function
	
	function trans_h(c)
		
		c=replace(c,"<br>",vbcrlf,1,-1,1)
		c=replace(c,"&nbsp;"," ",1,-1,1)
		c=CutHtml(c,len(c))
		
		trans_h= c
	
	end function
	
	function CutHtml(str,l) 
		Dim re 
		Set re=new RegExp 
		re.IgnoreCase =True 
		re.Global=true 
		re.Pattern="<([^<>]*?)>" 
	
		Do while re.Test(str) 
			str=re.Replace(str,"") 
		Loop 
		set re=Nothing 
	
		CutHtml=str
		//CutHtml=Replace(CutHtml,chr(10),"") 
		//CutHtml=Replace(CutHtml,chr(13),"") 
		CutHtml=left(CutHtml,l)
	
	End Function
	
	Function getlines(c)
		//alert(c)
		if c="" then 
			getlines=-1
			exit function
		end if
		
		c=trans_h(c)
		
		if c="" then 
			getlines=-1
			exit function
		end if
		
		getlines=ubound(split(c,vbcrlf))
		getlines=getlines+ubound(split(c,"<br>"))
		getlines=getlines+ubound(split(c,"<BR>"))
	
	End Function
	
	Function replace_re(str,str1,str2)
		dim regEx
		
		Set regEx = New RegExp // 建立正则表达式。 
		regEx.Pattern = str1 // 设置模式。 
		regEx.IgnoreCase = true // 设置是否区分大小写。 
		regEx.Global=true
		replace_re=regEx.Replace(str, str2)
		set regEx=nothing
		
	End Function
	
	Function ShowLabel(c_c,c_str)//文本，待替换的标签，显示的颜色，是否有结束标签,其他样式 div|color:#ffffff $$ 
	
		dim cc
		dim c
		dim re
		dim re_c
		
		re=""
		re_c=""
		c=c_c
		cc=c_str
		
		if c="" or cc="" then 
			ShowLabel=c
			exit function
		end if
		
		cc=split(cc,"$$")
		
		for i=0 to ubound(cc)
			cc(i)=split(cc(i),"|")
	
			re="(\<"&cc(i)(0)&"[^\<]*\>)"
			re_c="&lt;##span style=##"&cc(i)(1)&"####&gt;$1&lt;##/span##&gt;"
			c=replace_re(c,re,re_c)
			
			re="(\<\/"&cc(i)(0)&"\>)"
			re_c="&lt;##span style=##"&cc(i)(1)&"####&gt;$1&lt;##/span##&gt;"
			c=replace_re(c,re,re_c)
		
		next
		//response.end
		ShowLabel=c
	
	End Function
	
	Function ShowLabels(c_s,cc_s)//需要染色的html代码,染色标签连接字符串
	
		dim c,cc
		c=c_s
		cc=cc_s
	
		/////////////常规html标签染色
		if cc="" then
			cc="[^\<]*|color:#000099"
			cc=cc+"$$script|color:#990033"
			cc=cc+"$$style|color:red"
			cc=cc+"$$html|color:#000066;font-weight:bold"
			cc=cc+"$$head|color:#CC6600"
			cc=cc+"$$meta|color:#CC6600"
			cc=cc+"$$title|color:#CC6600"
			cc=cc+"$$body|color:#000066;font-weight:bold"
			cc=cc+"$$table|color:#009999"
			cc=cc+"$$tr|color:#009999"
			cc=cc+"$$td|color:#009999"
			cc=cc+"$$form|color:#FF00FF"
			cc=cc+"$$input|color:#FF00FF"
			cc=cc+"$$img|color:#990033"
		end if
		
		c=showlabel(c,cc)
		
		/////////////特殊html标签染色
		c=replace_re(c,"('[^\']*\')","&lt;##span style=##color:blue## ##&gt;$1&lt;##/span##&gt;")
		
		c=replace_re(c,"(""[^\""]*\"")","&lt;##span style=##color:blue## ##&gt;$1&lt;##/span##&gt;")
		
		/////////////转换为可显示模式
		c=replace(c,"&","&amp;")
		c=replace(c,"<","&lt;")
		c=replace(c,">","&gt;")
		c=replace(c,"&amp;lt;##","<")
		c=replace(c,"##&amp;gt;",">")
		c=replace(c,"'","&#39;")
		c=replace(c,"""","&quot;")
		c=replace(c,"##","'")
		c=replace(c,"###","""")
		c=replace(c,"&lt;!--","<font color=gray>&lt;!--")
		c=replace(c,"--&gt;","--&gt;</font>")
		c=replace(c,"{$","<font color=green >{$")
		c=replace(c,"$}","$}</font>")
		
		ShowLabels=c
		
	End Function


</script>

<script language="javascript">
	function ColorLabels() {  
		var s=frames.message.document.getElementsByTagName("pre")[0];
		var c=s.innerHTML;
		frames.message.document.getElementById("source").innerHTML="<pre>"+ShowLabels(trans_s(trans_h(c)),"")+"</pre>";
	}
</script>
</body>
<!--#include file="admin_end.asp" -->