function smilieopen2() 
{

sx=window.prompt("输入样式名","css_name");
px=window.prompt("输入内容","content");
if (sx!=null && px!=null)
{
temp_mp="[css:"+sx+"]"+px+"[/css]"
AddText2(temp_mp);
}

}
function viewubb2() {msg=window.open("ubbcode.htm","","height=500,width=500,left=5,top=5,scrollbars=yes,toolbar=no,directories=no,status=no,menubar=no,resizable=yes");}
function afp2() {msg=window.open("afp.htm","","height=315,width=420,left=5,top=5,scrollbars=no,toolbar=no,directories=no,status=no,menubar=no,resizable=yes");}

helpstat = false;
stprompt = true;
basic = false;
function thelp2(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 storeCaret2 (textEl) {
if (textEl.createTextRange) 
textEl.caretPos = document.selection.createRange().duplicate();    
}
function insertAtCaret2 (textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text =caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?text + ' ' : text;      
}      
else        
textEl.value  = text;
    
}    
function AddText2(NewCode) {
insertAtCaret2(document.PostTopic2.Message, NewCode)
}
///////////////////////////////////////////////////////
function email2() {
	if (helpstat) {
		alert("Email Tag\nTurns an email address into a mailto hyperlink.\nUSE: [email]someone@anywhere.com[/email]\nUSE: [email=someone@anywhere.com]link text[/email]");
	} else if (basic) {
		AddTxt="[email][/email]";
		AddText2(AddTxt);
	} else { 
		txt2=prompt("Text to be shown for the link.\nLeave blank if you want the email address to be shown for the link.",""); 
		if (txt2!=null) {
			txt=prompt("Email address.","name@domain.com");      
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[email]"+txt+"[/email]";
				} else {
					AddTxt="[email="+txt+"]"+txt2+"[/email]";
				} 
				AddText2(AddTxt);	        
			}
		}
	}
}

function showsize2(size) {
	if (helpstat) {
		alert("Size Tag\nSets the text size.\nPossible values are 1 to 6.\n 1 being the smallest and 6 the largest.\nUSE: [size="+size+"]This is size "+size+" text[/size]");
	} else if (basic) {
		AddTxt="[size="+size+"][/size]";
		AddText2(AddTxt);
	} else {                       
		txt=prompt("Text to be size "+size,"Text"); 
		if (txt!=null) {             
			AddTxt="[size="+size+"]"+txt+"[/size]";
			AddText2(AddTxt);
		}        
	}
}

function bold2() {
	if (helpstat) {
		alert("Bold Tag\nMakes the enlosed text bold.\nUSE: [b]This is some bold text[/b]");
	} else if (basic) {
		AddTxt="[b][/b]";
		AddText2(AddTxt);
	} else {  
		txt=prompt("Text to be made BOLD.","Text");     
		if (txt!=null) {           
			AddTxt="[b]"+txt+"[/b]";
			AddText2(AddTxt);
		}       
	}
}

function italicize2() {
	if (helpstat) {
		alert("Italicize Tag\nMakes the enlosed text italicized.\nUSE: [i]This is some italicized text[/i]");
	} else if (basic) {
		AddTxt="[i][/i]";
		AddText2(AddTxt);
	} else {   
		txt=prompt("Text to be italicized","Text");     
		if (txt!=null) {           
			AddTxt="[i]"+txt+"[/i]";
			AddText2(AddTxt);
		}	        
	}
}

function quote2() {
	if (helpstat){
		alert("Quote tag\nQuotes the enclosed text to reference something specific that someone has posted.\nUSE: [quote]This is a quote[/quote]");
	} else if (basic) {
		AddTxt="\r[quote]\r[/quote]";
		AddText2(AddTxt);
	} else {   
		txt=prompt("Text to be quoted","Text");     
		if(txt!=null) {          
			AddTxt="\r[quote]\r"+txt+"\r[/quote]";
			AddText2(AddTxt);
		}	        
	}
}

