	function insert(aTag, eTag,Smilies) {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		if (Smilies == 'FALSE') document.getElementById("BBBarSmilies").style.display = 'none';
		var input = document.getElementById("CommentBox");
		var wert;
		var opentag;
		var closetag;
/*		if(document.getElementById("Radio_BBCode")){
			if (document.getElementById('Radio_BBCode').checked) wert = 'BBCode';
		}
		if(document.getElementById("Radio_Html")){
			if (document.getElementById('Radio_Html').checked) wert = 'Html';
		}
		if(document.getElementById("Radio_Text")){
			if (document.getElementById('Radio_Text').checked) wert = 'Text';
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			if (wert == 'Html') {
				opentag = '<';
				closetag = '>';
			}
			if (wert == 'BBCode') {
				opentag = '[';
				closetag = ']';
			}
			input.focus();	
			/* für Internet Explorer */
			if(typeof document.selection != 'undefined') {
				/* Einfügen des Formatierungscodes */
				var range = document.selection.createRange();
				var insText = range.text;
				range.text = opentag + aTag + closetag + insText + opentag + eTag + closetag;
				/* Anpassen der Cursorposition */
				range = document.selection.createRange();
				if (insText.length == 0) {
					range.move('character', -eTag.length);
				} else {
					range.moveStart('character', aTag.length + insText.length + eTag.length);      
				}
				range.select();
			} else if (typeof input.selectionStart != 'undefined'){
				/* Einfügen des Formatierungscodes */
				var start = input.selectionStart;
				var end = input.selectionEnd;
				var insText = input.value.substring(start, end);
				input.value = input.value.substr(0, start) + opentag + aTag + closetag +  insText + opentag +  eTag + closetag + input.value.substr(end) ;
				/* Anpassen der Cursorposition */
				var pos;
				if (insText.length == 0) {
					pos = start + aTag.length+opentag.length+closetag.length;
				} else {
					pos = start + aTag.length + insText.length + eTag.length;
				}
				input.selectionStart = pos;
				input.selectionEnd = pos;
			} else {
				/* Abfrage der Einfügeposition */
				var pos;
				var re = new RegExp('^[0-9]{0,3}$');
				while(!re.test(pos)) {
					pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
				}
				if(pos > input.value.length) {
					pos = input.value.length;
				}
				/* Einfügen des Formatierungscodes */
				var insText = prompt("Please insert the text, that should be formatted:");
				input.value = input.value.substr(0, pos) + openTag+  aTag + closeTag+ insText +openTag+  eTag + closeTag+ input.value.substr(pos);
			}
		}
	}

	function insertURL(Smilies) {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		if (Smilies == 'FALSE') {
			document.getElementById("BBBarSmilies").style.display = 'none';
		}
/*		if (document.getElementById("Radio_BBCode")) {
			if (document.getElementById('Radio_BBCode').checked) wert = 'BBCode';
		}
		if (document.getElementById("Radio_Html")) {
			if (document.getElementById('Radio_Html').checked) wert = 'Html';
		}
		if (document.getElementById("Radio_Text")) {
			if (document.getElementById('Radio_Text').checked) wert = 'Text';
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			linkZiel = prompt("Input the destination for this Link","http://");
			linkBeschreibung = prompt("Input the Title of this Link","");
			var input = document.getElementById("CommentBox");
			input.focus();
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			if (linkBeschreibung == '') linkBeschreibung = linkZiel;
			if (wert == 'BBCode' & linkZiel != ''& linkZiel != 'http://' & linkZiel != 'NULL') input.value = input.value.substr(0, start) + '[url=' + linkZiel + ']'+ linkBeschreibung + '[/url]' + input.value.substr(end);
			if (wert == 'Html' & linkZiel != ''& linkZiel != 'http://' & linkZiel != 'NULL') input.value = input.value.substr(0, start) + '<a href="' + linkZiel + '">'+ linkBeschreibung + '</a>' + input.value.substr(end);
		}
	}


	function insertMail(Smilies) {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		if (Smilies == 'FALSE') {
			document.getElementById("BBBarSmilies").style.display = 'none';
		}
/*		if (document.getElementById("Radio_BBCode")) {
			if (document.getElementById('Radio_BBCode').checked) wert = 'BBCode';
		}
		if (document.getElementById("Radio_Html")) {
			if (document.getElementById('Radio_Html').checked) wert = 'Html';
		}
		if (document.getElementById("Radio_Text")) {
			if (document.getElementById('Radio_Text').checked) wert = 'Text';
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			var input = document.getElementById("CommentBox");
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			linkZiel = 'mailto://' + prompt("Input the E-Mail Adress","");
			if (insText == '') {
				linkBeschreibung = prompt("Input the title for this Mail Link","");
			}
			input.focus();
			if (linkBeschreibung == '') {
				linkBeschreibung = linkZiel;  
			}
			if (linkZiel != '')	{
				if (wert == 'BBCode' & linkZiel != '' & linkZiel != 'mailto://' & linkZiel != 'NULL') {
					if (insText != '') input.value = input.value.substr(0, start) + '[url=' + linkZiel + ']'+ insText + '[/url]' + input.value.substr(end);
					if (insText == '') input.value = input.value.substr(0, start) + '[url=' + linkZiel + ']'+ linkBeschreibung + '[/url]' + input.value.substr(end);
				}
				if (wert == 'Html' & linkZiel != '' & linkZiel != 'mailto://' & linkZiel != 'NULL') {
					if (insText != '') input.value = input.value.substr(0, start) + '<a href="' + linkZiel + '">'+ insText + '</a>' + input.value.substr(end);
					if (insText == '') input.value = input.value.substr(0, start) + '<a href="' + linkZiel + '">'+ linkBeschreibung + '</a>' + input.value.substr(end);
				}
			}
		}
	}


	function insertImage(Smilies) {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		if (Smilies == 'FALSE') document.getElementById("BBBarSmilies").style.display = 'none';
/*		if(document.getElementById("Radio_BBCode")){
		if (document.getElementById('Radio_BBCode').checked) wert = 'BBCode';
		}
		if(document.getElementById("Radio_Html")){
		if (document.getElementById('Radio_Html').checked) wert = 'Html';
		}
		if(document.getElementById("Radio_Text")){
		if (document.getElementById('Radio_Text').checked) wert = 'Text';
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			image = prompt("Input the link where the image ist hosted:","http://www.");
			var input = document.getElementById("CommentBox");
			input.focus();
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			if (wert == 'BBCode' & image != 'http://www.' & image != '' & image != 'NULL')   input.value = input.value.substr(0, start) + '[img]'+ image + '[/img]' + input.value.substr(end);
			if (wert == 'Html' & image != 'http://www.' & image != '' & image != 'NULL')   input.value = input.value.substr(0, start) + '<img src="'+ image + '" />' + input.value.substr(end);
		}
	}

	function align(direction,Smilies) {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		if (Smilies == 'FALSE') document.getElementById("BBBarSmilies").style.display = 'none';
/*		if(document.getElementById("Radio_BBCode")){
		if (document.getElementById('Radio_BBCode').checked) wert = 'BBCode';
		}
		if(document.getElementById("Radio_Html")){
		if (document.getElementById('Radio_Html').checked) wert = 'Html';
		}
		if(document.getElementById("Radio_Text")){
		if (document.getElementById('Radio_Text').checked) wert = 'Text';
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			var input = document.getElementById("CommentBox");
			input.focus();
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			if (wert == 'BBCode')   input.value = input.value.substr(0, start) + '[align='+direction+']'+ insText + '[/align]' + input.value.substr(end);
			if (wert == 'Html')   input.value = input.value.substr(0, start) + '<div style="text-align: '+ direction + ';">'+insText+'</div>' + input.value.substr(end);
		}
	}

	function list(type,Smilies) {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		if (Smilies == 'FALSE') document.getElementById("BBBarSmilies").style.display = 'none';
/*		if(document.getElementById("Radio_BBCode")){
		if (document.getElementById('Radio_BBCode').checked) wert = 'BBCode';
		}
		if(document.getElementById("Radio_Html")){
		if (document.getElementById('Radio_Html').checked) wert = 'Html';
		}
		if(document.getElementById("Radio_Text")){
		if (document.getElementById('Radio_Text').checked) wert = 'Text';
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			var input = document.getElementById("CommentBox");
			input.focus();
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			if (type == 'u') {
				if (wert == 'BBCode')   input.value = input.value.substr(0, start) + '[ulist]\n[*]'+ insText + '\n[/ulist]' + input.value.substr(end);
				if (wert == 'Html')   input.value = input.value.substr(0, start) + '<ul>\n<li>'+insText+'</li>\n</ul>' + input.value.substr(end);
			}
			if (type == 'o') {
				if (wert == 'BBCode')   input.value = input.value.substr(0, start) + '[list]\n[*]'+ insText + '\n[/list]' + input.value.substr(end);
				if (wert == 'Html')   input.value = input.value.substr(0, start) + '<ol>\n<li>'+insText+'</li>\n</ol>' + input.value.substr(end);
			}
		}
	}

	function quotetext(Smilies) {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		if (Smilies == 'FALSE') document.getElementById("BBBarSmilies").style.display = 'none';
/*		if(document.getElementById("Radio_BBCode")){
		if (document.getElementById('Radio_BBCode').checked) wert = 'BBCode';
		}
		if(document.getElementById("Radio_Html")){
		if (document.getElementById('Radio_Html').checked) wert = 'Html';
		}
		if(document.getElementById("Radio_Text")){
		if (document.getElementById('Radio_Text').checked) wert = 'Text';
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			var input = document.getElementById("CommentBox");
			input.focus();
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			if (wert == 'BBCode')   input.value = input.value.substr(0, start) + '[quote]'+ insText + '[/quote]' + input.value.substr(end);
			if (wert == 'Html')   input.value = input.value.substr(0, start) + '<blockquote>'+insText+'</blockquote>' + input.value.substr(end);
		}
	}

	function showColor(Smilies){
		var wert;
		if (document.getElementById("BBBarColorPicker").style.display == 'inherit') wert = 'none';
		if (document.getElementById("BBBarColorPicker").style.display == 'none') wert = 'inherit';
		if (Smilies == 'FALSE') document.getElementById("BBBarSmilies").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		document.getElementById("BBBarColorPicker").style.display = wert;
	}


	function writeColor(color){
		document.getElementById("BBBarColorPicker").style.display = 'none';
		var wert;
/*		if(document.getElementById("Radio_BBCode")){
		if (document.getElementById('Radio_BBCode').checked) wert = 'BBCode';
		}
		if(document.getElementById("Radio_Html")){
		if (document.getElementById('Radio_Html').checked) wert = 'Html';
		}
		if(document.getElementById("Radio_Text")){
		if (document.getElementById('Radio_Text').checked) wert = 'Text';
		}*/
		wert = 'BBCode'
		if (wert != 'Text') {
			input = document.getElementById("CommentBox");
			input.focus();
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			if (wert == 'BBCode') {
				input.value = input.value.substr(0, start) + '[color=#'+color+']'+ insText + '[/color]' + input.value.substr(end);
			}
			if (wert == 'Html') {
				input.value = input.value.substr(0, start) + '<font color="#'+ color + '">'+insText+'</font>' + input.value.substr(end);
			}
		}
	}

	function showFont(Smilies) {
		var wert;
		if (document.getElementById("BBBarFontPicker").style.display == 'inherit') {
			wert = 'none';
		}
		if (document.getElementById("BBBarFontPicker").style.display == 'none') {
			wert = 'inherit';
		}
		document.getElementById("BBBarColorPicker").style.display = 'none';
		if (Smilies == 'FALSE') {
			document.getElementById("BBBarSmilies").style.display = 'none';
		}
		document.getElementById("BBBarFontPicker").style.display = wert;
	}

	function writeFont(font) {
		document.getElementById("BBBarFontPicker").style.display = 'none';
		var wert;
/*		if (document.getElementById("Radio_BBCode")) {
			if (document.getElementById('Radio_BBCode').checked) {
				wert = 'BBCode';
			}
		}
		if (document.getElementById("Radio_Html")) {
			if (document.getElementById('Radio_Html').checked) {
				wert = 'Html';
			}
		}
		if (document.getElementById("Radio_Text")) {
			if (document.getElementById('Radio_Text').checked) {
				wert = 'Text';
			}
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			input = document.getElementById("CommentBox");
			input.focus();
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			if (wert == 'BBCode') {
				input.value = input.value.substr(0, start) + '[font="'+ font +'"]'+ insText + '[/font]' + input.value.substr(end);
			}
			if (wert == 'Html') {
				input.value = input.value.substr(0, start) + '<font face="'+ font + '">'+insText+'</font>' + input.value.substr(end);
			}
		}
	}

	function insertselFont() {
/*		if (document.getElementById("Radio_BBCode")) {
			if (document.getElementById('Radio_BBCode').checked) {
				wert = 'BBCode';
			}
		}
		if (document.getElementById("Radio_Html")) {
			if (document.getElementById('Radio_Html').checked) {
				wert = 'Html';
			}
		}
		if (document.getElementById("Radio_Text")) {
			if (document.getElementById('Radio_Text').checked) {
				wert = 'Text';
			}
		}*/
		wert = 'BBCode';
		if (wert != 'Text') {
			input = document.getElementById("CommentBox");
			var font = document.forms[0].fontpicker.value;
			document.forms[0].fontpicker.value = '';
			input.focus();
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			if (wert == 'BBCode') {
				input.value = input.value.substr(0, start) + '[font="'+ font +'"]'+ insText + '[/font]' + input.value.substr(end);
			}
			if (wert == 'Html') {
				input.value = input.value.substr(0, start) + '<font face="'+ font + '">'+insText+'</font>' + input.value.substr(end);
			}
		}
	}

	function BBformatselectchanged() {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		document.getElementById("BBBarSmilies").style.display = 'none';
		document.getElementById("Vanillacons").style.display = 'none';

/*		if (document.getElementById("Radio_BBCode")) {
			if (document.getElementById('Radio_BBCode').checked) {
				wert = 'BBCode';
			}
		}
		if (document.getElementById("Radio_Html")) {
			if (document.getElementById('Radio_Html').checked) {
				wert = 'Html';
			}
		}
		if (document.getElementById("Radio_Text")) {
			if (document.getElementById('Radio_Text').checked) {
				wert = 'Text';
			}
		}*/
		wert = 'BBCode';
		if (wert == 'Html') {
			document.getElementById("BBBar").style.display = 'inherit';
		}
		if (wert == 'BBCode') {
			document.getElementById("BBBar").style.display = 'inherit';
		}
		if (wert == 'Text') {
			document.getElementById("BBBar").style.display = 'none';
		}
	}

	function BBformatselectchangedwv() {
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';

/*		if (document.getElementById("Radio_BBCode")) {
			if (document.getElementById('Radio_BBCode').checked) {
				wert = 'BBCode';
			}
		}
		if (document.getElementById("Radio_Html")) {
			if (document.getElementById('Radio_Html').checked) {
				wert = 'Html';
			}
		}
		if (document.getElementById("Radio_Text")) {
			if (document.getElementById('Radio_Text').checked) {
				wert = 'Text';
			}
		}*/

		wert = 'BBCode';
		if (wert == 'Html') {
			document.getElementById("BBBar").style.display = 'inherit';
		}
		if (wert == 'BBCode') {
			document.getElementById("BBBar").style.display = 'inherit';
		}
		if (wert == 'Text') {
			document.getElementById("BBBar").style.display = 'none';
		}
	}

	function insertBBSmilie(){
		if (document.getElementById("BBBarSmilies").style.display == 'inherit') {
			wert = 'none';
		}
		if (document.getElementById("BBBarSmilies").style.display == 'none') {
			wert = 'inherit';
		}
		document.getElementById("BBBarColorPicker").style.display = 'none';
		document.getElementById("BBBarFontPicker").style.display = 'none';
		document.getElementById("BBBarSmilies").style.display = wert;
	}