<!--
function storeCaret(text) { 
	if (text.createTextRange) {
		text.caretPos = document.selection.createRange().duplicate();
	}
}

function addText(text) {
	var myContent =  document.add_article.Content;
	if(document.all)
	{
		if (document.add_article.Content.createTextRange && document.add_article.Content.caretPos) {      
			var caretPos = document.add_article.Content.caretPos;      
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
			text + ' ' : text;
		}
		else document.add_article.Content.value += text;
		document.add_article.Content.focus(caretPos)
	}else
	{	
            var startPos = document.add_article.Content.selectionStart;
            var endPos = document.add_article.Content.selectionEnd;
            var chaineBBCode = document.add_article.Content.value;

            myContent.value = chaineBBCode.substring(0, startPos) + text + chaineBBCode.substring(endPos, chaineBBCode.length);
		
	}//end if	
}
 /* function addText(text)
  {
    var obj = document.add_article;  
    var Content = obj.Content.value;
	obj.Content.value = Content + text;
	
	  var insert=document.getElementById("BBCodeContent").value;
	  switch(bbcode)
	  {
		  case B:
		  		insert = "[b]"+insert+"[/b]";
		  break;
	  }//end switch
	  addText(insert);	  
	
  }*/

  function BBCodeWinShow(bbcode)
  {
	  var BBCodeDiv=document.getElementById("BBCode");
	  BBCodeDiv.style.display="";
	  
	  var CodeStr = bbcode;
	  var insert;
	  var explain; 
	  switch(CodeStr)
	  {
		  case B:
		  		insert = "[b]請在此填入內容[/b]";
				explain = "將文字內容變成 <b>粗體</b> !!";
				example = "[b]粗體[/b]";
		  break
		  case I:
		  		insert = "[i]請在此填入內容[/i]";
				explain = "將文字內容變成 <i>斜體</i> !!";
				example = "[i]斜體[/i]";
		  break
		  case U:
		  		insert = "[u]請在此填入內容[/u]";
				explain = "在文字內容下加上 <u>底線</u> !!";
				example = "[u]底線[/u]";
		  break
		  //顏色碼部分 ##############################################################
		  case 1:
		  		insert = "[red]請在此填入內容[/red]";
				explain = "文字內容變成 <span style='color:red'>紅色</span> !!";
				example = "[red]紅色[/red]";
		  break
		  case 2:
		  		insert = "[blue]請在此填入內容[/blue]";
				explain = "文字內容變成 <span style='color:blue'>藍色</span> !!";
				example = "[blue]藍色[/blue]";
		  break
		  case 3:
		  		insert = "[green]請在此填入內容[/green]";
				explain = "文字內容變成 <span style='color:green'>綠色</span> !!";
				example = "[green]綠色[/green]";
		  break
		  case 4:
		  		insert = "[gray]請在此填入內容[/gray]";
				explain = "文字內容變成 <span style='color:gray'>灰色</span> !!";
				example = "[gray]灰色[/gray]";				
		  break
		  case 5:
		  		insert = "[white]請在此填入內容[/white]";
				explain = "文字內容變成 <span style='color:white'>白色</span> !!";
				example = "[white]白色[/white]";				
		  break
		  case 6:
		  		insert = "[maq]請在此填入內容[/maq]";
				explain = "<marquee style='width:200px' onMouseOver=stop(); onMouseOut=start();>文字內容變成跑馬燈</marquee>";
				example = "[maq]跑馬燈[/maq]";				
		  break
		  
	  }//end switch
	 document.getElementById("BBCodeContent").value = insert; 
	 document.getElementById("BBCodeExplain").innerHTML = explain;
	 document.getElementById("BBCodeExample").innerHTML = example;
  }

  function BBCodeWinInsert()
  {
	  var BBCodeDiv=document.getElementById("BBCode");
	  var Code=document.getElementById("BBCodeContent").value;
			 
	  addText(Code);
	  BBCodeDiv.style.display="none";
  }
  
  function BBCodeWinClose()
  {
	  var BBCodeDiv=document.getElementById("BBCode");
	  BBCodeDiv.style.display="none";
  }
  

  function B()
  {
	BBCodeWinShow(B);	
  }
  
  function I()
  {
	BBCodeWinShow(I);
  }  
  
  function U()
  {
	BBCodeWinShow(U);
  }  
  
  function Red()
  {
	BBCodeWinShow(1);
  } 
  
  function Blue()
  {
	BBCodeWinShow(2);
  }   
  
  function Green()
  {
	BBCodeWinShow(3);
  } 
  
  function Gray()
  {
    BBCodeWinShow(4);
  }   
  
  function White()
  {
	BBCodeWinShow(5);
  }  
  
  function Move()
  {
	BBCodeWinShow(6);
  } 
    
  function Img()
  {
    var insert=prompt("請填入圖片所在網址", "");
	Code = "[img]"+insert+"[/img]";    
	addText(Code);
  }

  function Url()
  {    
	Code = "[url]輸入網址[/url]";
	addText(Code);
  }  

  function Email()
  {
    var insert=prompt("請填入 e-mail", "");	  
	Code = "[email]"+insert+"[/email]";        
	addText(Code);
  }  

  function Quote()
  {
    Code = "[quote]請輸入引用文字[/quote]";
	addText(Code);
  }
  
  function Bq()
  {
    Code = "[bq][/bq]";
	addText(Code);
  }  

  function Move2()
  {
    Code = "[maq2][/maq2]";
	addText(Code);
  } 

  function Url2()
  {
    Code = "[url2]輸入網址[str]輸入網站名稱[/url2]";
	addText(Code);
  }  
  
  function hr()
  {
    Code = "[hr]";
	addText(Code);
  } 