function showcolor2(color) {
	if (helpstat) {
		alert("Color Tag\nSets the text color.  Any named color can be used.\nUSE: [color="+color+"]This is some "+color+" text[/color]");
	} else if (basic) {
		AddTxt="[color="+color+"][/color]";
		AddText2(AddTxt);
	} else {  
     	txt=prompt("Text to be "+color,"Text");
		if(txt!=null) {
			AddTxt="[color="+color+"]"+txt+"[/color]";
			AddText2(AddTxt);        
		} 
	}
}

function center2() {
 	if (helpstat) {
		alert("Centered tag\nCenters the enclosed text.\nUSE: [center]This text is centered[/center]");
	} else if (basic) {
		AddTxt="[center][/center]";
		AddText2(AddTxt);
	} else {  
		txt=prompt("Text to be centered","Text");     
		if (txt!=null) {          
			AddTxt="\r[center]"+txt+"[/center]";
			AddText2(AddTxt);
		}	       
	}
}

function hyperlink2() {
	if (helpstat) {
		alert("Hyperlink Tag\nTurns an url into a hyperlink.\nUSE: [url]http://www.anywhere.com[/url]\nUSE: [url=http://www.anywhere.com]link text[/url]");
	} else if (basic) {
		AddTxt="[url][/url]";
		AddText2(AddTxt);
	} else { 
		txt2=prompt("Text to be shown for the link.\nLeave blank if you want the url to be shown for the link.",""); 
		if (txt2!=null) {
			txt=prompt("URL for the link.","http://");      
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[url]"+txt+"[/url]";
					AddText2(AddTxt);
				} else {
					AddTxt="[url="+txt+"]"+txt2+"[/url]";
					AddText2(AddTxt);
				}         
			} 
		}
	}
}

function image2() {
	if (helpstat){
		alert("Image Tag\nInserts an image into the post.\nUSE: [img]http:\www.anywhere.comimage.gif[/img]");
	} else if (basic) {
		AddTxt="[img][/img]";
		AddTex2t(AddTxt);
	} else {  
		txt=prompt("插入图片地址","http://");    
		tp=prompt("输入图片对齐方式，可以输入l（左）或者r（右），默认请不填","");  
		if(txt!=null) {  
		if(tp==null) tp="";         
			AddTxt="\r["+tp+"img]"+txt+"[/"+tp+"img]";
			AddText2(AddTxt);
		}	
	}
}

function showcode2() {
	if (helpstat) {
		alert("Code Tag\nBlockquotes the text you reference and preserves the formatting.\nUsefull for posting code.\nUSE: [code]This is formated text[/code]");
	} else if (basic) {
		AddTxt="\r[code]\r[/code]";
		AddText2(AddTxt);
	} else {   
		txt=prompt("Enter code","");     
		if (txt!=null) {          
			AddTxt="\r[code]"+txt+"[/code]";
			AddText2(AddTxt);
		}	       
	}
}

function list2() {
	if (helpstat) {
		alert("List Tag\nBuilds a bulleted, numbered, or alphabetical list.\nUSE: [list]\n[*]item1\n[*]item2\n[*]item3\n[/list]");
	} else if (basic) {
		AddTxt="\r[list]\r[*]\r[*]\r[*]\r[/list]";
		AddText2(AddTxt);
	} else {  
		txt=prompt("Type of list\nEnter 'A' for alphabetical, '1' for numbered, Leave blank for bulleted.","");               
		while ((txt!="") && (txt!="A") && (txt!="a") && (txt!="1") && (txt!=null)) {
			txt=prompt("ERROR!\nThe only possible values for type of list are blank 'A' and '1'.","");               
		}
		if (txt!=null) {
			if (txt=="") {
				AddTxt="\r[list]\r\n";
			} else {
				AddTxt="\r[list="+txt+"]\r";
			} 
			txt="1";
			while ((txt!="") && (txt!=null)) {
				txt=prompt("List item\nLeave blank to end list",""); 
				if (txt!="") {             
					AddTxt+="[*]"+txt+"\r"; 
				}                   
			} 
			AddTxt+="[/list]\r\n";
			AddText2(AddTxt); 
		}
	}
}

