// speichert den text im message feld
function AddText(addtext) {
	var current = document.post.message.value;
	var newtext = current + addtext;
	document.post.message.value = newtext;
	document.post.message.focus();
}

// fügt den [IMG] tag hinzu
function AddImg() {
	inserttext = prompt("Enter the URL to the Image:" + "\n[IMG]xxx[/IMG]", "http://");
	if ((inserttext != "http://") && (inserttext != "")) addtext = " [IMG]" + inserttext + "[/IMG] ";
	else addtext="";
	
	AddText(addtext);
}

// fügt [URL] oder [EMAIL] ein
function AddLink(thetype) {
	linktext = prompt("Enter a Linkname (optional)", "");
	var prompttext;
	if (thetype == "URL") linkurl = prompt("Enter the URL", "http://");
	else linkurl = prompt("Enter the E-Mail Address", "");
	
	if ((linkurl != "http://") && (linkurl != "")) {
		if ((linktext != null) && (linktext != "")) {
			addtext = " [" + thetype + "=" + linkurl + "]" + linktext + "[/" + thetype + "] ";
		}
		else {
			addtext = " [" + thetype + "]" + linkurl + "[/" + thetype + "] ";
		}
	}
	else addtext = "";
	
	AddText(addtext);
}

// fügt eine HTML-Liste ein
function AddList() {
	type = prompt("enter '1' for a numbered List, 'a' for an alphabetic List or '' for a pointed List", "");
	if ((type == "a") || (type == "1")) {
		list = " [LIST=" + type + "]\n";
		listend = "[/LIST=" + type + "] ";
	}
	else {
		list = " [LIST]\n";
		listend = "[/LIST] ";
	}
	entry = "start";
	while ((entry != "") && (entry != null)) {
		entry = prompt("Enter a List-Point. Enter nothing or click 'Cancel' to finish the list.", "");
		if ((entry != "") && (entry != null))
			list = list + "[*]" + entry + "\n";
	}
	addtext = list + listend;
	
	AddText(addtext);
}

// fügt code ein
function AddCode(thecode) {
	addtext = " " + thecode + " ";
	AddText(addtext);
}

// fügt code eines andern fensters ein
function AddCodeFromWindow(thecode) {
	opener.document.post.message.value += thecode + " ";
	opener.post.message.focus();
}

tags = new Array('[B]','[/B]','[U]','[/U]','[I]','[/I]','[CODE]','[/CODE]','[QUOTE]','[/QUOTE]','[TOGGLE=read more]', '[/TOGGLE]');

// fügt code ein
function AddTag(thetag) {
	// markierung
	theSelection = document.selection.createRange().text;
	if (theSelection) {
		document.selection.createRange().text = tags[thetag] + theSelection + tags[thetag+1] + " ";
		theSelection = false;
		document.post.message.focus();
		return;
	}
	
	// ändern des buttons und intragen des tags
	if(thetag<6) initial=1;
	if(thetag==6) initial=4;
	if(thetag==8) initial=5;
	if(thetag==10) initial=6;
	
	button = eval('document.post.addtag' + thetag + '.value');
	if(button.length == initial) {
		eval('document.post.addtag' + thetag + '.value += "*"');
		addtext = tags[thetag];
	}
	else {
		eval('document.post.addtag' + thetag + '.value = "' + button.substr(0,(button.length - 1)) + '"');
		addtext = tags[thetag+1] + " ";
	}
	
	AddText(addtext);
}


// toggle funktion - read more
function Toggle (id) {
	if (document.all.item("ToggleRow_" + id).style.display == 'none') {
		document.all.item("ToggleImg_" + id).src = "images/icons/collapse.gif";
		document.all.item("ToggleRow_" + id).style.display = "inline";
		document.all.item("ToggleImg_" + id).alt = "read more";
	}
	else {
		document.all["ToggleImg_" + id].src = "images/icons/expand.gif";
		document.all["ToggleRow_" + id].style.display = "none";
		document.all["ToggleImg_" + id].alt = "hide";
	}
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_confirm(msg, url) { //v1.0
  if(confirm(msg)) location.replace(url);
}

function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function SelectAll() {
	for(var x=0;x<document.form.elements.length;x++) {
		var y=document.form.elements[x];
		if(y.name!='ALL') y.checked=document.form.ALL.checked;
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}