function insert(aTag, eTag, formName, inputName) {
  var input = document.forms[formName].elements[inputName];
  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);
  }
}

wmtt = null;
function updateWMTT(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (wmtt != null) {
		wmtt.style.left = (x + 20) + "px";
		wmtt.style.top 	= (y + 20) + "px";
	}
}

function showWMTT(id) {
	wmtt = document.getElementById(id);
	wmtt.style.display = "block"
}

function hideWMTT() {
	wmtt.style.display = "none";
}
function zeigMenu(ziel, quelle)
{
	zielObjekt = document.getElementById(ziel);
	quellObjekt = document.getElementById(quelle);
	zielObjekt.style.display = "block";
	x = (document.all) ? window.event.x + document.body.scrollLeft : quellObjekt.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : quellObjekt.pageY;
	if (zielObjekt != null) {
		zielObjekt.style.left = (x + 20) + "px";
		zielObjekt.style.top  = (y + 20) + "px";
	}
}
function versteckeMenu(ziel)
{
	zielObjekt = document.getElementById(ziel);
	zielObjekt.style.display = "none";
}
function showTooltip(text)
{
	span = document.getElementById('tooltip');

	span.innerHTML = text;
	span.width = '';
	span.height = '';
	span.style.cursor = 'help';
	span.style.visibility = 'visible';
}
function hideTooltip()
{
	//span.style.visibility = 'hidden';	
}
