<!-- {{{ -->
<script language="JavaScript" type="text/javascript">
<!--
// original code:
// bbCode control by
// subBlue design
// www.subBlue.com
//
// changes by alex killing for ILIAS open source alex.killing@gmx.de

// Startup variables
var imageTag = false;
var theSelection = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

// Helpline messages
b_help = "{TXT_STR} [str]text[/str]  (alt+s)";
e_help = "{TXT_EMP} [emp]text[/emp]  (alt+e)";
u_help = "{TXT_COM} [com]text[/com]  (alt+c)";
f_help = "{TXT_FN} [fn]text[/fn]  (alt+f)";
q_help = "{TXT_QUOT} [quot]text[/quot]  (alt+q)";
c_help = "{TXT_CODE} [code]code[/code]  (alt+c)";
i_help = "{TXT_ILN} [iln page=\"page_id\"]text[/iln]";
x_help = "{TXT_XLN} [xln url=\"http://url\"]text[/xln]  (alt+x)";
t_help = "{TXT_TEX} [tex]LaTeX code[/tex]  (alt+t)";

// old helpline messages of phpbb
z_help = "List: [list]text[/list] (alt+l)";
o_help = "Ordered list: [list=]text[/list]  (alt+o)";
p_help = "Insert image: [img]http://image_url[/img]  (alt+p)";
w_help = "Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url]  (alt+w)";
a_help = "Close all open bbCode tags";
s_help = "Font color: [color=red]text[/color]  Tip: you can also use color=#FF0000";
//f_help = "Font size: [size=x-small]small text[/size]";

// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('[str]','[/str]','[emp]','[/emp]','[com]','[/com]','[quot]','[/quot]','[code]','[/code]','[fn]','[/fn]','[iln page=""]','[/iln]','[xln url="http://"]','[/xln]','[url]','[/url]', '[tex]','[/tex]');
imageTag = false;

// Shows the help messages in the helpline window
function helpline(help) {
	document.post.helpbox.value = eval(help + "_help");
}


// Replacement for arrayname.length property
function getarraysize(thearray) {
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
			return i;
		}
	return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
	thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}


function checkForm() {

	formErrors = false;

	if (document.post.{PAR_TA_NAME}.value.length < 2) {
		formErrors = "You must enter a message when posting.";
	}

	if (formErrors) {
		alert(formErrors);
		return false;
	} else {
		bbstyle(-1);
		//formObj.preview.disabled = true;
		//formObj.submit.disabled = true;
		return true;
	}
}

function emoticon(text) {
	var txtarea = document.post.{PAR_TA_NAME};
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function bbfontstyle(bbopen, bbclose) {
	var txtarea = document.post.{PAR_TA_NAME};

	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (!theSelection) {
			txtarea.value += bbopen + bbclose;
			txtarea.focus();
			return;
		}
		document.selection.createRange().text = bbopen + theSelection + bbclose;
		txtarea.focus();
		return;
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbopen, bbclose);
		return;
	}
	else
	{
		txtarea.value += bbopen + bbclose;
		txtarea.focus();
	}
	storeCaret(txtarea);
}


function bbstyle(bbnumber) {
	var txtarea = document.post.{PAR_TA_NAME};

	donotinsert = false;
	theSelection = false;
	bblast = 0;

	if (bbnumber == -1) { // Close all open tags & default button names
		while (bbcode[0]) {
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			buttext = eval('document.post.addbbcode' + butnumber + '.value');
			eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
		}
		imageTag = false; // All tags are closed including image tags :D
		txtarea.focus();
		return;
	}

	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text; // Get text selection
		if (theSelection) {
			// Add tags around selection
			document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
			txtarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
		return;
	}

	// Find last occurance of an open tag the same as the one just clicked
	for (i = 0; i < bbcode.length; i++) {
		if (bbcode[i] == bbnumber+1) {
			bblast = i;
			donotinsert = true;
		}
	}

	if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
		while (bbcode[bblast]) {
				butnumber = arraypop(bbcode) - 1;
				txtarea.value += bbtags[butnumber + 1];
				buttext = eval('document.post.addbbcode' + butnumber + '.value');
				eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
				imageTag = false;
			}
			txtarea.focus();
			return;
	} else { // Open tags

		if (imageTag && (bbnumber != 14)) {		// Close image tag before adding another
			txtarea.value += bbtags[15];
			lastValue = arraypop(bbcode) - 1;	// Remove the close image tag from the list
			document.post.addbbcode14.value = "Img";	// Return button back to normal state
			imageTag = false;
		}

		// Open tag
		txtarea.value += bbtags[bbnumber];
		if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
		arraypush(bbcode,bbnumber+1);
		eval('document.post.addbbcode'+bbnumber+'.value += "*"');
		txtarea.focus();
		return;
	}
	storeCaret(txtarea);
}

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

