text_tag_prompt = "Zu formatierenden Text eingeben:";
img_tag_prompt = "URL zur Bilddatei eingeben";
img_size_prompt = "Größe der Bilddatei eingeben";
urltext_tag_prompt = "Beschreibung des Links:";
urllink_tag_prompt = "Link-Adresse:";
emailtext_tag_prompt = "Beschreibung der E-Mail-Adresse:";
emaillink_tag_prompt = "E-Mail-Adresse:";
list_type_prompt = "Listentyp:\nGib ein:\n1 - nummerierte Liste (Ziffern)\ni - nummerische Liste (Römische Zahlen klein)\nI - nummerische Liste (Römische Zahlen gross)\na - alphabetische Liste (klein)\nA - alphabetische Liste (gross)\ngar nichts für eine einfache Punktliste";
list_item_prompt = "Gebe eine Listepunkt ein.\nGebe nichts ein oder drücke 'Cancel' um die Liste fertigzustellen.";

function addtext(newtext,theform) {
 if (theform.createTextRange && theform.caretPos) {
  var caretPos = theform.caretPos;
  caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? newtext + ' ' : newtext;
 } 
 else theform.value+=newtext
 text2add = "";
}

function bbcode(theform,bbcode,prompttext) {
inserttext = prompt(text_tag_prompt+"\n["+bbcode+"]xxx[/"+bbcode+"]",prompttext);
if ((inserttext != null) && (inserttext != ""))
 addtext("["+bbcode+"]"+inserttext+"[/"+bbcode+"] ",theform);
theform.focus();
}

function imgcode(theform,prompttext) {
insertimage = prompt(img_tag_prompt,prompttext);
if ((insertimage != null) && (insertimage != ""))
 addtext("[IMG]"+insertimage+"[/IMG] ",theform);
theform.focus();
}

function imgsizecode(theform,prompttext) {
insertimage = prompt(img_tag_prompt,prompttext);
imagesize = prompt(img_size_prompt,"50%");
if ((insertimage != null) && (insertimage != "") && (imagesize != null) && (imagesize != ""))
 addtext("[IMGSIZE="+imagesize+"]"+insertimage+"[/IMGSIZE] ",theform);
theform.focus();
}

function urlcode(theform,prompttext) {
urltext = prompt(urltext_tag_prompt,prompttext);
urllink = prompt(urllink_tag_prompt,"http://");
if ((urllink != null) && (urllink != "")) {
 if ((urltext != null) && (urltext != "")) {
  addtext("[URL="+urllink+"]"+urltext+"[/URL] ",theform); }
 else {
  addtext("[URL]"+urllink+"[/URL] ",theform); } 
 }
theform.focus();
}

function emailcode(theform,prompttext) {
emailtext = prompt(emailtext_tag_prompt,prompttext);
emaillink = prompt(emaillink_tag_prompt,"name@domain.de");
if ((emaillink != null) && (emaillink != "")) {
 if ((emailtext != null) && (emailtext != "")) {
  addtext("[EMAIL="+emaillink+"]"+emailtext+"[/EMAIL] ",theform); }
 else {
  addtext("[EMAIL]"+emaillink+"[/EMAIL] ",theform); } 
 }
theform.focus();
}

function listcode(theform) {
listtype = prompt(list_type_prompt, "");
if ((listtype == "a") || (listtype == "A") || (listtype == "i") || (listtype == "I") || (listtype == "1")) {
 thelist = "[LIST="+listtype+"]\n";
 listend = "[/LIST]\n";
}
else {
 thelist = "[LIST]\n";
 listend = "[/LIST]\n";
}
listentry = "initial";
while ((listentry != "") && (listentry != null)) {
 listentry = prompt(list_item_prompt, "");
 if ((listentry != "") && (listentry != null)) thelist = thelist+"[*]"+listentry+"\n";
}
thelist += listend;
addtext(thelist,theform);
theform.focus();
}