// facial icon ##################################################################### start
   
  function smiley()
  {
    Code = "mtmd:)";
	addText(Code);
  } 
  function wink()
  {
    Code = "mtmd;)";
	addText(Code);
  } 

  function cheesy()
  {
    Code = "mtmd:D";
	addText(Code);
  } 

  function grin()
  {
    Code = "mtmd;D";
	addText(Code);
  } 

  function angry()
  {
    Code = "mtmd〉:(";
	addText(Code);
  } 

  function sad()
  {
    Code = "mtmd:(";
	addText(Code);
  } 

  function shocked()
  {
    Code = "mtmd:o";
	addText(Code);
  } 

  function cool()
  {
    Code = "mtmd8)";
	addText(Code);
  }
  
  function huh()
  {
    Code = "mtmd???";
	addText(Code);
  } 

  function rolleyes()
  {
    Code = "mtmd::)";
	addText(Code);
  }          
  <!--08-14-2003 Add-->
  function tongue()
  {
    Code = "mtmd:P";
	addText(Code);
  }  
          
  function embarassed()
  {
    Code = "mtmd:-[";
	addText(Code);
  }              
  
  function lipsrsealed()
  {
    Code = "mtmd:-X";
	addText(Code);
  }
            
    function undecided()
  {
    Code = "mtmd:-i";
	addText(Code);
  }
            
    function kiss()
  {
    Code = "mtmd:-*";
	addText(Code);
  }
 /*            
    function cry()
  {
    Code = "mtmd:'(";
	addText(Code);
  }*/ 
  
    function cry()
  {
    Code = "mtmd!_!";
	addText(Code);
  } 
  
  <!--08-17-2003 #####################################################################-->
     function size()
  {
    Code = "[fs=12][/fs]";
	addText(Code);
  } 

     function fontstrike()
  {
    Code = "[strike][/strike]";
	addText(Code);
  }                                               
  
     function Orange()
  {
    Code = "[orange][/orange]";
	addText(Code);
  }  
  <!--Sup、Sup ######################################################################--> 
     function Sup()
  {
    Code = "[sup][/sup]";
	addText(Code);
  }  

     function Sub()
  {
    Code = "[sub][/sub]";
	addText(Code);
  }  

     function table()
  {
    Code = "[table][tr][td][/td][/tr][/table]";
	addText(Code);
  }  

     function tr()
  {
    Code = "[tr][/tr]";
	addText(Code);
  }  

     function td()
  {
    Code = "[td][/td]";
	addText(Code);
  }  
  <!--08-17-2003 #######################################################-->
     function wave()
  {
    Code = "mtmd^^y";
	addText(Code);
  }  

     function clap()
  {
    Code = "mtmd()";
	addText(Code);
  }  
  <!--12-03-2003 Flash 以及空白 #######################################-->
     function space()
  {
    Code = "[s]";
	addText(Code);
  } 
  
      function flash()
  {
    var insert=prompt("請輸入 Flash 所在網址", "");	  
	Code = "[flash=200,200]"+insert+"[/flash]";        
	addText(Code);
  } 
  
      function movie()
  {
    Code = "[movie=200,200 autoplay=1]請輸入網址[/movie]";
	addText(Code);
  }

      function qtmovie()
  {
    Code = "[qtmovie=200,200 autoplay=1]請輸入QuickTime 影音網址[/qtmovie]";
	addText(Code);
  }
  <!-- $RCSfile: FlashDetection2k.pm,v $ $Revision: 1.71 $ :  server can't tell if your browser has Flash;  you have a Netscape-like browser, here is some client-side JavaScript to detect if you have Flash. --><script type="text/javascript" language="JavaScript">
<!-- start JS detection
FlashMode = 0;
if (navigator.plugins && navigator.plugins.length > 0)
{
	if (navigator.plugins["Shockwave Flash"])
	{
		var plugin_version = 0;
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");

		for (var i = 0; i < words.length; ++i)
		{
			if (isNaN(parseInt(words[i])))
			continue;
			plugin_version = words[i];
		}
		if (plugin_version >= 6)
		{
			var plugin = navigator.plugins["Shockwave Flash"];
			var numTypes = plugin.length;
			for (j = 0; j < numTypes; j++)
			{
				mimetype = plugin[j];
				if (mimetype)
				{
					if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1))
						FlashMode = 1;
					// Mac wierdness
					if (navigator.mimeTypes["application/x-shockwave-flash"] == null)
						FlashMode = 0;
				}
			}
		}
	}
}
do_dw_var = FlashMode;
browser_flash_version = plugin_version;
// end JS detection -->   

//2005-08-19 增加項目 #####################################################################
      function Arrow()
  {
    Code = "[->]";
	addText(Code);
  } //end func

      function Linux()
  {
    Code = "[linux name=請輸入標題]請輸入內容[/linux]";
	addText(Code);
  } //end func

      function realmovie()
  {
    Code = "[real=200,200 autoplay=1]請輸入 RealPlay 影音網址[/real]";
	addText(Code);
  }//end 

      function Color()
  {
    Code = "[color=請輸入顏色碼][/color]";
	addText(Code);
  }//end 

  function Img2()
  {
    Code = "[img border=1 align=center alt=圖形說明文字]輸入圖片路徑[/img]";
	addText(Code);
  }//end 

//-->      