<!--
function openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function openPopup(img, width, height) {
   if (img && width && height) {
      width = Math.min(width, 840);
      height = Math.min(height, 710);
      var popUp = window.open(img,"popUp","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + width + ",height=" + height);
   }
   return;
}

function write_imagetag (id)
{
	// generate correct formidentifier
	formid = 'form' + id;
	form = document.getElementById(formid);
	
	// build imagetag
	if(form.align.value != ''){
		imagetag = '<img id="sub_content_img" src="' + form.location.value + '" ' + form.size.value;
	}
	
	// add end tag
	imagetag = imagetag + ' alt="" />'; 
	
	insertTagsPopUp('', imagetag, '');
	
	window.close();
}

function write_link (id)
{
	// generate correct formidentifier
	formid = 'form' + id;
	form = document.getElementById(formid);
	
	// build imagetag
	imagetag ='[› Link Title](' + form.location.value + ')';
	
	insertTagsPopUp('', imagetag, '');
	
	window.close();
}


function newhtml(js_code) {
		var str = document.form.text.value;
		document.form.text.value = str + js_code; 
		document.form.text.focus();
}

function js_format(js_format) {
    if (!document.selection) return;
    var str = document.selection.createRange().text;
    document.selection.createRange().text = str + js_format; 
}
function js_align(js_format) {
	if (!document.selection) return;
    var str = document.selection.createRange().text;
	if (str != '') {
		document.selection.createRange().text = "<div align=\""+js_format+"\">"+str+"</div>";
	} else {
		document.selection.createRange().text = "<div align=\""+js_format+"\">"+str+"</div>";
	}
}

function insertLink() {
	text = prompt("Vollständige URL eintragen (ohne http://):","");
	if (text != "" && text != null) { 
		js_code = "(http://"+text+")";
		insertTags("[› " , "]"+js_code, 'Link');
	}  
}

function insertEmail() {
	text = prompt("Vollständige eMail-Adresse eintragen:","");
	if (text != "" && text != null) { 
		js_code = "(mailto:"+text+"";
		text2 = prompt("Betreffzeile eintragen:","");
		insertTags("[› " , "]"+js_code+"?subject="+text2+")", 'eMail');
	}  
}


function insertHervor() {

text = prompt("Soll ein Bild mit einer Bildunterschrift hervorgehoben werden, bitte dieses Feld NICHT ausfüllen.\nDieses Feld nur mit reinem Text ausfüllen!");
	if (text == "") { 
	js_code = "Bildcode</div><p>";
	} 
	if (text != "") { 
		js_code = "<p>"+text+"</p></div><p>";
	}

text2 = prompt("Die Ausrichtung des Fensters im Artikel festlegen.\nMöglich sind \"R\" bzw. \"L\"","");

	if (text == "" && (text2 == "r") || (text2 == "R")) {
		js_code2 = "float:right;";
	}
	
	if (text == "" && (text2 == "l") || (text2 == "L")) {
		js_code2 = "float:left";
	}

	if (text != "" && text2 == "") {
		js_code2 = "";
	}

text3 = prompt("Bitte die Breite der Hervorhebung bzw. des Bildes hier eintragen.\nDie Breite bitte wie folgt angeben (Beispiel): 250px oder 80%","");

	if (text3 == "") {
		js_code3 = "<div id=hervor"+js_code2+">";
	}

	if (text3 != "") {
		js_code3 = "<div id=hervor style=width:"+text3+js_code2+">";
	}

	insertTags(js_code3, js_code, 'Hervorhebung');  
	}

function insertList(type) {
	text = prompt("erste Zeile der Aufzählung bzw. Aufllistung eintragen:","");     
	if (text != "" && text != null) { 
		var js_code = "\n";
		if (type == 'ul') {
			while (text != "" && text != null) {
				js_code += " - "+text+"\n";
				text = prompt("nächste Zeile der Aufzählung bzw. Aufllistung eintragen: \n(zum Beenden das Feld leer lassen)","");
			}
		} else {
			counter = 1;
			while (text != "" && text != null) {
				js_code += " "+counter+". "+text+"\n";
				text = prompt("nächste Zeile der Aufzählung bzw. Aufllistung eintragen: \n(zum Beenden das Feld leer lassen)","");
				counter++;
			}
		}
		insertTags('', '', js_code);
	}  
}

// taken from mediawiki
// http://sourceforge.net/projects/wikipedia
function insertTags(tagOpen, tagClose, sampleText)
{
	var txtarea = document.getElementById('text');
	// IE
	if(document.selection) {
		var theSelection = document.selection.createRange().text;
		if(!theSelection) { theSelection=sampleText;}
		txtarea.focus();
		if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} else {
			document.selection.createRange().text = tagOpen + theSelection + tagClose;
		}
	// Mozilla -- disabled because it induces a scrolling bug which makes it virtually unusable
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
 		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		var scrollTop=txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if(!myText) { myText=sampleText;}
		if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " "; 
		} else {
			subst = tagOpen + myText + tagClose; 
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst + txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();
		var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
		txtarea.selectionStart=cPos;
		txtarea.selectionEnd=cPos;
		txtarea.scrollTop=scrollTop;
	// All others
	} else {
		// Append at the end: Some people find that annoying
		//txtarea.value += tagOpen + sampleText + tagClose;
		//txtarea.focus();
		var re=new RegExp("\\n","g");
		tagOpen=tagOpen.replace(re,"");
		tagClose=tagClose.replace(re,"");
		document.infoform.infobox.value=tagOpen+sampleText+tagClose;
		txtarea.focus();
	}
	// reposition cursor if possible
	if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
}

// taken from mediawiki
// http://sourceforge.net/projects/wikipedia
function insertTagsPopUp(tagOpen, tagClose, sampleText)
{
	var txtarea = opener.document.getElementById('text');
	// IE
	if(opener.document.selection) {
		var theSelection = opener.document.selection.createRange().text;
		if(!theSelection) { theSelection=sampleText;}
		txtarea.focus();
		if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			opener.document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} else {
			opener.document.selection.createRange().text = tagOpen + theSelection + tagClose;
		}
	// Mozilla -- disabled because it induces a scrolling bug which makes it virtually unusable
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
 		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		var scrollTop=txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if(!myText) { myText=sampleText;}
		if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " "; 
		} else {
			subst = tagOpen + myText + tagClose; 
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst + txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();
		var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
		txtarea.selectionStart=cPos;
		txtarea.selectionEnd=cPos;
		txtarea.scrollTop=scrollTop;
	// All others
	} else {
		// Append at the end: Some people find that annoying
		//txtarea.value += tagOpen + sampleText + tagClose;
		//txtarea.focus();
		var re=new RegExp("\\n","g");
		tagOpen=tagOpen.replace(re,"");
		tagClose=tagClose.replace(re,"");
		opener.document.infoform.infobox.value=tagOpen+sampleText+tagClose;
		txtarea.focus();
	}
	// reposition cursor if possible
	if (txtarea.createTextRange) txtarea.caretPos = opener.document.selection.createRange().duplicate();
}

function unsetByWikitext(cur)
{
	formular =  document.getElementById('form');
	
	if (cur == 'wikitext') {
		formular.linebreaks.checked = false;
		formular.convert.checked = false;
	} else {
		formular.wikitext.checked = false;
	}
}

//-->