function CheckCommentForm() {
	if (
		!document.getElementById('commentText').value ||
		'' == document.getElementById('commentText').value
	) {
		alert('Введите текст комментария!');
		return false;
	}

	if (
		!document.getElementById('captchaText').value ||
		'' == document.getElementById('captchaText').value
	) {
		alert('Введите код подтверждения!');
		return false;
	}

	//check captcha
	var req = new JsHttpRequest();
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if (req.responseJS && req.responseJS.result && 'ok' == req.responseJS.result) {
				if (!req.responseJS.data) {
					ReplaceChildText(document.getElementById('commentInfoBlock'), 'Код подтверждения неверный');
					return;
				}
 				else
 					document.getElementById('formComment').submit();
			}
			else
				document.getElementById('formComment').submit();
		}
	}
	req.caching = false;
	req.open(null, '/tool/load.php', true);
	req.send( { type:'commentCaptcha', captcha:document.getElementById('captchaText').value } );

	return false;
}
function CaptchaReload() {
	document.getElementById('captchaImg').src = '/tool/captcha.php?rnd=' + Math.round(Math.random(0)*100000);
}

function RestoreComment() {
	if (userName = GetCookie('commentUserName')) {
		DeleteCookie('commentUserName', '/', 'mobilnik2');
	}
	if (text = GetCookie('commentText')) {
		document.getElementById('commentText').value = text;
		if (userName)
			document.getElementById('userName').value = userName;
		ShowHideCommentForm();
		DeleteCookie('commentText', '/', 'mobilnik2');
	}
}
