rem: var range = document.selection.createRange().text = subst; this.textarea.caretPos -= suffix.length; 
add: document.selection.createRange().text = subst; var range = this.textarea.createTextRange(); range.collapse(false); range.move('character', -suffix.length); range.select();  
context: 	encloseSelection: function(prefix, suffix, fn) {		this.textarea.focus();				prefix = prefix || '';		suffix = suffix || '';				var start, end, sel, scrollPos, subst, res;				if (typeof(document["selection"]) != "undefined") {			sel = document.selection.createRange().text;		} else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {			start = this.textarea.selectionStart;			end = this.textarea.selectionEnd;			scrollPos = this.textarea.scrollTop;			sel = this.textarea.value.substring(start, end);		}				if (sel.match(/ $/)) { // exclude ending space char, if any			sel = sel.substring(0, sel.length - 1);			suffix = suffix + " ";		}				if (typeof(fn) == 'function') {			res = (sel) ? fn.call(this,sel) : fn('');		} else {			res = (sel) ? sel : '';		}				subst = prefix + res + suffix;				if (typeof(document["selection"]) != "undefined") {			var range = document.selection.createRange().text = subst;			this.textarea.caretPos -= suffix.length;		} else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {			this.textarea.value = this.textarea.value.substring(0, start) + subst +			this.textarea.value.substring(end);			if (sel) {				this.textarea.setSelectionRange(start + subst.length, start + subst.length);			} else {				this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);			}			this.textarea.scrollTop = scrollPos;		}	},
meta: 7587	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/7587/f589ca934bf28f95c99c1f2b66a312a99b5eac67/jstoolbar.js/clean/public/javascripts/jstoolbar.js