var text = "";
var Emot_type = ".gif";

function DoTitle(addTitle) {
  var revisedTitle;
  var currentTitle = document.form.titles.value;
  revisedTitle = currentTitle+addTitle;
  document.form.titles.value=revisedTitle;
  document.form.titles.focus();
  return;
 } 
 

function presskey(evt){
var i=0;
evt = evt ? evt : (window.event ? window.event : null);

if(evt.ctrlKey && evt.keyCode==13){i++;if (i>1) {alert('The topic had send. Please wait...');return false;}
document.form.submit();
}
}


function getActiveText(selectedtext) { 
	text = (document.all) ? document.selection.createRange().text : document.getSelection();
	if (selectedtext.createTextRange) {	
    selectedtext.caretPos = document.selection.createRange().duplicate();	
  }
	return true;
}

function AddText(NewCode) {
	if (document.form.article_content.createTextRange && document.form.article_content.caretPos) {
		var caretPos = document.form.article_content.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
	} 
  else {
		document.form.article_content.value+=NewCode
	}
	setfocus();
}

function setfocus() {
  document.form.article_content.focus();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function bold() {
	AddTxt="[b]"+text+"[/b]";
	AddText(AddTxt);	
}

function italicize() {
	AddTxt="[i]"+text+"[/i]";
	AddText(AddTxt);
}
function underline() {
	AddTxt="[u]"+text+"[/u]";
	AddText(AddTxt);
}
function hyperlink() {
	AddTxt="[url]"+text+"[/url]";
	AddText(AddTxt);
}

function fly() {
	AddTxt="[fly]"+text+"[/fly]";
	AddText(AddTxt);
}
function marquee() {
	AddTxt="[marquee]"+text+"[/marquee]";
	AddText(AddTxt);
}

function image() {
	AddTxt="[img]"+text+"[/img]";
	AddText(AddTxt);
}
function flash() {
	AddTxt="[swf]"+text+"[/swf]";
	AddText(AddTxt);
}

function wmv() {
	AddTxt="[wmv]"+text+"[/wmv]";
	AddText(AddTxt);
}
function rm() {
	AddTxt="[rm]"+text+"[/rm]";
	AddText(AddTxt);
}

function quote() {
	AddTxt="[quote]"+text+"[/quote]";
	AddText(AddTxt);
}

function showsize(size) {
	AddTxt="[size="+size+"]"+text+"[/size]";
	AddText(AddTxt);
	document.form.size.value = "";
}

function showcolor(color) {
	AddTxt="[color="+color+"]"+text+"[/color]";
	AddText(AddTxt);
	document.form.color.value = "";
}

function ShowForum_Emot(thepage)
{
	var Emot_PageCount;
	if(Emot_Count%Emot_PageSize==0)
	{
		Emot_PageCount=(Emot_Count)/Emot_PageSize
	}else{
		Emot_PageCount=Math.floor((Emot_Count)/Emot_PageSize)+1
	}
	if (thepage<=Emot_PageCount){
	var istr
	var istrrq
	var EmotStr='&nbsp;';
	var EmotPath=Forum_Emot[0];
	if (thepage!=1 && Emot_PageCount>1)
	{EmotStr+='<img style="cursor: pointer;" onClick="ShowForum_Emot('+(thepage-1)+');" src="'+ruan_page+'Previous.gif" width="14" height="14" title="上一页">&nbsp;&nbsp;&nbsp;&nbsp;';}
else
	{EmotStr+='<img style="cursor: pointer;" src="'+ruan_page+'Previous0.gif" width="14" height="14" title="首页">&nbsp;&nbsp;&nbsp;&nbsp;';}
		for(i=(thepage-1)*Emot_PageSize;i<(thepage-1)*Emot_PageSize+Emot_PageSize;i++)
	{
		if (i==Emot_Count){break}
		istr='表情: '+Forum_Emot[i+1]
		istrrq='[CCB]'+Forum_Emot[i+1]+'[/CCB]'
		EmotStr+='<img title="'+istr+'" style="cursor: pointer;" onClick=AddText("'+istrrq+'"); src="'+EmotPath+Forum_Emot[i+1]+Emot_type+'">&nbsp;';
	}
	if (thepage!=Emot_PageCount)
	{EmotStr+='&nbsp;&nbsp;&nbsp;&nbsp;<img style="cursor: pointer;" onClick="ShowForum_Emot('+(thepage+1)+');" src="'+ruan_page+'Next.gif" width="14" height="14" title="下一页">&nbsp;';}
else	{EmotStr+='&nbsp;&nbsp;&nbsp;&nbsp;<img style="cursor: pointer;" src="'+ruan_page+'Next0.gif" width="14" height="14" title="末页">&nbsp;';}
	EmotStr+='第<b> '+thepage+' </b>页,共<b> '+Emot_PageCount+' </b>页<b> '+(Emot_Count)+' </b>个';
	var Forum_EmotObj=document.getElementById("emot")
	Forum_EmotObj.innerHTML=EmotStr;
	}
}
function rrqshowall(){
	var out = "";
	var allr
	var allrrq
	var i
	for(i=0;i<Emot_Count;i++)
	{
		allr='表情: '+Forum_Emot[i+1]
		allrrq='[CCB]'+Forum_Emot[i+1]+'[/CCB]'

		out+='<img title="'+allr+'" style="cursor: pointer;" onClick=AddText("'+allrrq+'"); src="'+EmotPath+Forum_Emot[i+1]+Emot_type+'"> '

	}
	var Forum_EmotObj=document.getElementById("emot")
	Forum_EmotObj.innerHTML=out;
}
function qiaoshow(){
	var ourt ='<iframe name="qiaozui" src="'+ruan_page+'/qiaozui/index.htm" height="51" width="551" scrolling="no" frameborder=0 marginwidth="1" marginheight="1" allowtransparency="true">浏览器不支持嵌入式框架，或被配置为不显示嵌入式框架。</iframe>'
	var Forum_EmotObj=document.getElementById("emot")
	Forum_EmotObj.innerHTML=ourt;
}
function magicshow(){
	var ourt ='<iframe name="magic" src="'+ruan_page+'/magic/index.html" height="100" width="551" scrolling="no" frameborder=0 marginwidth="1" marginheight="1" allowtransparency="true">浏览器不支持嵌入式框架，或被配置为不显示嵌入式框架。</iframe>'
	var Forum_EmotObj=document.getElementById("emot")
	Forum_EmotObj.innerHTML=ourt;
}
