helpstat = false;
stprompt = true;
basic = false;
function thelp(swtch){
        if (swtch == 1){
                basic = false;
                stprompt = false;
                helpstat = true;
        } else if (swtch == 0) {
                helpstat = false;
                stprompt = false;
                basic = true;
        } else if (swtch == 2) {
                helpstat = false;
                basic = false;
                stprompt = true;
        }
}

var text = "";
function getActiveText(selectedtext) {
        text = (document.all) ? document.selection.createRange().text : document.getSelection();
        if (selectedtext.createTextRange) {
            selectedtext.caretPos = document.selection.createRange().duplicate();
        }
        return true;
}

function AddText(NewCode) {
        if (document.creator.message.createTextRange && document.creator.message.caretPos) {
                var caretPos = document.creator.message.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
        } else {
                document.creator.message.value+=NewCode
        }
        setfocus();
}

function setfocus() {
document.creator.message.focus();
}

function meiler() {
        if (helpstat) {
                alert("Email Tag\nE-Mailadresse mit mailto hyperlink verlinken.\nUSE: [email]name@domain.de[/email]\nUSE: [email=name@domain.de]link text[/email]");
        } else if (basic) {
                AddTxt="[email][/email]";
                AddText(AddTxt);
        } else {
                txt2=prompt("Welcher Name soll anstatt der Email Adresse angezeigt werden?\nWird dieses Feld freigelassen, so wird die Email Adresse angezeigt.","");
                if (txt2!=null) {
                        txt=prompt("Bitte geben Sie die Email Adresse ein.","name@domain.com");
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[email]"+txt+"[/email]";

                                } else {
                                        AddTxt="[email="+txt+"]"+txt2+"[/email]";
                                }
                                AddText(AddTxt);
                        }
                }
        }
}



function showsize(size) {
        if (helpstat) {
                alert("Size Tag\nMacht einen Text grösser oder kleiner.\nMögliche Werte sind 1 bis 6.\n 1 ist der kleinste und 6 der größte Wert.\nUse: [size="+size+"]Dies ist Dein Text in der Größe "+size+".[/size]");
        } else if (basic) {
                AddTxt="[size="+size+"]"+text+"[/size]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text der in der Größe "+size+" dargestellt werden soll:",dtext);
                if (txt!=null) {
                        AddTxt="[size="+size+"]"+txt+"[/size]";
                        AddText(AddTxt);
                }
        }
}



function showfont(font) {
        if (helpstat) {
                alert("Schriftart Code\nErzeugt den eingeschlossenen Text in der Schriftart "+font+".\nUSE: [font="+font+"]Die Schriftart ist die "+font+"[/font]");
        } else if (basic) {
                AddTxt="[font="+font+"]"+txt+"[/font]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text der in der Schriftart "+font+" dargestellt werden soll:",dtext);
                if (txt!=null) {
                        AddTxt="[font="+font+"]"+txt+"[/font]";
                        AddText(AddTxt);
                }
        }
}




function bold() {
        if (helpstat) {
                alert("Bold Code\nMacht einen Text fettgedruckt.\nUSE: [b]Dies ist Ihr fetter Text[/b]");
        } else if (basic) {
                AddTxt="[b]"+text+"[/b]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text der Fett sein soll.",dtext);
                if (txt!=null) {
                        AddTxt="[b]"+txt+"[/b]";
                        AddText(AddTxt);
                }
        }
}



function italicize() {
        if (helpstat) {
                alert("Bold Code\nMacht einen Text kursiv.\nUSE: [i]Das ist Dein Text in kursiv[/i]");
        } else if (basic) {
                AddTxt="[i]"+text+"[/i]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text der kursiv sein soll.",dtext);
                if (txt!=null) {
                        AddTxt="[i]"+txt+"[/i]";
                        AddText(AddTxt);
                }
        }
}


function quote() {
        if (helpstat) {
                alert("Zitat Code\nZitiert einen bereits geposteten Text.\nUSE: [quote]Dies ist ein Zitat aus einem anderen Posting[/quote]");
        } else if (basic) {
                AddTxt="[quote]"+txt+"[/quote]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text aus einem anderen Posting, der zitiert werden soll:",dtext);
                if (txt!=null) {
                        AddTxt="[quote]"+txt+"[/quote]";
                        AddText(AddTxt);
                }
        }
}