//-->
</script>
<!-- }}} -->
<form action="{FORMACTION}" name="post" method="post">

<input type="hidden" name="usedwsiwygeditor" id="usedwsiwygeditor" value="0">

<table class="fullwidth">
<tr class="tblheader">
	<td class="std" colspan="4">
		{TXT_ACTION}
	</td>
</tr>
<tr>
	<td class="option" width="1">
		{TXT_LANGUAGE}
	</td>
	<td class="option_value" width="1">
		{SELECT_LANGUAGE}
	</td>
	<td class="option" width="1">
		{TXT_CHARACTERISTIC}
	</td>
	<td class="option_value">
		{SELECT_CHARACTERISTIC}
	</td>
</tr>

<!-- BEGIN bb_buttons -->
<tr class="std">
	<td class="option_value" colspan="4">
    <div id="bbcodebuttons" style="position:relative;visibility:visible;">
	<input type="text" name="helpbox" size="90" maxlength="100" class="ilEditHelpline" value="Tip: Styles can be applied quickly to selected text." />
	<br />
	<input type="button" class="ilEditSubmit" accesskey="s" name="addbbcode0" value=" str " onClick="bbstyle(0)" onMouseOver="helpline('b')" />
	<input type="button" class="ilEditSubmit" accesskey="e" name="addbbcode2" value=" emp " onClick="bbstyle(2)" onMouseOver="helpline('e')" />
	<input type="button" class="ilEditSubmit" accesskey="c" name="addbbcode4" value=" com " onClick="bbstyle(4)" onMouseOver="helpline('u')" />
	<input type="button" class="ilEditSubmit" accesskey="q" name="addbbcode6" value=" quot " onClick="bbstyle(6)" onMouseOver="helpline('q')" />
	<input type="button" class="ilEditSubmit" accesskey="c" name="addbbcode8" value=" code " onClick="bbstyle(8)" onMouseOver="helpline('c')" />
	<input type="button" class="ilEditSubmit" accesskey="x" name="addbbcode18" value=" tex " onClick="bbstyle(18)" onMouseOver="helpline('t')" />
	<input type="button" class="ilEditSubmit" accesskey="f" name="addbbcode10" value=" fn " onClick="bbstyle(10)" onMouseOver="helpline('f')" />
	<input type="button" class="ilEditSubmit" accesskey="x" name="addbbcode14" value=" xln " onClick="bbstyle(14)" onMouseOver="helpline('x')" />
	<!-- BEGIN bb_ilink_button -->
	<a class="ilEditSubmit" href="{BB_LINK_ILINK}" target="tree" onMouseOver="helpline('i')">&nbsp;iln&nbsp;</a>
	<!-- END bb_ilink_button -->
    </div>
	</td>
</tr>
<!-- END bb_buttons -->

<tr class="std">
<td class="std" colspan="4">
<textarea id="{PAR_TA_NAME}" name="{PAR_TA_NAME}" onselect="storeCaret(this);" onclick="storeCaret(this);" style="width:95%" onkeyup="storeCaret(this);" cols="80" rows="12" wrap="virtual">{PAR_TA_CONTENT}</textarea>
</td>
</tr>
<!-- BEGIN commands -->
<tr>
	<td class="submit"  colspan="4">
		<input class="submit" type="submit" name="cmd[{BTN_NAME}]" value="{BTN_TEXT}" />
		<input class="submit" type="submit" name="cmd[{BTN_CANCEL}]" value="{TXT_CANCEL}" />
	</td>
</tr>
<!-- END commands -->
<!-- BEGIN content_selection -->
<tr>
	<td class="submit"  colspan="4">
		{SELECT_CONTENT}
		<input class="submit" type="submit" name="cmd[{BTN_NAME}]" value="{TXT_SELECT}" />
	</td>
</tr>
<!-- END content_selection -->
</table>

<input type="hidden" value="" name="footnotelist">

</form>


<div id="footnotelistdiv"></div>

<div id="subformeditor" style="visibility:hidden;">
<p>
<form name="subform">
<textarea rows=3 cols=80 style="width:100%" name="subform" id="subform"></textarea>
</form>
</div>


<!-- Configure the path to the editor.  We make it relative now, so that the
    example ZIP file will work anywhere, but please NOTE THAT it's better to
    have it an absolute path, such as '/htmlarea/'. -->
<script type="text/javascript">
  _editor_url = "{EDITOR_URL}";
  _editor_lang = "de";
</script>
<script type="text/javascript" src="{JS_HTMLAREA}"></script>
<script type="text/javascript" src="{JS_HANDLETAGS}"></script>

<script type="text/javascript">
var editor = null;
var subeditor = null;

