var status="";

function stat(s){
   status=s;
}

function smilie(thesmilie) {
     var textfeld=document.getElementById('posting');
     var text=document.getElementById('posting').value;
     if (textfeld.createTextRange && textfeld.caretPos) {
          var caretPos = textfeld.caretPos;
          caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? thesmilie + ' ' : thesmilie;
     } else if (textfeld.selectionStart || textfeld.selectionStart == '0') {
          var start_selection = textfeld.selectionStart;
          var end_selection = textfeld.selectionEnd;
          var start = (textfeld.value).substring(0, start_selection);
          var middle = thesmilie;
          var end = (textfeld.value).substring(end_selection, textfeld.textLength);
          textfeld.value = start + middle + end;
          textfeld.selectionStart = end_selection + middle.length; textfeld.selectionEnd = start_selection + middle.length;
     } else { textfeld.value += thesmilie; }
     textfeld.focus();
}

function storeCaret( id ) {
   if (id.createTextRange) id.caretPos = document.selection.createRange().duplicate();
 }
function insertcode(feld,ubbcode,prompttext,beschreibung) {
   var code = "";
   var textfeld = document.getElementById('posting');
   if (ubbcode == "IMG") {
       textprint = prompt("Wir weisen Sie darauf hin, das nur Bilder eingebunden werden dürfen, auf denen keine Copyright liegt. Diese Ausgabe wird erzeugt: ["+ubbcode+"]BILD-LINK[/"+ubbcode+"]","http://"); }
  else if (ubbcode == "URL") {
       textprint = prompt("Bitte geben Sie die Internetadresse ein, auf die Sie verlinken möchten.\nDiese Ausgabe wird erzeugt: ["+ubbcode+"]URL[/"+ubbcode+"]","http://"); }

   // alert(textfeld+"   "+textfeld.selectionStart+"  "+ textfeld.selectionEnd+"\n"+ubbcode);

   if (textfeld.selectionEnd > textfeld.selectionStart ) {
      textprint = (textfeld.value).substring(textfeld.selectionStart,textfeld.selectionEnd);
      code = "["+ubbcode+"]"+textprint+"[/"+ubbcode+"] ";
     javascript:smilie(code);
      return;
      }
   else { textprint = prompt("Bitte geben Sie den Text ein, den Sie "+beschreibung+" wollen\nDiese Ausgabe wird erzeugt: ["+ubbcode+"]IHR TEXT[/"+ubbcode+"]",prompttext); }

   if ((textprint != null) && (textprint != ""))  code = "["+ubbcode+"]"+textprint+"[/"+ubbcode+"] ";
   if (textprint){ javascript:smilie(code); }
}
function returntoforum() {
   return confirm("Sind Sie wirklich sicher, das Sie Ihren Beitrag nicht abschicken wollen und stattdessen zurück zur Forenübersicht möchten ?");
 }