function showcolor(color) {
        if (helpstat) {
                alert("Farb-Tag\nMacht einen Text buntig. Alle mit Namen benannten Farben können verwendet werden\nUSE: [color="+color+"]Dies ist ein Text in "+color+"[/color]");
        } else if (basic) {
                AddTxt="[color="+color+"]"+txt+"[/color]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text der "+color+" sein soll:",dtext);
                if (txt!=null) {
                        AddTxt="[color="+color+"]"+txt+"[/color]";
                        AddText(AddTxt);
                }
        }
}




function move() {
        if (helpstat) {
                alert("Move Code\nErzeugt einen Text, der von rechts nach links bewegt (MS-Explorer-spezifischer Filter.)\nUSE: [move]Text der sich bewegen soll:[/move]");
        } else if (basic) {
                AddTxt="[move]"+txt+"[/move]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text, der von rechts nach links saufen soll: (funzt nur mit IExplorer)",dtext);
                if (txt!=null) {
                        AddTxt="[move]"+txt+"[/move]";
                        AddText(AddTxt);
                }
        }
}



function shadow() {
        if (helpstat) {
               alert("Shadow Tag\nErzeugt ein Schattenartiger Text. (MS-Explorer-spezifischer Filter.)\nUSE: [SHADOW=blue,225]This is the same shadowed text[/SHADOW=blue,225,400]");
        } else if (basic) {
                AddTxt="[shadow][/shadow]";
                AddText(AddTxt);
        } else {
                txt2=prompt("Welche farbe,dicke,breite soll Shadow haben ?","blue,255,400");
                if (txt2!=null) {
                        txt=prompt("Bitte geben Sie den Text ein, der SHADOW dargestellt werden soll.","Text");
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[SHADOW=blue,255,400]"+txt+"[/SHADOW]";
                                        AddText(AddTxt);
                                } else {
                                        AddTxt="[SHADOW="+txt2+"]"+txt+"[/SHADOW]";
                                        AddText(AddTxt);
                                }
                        }
                }
        }
}

function glow() {
        if (helpstat) {
                alert("Glow Tag\nErzeugt einen leuchtenden Text. (MS-Explorer-spezifischer Filter.)\nUSE: [GLOW=red,2,400]This is the same glowed text[/GLOW]");
        } else if (basic) {
                AddTxt="[glow][/glow]";
                AddText(AddTxt);
        } else {
                txt2=prompt("Welche farbe,dicke,breite soll Glow haben ?","red,2,400");
                if (txt2!=null) {
                        txt=prompt("Bitte geben Sie den Text ein, der GLOWED dargestellt werden soll.","Text");
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[glow=red,2,400]"+txt+"[/glow]";
                                        AddText(AddTxt);
                                } else {
                                        AddTxt="[glow="+txt2+"]"+txt+"[/glow]";
                                        AddText(AddTxt);
                                }
                        }
                }
        }
}


function center() {
        if (helpstat) {
                alert("Center Code\nStellt einen Text auf Mitte.\nUSE: [center]Dieser Text ist zentriert.[/center]");
        } else if (basic) {
                AddTxt="[center]"+txt+"[/center]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text, der zentriert werden soll:",dtext);
                if (txt!=null) {
                        AddTxt="[center]"+txt+"[/center]";
                        AddText(AddTxt);
                }
        }
}


function left() {
         if (helpstat) {
                alert("Text der Links dargestellt werden soll.");
        } else if (basic) {
                AddTxt="[left][/left]";
                AddText(AddTxt);
        } else {
                txt=prompt("Bitte geben Sie den Text ein, der LINKS dargestellt werden soll.","Text");
                if (txt!=null) {
                        AddTxt="[left]"+txt+"[/left]";
                        AddText(AddTxt);
                }
        }
}

function right() {
         if (helpstat) {
                alert("Text der Rechts dargestellt werden soll.");
        } else if (basic) {
                AddTxt="[right][/right]";
                AddText(AddTxt);
        } else {
                txt=prompt("Bitte geben Sie den Text ein, der Rechts dargestellt werden soll.","Text");
                if (txt!=null) {
                        AddTxt="[right]"+txt+"[/right]";
                        AddText(AddTxt);
                }
        }
}