function initSubEditor(TextAreaName) 
{
// {{{
  subeditor = new HTMLArea(TextAreaName);
  var subcfg = subeditor.config; // this is the default configuration

	subcfg.statusBar = false;

	subcfg.pageStyleLink = "<link rel=\"stylesheet\" type=\"text/css\" href=\"{LOCATION_CONTENT_STYLESHEET_HTMLAREA}\" /><link rel=\"stylesheet\" type=\"text/css\" href=\"{LOCATION_STYLESHEET_HTMLAREA}\" />";
	subcfg.pageStyle += "p {margin-top: 0px !important; margin-bottom: 0px !important;}";
	
	
	subcfg.toolbar = [
		[ 
		  "bold","italic"
          ],

	];

  subeditor.config = subcfg;
  subeditor.generate();
  return false;
	// }}}
}


function initEditor(TextAreaName) 
{
// {{{
/**
* <p> in IE while <br /> in Mozilla
* see: http://www.htmlarea.com/forum/htmlArea_3_(beta)_C4/htmlArea_v3.0_-_Beta_Release_F14/gforum.cgi?post=36031;search_string=linebreak;guest=10274569&t=search_engine#36031
* possible solution:
* see: http://www.htmlarea.com/forum/htmlArea_3_(beta)_C4/htmlArea_v3.0_-_Beta_Release_F14/gforum.cgi?post=17397;search_string=linebreak;guest=10274569&t=search_engine#17397
*/

  editor = new HTMLArea(TextAreaName);

  var cfg = editor.config; // this is the default configuration


	cfg.registerButton(
	{
      id        : "ilias-str",
      tooltip   : "Strong",
      image     : "<span class=ilc_Strong>[str]</span>",
      textMode  : false,
	  context   : "",
      action    : function(editor, id) 
	  			  {
					if (checkAllowTagInside("str"))
					{
                    	//editor.surroundHTML('<span class="ilc_Strong">', '</span>');
						addTagInEditor("span", "ilc_Strong");
					}
                  }
    });

    cfg.registerButton(
	{
      id        : "ilias-emp",
      tooltip   : "Italic",
      image     : "<span class=ilc_Emph>[emp]</span>",
      textMode  : false,
      action    : function(editor, id)
	  			  {
				  	if (checkAllowTagInside("emp"))
					{
                    	//editor.surroundHTML('<span class="ilc_Emph">', '</span>');
						addTagInEditor("span", "ilc_Emph");
					}
                  }
    });

    cfg.registerButton(
	{
      id        : "ilias-com",
      tooltip   : "",	// Kommentar
      image     : "<span class=ilc_Comment>[com]</span>",
      textMode  : false,
      action    : function(editor, id) 
	  			  {
				  	if (checkAllowTagInside("com"))
					{
                    	//editor.surroundHTML('<span class="ilc_Comment">', '</span>');
						addTagInEditor("span", "ilc_Comment");
					}
                  }
    });

    cfg.registerButton(
	{
      id        : "ilias-quot",
      tooltip   : "",	// Quotation
      image     : "<span class=ilc_Quotation>[quot]</span>",
      textMode  : false,
      action    : function(editor, id) 	
	  			  {
				  	if (checkAllowTagInside("quot"))
					{
                    	//editor.surroundHTML('<span class="ilc_Quotation">', '</span>');
						addTagInEditor("span", "ilc_Quotation");
					}
                  }
    });
    
    cfg.registerButton(
	{
      id        : "ilias-code",
      tooltip   : "",	// Code
      image     : "<code>[code]</code>",
      textMode  : false,
      action    : function(editor, id) 
	  			  {
				  	if (checkAllowTagInside("code"))
					{
                    	//editor.surroundHTML('<code>', '</code>');
						addTagInEditor("code", "ilc_Code");
					}
                  }
    });

	cfg.registerButton(
	{
      id        : "ilias-fn",
      tooltip   : "",	// Footnote
      //image     : "../content/htmlarea/images/ed_footnote.gif",
	  image     : "[fn]",
      textMode  : false,
      action    : function(editor, id) 
	  			  {
				  	if (checkAllowTagInside("fn"))
					{
                    	buttonFootnote();
					}
                  }
    });

	cfg.registerButton(
	{
      id        : "ilias-xtl",
      tooltip   : "",	// External link
      //image     : "../content/htmlarea/images/ed_xtl.gif",
	  image	    : "[xln]",
      textMode  : false,
      action    : function(editor, id) 
	  			  {
				  	if (checkAllowTagInside("xln"))
					{
	                    buttonExternalLink();
					}
                  }
    });
	
	<!-- BEGIN internal_link_active2 -->
	cfg.registerButton(
	{
      id        : "ilias-itl",
      tooltip   : "",	//Internal link
//      image     : "../content/htmlarea/images/ed_itl.gif",
	  image	    : "[iln]",
      textMode  : false,
      action    : function(editor, id) 
	  			  {
				  	if (checkAllowTagInside("iln"))
					{
                    	buttonInternalLink();
					}
                  }
    });
	<!-- END internal_link_active2 -->
	
	cfg.registerButton(
	{
      id        : "ilias-x",
      tooltip   : "",	//Internal link
      image     : "<strike>LN</strike>",
      textMode  : false,
      action    : function(editor, id) 
	  			  {
                    buttonX();
                  }
    });

	
	
	

	//alert("{XX}");
	cfg.pageStyleLink = "<link rel=\"stylesheet\" type=\"text/css\" href=\"{LOCATION_CONTENT_STYLESHEET_HTMLAREA}\" /><link rel=\"stylesheet\" type=\"text/css\" href=\"{LOCATION_STYLESHEET_HTMLAREA}\" />";
	cfg.pageStyle = "body{ background:#FFFFFF; } ";
  	cfg.pageStyle += ".footnote { color:0000FF; } ";
	cfg.pageStyle += ".iliasxln {color: 0000FF;text-decoration:underline;}";
	cfg.pageStyle += ".iliasiln {color: 000FFF;text-decoration:underline;}";
	cfg.pageStyle += "p {margin-top: 0px !important; margin-bottom: 0px !important;}";
	
	cfg.pageStyle += "u {font-size:middle;font-weight:normal;vertical-align:middle;color: green;}";
	
	cfg.pageStyle += "strike {font-size:middle;font-weight:normal;font-style: italic;vertical-align:middle;text-decoration:none;color: brown;}";
	cfg.pageStyle += "sub {font-size:large;font-weight:normal;vertical-align:middle;font-family:courier;}";
	cfg.pageStyle += "sup {font-size:large;font-weight:normal;color:green;vertical-align:middle;}";
	
	cfg.statusBar = false;
	
//		  "bold", "italic", "ilias-com", "ilias-quot", "ilias-code", "separator",
// "bold", "italic",
//"bold", "italic","separator",
// "ilias-str", "ilias-emp", "ilias-com", "ilias-quot", "ilias-code", "separator",
// "ilias-com", "ilias-quot", "ilias-code",
// "bold", "italic",  "separator",
//"ilias-str", "ilias-emp", "ilias-com", "ilias-quot", "ilias-code", "separator",
// "bold","superscript","underline", "strikethrough", "subscript", "separator",

	cfg.toolbar = [
		[ 
          
		  "ilias-str", "ilias-emp", "ilias-com", "ilias-quot", "ilias-code", "separator","ilias-fn", "separator",
		   "ilias-xtl",
		   <!-- BEGIN internal_link_active1 -->
		   "ilias-itl",
		   <!-- END internal_link_active1 -->
		  "separator",
		  "copy", "cut", "paste"
		  
          ],

	];
	//, "ilias-x", "separator", ,"htmlmode" , "separator" ,"htmlmode"
	/*
	"separator","superscript","underline", "strikethrough", "subscript", "separator",
	*/
	// "ilias-fn",	"ilias-x", "separator", "separator","htmlmode"
//"ilias-fn",,"htmlmode" "separator","htmlmode"
    
/*
"ilias-str", "ilias-emp",
, "space", "undo", "redo", "htmlmode"
"insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
	cfg.toolbar = [
		[ "fontname", "space",
		  "fontsize", "space",
		  "formatblock", "space",
		  "bold", "italic", "underline", "strikethrough", "separator",
		  "subscript", "superscript", "separator",
		  "copy", "cut", "paste", "space", "undo", "redo" ],

		[ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
		  "lefttoright", "righttoleft", "separator",
		  "insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
		  "forecolor", "hilitecolor", "separator",
		  "inserthorizontalrule", "createlink", "insertimage", "inserttable", "htmlmode", "separator",
		  "popupeditor", "separator", "showhelp", "about" ]
	];

*/    
    
  editor.config = cfg;
  
  // comment the following two lines to see how customization works
  editor.generate();
  return false;
  // }}}
}

