var checkboxImgs = [
//	["/who/whoelect/vote/checkboxRedUnchecked32.png","/who/whoelect/vote/checkboxRedChecked32.png"],
//	["/who/whoelect/vote/checkboxGreenUnchecked32.png","/who/whoelect/vote/checkboxGreenChecked32.png"],
//	["/who/whoelect/vote/checkboxYellowUnchecked32.png","/who/whoelect/vote/checkboxYellowChecked32.png"]
	["/who/whoelect/vote/checkboxBlackUnchecked32.png","/who/whoelect/vote/checkboxBlackChecked32.png"],
	["/who/whoelect/vote/checkboxBlackUnchecked32.png","/who/whoelect/vote/checkboxBlackChecked32.png"],
	["/who/whoelect/vote/checkboxBlackUnchecked32.png","/who/whoelect/vote/checkboxBlackChecked32.png"]
	];
	
//var votes = new Array();	

function changeVote(voteId,lastActionId,voterId,voteRowNum,choice) {
	// hit server to update vote
	var cookie = getCookie('user');
	if(cookie==null) {
		popupLoginBox('login'+voteId,'In order to vote you\'ll need need to log in first. It only takes a moment!',unescape('${thisUrl}'),'000000','ffffff');
		return;
	}


	displayVote(voteId,voterId,voteRowNum,choice);
	
//TODO: if cookie==null, redirect to login.	
	VoteService.changeVote( cookie,lastActionId,choice );
//	final String userCookieStr, final int billActionId, final int choice) {
}

function displayVote(voteId,voterId,voteRowNum,choice) {
	var voteRow = document.getElementById('voteRow_'+voterId+'_'+voteId);

	var yesBox = document.getElementById('v1_'+voteId);
	var noBox = document.getElementById('v0_'+voteId);
	var abstainBox = document.getElementById('v2_'+voteId);

//	votes[voteId] = choice;
	if(choice==1) {
		yesBox.src = checkboxImgs[1][1];
		noBox.src = checkboxImgs[0][0];
		abstainBox.src = checkboxImgs[2][0];
	} else if(choice==0) {
		yesBox.src = checkboxImgs[1][0];
		noBox.src = checkboxImgs[0][1];
		abstainBox.src = checkboxImgs[2][0];
	} else {
		yesBox.src = checkboxImgs[1][0];
		noBox.src = checkboxImgs[0][0];
		abstainBox.src = checkboxImgs[2][1];
	}
	
	voteRow.className = 'billRow'+ voteRowNum +'_'+ choice;
}

function makeVoteRow1Colored(shouldColor) {
	var voteRow1 = getCSSRule('.voteRow1');
	var billRow1_0 = getCSSRule('.billRow1_0');
	var billRow1_1 = getCSSRule('.billRow1_1');

	if(shouldColor) {
		voteRow1.style.backgroundColor='';
		billRow1_0.style.backgroundColor='#fdd';
		billRow1_1.style.backgroundColor='#dfd';
	} else {
		voteRow1.style.backgroundColor='#fff';
		billRow1_0.style.backgroundColor='';
		billRow1_1.style.backgroundColor='';
	}
}
function makeVoteRow2Colored(shouldColor) {
	var voteRow2 = getCSSRule('.voteRow2');
	var billRow2_0 = getCSSRule('.billRow2_0');
	var billRow2_1 = getCSSRule('.billRow2_1');
	
	if(shouldColor) {
		voteRow2.style.backgroundColor='';
		billRow2_0.style.backgroundColor='#fbb';
		billRow2_1.style.backgroundColor='#bfb';
	} else {
		voteRow2.style.backgroundColor='#ddd';
		billRow2_0.style.backgroundColor='';
		billRow2_1.style.backgroundColor='';
	}
}



	