function strike() {
         if (helpstat) {
                alert("Text der Durchgestrichen dargestellt werden soll.");
        } else if (basic) {
                AddTxt="[s][/s]";
                AddText(AddTxt);
        } else {
                txt=prompt("Bitte geben Sie den Text ein, der DRUCHGESTRICHEN dargestellt werden soll.","Text");
                if (txt!=null) {
                        AddTxt="[s]"+txt+"[/s]";
                        AddText(AddTxt);
                }
        }
}

function sub() {
         if (helpstat) {
                alert("Text der Runterstellt dargestellt werden soll.\nUSE: [sub]text[/sub]");
        } else if (basic) {
                AddTxt="[sub][/sub]";
                AddText(AddTxt);
        } else {
                txt=prompt("Bitte geben Sie den Text ein, der RUNTERGESTELLT dargestellt werden soll.","Text");
                if (txt!=null) {
                        AddTxt="[sub]"+txt+"[/sub]";
                        AddText(AddTxt);
                }
        }
}

function sup() {
         if (helpstat) {
                alert("Text der Hochgestellt dargestellt werden soll.\nUSE: [sup]text[/sup]");
        } else if (basic) {
                AddTxt="[sup][/sup]";
                AddText(AddTxt);
        } else {
                txt=prompt("Bitte geben Sie den Text ein, der HOCHGESTELLT dargestellt werden soll.","Text");
                if (txt!=null) {
                        AddTxt="[sup]"+txt+"[/sup]";
                        AddText(AddTxt);
                }
        }
}

function tt() {
         if (helpstat) {
                alert("Schreibmachinen Formatiertet Text\nUSE: [tt]Text[/tt]");
        } else if (basic) {
                AddTxt="[tt][/tt]";
                AddText(AddTxt);
        } else {
                txt=prompt("Bitte geben Sie den Text ein, der SCHREIBMASCHINEN art dargestellt werden soll.","Text");
                if (txt!=null) {
                        AddTxt="[tt]"+txt+"[/tt]";
                        AddText(AddTxt);
                }
        }
}

function ftp() {
         if (helpstat) {
                alert("FTP Link.\nUSE: [ftp]ftp://ftp.domain.de[/ftp]");
        } else if (basic) {
                AddTxt="[ftp][/ftp]";
                AddText(AddTxt);
        } else {
                txt=prompt("Bitte geben Sie die URL des FTPs ein.","Text");
                if (txt!=null) {
                        AddTxt="[ftp]"+txt+"[/ftp]";
                        AddText(AddTxt);
                }
        }
}

function pre() {
         if (helpstat) {
                alert("Pre darstellung um den Text in Original Zustand darzustellen nicht Programmcode!");
        } else {
                AddTxt="[pre][/pre]";
                AddText(AddTxt);
        }
}

function table() {
         if (helpstat) {
                alert("Tabelle table");
        } else {
                AddTxt="[table][/table]";
                AddText(AddTxt);
        }
}

function tr() {
         if (helpstat) {
                alert("Tabelle tr");
        } else {
                AddTxt="[tr][/tr]";
                AddText(AddTxt);
        }
}

function td() {
         if (helpstat) {
                alert("Tabelle td");
        } else {
                AddTxt="[td][/td]";
                AddText(AddTxt);
        }
}

function hyperlink() {
        if (helpstat) {
                alert("Hyperlink Tag\nEine URL Verlinken als hyperlink.\nUSE: [url]http://www.coder-world.de[/url]\nUSE: [url=http://www.coder-world.de]Link Text[/url]");
        } else if (basic) {
                AddTxt="[url][/url]";
                AddText(AddTxt);
        } else {
                txt2=prompt("Welchen Namen soll der Link erhalten?\nWird dieses Feld freigelassen, so wird die URL angezeigt.","");
                if (txt2!=null) {
                        txt=prompt("Bitte geben Sie die Link-URL ein.","http://");
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[url]"+txt+"[/url]";
                                        AddText(AddTxt);
                                } else {
                                        AddTxt="[url="+txt+"]"+txt2+"[/url]";
                                        AddText(AddTxt);
                                }
                        }
                }
        }
}

