<!--

var hwnd = null;

function doVote(url, showResult) {
	if(!showResult) {
	    var ans_index = checkVoteForm();
	    if (ans_index < 0) { return; }
	}

    var vform = document.forms.poll;
    var url_vars = "?poll_id=" + vform.poll_id.value + "&ans=" + (ans_index + 1);
    if (hwnd == null || (hwnd != null && hwnd.closed)) {
	hwnd = showWindow(url + url_vars);
    } else { hwnd.focus(); }
}

function showWindow(url) {
    var width = 535,
        height = 400;

    hwnd = window.open(url, "Results", "left=" + ((screen.availWidth  - width) / 2) + ",top=" + ((screen.availHeight  - height) / 2) + ",width=" + width + ",height=" + height + ",titlebar=1,resizable=1,scrollbars=1");
    hwnd.focus();

    return hwnd;
}

function checkVoteForm() {
    var vform = document.forms.poll;
    for (var i = 0; i < vform.ans.length; i++) {
	if (vform.ans[i].checked) { return i; }
    }
    return -1;
}

//-->