function Cbold()
{
	if (document.selection && document.selection.type == "Text")
	{
  		var range = document.selection.createRange(); range.text = "[b]" + range.text + "[/b]"; 
	}
	
}

function Citalic()
{
	if(document.selection && document.selection.type=="Text")
	{
		var range=document.selection.createRange();
		range.text="[i]"+range.text+"[/i]";
	}
}	

function Cunder()
{
	if(document.selection && document.selection.type=="Text")
	{
		var range=document.selection.createRange();
		range.text="[u]"+range.text+"[/u]";
	}
}	
function Ccenter()
{
	if(document.selection && document.selection.type=="Text")
	{
		var range=document.selection.createRange();
		range.text="[align=center]"+range.text+"[/align]";
	}

}

function Curl()
{	var turl
	turl=prompt("请输入链接地址","http://")
	if(turl!=null)
	{
		
		turl="[url]"+turl+"[/url]";
		AddText(turl);
	}
}

function Cemail()
{	var teml
	teml=prompt("请输入邮件地址","")
	if(teml!=null)
	{
	if ((teml.indexOf ("@")==-1)||(teml.indexOf (".")==-1)||(teml.lastIndexOf(".")==0)||(teml.lastIndexOf("@")!=teml.indexOf("@")))
		{ alert ("请输入正确的邮件地址!!");
		  return false;
		}
	else	
		{teml="[email]"+teml+"[/email]";
		AddText(teml)
		return true}
		
	}
}

function Cimage()
{	var AddTxt
   var txt=prompt("请输入图像的 URL！例：http://www.joekoe.com/images/logo.gif","http://");    
    if(txt!=null) { AddTxt="\r[IMG]"+txt+"[/IMG]"; AddText(AddTxt);}
}

function Cswf()
{
      txt=prompt("请输入 Flash 动画的地址！","http://");
      if(txt!=null) { AddTxt="\r[FLASH]"+txt+"[/FLASH]"; AddText(AddTxt); }
}
function Cdir()
{
      txt=prompt("请输入 Shockwave音乐文件地址！","http://");
      if(txt!=null) { AddTxt="\r[DIR=500,350]"+txt+"[/DIR]"; AddText(AddTxt); }
}
function Crm()
{	
      txt=prompt("请输入 Realplay 视频文件的地址 rstp://等都支持","http://");
      if(txt!=null) { AddTxt="\r[RM=500,300]"+txt+"[/RM]"; AddText(AddTxt);  }
}
function Cwmv()
{
      txt=prompt(ubb_name+"请输入 Windows Media Player 视频文件的地址，各种地址头都支持！","http://");    
      if(txt!=null) { AddTxt="\r[MP=500,350]"+txt+"[/MP]"; AddText(AddTxt); }
} 

function Cmov()
{
      txt=prompt("请输入QuickTIme音乐文件地址！","http://");
      if(txt!=null) { AddTxt="\r[DIR=500,350]"+txt+"[/DIR]"; AddText(AddTxt); }
}
function Cquote()
{
	if(document.selection && document.selection.type == "Text")
	  { var range = document.selection.createRange(); range.text = "[quote]" + range.text + "[/quote]"; }

}
function Cfly()
{
	if(document.selection && document.selection.type == "Text")
	  { var range = document.selection.createRange(); range.text = "[fly]" + range.text + "[/fly]"; }
}

function Cmarquee()
{
	if(document.selection && document.selection.type == "Text")
	  { var range = document.selection.createRange(); range.text = "[move]" + range.text + "[/move]"; }
}
function Cguang()
{
var stxt,rtxt,ctxt
if(document.selection && document.selection.type == "Text")
{
    stxt=prompt("请输入发光特效的宽度！");
    if (stxt!=null)
    {	rtxt=prompt("请输入颜色");
		if(rtxt!=null)
		{
      		ctxt=prompt("请输入边界宽度");    
		  if(ctxt!=null) 
		  { 
				var range=document.selection.createRange();range.text="[glow="+stxt+","+rtxt+","+ctxt+"]"+range.text+"[/glow]";
			 }
		 }
	  }
    }
}

function Cying()
{
var stxt,rtxt,ctxt
if(document.selection && document.selection.type == "Text")
{
    stxt=prompt("请输入阴影特效的宽度！");
    if (stxt!=null)
    {	rtxt=prompt("请输入颜色");
		if(rtxt!=null)
		{
      		ctxt=prompt("请输入边界宽度");    
		  if(ctxt!=null) 
		  { 
				var range=document.selection.createRange();range.text="[sadow="+stxt+","+rtxt+","+ctxt+"]"+range.text+"[/sadow]";
			 }
		 }
	  }
    }
}

function showfont(font)
{
 if (document.selection && document.selection.type == "Text")
  { var range = document.selection.createRange(); range.text = "[face=" + font + "]" + range.text + "[/face]"; }
}

function showsize(size)
{
 if (document.selection && document.selection.type == "Text")
  { var range = document.selection.createRange(); range.text = "[size=" + size + "]" + range.text + "[/size]"; }
}

function showcolor(color)
{
 if (document.selection && document.selection.type == "Text")
  { var range = document.selection.createRange(); range.text = "[color=" + color + "]" + range.text + "[/color]"; }
}

function insertsmilie(tmpstr)
{
	AddText(tmpstr);
}
function insertAtCaret (textEl, text)
{
  if (textEl.createTextRange && textEl.caretPos)
  {
    var caretPos = textEl.caretPos;
    caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text;
  }
  else if(textEl)
  { textEl.value += text; }
  else
  { textEl.value = text; }
}


function AddText(NewCode)
{
  if(document.all)
  { insertAtCaret(document.form1.contnet, NewCode); setfocus(); } 
  else
  { document.form1.contnet.value += NewCode; setfocus(); }
}	  
