function PostCommentBoxMessage(text,commentbox,answerto)
{
	var rand;
	rand = Math.round(Math.random()*1115000)
	text = escape(text);
	Loading();
	$.post("widgets/commentbox_post.php", 
			  { text: text,commentbox: commentbox,answerto: answerto }, 
				function(data)
				{
					$(this).parent().html(data);
				}
			);
		if(answerto!='0')
		{
			$("#comment_"+answerto).append('<div id="'+rand+'"></div>');
			LoadDummy(text,rand);
		}
		else
		{
			$("#commentbox_text_"+commentbox).prepend('<div id="'+rand+'"></div>');
			$("#"+rand).load("widgets/commentbox_dummy.php",function(){$("#"+rand+" #comment_text_dummy").html(unescape(text));});
			LoadDummy(text,rand);
		}
		//$("#statusmessage_dummy").fadeIn();
	NotLoadingAnymore();
}

function GetCommentBoxAnswerForm(commentbox,answerto)
{
	if(answerto!='0')
		$("#comment_"+answerto).append('<textarea class="wysiwyg" id="comment_box_answer_text_'+answerto+'" cols="50" rows="5" ></textarea> <input type="button" value="Antworten" onClick="PostCommentBoxMessage(document.getElementById(\'comment_box_answer_text_'+answerto+'\').value,\''+commentbox+'\',\''+answerto+'\');$(this).hide();$(\'#comment_box_answer_text_'+answerto+'\').parent().parent().parent().hide();">'    );
	else
		$("#commentbox_text_"+commentbox).prepend('<textarea class="wysiwyg" id="comment_box_answer_text_'+commentbox+'" cols="50" rows="5" /></textarea> <input type="button" value="Antworten" onClick="PostCommentBoxMessage(document.getElementById(\'comment_box_answer_text_'+commentbox+'\').value,\''+commentbox+'\',\'0\');$(this).hide();$(\'#comment_box_answer_text_'+commentbox+'\').parent().parent().parent().hide();">');
		
		LoadWYSIWYG();
}

function LoadDummy(text,rand)
{
	$.get("widgets/commentbox_dummy.php",{ text: text, rand: rand}, 
		function(data)
		{
			$("#"+rand).html(unescape(data));
		}
	);
}
