function showb(){
fontbegin="[b]";
fontend="[/b]";
fontchuli();
}

function showi(){
fontbegin="[i]";
fontend="[/i]";
fontchuli();
}

function showu(){
fontbegin="[u]";
fontend="[/u]";
fontchuli();
}

function showc(){
fontbegin="[center]";
fontend="[/center]";
fontchuli();
}

function showl(){
fontbegin="[left]";
fontend="[/left]";
fontchuli();
}

function showr(){
fontbegin="[right]";
fontend="[/right]";
fontchuli();
}

function showcode(){
fontbegin="[code]";
fontend="[/code]";
fontchuli();
}

function showmdown(){
fontbegin="[mdown=]";
fontend="[/mdown]";
fontchuli();
}

function showurl(url){
fontbegin="[url=]";
fontend="[/url]";
fontchuli();
}
function showimg(){
fontbegin="[img]";
fontend="[/img]";
fontchuli();
}

function showmp(){
fontbegin="[mp=400,300]";
fontend="[/mp]";
fontchuli();
}

function showrm(){
fontbegin="[rm=400,300]";
fontend="[/rm]";
fontchuli();
}

function showflash(){
fontbegin="[swf=400,300";
fontend="[/swf]";
fontchuli();
}

function showsize(size){
fontbegin="[size="+size+"]";
fontend="[/size]";
fontchuli();
}

function showfont(font){
fontbegin="[face="+font+"]";
fontend="[/face]";
fontchuli();
}

function showcolor(color){
fontbegin="[color="+color+"]";
fontend="[/color]";
fontchuli();
}

function fontchuli(){
if ((document.selection)&&(document.selection.type == "Text")) {
var range = document.selection.createRange();
var ch_text=range.text;
range.text = fontbegin + ch_text + fontend;
} 
else {
document.form1.content.value=fontbegin+document.form1.content.value+fontend;
document.form1.content.focus();
}
}





//表情分页
var pageSize=28;//每页显示表情数
var recordCount=81;//总表情数
var pageCount=(recordCount+pageSize-1)/pageSize;//页数

function ubbshowface()
{
  var facediv=document.getElementById('ubbface');
  var tmpstr="";
  if(facediv.style.display!="none")
  {
	  facediv.innerHTML="";
	  facediv.style.display="none";
  }else{
      facediv.style.display="block";
  }
  
  facediv.innerHTML=showFace(1)+showPage(1);
}

function reloadFace(i)
{
	document.getElementById('ubbface').innerHTML=showFace(i)+showPage(i);
}

function showFace(currentPage)
{
	var faceHTML="";
	faceHTML+="<div id=\"showFaceDiv\">";
	for(var p=(currentPage-1)*pageSize+1;p<=currentPage*pageSize;p++)
	{
		faceHTML+='<a href=javascript:insertubbface("[face'+p+']");><img src=images/smilies/em'+p+'.gif border=0></a>';
		if(p>=recordCount)break;
	}
	faceHTML+="</div>";
	
	return faceHTML;
	
}
function showPage(currentPage)
{
	var pageHTML="";
	pageHTML+="<div>";
	if(currentPage==1)
	{
		pageHTML+=" <font face=webdings>9</font> <font face=webdings>7</font> ";
	}
	else
	{
		pageHTML+=" <a href='javascript:reloadFace("+1+")'><font face=webdings>9</font></a> <a href='javascript:reloadFace("+(currentPage-1)+")'><font face=webdings>7</font></a> ";
	}
	for(var p=1;p<=pageCount;p++)
	{
		pageHTML+=" <a href='javascript:reloadFace("+p+")'>"+p+"</a> ";
	}
	if(currentPage==pageCount)
	{
		pageHTML+=" <font face=webdings>8</font> <font face=webdings>:</font> ";
	}
	else
	{
		pageHTML+=" <a href='javascript:reloadFace("+(currentPage+1)+")'><font face=webdings>8</font></a> <a href='javascript:reloadFace("+pageCount+")'><font face=webdings>:</font></a> ";
	}
	pageHTML+="</div>";
	return pageHTML;
	
}






function playmedia(strType,strID,strURL,intWidth,intHeight)
{
	var objdiv=document.getElementById(strID);
	var objid=document.getElementById('m'+strID);
	var tmpstr="";
	if(objdiv.style.display!="none"){
		objdiv.innerHTML ="";
		objdiv.style.display="none";
		objid.style.background="url(images/mv_on.gif) no-repeat";
	}else{
		switch(strType){
			case "swf":
				tmpstr='<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+intWidth+'" height="'+intHeight+'"><param name="movie" value="'+strURL+'" /><param name="quality" value="high" /><param name="AllowscriptAccess" value="never" /><embed src="'+strURL+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+intWidth+'" height="'+intHeight+'" /></object>';
				objid.style.background="url(images/mv_off.gif) no-repeat";
				objdiv.style.display="block";
				break;
			case "mp":
				tmpstr='<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" type="application/x-oleobject" standby="Loading..." width="'+intWidth+'" height="'+intHeight+'"><param name="FileName" VALUE="'+strURL+'" /><param name="ShowStatusBar" value="-1" /><param name="AutoStart" value="true" /><PARAM NAME=loop value=True/><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+strURL+'" autostart="true" width="'+intWidth+'" height="'+intHeight+'" /></object>';
				objid.style.background="url(images/mv_off.gif) no-repeat";
				objdiv.style.display="block";
				break;
			case "rm":
				tmpstr='<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'+intWidth+'" height="'+intHeight+'"><param name="SRC" value="'+strURL+'" /><param name="CONTROLS" VALUE="ImageWindow" /><param name="CONSOLE" value="one" /><param name="AUTOSTART" value="true" /><embed src="'+strURL+'" nojava="true" controls="ImageWindow" console="one" width="'+intWidth+'" height="'+intHeight+'"></object>'+'<br /><object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'+intWidth+'" height="32" /><param name="CONTROLS" value="StatusBar" /><param name="AUTOSTART" value="true" /><param name="CONSOLE" value="one" /><embed src="'+strURL+'" nojava="true" controls="StatusBar" console="one" width="'+intHeight+'" height="24" /></object>'+'<br /><object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'+intWidth+'" height="32" /><param name="CONTROLS" value="ControlPanel" /><param name="AUTOSTART" value="true" /><param name="CONSOLE" value="one" /><embed src="'+strURL+'" nojava="true" controls="ControlPanel" console="one" width="'+intHeight+'" height="24" autostart="true" loop="false" /></object>';
				objid.style.background="url(images/mv_off.gif) no-repeat";
			    objdiv.style.display="block";
		}
		objdiv.innerHTML = tmpstr;
	}
}
function ubbface(str){
  var contentstr=document.getElementById('content');
  if(contentstr){
    if(contentstr.value!=''&&contentstr.value!=null){
	  contentstr.value+=str;
	}
	else{
	  contentstr.value=str;
	}
  }
}
function insertubbface(strcode) {
        if(document.all){
        	inserttext(document.form1.content, strcode);
        	document.form1.content.focus();
        } else{
        	document.form1.content.value += strcode;
        	document.form1.content.focus();
        }
}
function inserttext (strEl, text){
        if (strEl.createTextRange && strEl.caretPos){
                var caretPos = strEl.caretPos;
                caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text;
        } else if(strEl) {
                strEl.value += text;
        } else {
        	strEl.value = text;
        }
}
function storeCaret (strEl){
        if(strEl.createTextRange){
                strEl.caretPos = document.selection.createRange().duplicate();
        }
}


