function bbGetElementById(id)
{
	if (document.getElementById)
	{
		return (document.getElementById(id));
	}
	else if (document.all)
	{
		return (document.all[id]);
	}
	else
	{
		if ((navigator.appname.indexOf("Netscape") != -1) && parseInt(navigator.appversion == 4))
		{
			return (document.layers[id]);
		}
	}
}

function bbCodeUrl(id)
{
	var text = prompt("Type the URL of the link you want to add.", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var text2 = prompt("Type the title of the website.", "");
		if ( text2 != null )
		{
			if ( text2 == "" )
			{
				var result = "[url=" + text + "]" + text + "[/url]";
			}
			else
			{
				var result = "[url=" + text + "]" + text2 + "[/url]";
			}
			dom.value += result;
		}
	}
	dom.focus();
}

function bbCodeImg(id)
{
	var text = prompt("Type the URL of the image you want to add.", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var text2 = prompt("Placing of the image. 'R' or 'r' for right, 'L' or 'l' for left, or leave empty.", "");
		while ( ( text2 != "" ) && ( text2 != "r" ) && ( text2 != "R" ) && ( text2 != "l" ) && ( text2 != "L" ) && ( text2 != null ) )
		{
			text2 = prompt("Error! Placing of the image. 'R' or 'r' for right, 'L' or 'l' for left, or leave empty.","");           
		}
		if ( text2 == "l" || text2 == "L" )
		{ 
			text2 = " align=left";
		}
		else if ( text2 == "r" || text2 == "R" )
		{
			text2 = " align=right";
		}
		else
		{
			text2 = "";
		}
		var result = "[img" + text2 + "]" + text + "[/img]";
		var dom = bbGetElementById(id);
		dom.value += result;
	}
	dom.focus();
}

function bbCodeEmail(id)
{
	var text = prompt("Type the email adress you want to add.", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var result = "[email]" + text + "[/email]";
		dom.value += result;
	}
	dom.focus();
}

function bbCodeQuote(id)
{
	var text = prompt("Type the text you want to quote.", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var result = "[quote]" + text + "[/quote]";
		dom.value += result;
	}
	dom.focus();
}

function bbCodeBold(id)
{
	var text = prompt("Type the text you want to be bold.", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var result = "[b]" + text + "[/b]";
		dom.value += result;
	}
	dom.focus();
}

function bbCodeItalic(id)
{
	var text = prompt("Type the text you want to be italic.", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var result = "[i]" + text + "[/i]";
		dom.value += result;
	}
	dom.focus();
}

function bbCodePre(id)
{
	var text = prompt("Type the text you want to present in monospace.", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var result = "[code]" + text + "[/code]";
		dom.value += result;
	}
	dom.focus();
}

function bbCodeAbbr(id)
{
	var text = prompt("Type the abbreviation you want to add:", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var text2 = prompt("Type the expansion of the abbreviation:", "");
		if ( text2 != null )
		{
			if ( text2 == "" )
			{
				var result = "[abbr=" + text + "]" + text + "[/abbr]";
			}
			else
			{
				var result = "[abbr=" + text2 + "]" + text + "[/abbr]";
			}
			dom.value += result;
		}
	}
	dom.focus();
}

function bbCodeList(id)
{
	var text = prompt("Type the first item of the list:", "");
	var dom = bbGetElementById(id);
	if ( text != null && text != "" )
	{
		var result = "[list]";
		var result = result + "[*]" + text + "[/*]";

		var text2 = prompt("Type the second item of the lijst:", "");
		if ( text2 != null && text2 != "" )
		{
			var result = result + "[*]" + text2 + "[/*]";
			var text3 = prompt("Type the third item of the list:", "");
			if ( text3 != null && text3 != "" )
			{
				var result = result + "[*]" + text3 + "[/*]";
				var text4 = prompt("Type the fourth item of the list:", "");
				if ( text4 != null && text4 != "" )
				{
					var result = result + "[*]" + text4 + "[/*]";
					var text5 = prompt("Type the fifth item of the list:", "");
					if ( text5 != null && text5 != "" )
					{
						var result = result + "[*]" + text5 + "[/*]";
						var text6 = prompt("Type the sixth item of the list:", "");
						if ( text6 != null && text6 != "" )
						{
							var result = result + "[*]" + text6 + "[/*]";
							var text7 = prompt("Type the seventh item of the list:", "");
							if ( text7 != null && text7 != "" )
							{
								var result = result + "[*]" + text7 + "[/*]";
								var text8 = prompt("Type the eighth item of the list:", "");
								if ( text8 != null && text8 != "" )
								{
									var result = result + "[*]" + text8 + "[/*]";
								}
							}
						}
					}
				}
			}
		}

		var result = result + "[/list]";
		dom.value += result;
	}
	dom.focus();
}
