// JavaScript Document
function fade(alt,neu,tra,soll,aus,trb)
{
	aus = aus || 0;
	tra = tra || 100;
	document.getElementById(alt).style.opacity = tra/100;
	document.getElementById(alt).style.filter = "alpha(opacity=" + tra + ")"; // IE
	tra = tra - 15;
	if (tra > soll){window.setTimeout(function () { fade(alt,neu,tra,soll,aus,trb); }, 20);}
	if (tra <=soll)
	{
		if (aus == 1){document.getElementById(alt).style.visibility = 'hidden'};
		document.getElementById(neu).style.visibility = 'visible';
		fadein(neu,trb);
	}
}
function fadein(object,trb)
{
	
	trb = trb || 0;
	if (document.getElementById(object).style.visibility == 'hidden') {document.getElementById(object).style.visibility = 'visible';}
	document.getElementById(object).style.opacity = trb/100;
	document.getElementById(object).style.filter = "alpha(opacity=" + trb + ")"; // IE
	trb = trb + 15;
	if (trb < 100){window.setTimeout(function () { fadein(object,trb); }, 20);}
}

function einschalten(object,alt)
{
	if (object =="") {return;}
	document.getElementById(alt).style.opacity = 10/100;
	document.getElementById(alt).style.filter = "alpha(opacity = 10)"; // IE
	document.getElementById(object).style.opacity = 100/100;
	document.getElementById(object).style.filter = "alpha(opacity = 100)"; // IE
	document.getElementById(object).style.visibility = 'visible';
}

function schliessen(object)
{
	document.getElementById(object).style.visibility = "hidden";
}
function oeffnefenster (url)
{
	 fenster = window.open(url, "fenster1", "width=450,height=400,status=no,scrollbars=yes,resizable=no");
	 fenster.focus();
}
function insert(aTag, eTag) {
  var input = document.gb.Gbtext;
  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);
  }
}

