// UBB by qzenet
var Quote = 0;
var Bold  = 0;
var Italic = 0;
var Underline = 0;
var Code = 0;
var Center = 0;
var Strike = 0;
var Sound = 0;
var Swf = 0;
var Ra = 0;
var Rm = 0;
var Marquee = 0;
var Fly = 0;
var fanzi=0;
var text_enter_url      = "請輸入連接網址";
var text_enter_txt      = "請輸入連接說明";
var text_enter_image    = "請輸入圖片網址";
var text_enter_sound    = "請輸入聲音文件網址";
var text_enter_swf      = "請輸入FLASH動畫網址";
var text_enter_ra       = "請輸入Real音樂網址";
var text_enter_rm       = "請輸入Real影片網址";
var text_enter_wmv      = "請輸入Media影片網址";
var text_enter_wma      = "請輸入Media音樂網址";
var text_enter_mov      = "請輸入QuickTime音樂網址";
var text_enter_sw       = "請輸入shockwave音樂網址";
var text_enter_email    = "請輸入郵件網址";
var error_no_url        = "您必須輸入網址";
var error_no_txt        = "您必須連接說明";
var error_no_title      = "您必須輸入首頁標題";
var error_no_email      = "您必須輸入郵件網址";
var error_no_gset       = "必須正確按照各式輸入！";
var error_no_gtxt       = "必須輸入文字！";
var text_enter_guang1   = "文字的長度、顏色和邊界大小";
var text_enter_guang2   = "要產生效果的文字！";
function commentWrite(NewCode) {
document.FrontPage_Form1.Content.value+=NewCode;
document.FrontPage_Form1.Content.focus();
return;
}
ie = (document.all)? true:false
if (ie){
function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13){this.document.FrontPage_Form1.submit();}}
}

function storeCaret(text) { 
	if (text.createTextRange) {
		text.caretPos = document.selection.createRange().duplicate();
	}
        if(event.ctrlKey && window.event.keyCode==13){i++;if (i>1) {alert('帖子正在發出，請耐心等待！');return false;}this.document.form.submit();}
}
function AddText(text) {
	if (document.FrontPage_Form1.Content.createTextRange && document.FrontPage_Form1.Content.caretPos) {      
		var caretPos = document.FrontPage_Form1.Content.caretPos;      
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text + ' ' : text;
	}
	else document.FrontPage_Form1.Content.value += text;
	document.FrontPage_Form1.Content.focus(caretPos);
}

function inputs(str)
{
AddText(str);
}

function Curl() {
var FoundErrors = '';
var enterURL   = prompt(text_enter_url, "http://");
var enterTxT   = prompt(text_enter_txt, enterURL);
if (!enterURL)    {
FoundErrors += "\n" + error_no_url;
}
if (!enterTxT)    {
FoundErrors += "\n" + error_no_txt;
}
if (FoundErrors)  {
alert("錯誤！"+FoundErrors);
return;
}
var ToAdd = "[URL="+enterURL+"]"+enterTxT+"[/URL]";
document.FrontPage_Form1.Content.value+=ToAdd;
document.FrontPage_Form1.Content.focus();
}

function Cimage() 
{
var FoundErrors = '';
var enterURL   = prompt(text_enter_image, "http://");
if (!enterURL) {
FoundErrors += "\n" + error_no_url;
}
if (FoundErrors) 
{
alert("錯誤！"+FoundErrors);
return;
}
var ToAdd = "[IMG]"+enterURL+"[/IMG]";
document.FrontPage_Form1.Content.value+=ToAdd;
document.FrontPage_Form1.Content.focus();
}

function Cemail() {
var emailAddress = prompt(text_enter_email,"");
if (!emailAddress) { alert(error_no_email); return; }
var ToAdd = "[EMAIL]"+emailAddress+"[/EMAIL]";
commentWrite(ToAdd);
}

function Ccode() {
fontbegin="[CODE]";
fontend="[/CODE]";
fontchuli();
}

function Cquote() {
fontbegin="[QUOTE]";
fontend="[/QUOTE]";
fontchuli();
}

function Cbold() {
fontbegin="[B]";
fontend="[/B]";
fontchuli();
}

function Citalic() {
fontbegin="[I]";
fontend="[/I]";
fontchuli();
}

function Cunder() {
fontbegin="[U]";
fontend="[/U]";
fontchuli();
}

function Ccenter() {
fontbegin="[align=center]";
fontend="[/align]";
fontchuli();
}

