var current_comment_id = null;

function hideAnswerForms() 
{
	if ( current_comment_id != null ) 
	{
		var div = document.getElementById('answer_form_' + current_comment_id);
	
		for (var j=0; j<div.childNodes.length; j++) 
		{
			div.removeChild(div.childNodes[j]);
		}
		
		$('answer_form_' + current_comment_id).update('');
		
		current_comment_id = null;
	}
	
	elements = document.getElementsByName("answer_href");
	for (var i=0; i<elements.length; i++) 
	{
		elements[i].style.display = '';
	}
}

function showAnswerForm(comment_id, doc_id, doc_class) 
{
	hideAnswerForms();
	
	current_comment_id = comment_id;
	
	answer_form = $('answer_form_' + comment_id);
	answer_form_text = "<form action=\"http://www.tagantransport.ru/comments/submit.html\" method=\"post\" class=\"message_form\">"
							+ "<input type=\"hidden\" name=\"object_id\" value=\"" + doc_id + "\">"
							+ "<input type=\"hidden\" name=\"object_type\" value=\"" + doc_class + "\">"
							+ "<input type=\"hidden\" name=\"parent_comment_id\" value=\"" + comment_id + "\">"
							+ "<table cellpadding=\"0\" cellspacing=\"0\" class=\"answer_column\" >"
							+ "<tr><th>ваш ответ</th>"
							+ "<th class=\"close\"><a onclick=\"hideAnswerForms(); return false;\" href=\"#\">закрыть</a></th></tr>"
							+ "<tr><td colspan=2><textarea cols=\"1\" rows=\"1\" name=\"message\"></textarea></td></tr>"
							+ "<tr><td colspan=2 class=\"btn\"><input class=\"btn\" type=\"submit\" value=\"отправить\" name=\"submit\"></td></tr>"
							+ "</table></form>";
	answer_form.insert({bottom: answer_form_text});
	
	document.getElementById('answer_href_' + comment_id).style.display = 'none';
}