function emoticon(smilie)
{
	theInsert(" " + smilie + "  ", "", false);
}

function theInsert(theicon, thetag, isSingle)
{
    var myAgent   = navigator.userAgent.toLowerCase();
    var myVersion = parseInt(navigator.appVersion);

    var is_ie      = ((myAgent.indexOf("msie") != -1)  && (myAgent.indexOf("opera") == -1));
    var is_nav   = ((myAgent.indexOf('mozilla')!=-1) && (myAgent.indexOf('spoofer')==-1)
                            && (myAgent.indexOf('compatible') == -1) && (myAgent.indexOf('opera')==-1)
                            && (myAgent.indexOf('webtv') ==-1)       && (myAgent.indexOf('hotjava')==-1));

    var is_win   =  ((myAgent.indexOf("win")!=-1) || (myAgent.indexOf("16bit")!=-1));
    var is_mac    = (myAgent.indexOf("mac")!=-1);
	
	var isClose = false;
	var myform = window.document.gbuch.kommentar;

	if ( (myVersion >= 4) && is_ie && is_win) 
	{
		if(myform.isTextEdit){
			myform.focus();
			var sel = document.selection;
			var rng = sel.createRange();
			rng.colapse;
			if((sel.type == "Text" || sel.type == "None") && rng != null){
				if(thetag != "" && rng.text.length > 0)
					theicon += rng.text + thetag;
				else if(isSingle)
					isClose = true;
	
				rng.text = theicon;
			}
		}
		else{
			if(isSingle)
				isClose = true;
	
			myform.value += theicon;
		}
	}

	else if ( myform.selectionEnd )
	{
            var length = myform.textLength;
            var start = myform.selectionStart;
            var end = myform.selectionEnd;
            if (end == 1 || end == 2)
                end = length;
            var head = myform.value.substring(0,start);
            var rng = myform.value.substring(start, end);
            var tail = myform.value.substring(end, length);
            if( start != end ){
                if (thetag != "" && length > 0)
                    theicon += rng + thetag;
                else if (isSingle)
                    isClose = true;
                rng = theicon;
                myform.value = head + rng + tail;
                start = start + rng.length;
            }
            else{
                if(isSingle)
                    isClose = true;
                myform.value = head + theicon + tail;
                start = start + theicon.length;
            }
            myform.selectionStart = start;
            myform.selectionEnd = start;
	}

	else
	{
		if(isSingle)
			isClose = true;

		myform.value += theicon;
	}

	myform.focus();
	return isClose;
}