var notAllowedTagsInside = new Array();
// {{{
function addNATI(which, inWhich, inClass) 
{
	a = new Array();
	a[0] = which;
	a[1] = inWhich;
	a[2] = inClass;
	notAllowedTagsInside[notAllowedTagsInside.length] = a;
}
//      which | in which | classname
addNATI("str",	"str",	"ilc_Strong");
addNATI("str",	"code",	"code");
addNATI("emp",	"emp",	"ilc_Emph");
addNATI("emp",	"code",	"code");
addNATI("com",	"com",	"ilc_Comment");
addNATI("com",	"code",	"code");
addNATI("quot",	"quot",	"ilc_Quotation");
addNATI("quot",	"code",	"code");
addNATI("code",	"code",	"code");
//addNATI("xln",	"xln",	"ilc_ExtLink");
addNATI("iln",	"xln",	"ilc_ExtLink");
addNATI("xln",	"iln",	"ilc_IntLink");
addNATI("iln",	"iln",	"ilc_IntLink");
// }}}

function buttonX() 
{
// {{{

	var ancestors = editor.getAllAncestors();
	
	var el = ancestors[0];
	var cl = el.className;
	var tn = el.tagName.toLowerCase();
	if (tn=="em" || tn=="strong") return;
	
	if(ancestors.length<=1) {
	
		editor.surroundHTML("!1!1!","!2!2!");
		S = editor.getHTML();
		
		for(i=0;i<100;i++) 
		{
			S = S.replace("<br />","*?*");
			S = S.replace("<br/>","*?*");
			S = S.replace("<br>","*?*");
			S = S.replace("<BR>","*?*");
			S = S.replace("<BR/>","*?*");
			S = S.replace("<BR />","*?*");
		}
		
		S3 = S.substring(S.indexOf("!1!1!")+5,S.indexOf("!2!2!"));
		obj.value += S3+"\n";
		
		var re= /<\S[^>]*>/g; 
		S4 = S3.replace(re,"");
		
		S = S.replace("!1!1!"+S3+"!2!2!",S4);
		
		for(i=0;i<100;i++) 
		{
			S = S.replace("*?*", "<br />");
		}
		
		editor.setHTML(S+"&nbsp;");
		editor.focusEditor();

		return;
	}
	
	var el = ancestors[0];
	var cl = el.className;
	var tn = el.tagName.toLowerCase();
	//alert(tn+" "+cl);
	
	editor.surroundHTML("!1!1!","!2!2!");
	S = editor.getHTML();
	S = S.replace("!1!1!"+unescape("%A0")+"!2!2!","!1!1!!2!2!");
	
	//d = S.substring(S.indexOf("!1!1!"),S.indexOf("!2!2!")+5);
	//alert(escape(d));
	
	for(i=0;i<100;i++) 
	{
		S = S.replace("<br />","*?*");
		S = S.replace("<br/>","*?*");
		S = S.replace("<br>","*?*");
		S = S.replace("<BR>","*?*");
		S = S.replace("<BR/>","*?*");
		S = S.replace("<BR />","*?*");
	}
	
	pos1 = S.indexOf("!1!1!");
	
	
	if(pos1>=0)
	{
		S1 = S.substr(0,pos1);
		pos1b = S1.lastIndexOf(">");	// backwards
		pos1c = S1.lastIndexOf("<");	// backwards
		pos1d = S1.lastIndexOf("</");	// backwards
		
		start = S1.substring(pos1c,pos1);
		tagStart = S1.substring(pos1c,pos1b+1);
		

		if(pos1c>=0 && pos1d<pos1c) 
		{
			S1b = S1.substr(0,pos1c);
			
			pos2 = S.indexOf("!2!2!");
			

			if(pos2>=0) 
			{
				pos2 += 5;
				S2 = S.substring(pos2,S.length);
				pos2b = S2.indexOf(">");
				pos2c = S2.indexOf("<");
				tagEnde = S2.substring(pos2c,pos2b+1);
				ende = S2.substring(0,pos2b+1);
				

				if (pos2b>=0)
				{
					 
					pos2b+=1;
					S2b = S2.substring(pos2b,S2.length);
					//alert(S2b+"\n"+start+"\n"+ende+"\n"+tagStart+"\n"+tagEnde);
					
					start2 = start.replace(tagStart,"");
					ende2 = ende.replace(tagEnde,"");
					
					
					S = S.replace(start+"!1!1!",start2);
					S = S.replace("!2!2!"+ende,ende2);

					for(i=0;i<100;i++) 
					{
						S = S.replace("*?*", "<br />");
					}
					
					editor.setHTML(S+"&nbsp;");
					editor.focusEditor();
					
				}
			}
			
		}
		else 
		{
			
			S3 = S.substring(S.indexOf("!1!1!")+5,S.indexOf("!2!2!"));
			
			var re= /<\S[^>]*>/g; 
			S4 = S3.replace(re,"");
			
			S = S.replace("!1!1!"+S3+"!2!2!",S4);
			
			for(i=0;i<100;i++) 
			{
				S = S.replace("*?*", "<br />");
			}
			
			editor.setHTML(S+"&nbsp;");
			editor.focusEditor();
			
		}
	
	}
	// }}}
}