function underline2() {
  	if (helpstat) {
		alert("Underline Tag\nUnderlines the enclosed text.\nUSE: [u]This text is underlined[/u]");
	} else if (basic) {
		AddTxt="[u][/u]";
		AddText2(AddTxt);
	} else {  
		txt=prompt("Text to be Underlined.","Text");     
		if (txt!=null) {           
			AddTxt="[u]"+txt+"[/u]";
			AddText2(AddTxt);
		}	        
	}
}

function showfont2(font) {
 	if (helpstat){
		alert("Font Tag\nSets the font face for the enclosed text.\nUSE: [font="+font+"]The font of this text is "+font+"[/font]");
	} else if (basic) {
		AddTxt="[font="+font+"][/font]";
		AddText2(AddTxt);
	} else {                  
		txt=prompt("Text to be in "+font,"Text");
		if (txt!=null) {             
			AddTxt="[font="+font+"]"+txt+"[/font]";
			AddText2(AddTxt);
		}        
	}  
}
function setsmiley2(what) 
{ 
document.PostTopic2.Message.value = document.PostTopic2.Message.value+" "+what; 
document.PostTopic2.Message.focus(); 
} 
function face2(smile)
{
   
AddText2(smile);

}
function swf2()
{
sx=window.prompt('输入 Flash 文件地址：','http://');
vv=window.prompt('输入宽和高','350,280');
if (!(sx=='' || sx==null || vv=='' || vv==null))
{
temp_swf="[swf="+vv+"]"+sx+"[/swf]"
AddText(temp_swf);}
}
function cdir2()
{
sx=window.prompt('输入 Shockwave 文件地址：','http://');
vv=window.prompt('输入宽和高','350,280');
if (!(sx=='' || sx==null || vv=='' || vv==null))
{
temp_swf="[dir="+vv+"]"+sx+"[/dir]"
AddText(temp_swf);}
}
function cmp2()
{
sx=window.prompt('输入 Windows media player 文件地址：','');
vv=window.prompt('输入宽和高','350,300');
vc=window.prompt('是否自动播放，请输入小写的: y(是) or n(否)\n保持空表示默认为自动播放!','');
if (!(vc=='' || vc==null))
tvc=":"+vc;
else
tvc="";
if (!(sx=='' || sx==null || vv=='' || vv==null))
{
temp_mp="[mp="+vv+tvc+"]"+sx+"[/mp]"
AddText(temp_mp);}
}
function crm2()
{
sx=window.prompt('输入 RM 文件地址：','');
vv=window.prompt('输入宽和高','350,300');
vc=window.prompt('是否自动播放，请输入小写的: y(是) or n(否)\n保持空表示默认为自动播放!','');
if (!(vc=='' || vc==null))
tvc=":"+vc;
else
tvc="";
if (!(sx=='' || sx==null || vv=='' || vv==null))
{
temp_mp="[rm="+vv+tvc+"]"+sx+"[/rm]"
AddText(temp_mp);}
}
function cqt2()
{
sx=window.prompt('输入 Quick Time 文件地址：','');
vv=window.prompt('输入宽和高','350,300');
vc=window.prompt('是否自动播放，请输入小写的: y(是) or n(否)\n保持空表示默认为自动播放!','');
if (!(vc=='' || vc==null))
tvc=":"+vc;
else
tvc="";
if (!(sx=='' || sx==null || vv=='' || vv==null))
{
temp_mp="[qt="+vv+tvc+"]"+sx+"[/qt]"
AddText(temp_mp);}
}
function cmove2()
{
sx=window.prompt('Enter the word：','Text');
if (!(sx=='' || sx==null))
{
temp_mp="[move]"+sx+"[/move]"
AddText2(temp_mp);}
}
function cfly2()
{
sx=window.prompt('Enter the word：','Text');
if (!(sx=='' || sx==null))
{
temp_mp="[fly]"+sx+"[/fly]"
AddText2(temp_mp);}
}
function calign2()
{
sx=window.prompt('Enter the word：','Text');
if (!(sx=='' || sx==null))
{
temp_mp="[align=center]"+sx+"[/align]"
AddText2(temp_mp);}
}

