var AskAnExpert = {

	blankComment : function() {
		if ($('comment_comment').value == '') {
			alert("Please enter a comment");
			return true;
		} else {
			return false;
		}
	},
	
	setConfirm : function() {
		var a = $('moderate_action').value;
		var text = a + ' selected comments?';
		return (a == '' ? false : confirm(text));
	},

	addPrompt : function(id, text)
	{
		var obj = $(id);
		if (obj.value == '' || obj.value == text) {
		   obj.value = text;
		   obj.addClassName('prompt');
		   Event.observe(obj, 'click', AskAnExpert.removePrompt);
		}
	},

	removePrompt : function(event)
	{
		var elm = Event.element(event);
		elm.value='';
		elm.removeClassName('prompt')
		Event.stopObserving(elm, 'click', AskAnExpert.removePrompt);
	},

	escapeHTMLChars : function(text)
	{
		return text.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
	},
	
	setName : function()
	{
		// Get values
		var f = $('person_first_name').value;
		var l = $('person_last_name').value;
	
		if (f == '') { f = 'John'; l = 'Doe'; }
	
		var name0 = f;
		var name1 = f + (l == '' ? '' : ' ' + l.substring(0,1) + '.');
		var name2 = (l == '' ? f : f.substring(0,1) + '.' + l.substring(0,1) + '.');
	
		// Update labels
		$('anonymity_0_label').update(AskAnExpert.escapeHTMLChars(name0));
		$('anonymity_1_label').update(AskAnExpert.escapeHTMLChars(name1));
		$('anonymity_2_label').update(AskAnExpert.escapeHTMLChars(name2));
	},
	
	showCommentForm : function(form, link)
	{
		$(form).show();
		$(link).hide();
	}
}