function checkAllowTagInside3(which) 
{
	// {{{
	var ancestors = editor.getAllAncestors();
	if(ancestors.length==1) 
	{
		// if not inside another tag.
		
		S = editor.getSelectedHTML();
		if (S.indexOf("<")>=0 && S.indexOf("</")>=0) 
		{
			alert("{TXT_FORMATERROR}");
			return(false);
		}
		
		return(true);
	
	} 
	else {
		if(ancestors.length==2) 
		{
			var el = ancestors[0];
			var cl = el.className;
			var tn = el.tagName.toLowerCase();
			
			if (tn=="p") return(true); 
		}
		
		alert("{TXT_FORMATERROR}");
		return(false);
	}
	// }}}
}
// {{{
function checkAllowTagInside(which) 
{
// {{{
	return(true);
	
	
	var ancestors = editor.getAllAncestors();
	for (j=0;j<ancestors.length;j++) 
	{
		var el = ancestors[j];
		var cl = el.className;
		var tn = el.tagName.toLowerCase();
		
		for (i=0;i<notAllowedTagsInside.length;i++) 
		{
			a = notAllowedTagsInside[i];
			
			if (a[0] == which) 
			{
				//alert(a[2]+" "+cl+" "+tn);
				if (a[2] == cl || a[2] == tn)
				{
					if (editor.getSelectedHTML()=="" || editor.getSelectedHTML()=="&nbsp;") return(false);
					//alert("Error.");
					// -------------------------------------------------------
					N1 = "";
					N2 = "";
					var ancestors = editor.getAllAncestors();
					for (k=0;k<=j;k++)
					{
						var el = ancestors[k];
						var cl = el.className;
						var tn = el.tagName.toLowerCase();
						
						N1 = "<"+tn+" class=\""+cl+"\">"+N1;
						N2 += "</"+tn+">";
					}
					
					//alert(N2+"\n"+N1);
					
					S = editor.getSelectedHTML();
					editor.insertHTML("#!#*#!#");
					//alert(S);
					H = editor.getHTML();
					H = H.replace("#!#*#!#",N2+S+N1);
					//alert(H);
					
					for(k=0;k<20;k++) {
						H = H.replace("<span class=\"ilc_Comment\"></span>","");
						H = H.replace("<p>","");
						H = H.replace("</p>","");
					}
					
					editor.setHTML(H);
					editor.focusEditor();
					//editor.surroundHTML(N2,N1);
					// -------------------------------------------------------
					
					return(false);
				}
			}
		}
	}
	return(true);
	// }}}
}
// }}}

