var comment_offset = 0;
$(document).ready(function(){
	loadComments();	
});

function loadComments(){
	$.get(ImagePath+'/comments.php?id='+ImageId+'&r='+Math.random()+'&offset='+comment_offset, function(data){$('#comments').html(data);})
}

function comment(){
	$('#submitcomment').attr("disabled", "disabled");
	$.post(ImagePath+'/comments.php?id='+ImageId+'&r='+Math.random()+'&offset='+comment_offset, {comment: $('#comment').val()}, 
		function(data){
			$('#comment').val('');
			$('#newcomment').hide();
			$('#comments').html(data);
			$('#submitcomment').attr("disabled", "");
			$('#comment_link').html('');
		}
	);
}

function commentsNextPage(){
	comment_offset += 10;
	loadComments();
}

function commentsPrevPage(){
	comment_offset -= 10;
	loadComments();
}

function commentsPage(offset){
	comment_offset = offset;
	loadComments();
}	