var win = null;
function pollWin(h,w,pollpage,pollname) {
	// var w = 350;
	// var h = 350;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable'
	win = window.open(pollpage,pollname,settings);
}

function votenow(form) {
	var pollid = form.pollid.value;
	if (eval('form.myvote'+pollid+'.length') > 0) {
		for (var i=0;i<eval('form.myvote'+pollid+'.length');i++) {
			if (eval('form.myvote'+pollid+'[i].checked')) {
				var url = "/poll/poll.php?ops=castvote&pollid="+pollid+"&vote="+i;
				pollWin('350','350',url,"RESULTS");
			}
		}
		disableform(pollid, form);
	} else {
		alert('Please cast a vote.');
	}
	return false;
}

function resetform() {
	document.voteform.cv.disabled = true;
	if (document.voteform.myvote.length > 0) {
		for (var i=0;i<document.voteform.myvote.length;i++) {
			if (document.voteform.myvote[i].checked) {
				document.voteform.myvote[i].checked = false;
			}
		}
	}
}

function disableform(pollid, form) {
	form.cv.disabled = true;
	if (eval('form.myvote'+pollid+'.length') > 0) {
		for (var i=0;i<eval('form.myvote'+pollid+'.length');i++) {
			eval('form.myvote'+pollid+'[i].disabled = true');
		}
	}
}

