// JavaScript Document
function get_object(object_id) {
    if(document.getElementById && document.getElementById(object_id)) {
		return document.getElementById(object_id);
    } else if(document.all && document.all(object_id)) {
		return document.all(object_id);
    } else if(document.layers && document.layers[object_id]) {
		return document.layers[object_id];
    } else {
		return false;
    }
}

function smiley(id, text) {
	var obj = get_object(id);
	obj.focus();
	text = " " + text + " ";
	//obj.value  += text;
	insert_at_cursor(obj, text);
	//obj.focus();
}

function insert_at_cursor(obj, text) {
	if (document.selection) { //IE support
		obj.focus();
		sel = document.selection.createRange();
		sel.text = text;
	} else if (obj.selectionStart || obj.selectionStart == '0') { //MOZILLA/NETSCAPE support
		var start_pos = obj.selectionStart;
		var end_pos = obj.selectionEnd;
		obj.value = obj.value.substring(0, start_pos) + text + obj.value.substring(end_pos, obj.value.length);
	} else {
		obj.value += text;
	}
}




var isVisible=false;

function ShowSmileys() 
{
 	var smileys = document.getElementById("smileys");
	smileys.style.display= (isVisible ? "none" : "block");
	isVisible=!isVisible;
}