function getClearTags() 
{
// {{{
	N1 = "";
	N2 = "";
	var ancestors = editor.getAllAncestors();
	for (k=0;k<ancestors.length-1;k++)
	{
		var el = ancestors[k];
		var cl = el.className;
		var tn = el.tagName.toLowerCase();
		
		N0 = "<"+tn;
		if (cl!="") N0 += " class=\""+cl+"\"";
		N0 += ">";
		
		N1 = N0+N1;
		N2 += "</"+tn+">";
	}
	A = new Array();
	A[0] = N1;
	A[1] = N2;
	return(A);
	// }}}
}


var fussnoten = new Array();
var fnCount = 0;

function addFussnote(Tb)
{

	fussnoten[fnCount] = Tb;
	r = fnCount;
	fnCount++;
	return(r);
}

function refreshFootnotelist() 
{
	// {{{
	fhidden = "";
	fhtml = "<ul>";
	fhtml += "<table>";
	for (i=0;i<fussnoten.length;i++) 
	{
		j=i+1;
		if(fussnoten[i]!="") {
			//fhtml += "<tr><td valign=top>["+j+"]&nbsp;</td><td valign=top>"+fussnoten[i]+"<p>"+replaceAll(fussnoten[i],"<","&lt;");
			fhtml += "<tr><td valign=top>["+j+"]&nbsp;</td><td valign=top>"+fussnoten[i];
			fhtml += "</td>";
			fhtml += "</tr>";
			
			fhidden += i+"|*#"+fussnoten[i]+"|**#";
			
		}
	}
	fhtml += "</table>";
	fhtml += "</ul>";
	
	//document.post.footnotelist.value = replaceAll(fhidden,"\"","&quot;");
	document.post.footnotelist.value = fhidden;
	
	document.getElementById("footnotelistdiv").innerHTML = fhtml;
	// }}}
}


