function switchCommentsVisibility() {
	var comment_body = document.getElementById('comment_body');
	var comment_switch_text = document.getElementById('comment_switch_text');
	var comments_showall = document.getElementById('comment_showall');
	if (comments_showall.childNodes.length != 0) {
		xajax_run('xcomments','hideCommentsBody');
	} else {
		xajax_run('xcomments','showCommentsBody');
	}
	return true;
}


function checkFillContent(value)

{

	if (value == '') {

		alert("Заполните все поля, отмеченные символом '*'");

		return false;

	}

	return true;

}



function saveComment(pid, type)

{

	var content = $F('comment_content_' + pid);

	var login = $F('comment_login_' + pid);

	var code = $F('comment_code_' + pid);

	if (document.getElementById('comment_mess_pass_'+pid))
		var mes_pass = $F('comment_mess_pass_'+pid);
	else
		var mes_pass = false;
	
	
	if (checkFillContent(content)  && checkFillContent(code)) {

		xajax_run(
			'xcomments',
			'saveComment',
			pid,
			$F('comment_content_'+pid),
			type,
			login,
			$F('comment_pass_'+pid),
			code,
			1,
			mes_pass
		);

	}

}



function changeCommentNode(id)

{

	if ($('comment_child_' + id).style.display == 'none') {

		openSubComments(id);

	} else {

		closeSubComments(id);

	}

}



function openSubComments(id)

{

	if ($('comment_child_' + id).innerHTML == '') {

		xajax_run('xcomments','showSubComments', id);

		$('comment_child_' + id).style.display = 'block';

	} else {

		$('comment_child_' + id).style.display = 'block';

	}

	$('comment_img_' + id).src = "images/xcomments/minus.gif";

}



function closeSubComments(id)

{

	$('comment_child_' + id).style.display = 'none';

    $('comment_img_' + id).src = "images/xcomments/plus.gif";

}