	function ReplyBox(commentId){
		this.commentId =  commentId;
		this.GetCommentBoxView = GetCommentBoxView;
		this.Ready = function Ready(){
		
					$('#commentSubmitButton'+this.commentId).click(function(){
						var commentId = $(this).attr('commentId');
						var commentDescription = $('#commentDescriptionId'+commentId).val();
						
						
						
						$.ajax({
							   type: "POST",
							   url: 'Bend/CommentReply/commentId/'+commentId,
							   data: {commentDescription:commentDescription},
							   dataType : "json",
							   success: function(data){
								
								   if(data.status=="success"){
									   FmvAlert("Comment posted successfully.");
									   
										var postedTimeAgo = jQuery.timeago(data.data.postedTime);	
										formattedDescription = data.data.commentDescription.replace(/\n/gi,"<br>");
										formattedDescription = formattedDescription.replace(/ /gi,"&nbsp;");
										replyView = "<div id='commentContainer"+data.data.commentId+"' align='left'><table><tr><td valign='top'><img src='"+data.data.avatarUrl+"' width=25 height=25/></td>" +
												"<td valign='top'><table  cellpadding=0 cellspacing=0><tr><td valign='top'>" +
						                        "<a href='Profile/"+data.data.profileId+"'><span class='commentNickName profileLink' profileId='"+data.data.profileId+"' id='profileId"+data.data.commentId+"'>"+data.data.nickName+"</span></a><span id='postedTime'>posted "+postedTimeAgo+"</span></td></tr>" +
						                        "<tr><td><span id='commentDescription'>"+formattedDescription+"</span>" +
						                        "<span title='Delete this comment' class='commentDelete'  killcode='"+data.data.killcode+"'  id='commentDeleteId"+data.data.commentId+"'>Delete</span></td></tr>"+
						                        
						                        
												"</table></td></tr>" +
												"" +
												"</table></div>";
										
										$("#replyContainerId"+commentId).append(replyView);
										$('.commentDelete').mouseover(function(){
											$(this).css("cursor","pointer");
											$(this).css("color","#ff0000");
										});
											
										$('.commentDelete').mouseout(function(){
											$(this).css("color","#000000");
										});
										
										$('.profileLink').mouseover(function(){
											$(this).css("color","#ff0000");
										});
										
										$('.profileLink').mouseout(function(){
											$(this).css("color","#535998");
										});
										
										$('#commentDeleteId'+data.data.commentId).click(function(){
											
											if(FmvConfirm("Do you want to delete this comment ?")){
												$.getJSON('Bend/CommentDelete/killcode/' + $(this).attr('killcode'),function(data){
													
													if(data.status=="success"){
														$("#commentContainer"+data.data).effect("highlight", {}, 1000).fadeOut(1000);
													}
												});
											}	
											
										});
									}else if(data.errCode == UNREGISTEREDUSER.code){
										FmvConfirmCallback(UNREGISTEREDUSER.msg,function(){window.location = hosturl +"/SignUp";});
										
									}else{

										FmvAlert("Cannot create comment.");
									}
							   }
						});
						
					
						
						$("#commentReplyContainer"+commentId).remove();
						
					});
				}
	}
	
	function GetCommentBoxView(){
		var commentBoxView = "<div class='comment-box-container' id='commentReplyContainer"+this.commentId+"'><form ><textarea class='comment-box' id='commentDescriptionId"+this.commentId+"'></textarea><br><input style='width:70px; height:24px;' id='commentSubmitButton"+this.commentId+"' commentId='"+this.commentId+"' type='image' src='images/comment.png' ></form></div>";
		
		return commentBoxView;
		
	}
