if (Drupal.jsEnabled) { $('img.smiley-hand').click(function(){ var smiley = ' ' + this.alt + ' '; $('textarea#edit-body, textarea#edit-comment').each(function() { if (document.selection) { this.focus(); document.selection.createRange().text = smiley; this.focus(); } else if (text.selectionStart || text.selectionStart == '0') { var cursorPos = this.selectionEnd + smiley.length; this.value = this.value.substring(0, this.selectionStart) + smiley + this.value.substring(this.selectionEnd); this.focus(); this.selectionStart = this.selectionEnd = cursorPos; } else { this.value = this.value + smiley this.focus(); } }); }); }); }