var input;function setInput(input) {	this.input = input;}function setCursor() {	if(typeof input.createTextRange != 'undefined') {		input.cursorPos = document.selection.createRange().duplicate();	}}

function emoticon(text) {	if(input == null) {		if(document.getElementById('messageContent')) {			input = document.getElementById('messageContent');		} else {			return;		}	}    if(document.all && input.cursorPos) {      input.cursorPos.text = text;    } else if(typeof(input.selectionStart) != 'undefined') {      var sStart = input.selectionStart;      var sEnd = input.selectionEnd;      input.value = input.value.substr(0, sStart) + text + input.value.substr(sEnd, input.value.length);      input.selectionStart = (sStart == sEnd)? sStart + text.length:sStart;      input.selectionEnd = sStart + text.length;    } else {      input.value += text;    }    input.focus();    setCursor();}
