/*  01-Newsscript V2 - Copyright 2006/2007 by Michael Lorer - 01-Scripts.de   */
/*  Lizenzinformationen unter: http://www.01-scripts.de/lizenz.php            */
/*  Support unter: http://www.01-scripts.de/support.php                       */
/***  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  *  *        */
/*  letzte Dateiänderung: 09/01/07 - 16:22 von ML                             */
/*  letzte User-Bearbeitung am dd/mm/yy um hh:mm von Name                     */


function popup(id) {
window.open('help.php?id='+id+'','_blank','width=450,height=400,scrollbars=yes,resizable=yes,status=no,toolbar=no,left=200,top=150');
}

function redirect(url){
    window.location.href = url;
}

function CheckZahl(a, b){
var Wert = a;
 if(isNaN(Wert)){
  alert(Wert + " ist keine Zahl!");
  document.getElementById('feld'+b).value = "";
  return false;
 }
 else{
 return true;
 }
}

function smilie(text)
{
eval("document.post.newsfeld.value += \""+text+"\"");
document.post.newsfeld.focus();
}

var oldTag = "";
var newTag2 = "";
var closeTags = new Array();

function openTag(newTag){
if(newTag2 != newTag)
{
 newTag2=newTag;
 var vor_text = document.post.newsfeld.value;
 document.post.newsfeld.value = vor_text+"["+newTag+"]";
 closeTags.unshift(newTag);
}
document.post.newsfeld.focus();
}

function closeTag(){
if(closeTags.join() != "")
{
 var vor_text = document.post.newsfeld.value;
 document.post.newsfeld.value = vor_text+"[/"+closeTags[0]+"]";
 closeTags.shift()
 newTag2 = "";
 font = 0;
 size = 0;
 color = 0;
}
document.post.newsfeld.focus();
}

function url() {
b = prompt('Beschreibung für den Link (optional)','');
if(b==null) {
return;
}
if(b=="" || b!="") {
       c = prompt('Die Url zum Link','http://');
       if(c == null) return;
       if(b!="" && c!="")document.post.newsfeld.value += '[URL='+c+']'+b+'[/URL]';
       if(b=="" && c!="")document.post.newsfeld.value += '[URL]'+c+'[/URL]';
       else return;
       }
}

function email() {
b = prompt('Beschreibung für die E-Mail-Adresse','');
if(b==null) {
return;
}
if(b=="" || b!="") {
       c = prompt('Die E-Mail-Adresse','');
       if(c == null) return;
       if(b!="" && c!="")document.post.newsfeld.value += '[EMAIL='+c+']'+b+'[/EMAIL]';
       if(b=="" && c!="")document.post.newsfeld.value += '[EMAIL]'+c+'[/EMAIL]';
       else return;
       }
}

/*BB-Code-Funktion (c) by http://aktuell.de.selfhtml.org/artikel/javascript/bbcode/index.htm */
function bbcinsert(aTag, eTag) {
  var input = document.forms['post'].elements['newsfeld'];
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}
/* 01-Newsscript V2 Copyright 2006/2007 by Michael Lorer - 01-Scripts.de*/