<script type="text/javascript">
<!--{if $optiontype=='checkbox'}-->
	var max_obj = $maxchoices;
	var p = 0;
	function checkbox(obj) {
		if(obj.checked) {
			p++;
			for (var i = 0; i < poll.elements.length; i++) {
				var e = poll.elements[i];
				if(p == max_obj) {
					if(e.name.match('pollanswers') && !e.checked) {
						e.disabled = true;
					}
				}
			}
		} else {
			p--;
			for (var i = 0; i < poll.elements.length; i++) {
				var e = poll.elements[i];
				if(e.name.match('pollanswers') && e.disabled) {
					e.disabled = false;
				}
			}
		}
	}

<!--{/if}-->

	//public
	function showvoters(polloptionid) {
		var obj = document.getElementById('viewvoterframe'+polloptionid);
		var url = 'misc.php?action=viewvote&tid=$tid&sid=$sid&page=$page&polloptionid='+polloptionid;
		showframe(obj, url);
	}

	//public
	function showallvoters() {
		var obj = document.getElementById('viewallvoterdiv');
		var url = 'misc.php?action=viewvote&tid=$tid&sid=$sid&page=$page';
		showframe(obj, url);
	}

	//private
	function showframe(obj, url) {
		if(!obj.innerHTML) {
			obj.innerHTML = '<iframe width="100%" align="center" height="30" onload="setframeheight(this)" frameborder="0" scrolling="no" src="'+url+'"></iframe>';
		}
		if(obj.innerHTML) {
			obj.style.display = obj.style.display == '' ? 'none' : '';
		}
	}

	//private
	function setframeheight(obj) {
		obj.height = obj.contentDocument ? obj.contentDocument.body.scrollHeight + 30 : obj.Document.body.scrollHeight;
	}

</script>

<form name="poll" method="post" action="misc.php?action=votepoll&fid=$fid&tid=$tid">
<input type="hidden" name="formhash" value="{FORMHASH}">
<div class="block topblock">
	<span class="morelinks"><a href="javascript:;" onclick="showallvoters()">{lang poll_view_voters}</a></span>
	<h3>
		{lang poll_subject}: $thread[subject]&nbsp;
		<!--{if $multiple}-->{lang poll_multiple}<!--{if $maxchoices}-->: {lang poll_more_than}<!--{/if}--><!--{else}-->{lang poll_single}<!--{/if}-->
		<!--{if $expiration && $expirations > $timestamp}-->{lang poll_expiration}<!--{elseif $expiration && $expirations < $timestamp}-->{lang poll_finish}<!--{/if}-->
	</h3>
	<table cellpadding="0" cellspacing="0" border="0" class="threadspacial">
	<tbody>
		<tr>
			<td id="viewallvoterdiv" style="display: none;" colspan="2"></td>
		</tr>
	</tbody>
<!--{loop $polloptions $key $option}-->
	<tr>
	<th>
	<!--{if $allowvote}-->
		<input class="checkbox" type="$optiontype" name="pollanswers[]" value="$option[polloptionid]" <!--{if $optiontype=='checkbox'}-->onclick='checkbox(this)'<!--{/if}-->>
	<!--{/if}-->
	$option[polloption]</th>
	<!--{if !$visiblepoll}-->
	<td>
		<!--{if $adminid == 1}--><a href="javascript:;" onclick="showvoters($option[polloptionid])" class="more">[{lang poll_show_voter}]</a><!--{/if}-->
		<div class="percent" style="width: $option[width]px;">&nbsp;</div>
		<div class="percenttxt">&nbsp;$option[votes] <span class="smalltxt">($option[percent]%)</span></div>
		<!--{if $adminid == 1}--><div id="viewvoterframe$option[polloptionid]" style="width:100%;clear:both;display:none"></div><!--{/if}-->
	</td>
	<!--{else}-->
	<td>&nbsp;</td>
	<!--{/if}-->
	</tr>
<!--{/loop}-->
<!--{if $visiblepoll && $allowvote}--><tr><th>&nbsp;</th><td>{lang poll_after_result}</td></tr><!--{/if}-->
<!--{if $allowvote}--><tr><th>&nbsp;</th><td><input class="button" type="submit" name="pollsubmit" value="{lang submit}"></td></tr>
<!--{elseif $visiblepoll}--><tr><th>&nbsp;</th><td>{lang poll_nopermission}</td></tr><!--{/if}-->
</table>
</div>
</form>