	/**********************************************************************************************
	*																																															*
	*			This File belongs to the web.group.communication.center - please do not copy						*
	*											copyright by Micha Koller - micha81@gmx.de															*
	*																																															*
	**********************************************************************************************/


function addtext(text)
	{
		//mit Browser Erkennung 
	 if (navigator.appName.indexOf('Microsoft') > -1) { 
			//Microsoft Internet Explorer
  		var caretPos = window.document.bbcodeform.content.caretPos; 
  		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; 
 		} else window.document.bbcodeform.content.value+=text; 

 		window.document.bbcodeform.content.focus();
	}

function addtext_fromext(elementName,text)
	{

	 if(elementName == "content"){ 
		 if (navigator.appName.indexOf('Microsoft') > -1) { 
				//Microsoft Internet Explorer
				var caretPos = opener.document.forms[0].elements[elementName].caretPos; 
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; 
			} else 
				opener.document.forms[0].elements[elementName].value+=text; 
	 } else {
	 		if(opener.document.forms[0].elements[elementName].value.length == 0)
				opener.document.forms[0].elements[elementName].value+=text; 		
			else
				opener.document.forms[0].elements[elementName].value += "," + text;
	 }
	 
 		opener.document.forms[0].elements[elementName].focus();
	}
	
		
function getActiveText(msg) { 
 selectedText = (document.all) ? document.selection.createRange().text : window.getSelection(); 
 if (msg.createTextRange) msg.caretPos = document.selection.createRange().duplicate(); 
 return true; 
} 

function insert_bbcode(bbtag)
	{
		//Einfügen der BB Tags
		//mit Browsererkennung

		//abschließender Tag
		var bbtag_ende = "";
		if(bbtag.indexOf("=")==-1)	bbtag_ende = bbtag;
		else
			bbtag_ende = bbtag.substr(0,bbtag.indexOf("="));	//übergebene Argumente abschneiden
		
		
		
		
		if (document.selection) // für IE
   		{
    		var str = document.selection.createRange().text;
    		if(str != "")
    			{
						document.bbcodeform.content.focus();
						var inb = document.selection.createRange();
						inb.text = "[" + bbtag + "]" + str + "[/" + bbtag_ende + "]";
						return;
    			}
				else
					{
					// wenn nichts gewählt wurde, mache ein prompt und hängs hinten an
					inb = prompt("","");
						if(inb != "" && inb != null)
						{
							document.bbcodeform.content.value += " ["+bbtag+"]"+inb+"[/"+bbtag_ende+"] ";
							document.bbcodeform.content.focus();
						}
					}
			}

			else if (document.getElementById && !document.all) // für Mozilla/Gecko
			{
				var txtarea = document.bbcodeform.content;
				var selLength = txtarea.textLength;
				var selStart = txtarea.selectionStart;
				var selEnd = txtarea.selectionEnd;
				if (selEnd == 1 || selEnd == 2)
				selEnd = selLength;
				var start = (txtarea.value).substring(0,selStart);
				var inb = (txtarea.value).substring(selStart, selEnd)
		
				if(inb != "")
				{
				var end = (txtarea.value).substring(selEnd, selLength);
				txtarea.value = start + '[' + bbtag + ']' + inb + '[/' + bbtag_ende + ']' + end;
				return;
			}
			else
			{
        // wenn nichts gewählt wurde, mache ein prompt und hängs hinten an
        inb = prompt("","");
        if(inb != "" && inb != null)
        {
					document.bbcodeform.content.value += " [" + bbtag + "]" + inb + "[/" + bbtag_ende + "] ";
        	document.bbcodeform.content.focus();
        }
    	}
   }
   else
   {
       // wenn der browser nix versteht (z.B. opera) dann hängs hinten an
       inb = prompt("","");
       if(inb != "" && inb != null)
       {
	   			document.bbcodeform.content.value += " [" + bbtag + "]" + inb + "[/" + what + "]";
        	document.bbcodeform.content.focus();
       }
   }
}//endfunction

function txtcode(code)
{
  text = "[" + code + "]" + "[/" + code + "]";
  addtext(text);

}
function setFontColor(color)
{
	if(color!=0) {
	  text = "[COLOR=" + color + "][/color]";
  	addtext(text);
	}
}

