function adminNoConfirm(url, e) {
	$.ajax({
		url : url,
		context : e ? e : 'refresh',
		success : function() {
			if (this == 'refresh') {
				location.reload();
			} else {
				$(this).hide();
			}
		}
	});
}

function admin(url, e) {
	if (confirm('Are you sure?')) {
		$.ajax({
			url : url,
			context : e ? e : 'refresh',
			success : function() {
				if (this == 'refresh') {
					location.reload();
				} else {
					$(this).hide();
				}
			}
		});
	}
}

function voteForConversation(id, score) {
	var url = '';
	if (score < 0) {
		url = '/votedown/conversation/' + id;
	} else {
		url = '/voteup/conversation/' + id;
	}
	$.getJSON(url, function(data) {
		if (data == '0') {
			$('#score' + id).html('(0)').fadeOut();
		} else {
			$('#score' + id).html('(' + data + ')').fadeIn();
		}
	});
}

function voteForComment(id, score) {
	var url = '';
	if (score < 0) {
		url = '/votedown/comment/' + id;
	} else {
		url = '/voteup/comment/' + id;
	}
	$.getJSON(url, function(data) {
		if (data == '0') {
			$('#score' + id).html('(0)').fadeOut();
		} else {
			$('#score' + id).html('(' + data + ')').fadeIn();
		}
	});
}

function jump() {
	$('#jump').toggle('fast');
}

function post(e, id) {
	$.ajax({
		type : 'GET',
		url : '/comment/' + id,
		success : function(data) {
			containerPosition = $('#' + e).offset();
			$('#tooltip').hide();
			$('#tooltip').css({
				top : containerPosition.top + $('#' + e).outerHeight() + 1,
				left : containerPosition.left
			}).html(data).fadeIn();
		}
	});
}

function showOriginalPost() {
	$("#originalpost").fadeIn();
	$("#showlink").hide();
	$("#hidelink").show();
}

function hideOriginalPost() {
	$("#originalpost").hide();
	$("#hidelink").hide();
	$("#showlink").show();
}

function quickreply(e, parentCommentId) {
	$('#quickreply').hide();
	$('#parentCommentId').val(parentCommentId);
	$('#quickreply').insertAfter(e).fadeIn("fast", function() {
		$('#quickreplytext').focus();
	});
}

function loadbbcode() {
	$.ajax({
		type : 'GET',
		url : '/bbcode',
		success : function(data) {
			$('#bbcodetitle').fadeIn();
			$('#bbcode').html(data).fadeIn();
		}
	});
}

function hidequickreply() {
	$('#quickreply').hide();
}