function Cstrike() {
fontbegin="[strike]";
fontend="[/strike]";
fontchuli();
}

function Csound(){
var FoundErrors = '';
var enterURL   = prompt(text_enter_sound, "http://");
if (!enterURL) {
FoundErrors += "\n" + error_no_url;
}
if (FoundErrors) {
alert("錯誤！"+FoundErrors);
return;
}
var ToAdd = "[SOUND]"+enterURL+"[/SOUND]";
document.FrontPage_Form1.Content.value+=ToAdd;
document.FrontPage_Form1.Content.focus();
}

helpstat = false;
stprompt = true;
basic = false;

function thelp(swtch){
	if (swtch == 1){
		basic = false;
		stprompt = false;
		helpstat = true;
	} else if (swtch == 0) {
		helpstat = false;
		stprompt = false;
		basic = true;
	} else if (swtch == 2) {
		helpstat = false;
		basic = false;
		stprompt = true;
	}
}

function Cswf() {
        if (helpstat){
                alert("Flash\nFlash 動畫.\n用法: [swf]Flash 文件的地址[/swf]");
        } else if (basic) {
                AddTxt="[swf] [/swf]";
                AddText(AddTxt);
        } else {  
                txt=prompt("Flash 文件的地址","http://");
                if (txt!=null) {            
                        AddTxt="\r[swf]"+txt;
                        AddText(AddTxt);
                        AddText("[/swf]");
                }       
        }
}

