/***** USED TO SPAWN POPUPS *****/
// LIGHT WINDOW
function popInfo(id,pct) {
	if (!checkForLightWindow()) return;
	var path = "vote/" + id + ".php?pct="+pct;
	var w = 622;
	var h = 422;
	myLightWindow.activateWindow({href:path, width:w, height:h, title:""});
}

function popVote(cname) {
	if (!checkForLightWindow()) return;
	var w = 482;
	var h = 342;
	myLightWindow.activateWindow({href:"vote/form_vote.php?candidate=" + cname, width:w, height:h, title:""});
}

function popWrite() {
	if (!checkForLightWindow()) return;
	var element = document.getElementById('athlete');
	var cname = element.value;
	var w = 482;
	var h = 342;
	myLightWindow.activateWindow({href:"vote/form_write.php?candidate=" + cname, width:w, height:h, title:""});
}

function popHowItWorks() {
	if (!checkForLightWindow()) return;
	var path = "vote/pop_howitworks.html";
	var w = 622;
	var h = 422;
	myLightWindow.activateWindow({href:path, width:w, height:h, title:""});
}


function closeWin() {
	myLightWindow.deactivate();
}

function checkForLightWindow() {
	if (myLightWindow==null) {
		alert("Please wait for the page to finish loading, then try again.");
		return false;
	} else {
		return true;
	}
}

/***** USED IN FORM WINDOWS *****/
function drawName(addQuotes) {
	var cname = unescape(getQueryParamValue('candidate'));
	if (addQuotes) document.write("&quot;");
	document.write("<strong>" + cname + "</strong>");
	if (addQuotes) document.write("&quot;");
}

function drawAthleteField() {
	var cname = unescape(getQueryParamValue('candidate'));
	document.write('<input type="text" id="athlete" name="athlete" ');
	document.write('value="' + cname + '" />');
}