function buttonFootnote() 
{
	// {{{
	found = false;
	var ancestors = editor.getAllAncestors();
	for (k=0;k<ancestors.length-1;k++)
	{
		var el = ancestors[k];
		var cl = el.className;
		var tn = el.tagName.toLowerCase();
		
		if (tn=="span" && cl=="footnote") 
		{
			found = true;
			break;
		}
	}


	if(editor.hasSelectedText() && editor.getSelectedHTML()!="&nbsp;" && editor.getSelectedHTML().indexOf("footnote")==-1 && found==false) 
	{
		text = editor.getSelectedHTML();
		
		/*
		isbr = false;
		if(	text.indexOf("<br>")!=-1 || text.indexOf("<br/>")!=-1 ||text.indexOf("<br />")!=-1 || text.indexOf("<BR>")!=-1 || text.indexOf("<BR/>")!=-1 ||text.indexOf("<BR />")!=-1) 
		{
			isbr = true;
		}
		
		text = replaceAll(text,"<P>","");
		text = replaceAll(text,"</P>","");
		text = replaceAll(text,"<br>","");
		text = replaceAll(text,"<br/>","");
		text = replaceAll(text,"<br />","");
		text = replaceAll(text,"<BR>","");
		text = replaceAll(text,"<BR/>","");
		text = replaceAll(text,"<BR />","");
		*/
		
		r = addFussnote(text);
		//editor.surroundHTML('<span class=\"footnote\" value=\"','\">['+fnCount+']</span>');
		
		//ins = "<span class=\"footnote\" value=\""+text+"\">["+fnCount+"]</span>";
		r2 = r+1;
		
		ins = "<span class=\"footnote\" value=\""+r+"\">["+r2+"]</span>";
		//if(isbr) ins += "<br>";
		editor.insertHTML(ins);
		
		refreshFootnotelist()
		editor.updateToolbar();

	} 
	else 
	{
		w = window.open("{POPUP_TARGET_FOOTNOTE}","footnote","width=500,height=450,resizable=yes,scrollbars=yes");
		setTimeout("w.focus()",500);
	}
	// }}}
}

function addInternalLink(Link,title) 
{
	// {{{	

	if(Link.indexOf("[/iln]")==-1 && Link.indexOf("/]")!=-1) 
	{
		editor.insertHTML(Link);
	} 
	else 
	{
	
		Link = Link.replace("[iln ","<a class=\"ilc_IntLink\" ");
		Link = Link.replace("\"]","\">");
		Link = Link.replace(" [/iln]","");
	
	
		if(editor.hasSelectedText()) 
		{
			st = editor.getSelectedHTML();
			st = st.replace("&nbsp;","");
			st = st.trim();
			if(st!="") title = editor.getSelectedHTML();
		}
		
		A = getClearTags();
		if (A[0]=="") {
			editor.insertHTML(Link+title+"</a>");
			S = editor.getHTML();
			
			editor.setHTML(S+"&nbsp;&nbsp;");
		} else {
			N = Link+title+"</a>";
			S = editor.getSelectedHTML();
			editor.insertHTML("#!#*#!#");
			H = editor.getHTML();
			H = H.replace("#!#*#!#",A[1]+N+A[0]);
			
			for(k=0;k<20;k++) {
				H = H.replace("<span class=\"ilc_Comment\"></span>","");
				H = H.replace("<p>","");
				H = H.replace("</p>","");
				H = H.replace("<strong></strong>","");
			}
			
			editor.setHTML(H+"&nbsp;");
		}
	}
	editor.updateToolbar();
	editor.focusEditor();
	// }}}
}


function buttonExternalLink() 
{
	w = window.open("{POPUP_TARGET_XTL}","xtl","width=500,height=450,resizable=yes");
	setTimeout("w.focus()",500);
}	
	
function buttonInternalLink() 
{
	// {{{
	found = false;
	var ancestors = editor.getAllAncestors();
	for (k=0;k<ancestors.length-1;k++)
	{
		var el = ancestors[k];
		var cl = el.className;
		var tn = el.tagName.toLowerCase();
		
		if (tn=="a" && cl=="ilc_IntLink") 
		{
			found = true;
			break;
		}
	}
	
	if(editor.hasSelectedText()) 
	{
		if (editor.getSelectedHTML().indexOf("ilc_IntLink")!=-1) 
		{
			found = true;
		}
	}
	
	if (!found) {
		w = window.open("{LINK_ILINK}","itl","width=600,height=800,resizable=yes,scrollbars=yes");
		setTimeout("w.focus()",500);
	} else {
		if(confirm('{REMOVELINK}')) {
			buttonX();
		}
	}
	editor.updateToolbar();
	// }}}
}	
	

</script>

