function submitVote(app_id, v, c) {
	
	$.post(
		"/fhrc/applications/vote.php",
		{application_id: app_id, vote: v, comments: c},
		function(data) {
			data = data.split(",");
			$("#yes-"+app_id)[0].innerHTML = data[0];
			$("#no-"+app_id)[0].innerHTML = data[1];
			$("#buttons-"+app_id).hide();
			$("#buttons-"+app_id).remove();
			
		}
	);
	
	if ($("#view_page").val() == "true") {
		reloadVoteTable(app_id);	
	}
		
	
}

function reloadVoteTable(app_id) {
	$.post(
		"/fhrc/reload_vote_table.php",
		{application_id: app_id},
		function(data) {
			$("#vote_table").html(data);
			sorttable.makeSortable($("#vote_table table")[0]);
		}
	);
	
}

$(document).ready(
	function() {
		$("form.form").hide();
		$("form.form").submit(
			function() {
				$("#form-"+this.application_id.value).hide();
				submitVote(this.application_id.value, this.vote.value, this.comments.value);
				
				return false;
			}
		);
	}
);