function image() {
        if (helpstat){
                alert("Bild Tag\nein bild einf&uuml;gen.\nUSE: [img]http://www.anywhere.comimage.gif[/img]");
        } else if (basic) {
                AddTxt="[img][/img]";
                AddText(AddTxt);
        } else {
                txt=prompt("Bitte geben Sie die URL der Grafik ein.","http://");
                if(txt!=null) {
                        AddTxt="[img]"+txt+"[/img]";
                        AddText(AddTxt);
                }
        }
}



function showcode() {
        if (helpstat) {
                alert("Quellcode\nFormatiert einen Text als Programmcode.\nUSE:[code]This is formated text[/code]");
        } else if (basic) {
                AddTxt="[code]"+txt+"[/code]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text, der als Programmcode dargestellt werden soll:",dtext);
                if (txt!=null) {
                        AddTxt="[code]"+txt+"[/code]";
                        AddText(AddTxt);
                }
        }
}



function flash() {
        if (helpstat) {
                alert("Flash Tag\nUSE: [flash=200,50]urlzumfilm[/flash]");
        } else if (basic) {
                AddTxt="[flash][/flash]";
                AddText(AddTxt);
        } else {
                txt2=prompt("Flash Tag\n [flash=200,50]urlzumfilm[/flash]","breite,höhe");
                if (txt2!=null) {
                        txt=prompt("Bitte geben Sie die URL zum FlashVideo ein, der dargestellt werden soll.","URL");
                        if (txt!=null) {
                                if (txt2=="") {
                                        AddTxt="[flash]"+txt+"[/flash]";

                                } else {
                                        AddTxt="[flash="+txt2+"]"+txt+"[/flash]";
                                }
                                AddText(AddTxt);
                        }
                }
        }
}

function list() {
        if (helpstat) {
                alert("List Tag\nSortieren nach Alphabet, Nummern oder Auflistung.\nUSE: [list]\n[*]item1[/*]\n[*]item2[/*]\n[*]item3[/*]\n[/list]");
        } else if (basic) {
                AddTxt="\r[list]\r[*]\r[*]\r[*]\r[/list]";
                AddText(AddTxt);
        } else {
                txt=prompt("Art der Liste\n ('A' für alphabetisch, '1' für nummeriert) Frei lassen für normale Bullets","");
                while ((txt!="") && (txt!="A") && (txt!="a") && (txt!="1") && (txt!=null)) {
                        txt=prompt("FEHLER!\nZulässige Werte sind 'A', '1' und nix eintragen","");
                }
                if (txt!=null) {
                        if (txt=="") {
                                AddTxt="[list]\r";
                        } else {
                                AddTxt="[list="+txt+"]\r";
                        }
                        txt="1";
                        while ((txt!="") && (txt!=null)) {
                                txt=prompt("Listeneintrag:\nFeld leer lassen, um die Liste zu beenden.","");
                                if (txt!="") {
                                        AddTxt+="[*]"+txt+"\r";
                                }
                        }
                        AddTxt+="[/list]";
                        AddText(AddTxt);
                }
        }
}

function underline() {
        if (helpstat) {
                alert("Unterstreichen\nStellt einen Text unterstrichen dar.\nUSE: [u]Unterstrichener Text[/u]");
        } else if (basic) {
                AddTxt="[u]"+txt+"[/u]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("Text, der unterstrichen dargestellt werden soll:",dtext);
                if (txt!=null) {
                        AddTxt="[u]"+txt+"[/u]";
                        AddText(AddTxt);
                }
        }
}

function sound() {
        if (helpstat) {
                alert("Sound Einbinden\nStellt eine Funktion zur Verfügung um Sound einzubinden für die Endung WAV,MID und AU.\nUSE: [sound]http://domain.de/test.wav[/sound]");
        } else if (basic) {
                AddTxt="[sound]"+txt+"[/sound]";
                AddText(AddTxt);
        } else {
                if (text) { var dtext=text; } else { var dtext="Text"; }
                txt=prompt("URL, der als Sound ausgegeben werden soll:",dtext);
                if (txt!=null) {
                        AddTxt="[u]"+txt+"[/u]";
                        AddText(AddTxt);
                }
        }
}
