var NewsPrototype = Class.create();

NewsPrototype.prototype = {
	initialize: function() {
	},
	showComments: function(newsId)
	{
		$('commentsHref_' + newsId).style.display = "none";
		$('showComments_' + newsId).style.display = "block";
		$('addCommentHref_' + newsId).style.display = "block";
		$('slash_' + newsId).style.display = "none";
		$('showComments_' + newsId).scrollTo();
	},
	showAddCommentForm: function(newsId)
	{
		$('addCommentArea_' + newsId).style.display = "block";
		$('addCommentHref_' + newsId).style.display = "none";
		$('slash_' + newsId).style.display = "none";
		$('addCommentArea_' + newsId).scrollTo();
		new ResizingTextArea($('commentTextForm_' + newsId));
	},
	commentSend: function(newsId)
	{
		var err = false;
		var commentErr = new Array('commentEmpty_' + newsId, 'commentLong_' + newsId);

		commentObj = $('commentTextForm_' + newsId); 
		comment = commentObj.getValue(); 

		Xms.clearErrors(new Array('commentTextForm_' + newsId), commentErr);

		if(comment == '') {
			err = Xms.showErrors(commentObj,'commentEmpty_' + newsId);
		} else if(comment.length > 2000) {
			commentObj.setValue(comment.substr(0, 2000));
			err = Xms.showErrors(commentObj,'commentLong_' + newsId); 
		}
		if(!err) {
			commentObj.setValue('');
			var argsObj = new Object();
			argsObj["operation"]      = "sendComment";
			argsObj["itemId"]         = newsId;
			argsObj["textStripTags"]  = comment;
			ajaxCall('News/showNews', argsObj);
		}
	},
	commentPager: function(itemId, page)
	{
		var argsObj = new Object();
		argsObj["operation"] = "getComments";
		argsObj["itemId"]    = itemId;
		argsObj["page"]      = page;
		ajaxCall('News/showNews', argsObj);
	}
};

var News = new NewsPrototype();