function textarea_store_caret(obj) { if (obj.createTextRange) obj.currRange = document.selection.createRange().duplicate(); } function textarea_insert(obj, txt) { txt = "{{" + txt + "}}"; if (obj.currRange) { obj.currRange.text = obj.currRange.text.charAt(obj.currRange.text.length - 1) != ' ' ? txt : txt + ' '; obj.currRange.select(); } else { obj.value += txt; if (obj.createTextRange) { var v = obj.value; var r = obj.createTextRange(); r.moveStart('character', v.length); r.select(); } } } function textarea_insert_img(obj) { path = window.prompt('Please specify the path of the image to insert', 'http://'); if ((path != "") && (path != null)) { textarea_insert(obj, "img:" + path); } }