$(document).ready(function(){
		
	/**
	 * Script handling the comment on comment form is visible or not
	 */
	if($('#enableCommentOnCommentFormSkript').attr('id')){
		function toggleCommentForm(event){
			var idOfRelatedComment = $(event.target).attr('idOfRelatedComment');
			$('table.commentOnCommentForm').not('#commentOnCommentForm_'+idOfRelatedComment).hide('normal',function(){});
			$('#commentOnCommentForm_'+idOfRelatedComment).toggle('normal', function(){});
		}
		
		$('img[id=showCommentFormLink]').bind('click',
				function(event){
					toggleCommentForm(event);
				}
		);
		$('span[id=showCommentFormLink]').bind('click',
				function(event){
					toggleCommentForm(event);
				}
		);
		
		$('img[id=submitCommentOnCommentButton]').bind('click',
				function(event){
					var parentCommentId = $(event.target).attr('idOfRelatedComment');
					var articleId = $(event.target).attr('idOfRelatedArticle');
					
					var content = $('#commentOnCommentTextArea_'+parentCommentId).attr('value');
					
					if(content.length!=0){
						var clone = $('#commentOnCommentTemplate').clone();
						clone.find('#commentOnCommentContent').text(content);
						
						var form = $('#commentOnCommentFormTR_'+parentCommentId);
						form.after(clone);
						clone.show();
						
						
						// --- test
						//$('#commentOnCommentForm_'+parentCommentId).append(clone);
						//clone.show();
						// ---
						
						$('#commentOnCommentForm_'+parentCommentId).hide('normal', function(){});
						$('#commentOnCommentTextArea_'+parentCommentId).attr('value','');
						
						
						$.get(	'login_news_createCommentOnComment.htm',
								{	commentContent: content, 
									idOfRelatedComment: parentCommentId, 
									idOfRelatedArticle: articleId
								},
								function(data){}
							  );
					}else{
						for(var i=0; i<2; i++){
							$('#commentOnCommentTextArea_'+parentCommentId).fadeOut('fast', function(){});
							$('#commentOnCommentTextArea_'+parentCommentId).fadeIn('fast', function(){});
						}
					}

				}
		);
	}
	
	
	
	
		
	
	
	
})