var closePopupText = "<div id='closePopup' onclick='closePopup(event)'>close popup</div>";

var auditPopupText = new Array(
				"<div id='auditLeft' onclick='auditLeft(", // 0
				")'>Audit Left </div><div id='auditRight' onclick='auditRight(",//0
				")'>Audit Right </div>"
				);


var tablePopup = new Array(
				"<h4>&nbsp&nbsp&nbsp Print Table</h4>This table specifies the ballot that gets printed and shown to the voter. After a printed ballot is used for voting, this table exposes the side on which it was voted as well as the configuration of the scanned ballot sheet. If a row is audited, it will not be used to vote because that would link a ballot serial number directly to a vote for a particular candidate.<br/><br/>",

				"<h4>&nbsp&nbsp&nbsp Decryption Table</h4>This table specifies the ballot that will be used along with the Vote Side in the Print Table to determine the candidate voted for.  Each row also contains links to a row in the Print Table and a row in the Result Table.  Remember that the combination of top sheet and bottom sheet must point to the same door as the ballot in the Print Table.  This property will be audited for to make sure that the authority cannot cheat.<br/><br/>",

				"<h4>&nbsp&nbsp&nbsp Result Table</h4>This table holds the candidate that is voted for, linked through the Decryption table to the Print Table.<br/><br/>",

				"<h4>&nbsp&nbsp&nbsp Ballot #1237</h4> With this configuration, a vote for Dubya would be marked on the left.",
				"<h4>&nbsp&nbsp&nbsp Top and Bottom Ballots </h4> In a real election, the ballot would be paper.  It would be perforated in the middle so that a voter could simply fold the top over the bottom to line up the holes.  When the ballot is folded for voting, the bottom half only appears through the two holes.",
				"<h4>&nbsp&nbsp&nbsp Bottom Ballot </h4>  to specify how 'A' and 'B' match up with left and right.",
				"<h4>&nbsp&nbsp&nbsp Folded-Over Ballot </h4> If the cursor is placed over 'A' or 'B', the ballot can be marked by clicking the mouse button.  In a real election, an ink dauber, like the ones used in bingo, would be used to make sure both top and bottom ballots are marked.",
				"Both ballots would be necessary for anyone to see how you voted -- remember from before, sometimes a vote for Dubya is left and sometimes it is right.<br />"
				);





/**********************************************
 * Popup Functions
 *********************************************/
var timeoutID;
var lastNodeID = -1;

var timeoutID_ballot;


function MouseOutPopup(e)
{
	timeoutID = setTimeout("closePopup()", 400);
}


function MouseOverPopup(e)
{
	clearTimeout(timeoutID);
}


function closePopup()
{
	if (votingWindowOpen)
	{
		alert("Finish voting this ballot before closing the window");
		return;
	}

	el = document.getElementById("popup");

	el.style.visibility = "hidden";
	el.style.width = "";
	el.style.height = "";

	// make sure both ballots are invisible
	el = document.getElementById("ballotOverVote");
	if (el)
		el.style.visibility = "hidden";

	el = document.getElementById("ballotUnderVote");
	if (el)
		el.style.visibility = "hidden";

	el = document.getElementById("imageDiv");
	if (el)
		el.style.visibility = "hidden";

	// unhighlight the row that was written by voting
	if (document.getElementById("table1"))
		drawTable();

	lastNodeID = -1;

	if (highlightedRow != NO_ROW)
	{
		hideLinkedRows(highlightedRow);
		highlightedRow = NO_ROW;
	}
}


function mouseClickText(id, num, e)
{
	e = new Evt(e);

	// don't allow another window to open and leave a ballot in an inconsistent state
	if (votingWindowOpen)
	{
		return;
	}

	node = document.getElementById(id);

	if (id == "table3")
	{
		topPx = parseInt(node.style.top) - 10;
		leftPx = parseInt(node.style.left) - 300;
	}
	else
	{
		topPx = parseInt(node.style.top) - 10;
		leftPx = parseInt(node.style.left) + 320;
	}

	el = document.getElementById("popup");

	//el.style.top = topPx + "px";
	//el.style.left = leftPx + "px";
	el.style.width = "250px";
	el.style.height = "";

	text = tablePopup[num] + closePopupText;
	el.innerHTML = text;
	el.style.visibility = "visible";

	e.consume();
}




