	function Comment(){
		this.properties= {
			commentsBlockID: 'comments',
			postFormIDprefix: 'postform',
			siteUrl: SERVER+'/comments.php',
			postFormUrl: 'post_form',
			deleteCommentUrl: 'delete',
			saveRatingUrl: 'post_rating',
			nextComment: 'next_comment',
			limitComment: 5,
			theme: '',
			

		}

		var _self = this;
		
		this.CommentChange = function(comment) {
			var message = comment;
			var id_count_sum = $('.count_sum').attr('id');
			var count = 256;
			$('#'+id_count_sum).text(count);
			a = $('#'+message).val().length;
			if (a > count) {
				$('#'+message).val($('#'+message).val().substring(0, count));
			}
			a = $('#'+message).val().length;
			$('#'+id_count_sum).text(count - a);
			if (a > count){
				$('#'+message).css("disabled", "disabled");
			}
		}
		
		
		
		this.post_form = function(form_id, objectID, TypeGid){
			var comment = $("#comment_"+form_id).val();
			var submit_html = $('#submit_comment').html();
			var comment_count = $('.comment_wrapper').size();
			var id_count_sum = $('.count_sum').attr('id');
			$.ajax({
				type: 'POST',
				url: _self.properties.siteUrl,
				data: {'sel': _self.properties.postFormUrl, 'object_id': objectID, 'object_type_gid': TypeGid, 'comment': comment},
				success: function(msg){
					if(msg != "error"){
						$('#submit_comment').html(submit_html);
						$('#comment_'+form_id).val('');
						$('#comment_block_'+objectID).html(msg);
						$('#'+id_count_sum).html("256");
						if(comment_count>=5){
							document.getElementById("update_comment").style.display="block";
						}
					}else{
						$("#comment_"+form_id).html();
					}
				}
			});
		}
		
		this.DeleteComment = function (obj, comment_id){
			var comment_count = $('.comment_wrapper').size();
			if(comment_id == undefined || comment_id == 0 || obj == undefined){
				return;
			}
			$(obj).blur();
					$.ajax({
						type: 'POST',
						url: _self.properties.siteUrl,
						data: {'sel':_self.properties.deleteCommentUrl, 'comment_id':comment_id},
						success: function(msg){
							if(msg != 'ERROR'){
								$(obj).closest('.comment_wrapper').fadeOut(300,function(){
									$(obj).closest(".comment_wrapper").remove();
								});
								if(comment_count<5){
									document.getElementById("update_comment").style.display="none";
								}	
							}
							else{
								var del_comment = 'ERROR_DELETE_COMMENT';
								$(obj).html('ERROR_DELETE');
								if(del_comment != ''){
									alert(del_comment);
								}
							}
						}
					});
		}
		
		this.saveRating = function(comment_id, dir){
			$.ajax({
				type: 'POST',
				url: _self.properties.siteUrl,
				data: {'sel': _self.properties.saveRatingUrl, 'comment_id': comment_id, 'dir': dir},
				success: function(data){
				if(data != '') $("#commr_"+comment_id).html(data);
				}
			});
		}
		
		this.updateComment = function (objectID, TypeGid){
			$.ajax({
			  type: 'POST',
			  url: _self.properties.siteUrl,
			  data: {'sel': _self.properties.nextComment, 'limit': _self.properties.limitComment, 'object_id': objectID, 'object_type_gid': TypeGid},
			  success: function(data){
				  if(data == ""){
					document.getElementById("update_comment").style.display="none";
				  }else{
					$('#comment_block_'+objectID).after(data);
					 _self.properties.limitComment = _self.properties.limitComment+5;
				  }
			   }
			});
		}

		
	}