<html>

<head>
<title>{TXT_FOOTNOTES}</title>
<link rel="stylesheet" type="text/css" href="{LOCATION_STYLESHEET}" />
</head>

<body>

<script type="text/javascript">
  _editor_url = "./content/htmlarea/";
  _editor_lang = "de";
</script>
<script type="text/javascript" src="./content/htmlarea/htmlarea.js"></script>
<script type="text/javascript" src="./content/js/handletags.js"></script>


<b>{TXT_FOOTNOTES}</b>

<form method="post" name="footnotes">


<script>
	var foundf=0;
	var ta = new Array();
	var ta2 = new Array();
	document.write("<table width=100% cellspacing=0>");
	for (i=0;i<opener.fussnoten.length;i++) 
	{
		
		j=i+1;
		if(opener.fussnoten[i]!="") {
			document.write("<tr>");
			ta.push(i);
			ta2.push("");
			foundf++;
			//document.write( "["+j+"]&nbsp;<input type='text' name='fn"+i+"' value=\""+opener.fussnoten[i].replace("\"","&quot;")+"\" size=40>");
			document.write( "<td valign=top>["+j+"]&nbsp;</td><td valign=top><textarea name='fn"+i+"' id='fn"+i+"' style='width:100%;' rows=3 cols=50>"+opener.fussnoten[i]+"</textarea></td>");
			//document.write( "[<a href='#' onClick=\"if(confirm('{DELETE_QUESTION}')) {deleteFootnote("+i+");}\">X</a>]");
			document.write("<td valign=top><input type=\"button\" value=\"{BTN_DELETE}\" onClick=\"if(confirm('{DELETE_QUESTION}')) {deleteFootnote("+i+");}\" name=\"deletelink\">");
			document.write( "<input type='hidden' name='fnold"+i+"' value=\""+replaceAll(opener.fussnoten[i],"\"","&quot;")+"\">");
			document.write( "</td>");
			document.write("</tr>");
		} else {
			document.write( "<input type='hidden' name='fn"+i+"' value=\""+replaceAll(opener.fussnoten[i],"\"","&quot;")+"\">");	
			document.write( "<input type='hidden' name='fnold"+i+"' value=\""+replaceAll(opener.fussnoten[i],"\"","&quot;")+"\">");
		}
		
	}
	document.write("</table>");
	

function initSubEditor(i) 
{
// {{{
  ta2[i] = new HTMLArea("fn"+ta[i]);
  var subcfg = ta2[i].config; // this is the default configuration

	subcfg.statusBar = false;

	subcfg.pageStyleLink = "<link rel=\"stylesheet\" type=\"text/css\" href=\"{LOCATION_CONTENT_STYLESHEET_HTMLAREA}\" />";
	subcfg.pageStyle += "p {margin-top: 0px !important; margin-bottom: 0px !important;}";
	
	subcfg.registerButton(
	{
      id        : "ilias-str",
      tooltip   : "Strong",
      image     : "<span class=ilc_Strong><b>[str]</b></span>",
      textMode  : false,
	  context   : "",
      action    : function(ed, id) 
	  			  {
				  	editor = ed; 
					addTagInEditor("span", "ilc_Strong");
                  }
    });

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

	
	subcfg.toolbar = [
		[ 
		  "ilias-str","ilias-emp"
          ],

	];

  ta2[i].config = subcfg;
  ta2[i].generate();
  return false;
	// }}}
}

for(i=0;i<ta.length;i++) {
	initSubEditor(i);
}

var editor;
	
</script>


<script>
if(foundf>0) document.write("<input type='button' value='{BTN_SUBMIT}' onClick='refreshFootnotes();'>");
</script>

</form>
	
<form name='form' >
<hr size=1>
{TXT_INSERT_NEW_FOOTNOTES}:<br>
<input type='text' size=30 style='width:100%' name='fn' onKeyUp="if (document.form.fn.value!='') document.form.savenew.disabled=false; else document.form.savenew.disabled=true; ">
<p>
<table cellspacing=0 cellpadding=0 width="100%">
	<tr>
		<td>
			<input 	name="savenew" disabled type='button' 
					value='{BTN_SUBMIT}' 
					onClick="r=opener.addFussnote(document.form.fn.value);r2=r+1;
							 opener.refreshFootnotelist();
							 opener.editor.surroundHTML('<span class=&quot;footnote&quot; value=&quot;'+r+'&quot;>['+r2+']</span>','');
							 window.close();">
		</td>
		<td align=right>
			<input type='button' value='{BTN_CANCEL}' onClick='window.close();'>
		</td>
	</tr>
</table>
</form>

<script>
function refreshFootnotes() {

	TX = opener.editor.getHTML();

	for(i=0;i<ta.length;i++) 
	{
		F = ta2[i].getHTML();
		F = replaceAll(F,"<p>","");
		F = replaceAll(F,"</p>","<br>");
		opener.fussnoten[ta[i]] = F;
		fn = "document.footnotes.fnold"+ta[i]+"";
		obj2 = eval(fn);
	}
//	opener.editor.setHTML(TX);
	
	opener.editor.updateToolbar();
	opener.refreshFootnotelist();
	window.close();

}

function deleteFootnote(i) 
{
	TX = opener.editor.getHTML();
	
	j=i+1;
	TX = TX.replace("<span class=\"footnote\" value=\""+i+"\">["+j+"]</span>",opener.fussnoten[i]);
	TX = TX.replace("<span value=\""+i+"\" class=\"footnote\">["+j+"]</span>",opener.fussnoten[i]);
	
	of = new Array();
	for(j=0;j<opener.fussnoten.length;j++) 
	{
		//if (i!=j) of[of.length] = opener.fussnoten[j];
		if (i==j) opener.fussnoten[j]="";
	}
	//opener.fussnoten = of;
	//opener.fnCount = opener.fussnoten.length;
	
	opener.editor.setHTML(TX);
	opener.editor.updateToolbar();
	opener.refreshFootnotelist();
	
	window.location = "{FOOTNOTE_TARGET}";
	//window.location = "lm_edit.php?ref_id={REF_ID}&cmd=popup&ptype=footnote";
	
	//window.close();
}

</script>

</body>
</html>
