$(document).ready(function(){
	$('.comment_edit_button').live('click', function(){
		var get_id = $(this).attr('id');
		var id = get_id.split('_');

		var text = $('#comment_text_'+id[2]).text();
		$('#CommentCommentId').val(id[2]);		

		$('#comment').html(jQuery.trim(text));
	});	
	
	$('.comment_replay_button').live('click', function(){
		var get_id = $(this).attr('id');
		var id = get_id.split('_');
		var text = jQuery.trim($('#comment_text_'+id[2]).text());
		
		$('#comment_hidden_info').remove();		
		$('<div id="comment_hidden_info"><div class="blockquote">'+text+'</div><input type="hidden" value="'+id[2]+'" name="data[Comment][parent_id]"></div>').insertAfter('#comment_reaply_info_box');
	});	
	
	$('.comment_get_vote').live('click', function(){
		var get_id = $(this).attr('id');
		var id_info = get_id.split('_');
		
		$.post('/comments/insert_vote/'+id_info[1]+'/'+id_info[2], function(data){
			$('#comment_vote_button_place_'+id_info[2]).html('<span class="thanks_for_vote">Thanks for vote</span>');
			
			var rating = $('#comment_vote_rating_'+id_info[2]).text();

			if(id_info[1] == 'plus')
				rating = parseInt(rating) + 1;
			else
				rating = parseInt(rating) - 1;
			
			$('#comment_vote_rating_'+id_info[2]).html(rating);
		});		
	});
});

