
function validateNewsForm()
{
	bolRes = true;
	
	resetCommentErrors()
	
	bolRes = checkComment() && bolRes;

	return bolRes;
}

function resetCommentErrors()
{
	document.getElementById("CommentError").innerHTML = "";
}

function checkComment()
{
	var objComment = objWysiwyg.getContent();
	var objError = document.getElementById("CommentError");
	
	if(objComment == "")
	{
		objError.innerHTML = "Обязательное поле";
		return false;
	}
	
	return true;
}

function removeAjaxComment(_objLink, _custId, _commentId)
{
	var objAjaxPage = new AjaxPageManage();
	objAjaxPage.setResponseData = function() {doRemoveComment(_objLink);}
	objAjaxPage.getAjaxPage('get_news_comment', ['action', 'userId', 'commentId'], ["DELETE", _custId, _commentId]);
}

function doRemoveComment(_objLink)
{
	var objTable = _objLink.parentNode.parentNode.parentNode;
	objTable.parentNode.removeChild(objTable);
}

function getAjaxComment(_custId, _plantId)
{
	document.getElementById("CommentFormError").innerHTML = "";
	
	var UserComment = objWysiwyg.getContent();
	
	var objAjaxPage = new AjaxPageManage();
	objAjaxPage.doLoading = function() {}
	objAjaxPage.setResponseData = function() {doAddComment(objAjaxPage.responseText); doHideLoader("addCommentLoader");}
	
	objAjaxPage.getAjaxPage('get_news_comment', ['action', 'custId', 'newsId', 'UserComment'], ["ADD", _custId, _plantId, UserComment]);
}

function doAddComment(_responseText)
{
	if(_responseText != "")
	{
		var objContainer = document.getElementById("commentContainer");
		objContainer.innerHTML += _responseText;
		
		objWysiwyg.setContent("");
	}
	else
	{
		objError = document.getElementById("CommentFormError");
		objError.innerHTML = "Попробуйте еще раз";
	}
}

function doShowLoader(_id)
{
	var objLoader = document.getElementById(_id);
	objLoader.style.display = "inline";
}

function doHideLoader(_id)
{
	var objLoader = document.getElementById(_id);
	objLoader.style.display = "none";
}