<script type="text/javascript">
    function doInit() 
	{
    	// {{{
        obj = document.getElementById("{PAR_TA_NAME}");
        T = obj.value;
		
		T = replaceAll(T,"<", "&lt;");
		
        T = replaceAll(T, "[str]","<span class=\"ilc_Strong\">");
        T = replaceAll(T, "[/str]","</span>");
        
        T = replaceAll(T, "[emp]","<span class=\"ilc_Emph\">");
        T = replaceAll(T, "[/emp]","</span>");

/*
		T = replaceAll(T, "[str]","<strong>");
        T = replaceAll(T, "[/str]","</strong>");
        
        T = replaceAll(T, "[emp]","<em>");
        T = replaceAll(T, "[/emp]","</em>");
*/		
		
        T = replaceAll(T, "[com]","<span class=\"ilc_Comment\">");
        T = replaceAll(T, "[/com]","</span>");
		
        //T = replaceAll(T, "[com]","<span style=\"text-decoration: line-through;\">");
        //T = replaceAll(T, "[/com]","</span>");
        
        T = replaceAll(T, "[quot]","<span class=\"ilc_Quotation\">");
        T = replaceAll(T, "[/quot]","</span>");

        T = replaceAll(T, "[code]","<code class=\"ilc_Code\">");
        T = replaceAll(T, "[/code]","</code>");



		/**
		*	find all footnotes and copy to array
		*/
		T2 = T;
		while (T2.indexOf("[fn]")!=-1) 
		{
			Ta = T2.substr(0, T2.indexOf("[fn]") );
			Tb = T2.substring(T2.indexOf("[fn]")+4, T2.indexOf("[/fn]") );
			Tc = T2.substring(T2.indexOf("[/fn]")+5,T2.length);
			
			T2 = Tc;
			r = addFussnote(Tb);
			r2 = r+1;
			//T = T.replace("[fn]"+Tb+"[/fn]","<span class=\"footnote\" value=\""+Tb+"\">["+fnCount+"]</span>");
			T = T.replace("[fn]"+Tb+"[/fn]","<span class=\"footnote\" value=\""+r+"\">["+r2+"]</span>");
		}
		refreshFootnotelist();
		

		/**
		*	find all external links
		*/
		T = replaceAll(T,"[/xln]","</a>");
		T2 = T;
		while (T2.indexOf("[xln ")!=-1) 
		{
			T2 = T2.substring(T2.indexOf("[xln url=")+9,T2.length );
			
			Tb = T2.substr(0,T2.indexOf("]") );
			
			Tb = replaceAll(Tb, "&quot;","");
			Tb = replaceAll(Tb, "\"","");
			
			// alex changed
			//T = T.replace("[xln url=&quot;"+Tb+"&quot;]","<span class=\"iliasxln\" url=\""+Tb+"\">");
			//T = T.replace("[xln url=\""+Tb+"\"]","<span class=\"iliasxln\" url=\""+Tb+"\">");
			T = T.replace("[xln url=&quot;"+Tb+"&quot;]","<a class=\"ilc_ExtLink\" url=\""+Tb+"\">");
			T = T.replace("[xln url=\""+Tb+"\"]","<a class=\"ilc_ExtLink\" url=\""+Tb+"\">");
		}
		
		/**
		*	find all internal links
		*/
		T2 = T;
		while (T2.indexOf("[iln ")!=-1) 
		{
			// Suche [iln und beginne String dahinter
			T2 = T2.substring(T2.indexOf("[iln ")+5,T2.length );
			
			// in Tb der Teil zwischen [iln und ] 
			Tb = T2.substr(0,T2.indexOf("]") );

			// Td ist der gefundene TAG
			Td = "[iln "+Tb+"]";
			
			// Beginne T2 hinter ]
			T2 = T2.substring(T2.indexOf("]")+1,T2.length );
			
			// nach [/iln] nur dann suchen, wenn nicht der [iln-Tag direkt mit /] beendet wurde
			if(Td.indexOf("/]")==-1) 
			{
				// in Te der Teil zwischen �ffnendem und schlie�endem iln-TAG
				Te = T2.substr(0,T2.indexOf("[/iln]") );
				
				// Tc ist gesamter Tag inkl iln und inerem Teil
				Tc = Td+ Te+"[/iln]";
				
				// Ersetzen des �ffnenden Tags durch "a href" und class=...
				T = T.replace(Td,"<a class=\"ilc_IntLink\" "+Tb+">");
			}
			
		}
		T = replaceAll(T,"[/iln]","</a>");

        while (T.indexOf("\n")>-1) 
		{ 
            T = T.replace("\n","<br />");
        }
        
        
        obj.value = T;
    
        initEditor("{PAR_TA_NAME}");
		
		//initSubEditor("subform");
		
        obj = document.getElementById("usedwsiwygeditor");
        obj.value = "1";
        obj = document.getElementById("bbcodebuttons");
        obj.style.visibility = "hidden";
		// }}}
	}

</script>

<!-- BEGIN initwysiwygeditor -->
<script type="text/javascript">
    setTimeout("doInit()",200);
</script>
<!-- END initwysiwygeditor -->
	
<!-- [<a href="#" onClick="doInit();return(false);">Test WYSIWYG</a>] -->  

