function do_vote(entry_id) {
	$(function() {
		if (entry_id > 0 && war_id > 0) {
			// set ajax loading
			$('#vote_button_' + entry_id).html('<img src="/images/loading_011443.gif" width="16" height="16" border="0" alt="voting...">');
			$.getJSON("/wars/vote/" + war_id + "/" + entry_id, function(data){
				$("#voting_panel").hide();
				$("#vote_message").html(data.message);
				
				if (data.success == 1) {
					
					vote_results_count = data.vote_results_count;
					vote_results = data.vote_results;
					$("#vote_results").html(build_vote_results()).toggle();
					//show_vote_results();
				}
				
			});
		}
		return false;
	});
}
function abstain(entry_id) {
	$(function() {
		if (entry_id == 0 && war_id > 0) {
			// set ajax loading
			$('#abstain').html('<img src="/images/loading_011443.gif" width="16" height="16" border="0" alt="voting...">');
			$.getJSON("/wars/vote/" + war_id + "/" + entry_id, function(data){
				$("#voting_panel").hide();
				$("#vote_message").html(data.message);
				
				
				if (data.success == 1) {
					vote_results_count = data.vote_results_count;
					vote_results = data.vote_results;
					show_vote_results();
				}
				
			});
		}
		return false;
	});
}
function build_vote_results() {
    var x = 1;
	var columns = 6;
	var str = '<table>' + 
	'<tr><td colspan="' + columns + '" class="headings-bg-lightblue" valign="top" width="97%">' + 
	'<img src="assets/images/arrow_db.gif" width="17" height="17" hspace="3"> VOTE ROSTER</td></tr><tr>';
	 $.each(vote_results, function(i, vr) {
		str += '<td>' +
			'<span class="vote_roster_logo"><a href="/stats/user/' + vr.v_userid + '">' + 
			'<img src="' + vr.logo + '" alt="' + vr.username + '" width=90 height=45 border=0></a></span>' + 
			'<span class="vote_roster_link"><a href="/stats/user/' + vr.v_userid + '" class="links-light-blue">' + vr.username + '</a></span>' +
			'</td>';
	    if(x % columns == 0) { str += "</tr><tr>"; }
	    x++;
	}); 
	str += '</tr>' +
		'</table>';
	return str;	
}
