function AddText(NewCode)
	{
	    var txtc
	    txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		txtc.value+=NewCode
	}
function Hor()
	{
	    var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		txtc.value+="\r[hr]----------[/hr]\r"
	}
function email() {
		txt2=prompt("链接显示的文字；\n如果为空，则只显示 Email 地址",""); 
		if (txt2!=null) {
			txt=prompt("请输入Email地址：","name@domain.com");      
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[email]"+txt+"[/email]";
				} else {
					AddTxt="[email="+txt+"]"+txt2;
					AddText(AddTxt);
					AddTxt="[/email]";
				} 
				AddText(AddTxt);	        
			}
		}
}
function flash() {
		txt=prompt("Flash 文件的地址","http://");
		if (txt!=null) {             
			AddTxt="[flash]"+txt;
			AddText(AddTxt);
			AddTxt="[/flash]";
			AddText(AddTxt);
		}        
}
function showsize(size)
	{
		var txt="[size="+size+"]"+document.selection.createRange().text+"[/size]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function bold()
	{
		var txt="[b]"+document.selection.createRange().text+"[/b]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function italicize()
	{
		var txt="[i]"+document.selection.createRange().text+"[/i]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function quote()
	{
		var txt="[quote]"+document.selection.createRange().text+"[/quote]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function showcolor(color)
	{
		var txt="[color="+color+"]"+document.selection.createRange().text+"[/color]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function center() 
	{
		txt2=prompt("对齐样式\n输入 'center' 表示居中, 'left' 表示左对齐, 'right' 表示右对齐.","center");               
		while ((txt2!="") && (txt2!="center") && (txt2!="left") && (txt2!="right") && (txt2!=null))
			{
			txt2=prompt("错误!\n类型只能输入 'center' 、 'left' 或者 'right'.","");               
			}
		txt="\r[align="+txt2+"]"+document.selection.createRange().text+"[/align]";
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function hyperlink() {
		txt2=prompt("链接文本显示.\n如果不想使用, 可以为空, 将只显示超级链接地址. ",""); 
		if (txt2!=null) {
			txt=prompt("超级链接.","http://");      
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[url]"+txt;
					AddText(AddTxt);
					AddTxt="[/url]";
					AddText(AddTxt);
				} else {
					AddTxt="[url="+txt+"]"+txt2;
					AddText(AddTxt);
					AddTxt="[/url]";
					AddText(AddTxt);
				}         
			} 
		}
}
function image() {
		txt=prompt("图片的 URL","http://");    
		if(txt!=null) {            
			AddTxt="\r[img]"+txt;
			AddText(AddTxt);
			AddTxt="[/img]";
			AddText(AddTxt);
		}	
}
function list() {
		txt=prompt("列表类型\n输入 'a' 表示字母序列, '1' 表示数字序列, 留空表示无序列表.","");               
		while ((txt!="") && (txt!="a") && (txt!="1") && (txt!=null)) {
			txt=prompt("错误!\n类型只能输入 'a' 、 '1' 或者留空.","");               
		}
		if (txt!=null) {
			if (txt=="") {
				AddTxt="[list]";
			} else {
				AddTxt="[list="+txt+"]";
			} 
			txt="1";
			while ((txt!="") && (txt!=null)) {
				txt=prompt("列表项\n空白表示结束列表",""); 
				if (txt!="") {             
					AddTxt+="[*]"+txt+"[/*]"; 
				}                   
			} 
			AddTxt+="[/list] ";
			AddText(AddTxt); 
		}
}
function showfont(font)
	{
		var txt="[face="+font+"]"+document.selection.createRange().text+"[/face]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function ReplaceTxt (txtcontent,text)//插入\替换字符
		{
			var txt=document.selection.createRange().text; 
			if (txt!='') {
				document.getElementById('ctl00_ContentPlaceHolder1_txtcontent').value=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent').value.replace(txt,text);
			} else {
				//insertAtCaret(txtcontent,text)
				alert("请选择相应的文字后再试！");
				return false;
			}
		} 
function insertAtCaret (textEl, text) //Error????!!!!
		{
			if (textEl.createTextRange && textEl.caretPos) 
			{
				var caretPos = textEl.caretPos;
				caretPos.text =caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?text + ' ' : text; 
			} else {
				textEl.value = text;
			}
		} 
  
function underline() 
	{
		var txt="[u]"+document.selection.createRange().text+"[/u]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function setfly() 
	{
		var txt="[fly]"+document.selection.createRange().text+"[/fly]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function move()
	{
		var txt="[move]"+document.selection.createRange().text+"[/move]"; 
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function shadow()
	{
		txt2=prompt("文字的长度、颜色和边界大小。格式如下：","255,blue,1"); 
		if (txt2!=="")
		{
			txt="[SHADOW=255, blue, 1]"+document.selection.createRange().text+"[/SHADOW]"; 
		} else {
			txt="[SHADOW="+txt2+"]"+document.selection.createRange().text+"[/SHADOW]"; 
		}
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function glow()
	{
		txt2=prompt("文字的长度、颜色和边界大小。格式如下：","255,red,2"); 
		if (txt2!=="")
		{
			txt="[glow=255,red,2]"+document.selection.createRange().text+"[/glow]"; 
		} else {
			txt="[glow="+txt2+"]"+document.selection.createRange().text+"[/glow]"; 
		}
		var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
		ReplaceTxt(txtc,txt)
	}
function insertstr(str)
	{
		AddText(str);
	}
function recordContent()
	{
	    var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
	    var txt1=document.getElementById('displaya');
        txt1.value = txtc.value.length;
     }
function clears()
	{
	    var txtc=document.getElementById('ctl00_ContentPlaceHolder1_txtcontent');
        txtc.value="";
     }
function time_rota() 
{ 
	tim.innerText=parseInt(tim.innerText)-1;
	setTimeout( 'time_rota()', 1000);
} 
function closeit(){
	setTimeout("window.opener=null;self.close();",25000);
	tim.innerText=26
	time_rota();
}
