function code_insert(aTag, eTag) {

	if (currentFocus==null) return;

	var input = currentFocus;
	input.focus();


	if(typeof document.selection != 'undefined') {
		var range = document.selection.createRange();
		var insText = range.text;
		range.text = aTag + insText + eTag;


	    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();
	  }


		else
			if(typeof input.selectionStart != 'undefined')  {

			    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);

			    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;
			  }

		else  {

			    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;
			    }

			    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);
		  }
	}


var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
			    if (window.event&&event.srcElement.value.length>=maxlength)
			    return false
			    else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
			    var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
			    if (pressedkey.test(String.fromCharCode(e.which)))e.stopPropagation()
		  }
	}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(theform,thelimit){
var limit_text='<b><span class="Stil1" id="'+theform.toString()+'">'+thelimit+'</span></b> <span class="Stil2">Buchstaben</span>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}



function popup(pic){
        var temp = new Image();
        temp.src = pic;
        var head = "<html><head></head><body>";
        var foot = "</body></html>";
        
        var newWindow = window.open('#','headline','height='+(temp.height+20)+'px, width='+(temp.width+20)+'px',scrollbars='no',toolbar='no',resizable='yes');
        with(newWindow.document){
          open();
          write(head+'<img src="'+pic+'">'+foot);
          close();
        }
    }
	
	
	
function oeffnefenster (url) {
 fenster = window.open(url, "Bild", "width=800,height=600,status=no,scrollbars=yes,resizable=no");
 fenster.focus();
}