function Crm(){
	if (helpstat) {
               alert("realplay\n播放realplay文件.\n用法: [rm=寬度, 高度]文件地址[/rm]");
	} else if (basic) {
		AddTxt="[rm=400,20][/rm]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("視頻的寬度，高度","400,20"); 
		if (txt2!=null) {
			txt=prompt("視頻文件的地址","請輸入");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[rm=400,300]"+txt;
					AddText(AddTxt);
					AddTxt="[/rm]";
					AddText(AddTxt);
				} else {
					AddTxt="[rm="+txt2+"]"+txt;
					AddText(AddTxt);
					AddTxt="[/rm]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}

function Cwmv(){
	if (helpstat) {
               alert("Media Player\n播放Media Player文件.\n用法: [mp=寬度, 高度]文件地址[/mp]");
	} else if (basic) {
		AddTxt="[mp=400,300][/mp]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("視頻的寬度，高度","400,70"); 
		if (txt2!=null) {
			txt=prompt("視頻文件的地址","請輸入");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[mp=400,70]"+txt;
					AddText(AddTxt);
					AddTxt="[/mp]";
					AddText(AddTxt);
				} else {
					AddTxt="[mp="+txt2+"]"+txt;
					AddText(AddTxt);
					AddTxt="[/mp]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}

function Cmov(){
	if (helpstat) {
               alert("QuickTime\n播放QuickTime文件.\n用法: [qt=寬度, 高度]文件地址[/qt]");
	} else if (basic) {
		AddTxt="[qt=400,300][/qt]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("視頻的寬度，高度","400,300"); 
		if (txt2!=null) {
			txt=prompt("視頻文件的地址","請輸入");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[qt=400,300]"+txt;
					AddText(AddTxt);
					AddTxt="[/qt]";
					AddText(AddTxt);
				} else {
					AddTxt="[qt="+txt2+"]"+txt;
					AddText(AddTxt);
					AddTxt="[/qt]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}

function Cdir(){
	if (helpstat) {
               alert("Shockwave\n插入Shockwave文件.\n用法: [dir=寬度, 高度]文件地址[/dir]");
	} else if (basic) {
		AddTxt="[dir=400,300][/dir]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("Shockwave文件的寬度，高度","400,300"); 
		if (txt2!=null) {
			txt=prompt("Shockwave文件的地址","請輸入地址");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[dir=400,300]"+txt;
					AddText(AddTxt);
					AddTxt="[/dir]";
					AddText(AddTxt);
				} else {
					AddTxt="[dir="+txt2+"]"+txt;
					AddText(AddTxt);
					AddTxt="[/dir]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}



function Cra(){
var FoundErrors = '';
var enterURL   = prompt(text_enter_ra, "http://");
if (!enterURL) {
FoundErrors += "\n" + error_no_url;
}
if (FoundErrors) {
alert("錯誤！"+FoundErrors);
return;
}
var ToAdd = "[RA]"+enterURL+"[/RA]";
document.FrontPage_Form1.Content.value+=ToAdd;
document.FrontPage_Form1.Content.focus();
}

function Cfanzi(){
fontbegin="[xray]";
fontend="[/xray]";
fontchuli();
}

function Cwma(){
var FoundErrors = '';
var enterURL   = prompt(text_enter_wma, "http://");
if (!enterURL) {
FoundErrors += "\n" + error_no_url;
}
if (FoundErrors) {
alert("錯誤！"+FoundErrors);
return;
}
var ToAdd = "[wma]"+enterURL+"[/wma]";
document.FrontPage_Form1.Content.value+=ToAdd;
document.FrontPage_Form1.Content.focus();
}

function Cwmv(){
var FoundErrors = '';
var enterURL   = prompt(text_enter_wma, "http://");
if (!enterURL) {
FoundErrors += "\n" + error_no_url;
}
if (FoundErrors) {
alert("錯誤！"+FoundErrors);
return;
}
var ToAdd = "[wmv]"+enterURL+"[/wmv]";
document.FrontPage_Form1.Content.value+=ToAdd;
document.FrontPage_Form1.Content.focus();
}

function Cmarquee(){
fontbegin="[move]";
fontend="[/move]";
fontchuli();
}

function Cfly(){
fontbegin="[fly]";
fontend="[/fly]";
fontchuli();
}

function paste(text){
	if (opener.document.FrontPage_Form1.Content.createTextRange && opener.document.FrontPage_Form1.Content.caretPos) {      
		var caretPos = opener.document.FrontPage_Form1.Content.caretPos;      
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text + ' ' : text;
	}
	else opener.document.FrontPage_Form1.Content.value += text;
	opener.document.FrontPage_Form1.Content.focus(caretPos);
}

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.FrontPage_Form1.Content.value=fontbegin+document.FrontPage_Form1.Content.value+fontend;
document.FrontPage_Form1.Content.focus();
}
}

function Cguang(){
var FoundErrors = '';
var enterSET   = prompt(text_enter_guang1, "255,red,2");
var enterTxT   = prompt(text_enter_guang2, "文字");
if (!enterSET)    {
FoundErrors += "\n" + error_no_gset;
}
if (!enterTxT)    {
FoundErrors += "\n" + error_no_gtxt;
}
if (FoundErrors)  {
alert("錯誤！"+FoundErrors);
return;
}
var ToAdd = "[glow="+enterSET+"]"+enterTxT+"[/glow]";
document.FrontPage_Form1.Content.value+=ToAdd;
document.FrontPage_Form1.Content.focus();
}

function Cying(){
var FoundErrors = '';
var enterSET   = prompt(text_enter_guang1, "255,blue,1");
var enterTxT   = prompt(text_enter_guang2, "文字");
if (!enterSET)    {
FoundErrors += "\n" + error_no_gset;
}
if (!enterTxT)    {
FoundErrors += "\n" + error_no_gtxt;
}
if (FoundErrors)  {
alert("錯誤！"+FoundErrors);
return;
}
var ToAdd = "[SHADOW="+enterSET+"]"+enterTxT+"[/SHADOW]";
document.FrontPage_Form1.Content.value+=ToAdd;
document.FrontPage_Form1.Content.focus();
}

function DoTitle(addTitle){ 
var revisedTitle; 
var currentTitle = document.FrontPage_Form1.subject.value; 
revisedTitle = currentTitle+addTitle; 
document.FrontPage_Form1.subject.value=revisedTitle; 
document.FrontPage_Form1.subject.focus(); 
return; 
}

function insertsmilie(smilieface){

	document.FrontPage_Form1.Content.value+=smilieface;
}

function DoTitle(addTitle){
document.FrontPage_Form1.title.value=addTitle+document.FrontPage_Form1.title.value
document.FrontPage_Form1.title.focus();
return (false);
}

function FontType(HeadValue,FooterValue){
	document.FrontPage_Form1.Content.value=HeadValue+document.FrontPage_Form1.Content.value+FooterValue
	document.FrontPage_Form1.Content.focus();
	return (false);
}

function blogquote(objID,strAuthor,strTime){
	document.FrontPage_Form1.Content.value += "[quote][b]最初由 [color=blue]"+strAuthor+"[/color] 發表於 "+strTime+"：[/b]\n"+document.getElementById(objID).innerText+"[/quote]";
        document.FrontPage_Form1.Content.focus();
}

